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

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

Issue 1242793005: Refactor most c/b/profiles calls to ProfileInfoCache. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Windows unit test and ChromeOS build Created 5 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"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h" 24 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h"
25 #include "chrome/browser/browser_process.h" 25 #include "chrome/browser/browser_process.h"
26 #include "chrome/browser/chrome_notification_types.h" 26 #include "chrome/browser/chrome_notification_types.h"
27 #include "chrome/browser/download/download_service.h" 27 #include "chrome/browser/download/download_service.h"
28 #include "chrome/browser/download/download_service_factory.h" 28 #include "chrome/browser/download/download_service_factory.h"
29 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 29 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
30 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" 30 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h"
31 #include "chrome/browser/password_manager/password_store_factory.h" 31 #include "chrome/browser/password_manager/password_store_factory.h"
32 #include "chrome/browser/prefs/incognito_mode_prefs.h" 32 #include "chrome/browser/prefs/incognito_mode_prefs.h"
33 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" 33 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h"
34 #include "chrome/browser/profiles/profile_attributes_storage.h"
34 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 35 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
35 #include "chrome/browser/profiles/profile_destroyer.h" 36 #include "chrome/browser/profiles/profile_destroyer.h"
36 #include "chrome/browser/profiles/profile_info_cache.h" 37 #include "chrome/browser/profiles/profile_info_cache.h"
37 #include "chrome/browser/profiles/profile_metrics.h" 38 #include "chrome/browser/profiles/profile_metrics.h"
38 #include "chrome/browser/profiles/profiles_state.h" 39 #include "chrome/browser/profiles/profiles_state.h"
39 #include "chrome/browser/signin/account_fetcher_service_factory.h" 40 #include "chrome/browser/signin/account_fetcher_service_factory.h"
40 #include "chrome/browser/signin/account_reconcilor_factory.h" 41 #include "chrome/browser/signin/account_reconcilor_factory.h"
41 #include "chrome/browser/signin/account_tracker_service_factory.h" 42 #include "chrome/browser/signin/account_tracker_service_factory.h"
42 #include "chrome/browser/signin/cross_device_promo.h" 43 #include "chrome/browser/signin/cross_device_promo.h"
43 #include "chrome/browser/signin/cross_device_promo_factory.h" 44 #include "chrome/browser/signin/cross_device_promo_factory.h"
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 643
643 ProfileInfoCache& ProfileManager::GetProfileInfoCache() { 644 ProfileInfoCache& ProfileManager::GetProfileInfoCache() {
644 TRACE_EVENT0("browser", "ProfileManager::GetProfileInfoCache"); 645 TRACE_EVENT0("browser", "ProfileManager::GetProfileInfoCache");
645 if (!profile_info_cache_) { 646 if (!profile_info_cache_) {
646 profile_info_cache_.reset(new ProfileInfoCache( 647 profile_info_cache_.reset(new ProfileInfoCache(
647 g_browser_process->local_state(), user_data_dir_)); 648 g_browser_process->local_state(), user_data_dir_));
648 } 649 }
649 return *profile_info_cache_.get(); 650 return *profile_info_cache_.get();
650 } 651 }
651 652
653 ProfileAttributesStorage& ProfileManager::GetProfileAttributesStorage() {
654 return GetProfileInfoCache();
655 }
656
652 ProfileShortcutManager* ProfileManager::profile_shortcut_manager() { 657 ProfileShortcutManager* ProfileManager::profile_shortcut_manager() {
653 return profile_shortcut_manager_.get(); 658 return profile_shortcut_manager_.get();
654 } 659 }
655 660
656 void ProfileManager::ScheduleProfileForDeletion( 661 void ProfileManager::ScheduleProfileForDeletion(
657 const base::FilePath& profile_dir, 662 const base::FilePath& profile_dir,
658 const CreateCallback& callback) { 663 const CreateCallback& callback) {
659 DCHECK(profiles::IsMultipleProfilesEnabled()); 664 DCHECK(profiles::IsMultipleProfilesEnabled());
660 665
661 // Cancel all in-progress downloads before deleting the profile to prevent a 666 // Cancel all in-progress downloads before deleting the profile to prevent a
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 if (profile->GetPath().DirName() != cache.GetUserDataDir()) 808 if (profile->GetPath().DirName() != cache.GetUserDataDir())
804 return; 809 return;
805 810
806 size_t avatar_index; 811 size_t avatar_index;
807 std::string profile_name; 812 std::string profile_name;
808 std::string supervised_user_id; 813 std::string supervised_user_id;
809 if (profile->IsGuestSession()) { 814 if (profile->IsGuestSession()) {
810 profile_name = l10n_util::GetStringUTF8(IDS_PROFILES_GUEST_PROFILE_NAME); 815 profile_name = l10n_util::GetStringUTF8(IDS_PROFILES_GUEST_PROFILE_NAME);
811 avatar_index = 0; 816 avatar_index = 0;
812 } else { 817 } else {
813 size_t profile_cache_index = 818 ProfileAttributesEntry* entry;
814 cache.GetIndexOfProfileWithPath(profile->GetPath());
815 // If the cache has an entry for this profile, use the cache data. 819 // If the cache has an entry for this profile, use the cache data.
816 if (profile_cache_index != std::string::npos) { 820 if (GetProfileAttributesStorage().GetProfileAttributesWithPath(
817 avatar_index = 821 profile->GetPath(), &entry)) {
818 cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index); 822 avatar_index = entry->GetAvatarIconIndex();
819 profile_name = 823 profile_name = base::UTF16ToUTF8(entry->GetName());
820 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index)); 824 supervised_user_id = entry->GetSupervisedUserId();
821 supervised_user_id =
822 cache.GetSupervisedUserIdOfProfileAtIndex(profile_cache_index);
823 } else if (profile->GetPath() == 825 } else if (profile->GetPath() ==
824 profiles::GetDefaultProfileDir(cache.GetUserDataDir())) { 826 profiles::GetDefaultProfileDir(cache.GetUserDataDir())) {
825 // The --new-avatar-menu flag no longer uses the "First User" name. 827 // The --new-avatar-menu flag no longer uses the "First User" name.
826 bool is_new_avatar_menu = switches::IsNewAvatarMenu(); 828 bool is_new_avatar_menu = switches::IsNewAvatarMenu();
827 avatar_index = profiles::GetPlaceholderAvatarIndex(); 829 avatar_index = profiles::GetPlaceholderAvatarIndex();
828 profile_name = is_new_avatar_menu ? 830 profile_name = is_new_avatar_menu ?
829 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)) : 831 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)) :
830 l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME); 832 l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME);
831 } else { 833 } else {
832 avatar_index = cache.ChooseAvatarIconIndexForNewProfile(); 834 avatar_index = cache.ChooseAvatarIconIndexForNewProfile();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 content::Source<Profile>(profile), 1049 content::Source<Profile>(profile),
1048 content::NotificationService::NoDetails()); 1050 content::NotificationService::NoDetails());
1049 } 1051 }
1050 1052
1051 void ProfileManager::DoFinalInitForServices(Profile* profile, 1053 void ProfileManager::DoFinalInitForServices(Profile* profile,
1052 bool go_off_the_record) { 1054 bool go_off_the_record) {
1053 TRACE_EVENT0("browser", "ProfileManager::DoFinalInitForServices"); 1055 TRACE_EVENT0("browser", "ProfileManager::DoFinalInitForServices");
1054 TRACK_SCOPED_REGION("Startup", "ProfileManager::DoFinalInitForServices"); 1056 TRACK_SCOPED_REGION("Startup", "ProfileManager::DoFinalInitForServices");
1055 1057
1056 #if defined(ENABLE_EXTENSIONS) 1058 #if defined(ENABLE_EXTENSIONS)
1057 ProfileInfoCache& cache = GetProfileInfoCache();
1058 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( 1059 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile(
1059 !go_off_the_record); 1060 !go_off_the_record);
1060 // During tests, when |profile| is an instance of TestingProfile, 1061 // During tests, when |profile| is an instance of TestingProfile,
1061 // ExtensionSystem might not create an ExtensionService. 1062 // ExtensionSystem might not create an ExtensionService.
1062 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { 1063 if (extensions::ExtensionSystem::Get(profile)->extension_service()) {
1063 extensions::ExtensionSystem::Get(profile)->extension_service()-> 1064 extensions::ExtensionSystem::Get(profile)->extension_service()->
1064 RegisterContentSettings(profile->GetHostContentSettingsMap()); 1065 RegisterContentSettings(profile->GetHostContentSettingsMap());
1065 } 1066 }
1066 // Set the block extensions bit on the ExtensionService. There likely are no 1067 // Set the block extensions bit on the ExtensionService. There likely are no
1067 // blockable extensions to block. 1068 // blockable extensions to block.
1068 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); 1069 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
1069 if (profile_index != std::string::npos && 1070 ProfileAttributesEntry* entry;
1070 cache.ProfileIsSigninRequiredAtIndex(profile_index)) { 1071 if (storage.GetProfileAttributesWithPath(profile->GetPath(), &entry) &&
1072 entry->IsSigninRequired()) {
1071 extensions::ExtensionSystem::Get(profile) 1073 extensions::ExtensionSystem::Get(profile)
1072 ->extension_service() 1074 ->extension_service()
1073 ->BlockAllExtensions(); 1075 ->BlockAllExtensions();
1074 } 1076 }
1075 1077
1076 #endif 1078 #endif
1077 #if defined(ENABLE_SUPERVISED_USERS) 1079 #if defined(ENABLE_SUPERVISED_USERS)
1078 // Initialization needs to happen after extension system initialization (for 1080 // Initialization needs to happen after extension system initialization (for
1079 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the 1081 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the
1080 // initializing the supervised flag if necessary). 1082 // initializing the supervised flag if necessary).
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 } 1214 }
1213 1215
1214 void ProfileManager::FinishDeletingProfile( 1216 void ProfileManager::FinishDeletingProfile(
1215 const base::FilePath& profile_dir, 1217 const base::FilePath& profile_dir,
1216 const base::FilePath& new_active_profile_dir) { 1218 const base::FilePath& new_active_profile_dir) {
1217 // Update the last used profile pref before closing browser windows. This 1219 // Update the last used profile pref before closing browser windows. This
1218 // way the correct last used profile is set for any notification observers. 1220 // way the correct last used profile is set for any notification observers.
1219 profiles::SetLastUsedProfile( 1221 profiles::SetLastUsedProfile(
1220 new_active_profile_dir.BaseName().MaybeAsASCII()); 1222 new_active_profile_dir.BaseName().MaybeAsASCII());
1221 1223
1222 ProfileInfoCache& cache = GetProfileInfoCache();
1223 // TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we 1224 // TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we
1224 // start deleting the profile instance we need to close background apps too. 1225 // start deleting the profile instance we need to close background apps too.
1225 Profile* profile = GetProfileByPath(profile_dir); 1226 Profile* profile = GetProfileByPath(profile_dir);
1227 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
1228 ProfileAttributesEntry* entry;
1229 bool profile_in_storage =
1230 storage.GetProfileAttributesWithPath(profile_dir, &entry);
1226 1231
1227 if (profile) { 1232 if (profile) {
1228 // TODO: Migrate additional code in this block to observe this notification 1233 // TODO: Migrate additional code in this block to observe this notification
1229 // instead of being implemented here. 1234 // instead of being implemented here.
1230 content::NotificationService::current()->Notify( 1235 content::NotificationService::current()->Notify(
1231 chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 1236 chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
1232 content::Source<Profile>(profile), 1237 content::Source<Profile>(profile),
1233 content::NotificationService::NoDetails()); 1238 content::NotificationService::NoDetails());
1234 1239
1235 // By this point, all in-progress downloads for the profile being deleted 1240 // By this point, all in-progress downloads for the profile being deleted
1236 // must have been canceled (crbug.com/336725). 1241 // must have been canceled (crbug.com/336725).
1237 DCHECK(DownloadServiceFactory::GetForBrowserContext(profile)-> 1242 DCHECK(DownloadServiceFactory::GetForBrowserContext(profile)->
1238 NonMaliciousDownloadCount() == 0); 1243 NonMaliciousDownloadCount() == 0);
1239 BrowserList::CloseAllBrowsersWithProfile(profile); 1244 BrowserList::CloseAllBrowsersWithProfile(profile);
1240 1245
1241 // Disable sync for doomed profile. 1246 // Disable sync for doomed profile.
1242 if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( 1247 if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService(
1243 profile)) { 1248 profile)) {
1244 ProfileSyncServiceFactory::GetInstance()->GetForProfile( 1249 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
1245 profile)->RequestStop(ProfileSyncService::CLEAR_DATA); 1250 profile)->RequestStop(ProfileSyncService::CLEAR_DATA);
1246 } 1251 }
1247 1252
1248 ProfileMetrics::LogProfileDelete(cache.ProfileIsAuthenticatedAtIndex( 1253
1249 cache.GetIndexOfProfileWithPath(profile_dir))); 1254 if (profile_in_storage)
1255 ProfileMetrics::LogProfileDelete(entry->IsAuthenticated());
1250 // Some platforms store passwords in keychains. They should be removed. 1256 // Some platforms store passwords in keychains. They should be removed.
1251 scoped_refptr<password_manager::PasswordStore> password_store = 1257 scoped_refptr<password_manager::PasswordStore> password_store =
1252 PasswordStoreFactory::GetForProfile( 1258 PasswordStoreFactory::GetForProfile(
1253 profile, ServiceAccessType::EXPLICIT_ACCESS).get(); 1259 profile, ServiceAccessType::EXPLICIT_ACCESS).get();
1254 if (password_store.get()) { 1260 if (password_store.get()) {
1255 password_store->RemoveLoginsCreatedBetween( 1261 password_store->RemoveLoginsCreatedBetween(
1256 base::Time(), base::Time::Max(), base::Closure()); 1262 base::Time(), base::Time::Max(), base::Closure());
1257 } 1263 }
1258 1264
1259 // The Profile Data doesn't get wiped until Chrome closes. Since we promised 1265 // The Profile Data doesn't get wiped until Chrome closes. Since we promised
1260 // that the user's data would be removed, do so immediately. 1266 // that the user's data would be removed, do so immediately.
1261 profiles::RemoveBrowsingDataForProfile(profile_dir); 1267 profiles::RemoveBrowsingDataForProfile(profile_dir);
1262 } else { 1268 } else {
1263 // It is safe to delete a not yet loaded Profile from disk. 1269 // It is safe to delete a not yet loaded Profile from disk.
1264 BrowserThread::PostTask( 1270 BrowserThread::PostTask(
1265 BrowserThread::FILE, FROM_HERE, 1271 BrowserThread::FILE, FROM_HERE,
1266 base::Bind(&NukeProfileFromDisk, profile_dir)); 1272 base::Bind(&NukeProfileFromDisk, profile_dir));
1267 } 1273 }
1268 1274
1269 // Queue even a profile that was nuked so it will be MarkedForDeletion and so 1275 // Queue even a profile that was nuked so it will be MarkedForDeletion and so
1270 // CreateProfileAsync can't create it. 1276 // CreateProfileAsync can't create it.
1271 QueueProfileDirectoryForDeletion(profile_dir); 1277 QueueProfileDirectoryForDeletion(profile_dir);
1272 cache.DeleteProfileFromCache(profile_dir); 1278 if (profile_in_storage)
Mike Lerman 2015/08/06 16:06:19 Why do we need this caution now? How are we ever t
1279 storage.RemoveProfile(profile_dir);
1273 ProfileMetrics::UpdateReportedProfilesStatistics(this); 1280 ProfileMetrics::UpdateReportedProfilesStatistics(this);
1274 } 1281 }
1275 1282
1276 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile( 1283 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile(
1277 Profile* profile, 1284 Profile* profile,
1278 bool created) { 1285 bool created) {
1279 TRACE_EVENT0("browser", "ProfileManager::RegisterProfile"); 1286 TRACE_EVENT0("browser", "ProfileManager::RegisterProfile");
1280 ProfileInfo* info = new ProfileInfo(profile, created); 1287 ProfileInfo* info = new ProfileInfo(profile, created);
1281 profiles_info_.insert( 1288 profiles_info_.insert(
1282 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info))); 1289 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info)));
(...skipping 16 matching lines...) Expand all
1299 1306
1300 SigninManagerBase* signin_manager = 1307 SigninManagerBase* signin_manager =
1301 SigninManagerFactory::GetForProfile(profile); 1308 SigninManagerFactory::GetForProfile(profile);
1302 AccountTrackerService* account_tracker = 1309 AccountTrackerService* account_tracker =
1303 AccountTrackerServiceFactory::GetForProfile(profile); 1310 AccountTrackerServiceFactory::GetForProfile(profile);
1304 AccountTrackerService::AccountInfo account_info = 1311 AccountTrackerService::AccountInfo account_info =
1305 account_tracker->GetAccountInfo( 1312 account_tracker->GetAccountInfo(
1306 signin_manager->GetAuthenticatedAccountId()); 1313 signin_manager->GetAuthenticatedAccountId());
1307 base::string16 username = base::UTF8ToUTF16(account_info.email); 1314 base::string16 username = base::UTF8ToUTF16(account_info.email);
1308 1315
1309 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); 1316 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
1310 if (profile_index != std::string::npos) { 1317 ProfileAttributesEntry* entry;
1318 if (storage.GetProfileAttributesWithPath(profile->GetPath(), &entry)) {
1311 // The ProfileInfoCache's info must match the Signin Manager. 1319 // The ProfileInfoCache's info must match the Signin Manager.
1312 cache.SetAuthInfoOfProfileAtIndex(profile_index, account_info.gaia, 1320 entry->SetAuthInfo(account_info.gaia, username);
1313 username);
1314 return; 1321 return;
1315 } 1322 }
1316 1323
1317 // Profile name and avatar are set by InitProfileUserPrefs and stored in the 1324 // Profile name and avatar are set by InitProfileUserPrefs and stored in the
1318 // profile. Use those values to setup the cache entry. 1325 // profile. Use those values to setup the cache entry.
1319 base::string16 profile_name = 1326 base::string16 profile_name =
1320 base::UTF8ToUTF16(profile->GetPrefs()->GetString(prefs::kProfileName)); 1327 base::UTF8ToUTF16(profile->GetPrefs()->GetString(prefs::kProfileName));
1321 1328
1322 size_t icon_index = profile->GetPrefs()->GetInteger( 1329 size_t icon_index = profile->GetPrefs()->GetInteger(
1323 prefs::kProfileAvatarIndex); 1330 prefs::kProfileAvatarIndex);
1324 1331
1325 std::string supervised_user_id = 1332 std::string supervised_user_id =
1326 profile->GetPrefs()->GetString(prefs::kSupervisedUserId); 1333 profile->GetPrefs()->GetString(prefs::kSupervisedUserId);
1327 1334
1328 cache.AddProfileToCache(profile->GetPath(), 1335 storage.AddProfile(profile->GetPath(),
1329 profile_name, 1336 profile_name,
1330 account_info.gaia, 1337 account_info.gaia,
1331 username, 1338 username,
1332 icon_index, 1339 icon_index,
1333 supervised_user_id); 1340 supervised_user_id);
1341
1342 ProfileAttributesEntry* new_entry = nullptr;
1343 if (!storage.GetProfileAttributesWithPath(profile->GetPath(), &new_entry)) {
1344 NOTREACHED();
Mike Lerman 2015/08/06 16:06:19 Can you add some descriptive comment at this NOTRE
1345 return;
1346 }
1334 1347
1335 if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) { 1348 if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) {
Mike Lerman 2015/08/06 16:06:20 nit: no {}. Can even just write new_entry->SetIsE
1336 cache.SetProfileIsEphemeralAtIndex( 1349 new_entry->SetIsEphemeral(true);
1337 cache.GetIndexOfProfileWithPath(profile->GetPath()), true);
1338 } 1350 }
1339 } 1351 }
1340 1352
1341 void ProfileManager::SetNonPersonalProfilePrefs(Profile* profile) { 1353 void ProfileManager::SetNonPersonalProfilePrefs(Profile* profile) {
1342 PrefService* prefs = profile->GetPrefs(); 1354 PrefService* prefs = profile->GetPrefs();
1343 prefs->SetBoolean(prefs::kSigninAllowed, false); 1355 prefs->SetBoolean(prefs::kSigninAllowed, false);
1344 prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false); 1356 prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false);
1345 prefs->SetBoolean(bookmarks::prefs::kShowBookmarkBar, false); 1357 prefs->SetBoolean(bookmarks::prefs::kShowBookmarkBar, false);
1346 prefs->ClearPref(DefaultSearchManager::kDefaultSearchProviderDataPrefName); 1358 prefs->ClearPref(DefaultSearchManager::kDefaultSearchProviderDataPrefName);
1347 } 1359 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 DCHECK(local_state); 1391 DCHECK(local_state);
1380 // Only keep track of profiles that we are managing; tests may create others. 1392 // Only keep track of profiles that we are managing; tests may create others.
1381 // Also never consider the SystemProfile as "active". 1393 // Also never consider the SystemProfile as "active".
1382 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end() && 1394 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end() &&
1383 !last_active->IsSystemProfile()) { 1395 !last_active->IsSystemProfile()) {
1384 std::string profile_path_base = 1396 std::string profile_path_base =
1385 last_active->GetPath().BaseName().MaybeAsASCII(); 1397 last_active->GetPath().BaseName().MaybeAsASCII();
1386 if (profile_path_base != GetLastUsedProfileName()) 1398 if (profile_path_base != GetLastUsedProfileName())
1387 profiles::SetLastUsedProfile(profile_path_base); 1399 profiles::SetLastUsedProfile(profile_path_base);
1388 1400
1389 ProfileInfoCache& cache = GetProfileInfoCache(); 1401 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
1390 size_t profile_index = 1402 ProfileAttributesEntry* entry;
1391 cache.GetIndexOfProfileWithPath(last_active->GetPath()); 1403
1392 if (profile_index != std::string::npos) { 1404 if (storage.GetProfileAttributesWithPath(last_active->GetPath(), &entry)) {
1393 #if !defined(OS_CHROMEOS) 1405 #if !defined(OS_CHROMEOS)
1394 // Incognito Profiles don't have ProfileKeyedServices. 1406 // Incognito Profiles don't have ProfileKeyedServices.
1395 if (!last_active->IsOffTheRecord()) { 1407 if (!last_active->IsOffTheRecord()) {
1396 CrossDevicePromoFactory::GetForProfile(last_active) 1408 CrossDevicePromoFactory::GetForProfile(last_active)
1397 ->MaybeBrowsingSessionStarted( 1409 ->MaybeBrowsingSessionStarted(entry->GetActiveTime());
1398 cache.GetProfileActiveTimeAtIndex(profile_index));
1399 } 1410 }
1400 #endif 1411 #endif
1401 cache.SetProfileActiveTimeAtIndex(profile_index); 1412 entry->SetActiveTime();
1402 } 1413 }
1403 } 1414 }
1404 } 1415 }
1405 1416
1406 ProfileManager::BrowserListObserver::BrowserListObserver( 1417 ProfileManager::BrowserListObserver::BrowserListObserver(
1407 ProfileManager* manager) 1418 ProfileManager* manager)
1408 : profile_manager_(manager) { 1419 : profile_manager_(manager) {
1409 BrowserList::AddObserver(this); 1420 BrowserList::AddObserver(this);
1410 } 1421 }
1411 1422
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 } 1488 }
1478 1489
1479 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); 1490 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path);
1480 if (!original_callback.is_null()) 1491 if (!original_callback.is_null())
1481 original_callback.Run(loaded_profile, status); 1492 original_callback.Run(loaded_profile, status);
1482 } 1493 }
1483 1494
1484 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1495 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1485 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1496 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1486 } 1497 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698