| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/profiles/profile_manager.h" | 5 #include "chrome/browser/profiles/profile_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 } | 438 } |
| 439 #endif | 439 #endif |
| 440 Profile* profile = | 440 Profile* profile = |
| 441 profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( | 441 profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( |
| 442 profile_manager->user_data_dir()); | 442 profile_manager->user_data_dir()); |
| 443 // |profile| could be null if the user doesn't have a profile yet and the path | 443 // |profile| could be null if the user doesn't have a profile yet and the path |
| 444 // is on a read-only volume (preventing Chrome from making a new one). | 444 // is on a read-only volume (preventing Chrome from making a new one). |
| 445 // However, most callers of this function immediately dereference the result | 445 // However, most callers of this function immediately dereference the result |
| 446 // which would lead to crashes in a variety of call sites. Assert here to | 446 // which would lead to crashes in a variety of call sites. Assert here to |
| 447 // figure out how common this is. http://crbug.com/383019 | 447 // figure out how common this is. http://crbug.com/383019 |
| 448 CHECK(profile) << profile_manager->user_data_dir().AsUTF8Unsafe(); | 448 CHECK(profile); |
| 449 return profile; | 449 return profile; |
| 450 } | 450 } |
| 451 | 451 |
| 452 Profile* ProfileManager::GetProfile(const base::FilePath& profile_dir) { | 452 Profile* ProfileManager::GetProfile(const base::FilePath& profile_dir) { |
| 453 TRACE_EVENT0("browser", "ProfileManager::GetProfile"); | 453 TRACE_EVENT0("browser", "ProfileManager::GetProfile"); |
| 454 | 454 |
| 455 // If the profile is already loaded (e.g., chrome.exe launched twice), just | 455 // If the profile is already loaded (e.g., chrome.exe launched twice), just |
| 456 // return it. | 456 // return it. |
| 457 Profile* profile = GetProfileByPath(profile_dir); | 457 Profile* profile = GetProfileByPath(profile_dir); |
| 458 if (profile) | 458 if (profile) |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 // If we don't have a mounted profile directory we're in trouble. | 957 // If we don't have a mounted profile directory we're in trouble. |
| 958 // TODO(davemoore) Once we have better api this check should ensure that | 958 // TODO(davemoore) Once we have better api this check should ensure that |
| 959 // our profile directory is the one that's mounted, and that it's mounted | 959 // our profile directory is the one that's mounted, and that it's mounted |
| 960 // as the current user. | 960 // as the current user. |
| 961 chromeos::DBusThreadManager::Get()->GetCryptohomeClient()->IsMounted( | 961 chromeos::DBusThreadManager::Get()->GetCryptohomeClient()->IsMounted( |
| 962 base::Bind(&CheckCryptohomeIsMounted)); | 962 base::Bind(&CheckCryptohomeIsMounted)); |
| 963 | 963 |
| 964 // Confirm that we hadn't loaded the new profile previously. | 964 // Confirm that we hadn't loaded the new profile previously. |
| 965 base::FilePath default_profile_dir = user_data_dir_.Append( | 965 base::FilePath default_profile_dir = user_data_dir_.Append( |
| 966 GetInitialProfileDir()); | 966 GetInitialProfileDir()); |
| 967 CHECK(!GetProfileByPathInternal(default_profile_dir)) | 967 // The default profile was loaded before we mounted the cryptohome. |
| 968 << "The default profile was loaded before we mounted the cryptohome."; | 968 CHECK(!GetProfileByPathInternal(default_profile_dir)); |
| 969 } | 969 } |
| 970 return; | 970 return; |
| 971 } | 971 } |
| 972 #endif | 972 #endif |
| 973 bool save_active_profiles = false; | 973 bool save_active_profiles = false; |
| 974 switch (type) { | 974 switch (type) { |
| 975 case chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST: { | 975 case chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST: { |
| 976 // Ignore any browsers closing from now on. | 976 // Ignore any browsers closing from now on. |
| 977 closing_all_browsers_ = true; | 977 closing_all_browsers_ = true; |
| 978 save_active_profiles = true; | 978 save_active_profiles = true; |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 | 1667 |
| 1668 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); | 1668 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); |
| 1669 if (!original_callback.is_null()) | 1669 if (!original_callback.is_null()) |
| 1670 original_callback.Run(loaded_profile, status); | 1670 original_callback.Run(loaded_profile, status); |
| 1671 } | 1671 } |
| 1672 #endif // !defined(OS_ANDROID) | 1672 #endif // !defined(OS_ANDROID) |
| 1673 | 1673 |
| 1674 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1674 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
| 1675 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1675 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
| 1676 } | 1676 } |
| OLD | NEW |