Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 18615010: Refactor utility methods out of the ProfileManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: renamed util file Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/deferred_sequenced_task_runner.h" 12 #include "base/deferred_sequenced_task_runner.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/files/file_enumerator.h" 14 #include "base/files/file_enumerator.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/prefs/pref_registry_simple.h"
18 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
19 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
21 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
22 #include "chrome/browser/bookmarks/bookmark_model.h" 21 #include "chrome/browser/bookmarks/bookmark_model.h"
23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 22 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
24 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/chrome_notification_types.h" 24 #include "chrome/browser/chrome_notification_types.h"
26 #include "chrome/browser/content_settings/host_content_settings_map.h" 25 #include "chrome/browser/content_settings/host_content_settings_map.h"
27 #include "chrome/browser/prefs/incognito_mode_prefs.h" 26 #include "chrome/browser/prefs/incognito_mode_prefs.h"
28 #include "chrome/browser/prefs/scoped_user_pref_update.h" 27 #include "chrome/browser/prefs/scoped_user_pref_update.h"
29 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" 28 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h"
30 #include "chrome/browser/profiles/profile_destroyer.h" 29 #include "chrome/browser/profiles/profile_destroyer.h"
31 #include "chrome/browser/profiles/profile_info_cache.h" 30 #include "chrome/browser/profiles/profile_info_cache.h"
32 #include "chrome/browser/profiles/profile_metrics.h" 31 #include "chrome/browser/profiles/profile_metrics.h"
32 #include "chrome/browser/profiles/profiles_state.h"
33 #include "chrome/browser/profiles/startup_task_runner_service.h" 33 #include "chrome/browser/profiles/startup_task_runner_service.h"
34 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" 34 #include "chrome/browser/profiles/startup_task_runner_service_factory.h"
35 #include "chrome/browser/sync/profile_sync_service.h" 35 #include "chrome/browser/sync/profile_sync_service.h"
36 #include "chrome/browser/sync/profile_sync_service_factory.h" 36 #include "chrome/browser/sync/profile_sync_service_factory.h"
37 #include "chrome/browser/ui/browser.h" 37 #include "chrome/browser/ui/browser.h"
38 #include "chrome/browser/ui/sync/sync_promo_ui.h" 38 #include "chrome/browser/ui/sync/sync_promo_ui.h"
39 #include "chrome/common/chrome_constants.h" 39 #include "chrome/common/chrome_constants.h"
40 #include "chrome/common/chrome_paths_internal.h" 40 #include "chrome/common/chrome_paths_internal.h"
41 #include "chrome/common/chrome_switches.h" 41 #include "chrome/common/chrome_switches.h"
42 #include "chrome/common/logging_chrome.h" 42 #include "chrome/common/logging_chrome.h"
(...skipping 11 matching lines...) Expand all
54 54
55 #if defined(ENABLE_MANAGED_USERS) 55 #if defined(ENABLE_MANAGED_USERS)
56 #include "chrome/browser/managed_mode/managed_user_service.h" 56 #include "chrome/browser/managed_mode/managed_user_service.h"
57 #include "chrome/browser/managed_mode/managed_user_service_factory.h" 57 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
58 #endif 58 #endif
59 59
60 #if !defined(OS_IOS) 60 #if !defined(OS_IOS)
61 #include "chrome/browser/extensions/extension_service.h" 61 #include "chrome/browser/extensions/extension_service.h"
62 #include "chrome/browser/extensions/extension_system.h" 62 #include "chrome/browser/extensions/extension_system.h"
63 #include "chrome/browser/sessions/session_service_factory.h" 63 #include "chrome/browser/sessions/session_service_factory.h"
64 #include "chrome/browser/ui/browser_finder.h"
65 #include "chrome/browser/ui/browser_list.h" 64 #include "chrome/browser/ui/browser_list.h"
66 #include "chrome/browser/ui/browser_window.h"
67 #include "chrome/browser/ui/startup/startup_browser_creator.h"
68 #endif // !defined (OS_IOS) 65 #endif // !defined (OS_IOS)
69 66
70 #if defined(OS_WIN) 67 #if defined(OS_WIN)
71 #include "base/win/metro.h" 68 #include "base/win/metro.h"
72 #include "chrome/installer/util/browser_distribution.h" 69 #include "chrome/installer/util/browser_distribution.h"
73 #endif 70 #endif
74 71
75 #if defined(OS_CHROMEOS) 72 #if defined(OS_CHROMEOS)
76 #include "chrome/browser/browser_process_platform_part_chromeos.h" 73 #include "chrome/browser/browser_process_platform_part_chromeos.h"
77 #include "chrome/browser/chromeos/login/user.h" 74 #include "chrome/browser/chromeos/login/user.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 content::NotificationService::AllSources()); 301 content::NotificationService::AllSources());
305 302
306 if (ProfileShortcutManager::IsFeatureEnabled() && !user_data_dir_.empty()) 303 if (ProfileShortcutManager::IsFeatureEnabled() && !user_data_dir_.empty())
307 profile_shortcut_manager_.reset(ProfileShortcutManager::Create( 304 profile_shortcut_manager_.reset(ProfileShortcutManager::Create(
308 this)); 305 this));
309 } 306 }
310 307
311 ProfileManager::~ProfileManager() { 308 ProfileManager::~ProfileManager() {
312 } 309 }
313 310
314 base::FilePath ProfileManager::GetDefaultProfileDir(
315 const base::FilePath& user_data_dir) {
316 base::FilePath default_profile_dir(user_data_dir);
317 default_profile_dir =
318 default_profile_dir.AppendASCII(chrome::kInitialProfile);
319 return default_profile_dir;
320 }
321
322 base::FilePath ProfileManager::GetProfilePrefsPath(
323 const base::FilePath &profile_dir) {
324 base::FilePath default_prefs_path(profile_dir);
325 default_prefs_path = default_prefs_path.Append(chrome::kPreferencesFilename);
326 return default_prefs_path;
327 }
328
329 base::FilePath ProfileManager::GetInitialProfileDir() { 311 base::FilePath ProfileManager::GetInitialProfileDir() {
330 base::FilePath relative_profile_dir; 312 base::FilePath relative_profile_dir;
331 #if defined(OS_CHROMEOS) 313 #if defined(OS_CHROMEOS)
332 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 314 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
333 if (logged_in_) { 315 if (logged_in_) {
334 base::FilePath profile_dir; 316 base::FilePath profile_dir;
335 // If the user has logged in, pick up the new profile. 317 // If the user has logged in, pick up the new profile.
336 if (command_line.HasSwitch(chromeos::switches::kLoginProfile)) { 318 if (command_line.HasSwitch(chromeos::switches::kLoginProfile)) {
337 profile_dir = command_line.GetSwitchValuePath( 319 profile_dir = command_line.GetSwitchValuePath(
338 chromeos::switches::kLoginProfile); 320 chromeos::switches::kLoginProfile);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 return to_return; 395 return to_return;
414 } 396 }
415 397
416 Profile* ProfileManager::GetDefaultProfile( 398 Profile* ProfileManager::GetDefaultProfile(
417 const base::FilePath& user_data_dir) { 399 const base::FilePath& user_data_dir) {
418 #if defined(OS_CHROMEOS) 400 #if defined(OS_CHROMEOS)
419 base::FilePath default_profile_dir(user_data_dir); 401 base::FilePath default_profile_dir(user_data_dir);
420 if (logged_in_) { 402 if (logged_in_) {
421 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); 403 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir());
422 } else { 404 } else {
423 default_profile_dir = GetDefaultProfileDir(user_data_dir); 405 default_profile_dir = profiles::GetDefaultProfileDir(user_data_dir);
424 } 406 }
425 #else 407 #else
426 base::FilePath default_profile_dir(user_data_dir); 408 base::FilePath default_profile_dir(user_data_dir);
427 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); 409 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir());
428 #endif 410 #endif
429 #if defined(OS_CHROMEOS) 411 #if defined(OS_CHROMEOS)
430 if (!logged_in_) { 412 if (!logged_in_) {
431 Profile* profile = GetProfile(default_profile_dir); 413 Profile* profile = GetProfile(default_profile_dir);
432 // For cros, return the OTR profile so we never accidentally keep 414 // For cros, return the OTR profile so we never accidentally keep
433 // user data in an unencrypted profile. But doing this makes 415 // user data in an unencrypted profile. But doing this makes
434 // many of the browser and ui tests fail. We do return the OTR profile 416 // many of the browser and ui tests fail. We do return the OTR profile
435 // if the login-profile switch is passed so that we can test this. 417 // if the login-profile switch is passed so that we can test this.
436 // TODO(davemoore) Fix the tests so they allow OTR profiles. 418 // TODO(davemoore) Fix the tests so they allow OTR profiles.
437 if (ShouldGoOffTheRecord(profile)) 419 if (ShouldGoOffTheRecord(profile))
438 return profile->GetOffTheRecordProfile(); 420 return profile->GetOffTheRecordProfile();
439 return profile; 421 return profile;
440 } 422 }
441 423
442 ProfileInfo* profile_info = GetProfileInfoByPath(default_profile_dir); 424 ProfileInfo* profile_info = GetProfileInfoByPath(default_profile_dir);
443 // Fallback to default off-the-record profile, if user profile has not fully 425 // Fallback to default off-the-record profile, if user profile has not fully
444 // loaded yet. 426 // loaded yet.
445 if (profile_info && !profile_info->created) 427 if (profile_info && !profile_info->created)
446 default_profile_dir = GetDefaultProfileDir(user_data_dir); 428 default_profile_dir = profiles::GetDefaultProfileDir(user_data_dir);
447 #endif 429 #endif
448 return GetProfile(default_profile_dir); 430 return GetProfile(default_profile_dir);
449 } 431 }
450 432
451 bool ProfileManager::IsValidProfile(Profile* profile) { 433 bool ProfileManager::IsValidProfile(Profile* profile) {
452 for (ProfilesInfoMap::iterator iter = profiles_info_.begin(); 434 for (ProfilesInfoMap::iterator iter = profiles_info_.begin();
453 iter != profiles_info_.end(); ++iter) { 435 iter != profiles_info_.end(); ++iter) {
454 if (iter->second->created) { 436 if (iter->second->created) {
455 Profile* candidate = iter->second->profile.get(); 437 Profile* candidate = iter->second->profile.get();
456 if (candidate == profile || 438 if (candidate == profile ||
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 const base::FilePath& path) const { 574 const base::FilePath& path) const {
593 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path); 575 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path);
594 return (iter == profiles_info_.end()) ? NULL : iter->second.get(); 576 return (iter == profiles_info_.end()) ? NULL : iter->second.get();
595 } 577 }
596 578
597 Profile* ProfileManager::GetProfileByPath(const base::FilePath& path) const { 579 Profile* ProfileManager::GetProfileByPath(const base::FilePath& path) const {
598 ProfileInfo* profile_info = GetProfileInfoByPath(path); 580 ProfileInfo* profile_info = GetProfileInfoByPath(path);
599 return profile_info ? profile_info->profile.get() : NULL; 581 return profile_info ? profile_info->profile.get() : NULL;
600 } 582 }
601 583
602 // static
603 void ProfileManager::FindOrCreateNewWindowForProfile(
604 Profile* profile,
605 chrome::startup::IsProcessStartup process_startup,
606 chrome::startup::IsFirstRun is_first_run,
607 chrome::HostDesktopType desktop_type,
608 bool always_create) {
609 #if defined(OS_IOS)
610 NOTREACHED();
611 #else
612 DCHECK(profile);
613
614 if (!always_create) {
615 Browser* browser = chrome::FindTabbedBrowser(profile, false, desktop_type);
616 if (browser) {
617 browser->window()->Activate();
618 return;
619 }
620 }
621
622 content::RecordAction(UserMetricsAction("NewWindow"));
623 CommandLine command_line(CommandLine::NO_PROGRAM);
624 int return_code;
625 StartupBrowserCreator browser_creator;
626 browser_creator.LaunchBrowser(command_line, profile, base::FilePath(),
627 process_startup, is_first_run, &return_code);
628 #endif // defined(OS_IOS)
629 }
630
631 void ProfileManager::Observe( 584 void ProfileManager::Observe(
632 int type, 585 int type,
633 const content::NotificationSource& source, 586 const content::NotificationSource& source,
634 const content::NotificationDetails& details) { 587 const content::NotificationDetails& details) {
635 #if defined(OS_CHROMEOS) 588 #if defined(OS_CHROMEOS)
636 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { 589 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) {
637 logged_in_ = true; 590 logged_in_ = true;
638 591
639 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 592 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
640 if (!command_line.HasSwitch(switches::kTestType)) { 593 if (!command_line.HasSwitch(switches::kTestType)) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 // Invoke INITIALIZED or FAIL for all profiles. 838 // Invoke INITIALIZED or FAIL for all profiles.
886 RunCallbacks(callbacks, profile, 839 RunCallbacks(callbacks, profile,
887 profile ? Profile::CREATE_STATUS_INITIALIZED : 840 profile ? Profile::CREATE_STATUS_INITIALIZED :
888 Profile::CREATE_STATUS_LOCAL_FAIL); 841 Profile::CREATE_STATUS_LOCAL_FAIL);
889 } 842 }
890 843
891 base::FilePath ProfileManager::GenerateNextProfileDirectoryPath() { 844 base::FilePath ProfileManager::GenerateNextProfileDirectoryPath() {
892 PrefService* local_state = g_browser_process->local_state(); 845 PrefService* local_state = g_browser_process->local_state();
893 DCHECK(local_state); 846 DCHECK(local_state);
894 847
895 DCHECK(IsMultipleProfilesEnabled()); 848 DCHECK(profiles::IsMultipleProfilesEnabled());
896 849
897 // Create the next profile in the next available directory slot. 850 // Create the next profile in the next available directory slot.
898 int next_directory = local_state->GetInteger(prefs::kProfilesNumCreated); 851 int next_directory = local_state->GetInteger(prefs::kProfilesNumCreated);
899 std::string profile_name = chrome::kMultiProfileDirPrefix; 852 std::string profile_name = chrome::kMultiProfileDirPrefix;
900 profile_name.append(base::IntToString(next_directory)); 853 profile_name.append(base::IntToString(next_directory));
901 base::FilePath new_path = user_data_dir_; 854 base::FilePath new_path = user_data_dir_;
902 #if defined(OS_WIN) 855 #if defined(OS_WIN)
903 new_path = new_path.Append(ASCIIToUTF16(profile_name)); 856 new_path = new_path.Append(ASCIIToUTF16(profile_name));
904 #else 857 #else
905 new_path = new_path.Append(profile_name); 858 new_path = new_path.Append(profile_name);
(...skipping 15 matching lines...) Expand all
921 base::FilePath new_path = profile_manager->GenerateNextProfileDirectoryPath(); 874 base::FilePath new_path = profile_manager->GenerateNextProfileDirectoryPath();
922 875
923 profile_manager->CreateProfileAsync(new_path, 876 profile_manager->CreateProfileAsync(new_path,
924 callback, 877 callback,
925 name, 878 name,
926 icon_url, 879 icon_url,
927 is_managed); 880 is_managed);
928 return new_path; 881 return new_path;
929 } 882 }
930 883
931 // static
932 void ProfileManager::RegisterPrefs(PrefRegistrySimple* registry) {
933 registry->RegisterStringPref(prefs::kProfileLastUsed, std::string());
934 registry->RegisterIntegerPref(prefs::kProfilesNumCreated, 1);
935 registry->RegisterListPref(prefs::kProfilesLastActive);
936 }
937
938 size_t ProfileManager::GetNumberOfProfiles() { 884 size_t ProfileManager::GetNumberOfProfiles() {
939 return GetProfileInfoCache().GetNumberOfProfiles(); 885 return GetProfileInfoCache().GetNumberOfProfiles();
940 } 886 }
941 887
942 bool ProfileManager::CompareProfilePathAndName( 888 bool ProfileManager::CompareProfilePathAndName(
943 const ProfileManager::ProfilePathAndName& pair1, 889 const ProfileManager::ProfilePathAndName& pair1,
944 const ProfileManager::ProfilePathAndName& pair2) { 890 const ProfileManager::ProfilePathAndName& pair2) {
945 int name_compare = pair1.second.compare(pair2.second); 891 int name_compare = pair1.second.compare(pair2.second);
946 if (name_compare < 0) { 892 if (name_compare < 0) {
947 return true; 893 return true;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 size_t profile_cache_index = 950 size_t profile_cache_index =
1005 cache.GetIndexOfProfileWithPath(profile->GetPath()); 951 cache.GetIndexOfProfileWithPath(profile->GetPath());
1006 // If the cache has an entry for this profile, use the cache data. 952 // If the cache has an entry for this profile, use the cache data.
1007 if (profile_cache_index != std::string::npos) { 953 if (profile_cache_index != std::string::npos) {
1008 avatar_index = 954 avatar_index =
1009 cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index); 955 cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index);
1010 profile_name = 956 profile_name =
1011 UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index)); 957 UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index));
1012 is_managed = cache.ProfileIsManagedAtIndex(profile_cache_index); 958 is_managed = cache.ProfileIsManagedAtIndex(profile_cache_index);
1013 } else if (profile->GetPath() == 959 } else if (profile->GetPath() ==
1014 GetDefaultProfileDir(cache.GetUserDataDir())) { 960 profiles::GetDefaultProfileDir(cache.GetUserDataDir())) {
1015 avatar_index = 0; 961 avatar_index = 0;
1016 profile_name = l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME); 962 profile_name = l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME);
1017 } else { 963 } else {
1018 avatar_index = cache.ChooseAvatarIconIndexForNewProfile(); 964 avatar_index = cache.ChooseAvatarIconIndexForNewProfile();
1019 profile_name = UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); 965 profile_name = UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index));
1020 } 966 }
1021 967
1022 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex)) 968 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex))
1023 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index); 969 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index);
1024 970
(...skipping 13 matching lines...) Expand all
1038 command_line.HasSwitch(chromeos::switches::kLoginProfile))) { 984 command_line.HasSwitch(chromeos::switches::kLoginProfile))) {
1039 go_off_the_record = true; 985 go_off_the_record = true;
1040 } 986 }
1041 #endif 987 #endif
1042 return go_off_the_record; 988 return go_off_the_record;
1043 } 989 }
1044 990
1045 void ProfileManager::ScheduleProfileForDeletion( 991 void ProfileManager::ScheduleProfileForDeletion(
1046 const base::FilePath& profile_dir, 992 const base::FilePath& profile_dir,
1047 const CreateCallback& callback) { 993 const CreateCallback& callback) {
1048 DCHECK(IsMultipleProfilesEnabled()); 994 DCHECK(profiles::IsMultipleProfilesEnabled());
1049 PrefService* local_state = g_browser_process->local_state(); 995 PrefService* local_state = g_browser_process->local_state();
1050 ProfileInfoCache& cache = GetProfileInfoCache(); 996 ProfileInfoCache& cache = GetProfileInfoCache();
1051 997
1052 if (profile_dir.BaseName().MaybeAsASCII() == 998 if (profile_dir.BaseName().MaybeAsASCII() ==
1053 local_state->GetString(prefs::kProfileLastUsed)) { 999 local_state->GetString(prefs::kProfileLastUsed)) {
1054 // Update the last used profile pref before closing browser windows. This 1000 // Update the last used profile pref before closing browser windows. This
1055 // way the correct last used profile is set for any notification observers. 1001 // way the correct last used profile is set for any notification observers.
1056 base::FilePath last_non_managed_profile_path; 1002 base::FilePath last_non_managed_profile_path;
1057 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { 1003 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
1058 base::FilePath cur_path = cache.GetPathOfProfileAtIndex(i); 1004 base::FilePath cur_path = cache.GetPathOfProfileAtIndex(i);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 profile)) { 1090 profile)) {
1145 ProfileSyncServiceFactory::GetInstance()->GetForProfile( 1091 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
1146 profile)->DisableForUser(); 1092 profile)->DisableForUser();
1147 } 1093 }
1148 } 1094 }
1149 1095
1150 QueueProfileDirectoryForDeletion(profile_dir); 1096 QueueProfileDirectoryForDeletion(profile_dir);
1151 cache.DeleteProfileFromCache(profile_dir); 1097 cache.DeleteProfileFromCache(profile_dir);
1152 } 1098 }
1153 1099
1154 // static
1155 bool ProfileManager::IsMultipleProfilesEnabled() {
1156 #if defined(OS_ANDROID)
1157 return false;
1158 #endif
1159 #if defined(OS_CHROMEOS)
1160 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles))
1161 return false;
1162 #endif
1163
1164 return true;
1165 }
1166
1167 void ProfileManager::AutoloadProfiles() { 1100 void ProfileManager::AutoloadProfiles() {
1168 // If running in the background is disabled for the browser, do not autoload 1101 // If running in the background is disabled for the browser, do not autoload
1169 // any profiles. 1102 // any profiles.
1170 PrefService* local_state = g_browser_process->local_state(); 1103 PrefService* local_state = g_browser_process->local_state();
1171 if (!local_state->HasPrefPath(prefs::kBackgroundModeEnabled) || 1104 if (!local_state->HasPrefPath(prefs::kBackgroundModeEnabled) ||
1172 !local_state->GetBoolean(prefs::kBackgroundModeEnabled)) { 1105 !local_state->GetBoolean(prefs::kBackgroundModeEnabled)) {
1173 return; 1106 return;
1174 } 1107 }
1175 1108
1176 ProfileInfoCache& cache = GetProfileInfoCache(); 1109 ProfileInfoCache& cache = GetProfileInfoCache();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 ProfileManager::ProfileInfo::ProfileInfo( 1146 ProfileManager::ProfileInfo::ProfileInfo(
1214 Profile* profile, 1147 Profile* profile,
1215 bool created) 1148 bool created)
1216 : profile(profile), 1149 : profile(profile),
1217 created(created) { 1150 created(created) {
1218 } 1151 }
1219 1152
1220 ProfileManager::ProfileInfo::~ProfileInfo() { 1153 ProfileManager::ProfileInfo::~ProfileInfo() {
1221 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); 1154 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release());
1222 } 1155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698