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

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

Issue 1794353003: Refactor ProfileInfoCache in c/b/profiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replaced LOG(WARNING) by UMA histograms Created 4 years, 8 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 30 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
31 #include "chrome/browser/download/download_service.h" 31 #include "chrome/browser/download/download_service.h"
32 #include "chrome/browser/download/download_service_factory.h" 32 #include "chrome/browser/download/download_service_factory.h"
33 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" 33 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
34 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 34 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
35 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" 35 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h"
36 #include "chrome/browser/password_manager/password_manager_setting_migrator_serv ice_factory.h" 36 #include "chrome/browser/password_manager/password_manager_setting_migrator_serv ice_factory.h"
37 #include "chrome/browser/password_manager/password_store_factory.h" 37 #include "chrome/browser/password_manager/password_store_factory.h"
38 #include "chrome/browser/prefs/incognito_mode_prefs.h" 38 #include "chrome/browser/prefs/incognito_mode_prefs.h"
39 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" 39 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h"
40 #include "chrome/browser/profiles/profile_attributes_entry.h"
40 #include "chrome/browser/profiles/profile_attributes_storage.h" 41 #include "chrome/browser/profiles/profile_attributes_storage.h"
41 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 42 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
42 #include "chrome/browser/profiles/profile_destroyer.h" 43 #include "chrome/browser/profiles/profile_destroyer.h"
43 #include "chrome/browser/profiles/profile_info_cache.h" 44 #include "chrome/browser/profiles/profile_info_cache.h"
44 #include "chrome/browser/profiles/profile_metrics.h" 45 #include "chrome/browser/profiles/profile_metrics.h"
45 #include "chrome/browser/profiles/profiles_state.h" 46 #include "chrome/browser/profiles/profiles_state.h"
46 #include "chrome/browser/sessions/session_service_factory.h" 47 #include "chrome/browser/sessions/session_service_factory.h"
47 #include "chrome/browser/signin/account_fetcher_service_factory.h" 48 #include "chrome/browser/signin/account_fetcher_service_factory.h"
48 #include "chrome/browser/signin/account_reconcilor_factory.h" 49 #include "chrome/browser/signin/account_reconcilor_factory.h"
49 #include "chrome/browser/signin/account_tracker_service_factory.h" 50 #include "chrome/browser/signin/account_tracker_service_factory.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 424
424 // If the profile is already loaded (e.g., chrome.exe launched twice), just 425 // If the profile is already loaded (e.g., chrome.exe launched twice), just
425 // return it. 426 // return it.
426 Profile* profile = GetProfileByPath(profile_dir); 427 Profile* profile = GetProfileByPath(profile_dir);
427 if (profile) 428 if (profile)
428 return profile; 429 return profile;
429 return CreateAndInitializeProfile(profile_dir); 430 return CreateAndInitializeProfile(profile_dir);
430 } 431 }
431 432
432 size_t ProfileManager::GetNumberOfProfiles() { 433 size_t ProfileManager::GetNumberOfProfiles() {
433 return GetProfileInfoCache().GetNumberOfProfiles(); 434 return GetProfileAttributesStorage().GetNumberOfProfiles();
434 } 435 }
435 436
436 bool ProfileManager::LoadProfile(const std::string& profile_name, 437 bool ProfileManager::LoadProfile(const std::string& profile_name,
437 bool incognito, 438 bool incognito,
438 const ProfileLoadedCallback& callback) { 439 const ProfileLoadedCallback& callback) {
439 const base::FilePath profile_path = user_data_dir().AppendASCII(profile_name); 440 const base::FilePath profile_path = user_data_dir().AppendASCII(profile_name);
440 441
441 ProfileAttributesEntry* entry = nullptr; 442 ProfileAttributesEntry* entry = nullptr;
442 if (!GetProfileAttributesStorage().GetProfileAttributesWithPath(profile_path, 443 if (!GetProfileAttributesStorage().GetProfileAttributesWithPath(profile_path,
443 &entry)) { 444 &entry)) {
(...skipping 29 matching lines...) Expand all
473 474
474 // Create the profile if needed and collect its ProfileInfo. 475 // Create the profile if needed and collect its ProfileInfo.
475 ProfilesInfoMap::iterator iter = profiles_info_.find(profile_path); 476 ProfilesInfoMap::iterator iter = profiles_info_.find(profile_path);
476 ProfileInfo* info = NULL; 477 ProfileInfo* info = NULL;
477 478
478 if (iter != profiles_info_.end()) { 479 if (iter != profiles_info_.end()) {
479 info = iter->second.get(); 480 info = iter->second.get();
480 } else { 481 } else {
481 // Initiate asynchronous creation process. 482 // Initiate asynchronous creation process.
482 info = RegisterProfile(CreateProfileAsyncHelper(profile_path, this), false); 483 info = RegisterProfile(CreateProfileAsyncHelper(profile_path, this), false);
483 ProfileInfoCache& cache = GetProfileInfoCache();
484 // Get the icon index from the user's icon url
485 size_t icon_index; 484 size_t icon_index;
486 DCHECK(base::IsStringASCII(icon_url)); 485 DCHECK(base::IsStringASCII(icon_url));
487 if (profiles::IsDefaultAvatarIconUrl(icon_url, &icon_index)) { 486 if (profiles::IsDefaultAvatarIconUrl(icon_url, &icon_index)) {
488 // add profile to cache with user selected name and avatar 487 // add profile to cache with user selected name and avatar
489 cache.AddProfileToCache(profile_path, name, std::string(), 488 GetProfileAttributesStorage().AddProfile(profile_path, name,
490 base::string16(), icon_index, supervised_user_id); 489 std::string(), base::string16(), icon_index, supervised_user_id);
491 } 490 }
492 491
493 if (!supervised_user_id.empty()) { 492 if (!supervised_user_id.empty()) {
494 content::RecordAction( 493 content::RecordAction(
495 UserMetricsAction("ManagedMode_LocallyManagedUserCreated")); 494 UserMetricsAction("ManagedMode_LocallyManagedUserCreated"));
496 } 495 }
497 496
498 ProfileMetrics::UpdateReportedProfilesStatistics(this); 497 ProfileMetrics::UpdateReportedProfilesStatistics(this);
499 } 498 }
500 499
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 // Cancel all in-progress downloads before deleting the profile to prevent a 734 // Cancel all in-progress downloads before deleting the profile to prevent a
736 // "Do you want to exit Google Chrome and cancel the downloads?" prompt 735 // "Do you want to exit Google Chrome and cancel the downloads?" prompt
737 // (crbug.com/336725). 736 // (crbug.com/336725).
738 Profile* profile = GetProfileByPath(profile_dir); 737 Profile* profile = GetProfileByPath(profile_dir);
739 if (profile) { 738 if (profile) {
740 DownloadService* service = 739 DownloadService* service =
741 DownloadServiceFactory::GetForBrowserContext(profile); 740 DownloadServiceFactory::GetForBrowserContext(profile);
742 service->CancelDownloads(); 741 service->CancelDownloads();
743 } 742 }
744 743
745 ProfileInfoCache& cache = GetProfileInfoCache(); 744 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
746
747 // If we're deleting the last (non-legacy-supervised) profile, then create a 745 // If we're deleting the last (non-legacy-supervised) profile, then create a
748 // new profile in its place. 746 // new profile in its place.
749 base::FilePath last_non_supervised_profile_path; 747 base::FilePath last_non_supervised_profile_path;
750 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { 748 std::vector<ProfileAttributesEntry*> entries =
751 base::FilePath cur_path = cache.GetPathOfProfileAtIndex(i); 749 storage.GetAllProfilesAttributes();
750 for (ProfileAttributesEntry* entry : entries) {
751 base::FilePath cur_path = entry->GetPath();
752 // Make sure that this profile is not pending deletion, and is not 752 // Make sure that this profile is not pending deletion, and is not
753 // legacy-supervised. 753 // legacy-supervised.
754 if (cur_path != profile_dir && 754 if (cur_path != profile_dir &&
755 !cache.ProfileIsLegacySupervisedAtIndex(i) && 755 !entry->IsLegacySupervised() &&
756 !IsProfileMarkedForDeletion(cur_path)) { 756 !IsProfileMarkedForDeletion(cur_path)) {
757 last_non_supervised_profile_path = cur_path; 757 last_non_supervised_profile_path = cur_path;
758 break; 758 break;
759 } 759 }
760 } 760 }
761 761
762 if (last_non_supervised_profile_path.empty()) { 762 if (last_non_supervised_profile_path.empty()) {
763 std::string new_avatar_url; 763 std::string new_avatar_url;
764 base::string16 new_profile_name; 764 base::string16 new_profile_name;
765 765
766 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) 766 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
767 int avatar_index = profiles::GetPlaceholderAvatarIndex(); 767 int avatar_index = profiles::GetPlaceholderAvatarIndex();
768 new_avatar_url = profiles::GetDefaultAvatarIconUrl(avatar_index); 768 new_avatar_url = profiles::GetDefaultAvatarIconUrl(avatar_index);
769 new_profile_name = cache.ChooseNameForNewProfile(avatar_index); 769 new_profile_name = storage.ChooseNameForNewProfile(avatar_index);
770 #endif 770 #endif
771 771
772 base::FilePath new_path(GenerateNextProfileDirectoryPath()); 772 base::FilePath new_path(GenerateNextProfileDirectoryPath());
773 CreateProfileAsync(new_path, 773 CreateProfileAsync(new_path,
774 base::Bind(&ProfileManager::OnNewActiveProfileLoaded, 774 base::Bind(&ProfileManager::OnNewActiveProfileLoaded,
775 base::Unretained(this), 775 base::Unretained(this),
776 profile_dir, 776 profile_dir,
777 new_path, 777 new_path,
778 callback), 778 callback),
779 new_profile_name, 779 new_profile_name,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 void ProfileManager::AutoloadProfiles() { 813 void ProfileManager::AutoloadProfiles() {
814 // If running in the background is disabled for the browser, do not autoload 814 // If running in the background is disabled for the browser, do not autoload
815 // any profiles. 815 // any profiles.
816 PrefService* local_state = g_browser_process->local_state(); 816 PrefService* local_state = g_browser_process->local_state();
817 DCHECK(local_state); 817 DCHECK(local_state);
818 if (!local_state->HasPrefPath(prefs::kBackgroundModeEnabled) || 818 if (!local_state->HasPrefPath(prefs::kBackgroundModeEnabled) ||
819 !local_state->GetBoolean(prefs::kBackgroundModeEnabled)) { 819 !local_state->GetBoolean(prefs::kBackgroundModeEnabled)) {
820 return; 820 return;
821 } 821 }
822 822
823 ProfileInfoCache& cache = GetProfileInfoCache(); 823 std::vector<ProfileAttributesEntry*> entries =
824 size_t number_of_profiles = cache.GetNumberOfProfiles(); 824 GetProfileAttributesStorage().GetAllProfilesAttributes();
825 for (size_t p = 0; p < number_of_profiles; ++p) { 825 for (ProfileAttributesEntry* entry : entries) {
826 if (cache.GetBackgroundStatusOfProfileAtIndex(p)) { 826 if (entry->GetBackgroundStatus()) {
827 // If status is true, that profile is running background apps. By calling 827 // If status is true, that profile is running background apps. By calling
828 // GetProfile, we automatically cause the profile to be loaded which will 828 // GetProfile, we automatically cause the profile to be loaded which will
829 // register it with the BackgroundModeManager. 829 // register it with the BackgroundModeManager.
830 GetProfile(cache.GetPathOfProfileAtIndex(p)); 830 GetProfile(entry->GetPath());
831 } 831 }
832 } 832 }
833 } 833 }
834 834
835 void ProfileManager::CleanUpEphemeralProfiles() { 835 void ProfileManager::CleanUpEphemeralProfiles() {
836 const std::string last_used_profile = GetLastUsedProfileName(); 836 const std::string last_used_profile = GetLastUsedProfileName();
837 837
838 bool last_active_profile_deleted = false; 838 bool last_active_profile_deleted = false;
839 base::FilePath new_profile_path; 839 base::FilePath new_profile_path;
840 std::vector<base::FilePath> profiles_to_delete; 840 std::vector<base::FilePath> profiles_to_delete;
841 ProfileInfoCache& profile_cache = GetProfileInfoCache(); 841 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
842 size_t profiles_count = profile_cache.GetNumberOfProfiles(); 842 std::vector<ProfileAttributesEntry*> entries =
843 for (size_t i = 0; i < profiles_count; ++i) { 843 storage.GetAllProfilesAttributes();
844 base::FilePath profile_path = profile_cache.GetPathOfProfileAtIndex(i); 844 for (ProfileAttributesEntry* entry : entries) {
845 if (profile_cache.ProfileIsEphemeralAtIndex(i)) { 845 base::FilePath profile_path = entry->GetPath();
846 if (entry->IsEphemeral()) {
846 profiles_to_delete.push_back(profile_path); 847 profiles_to_delete.push_back(profile_path);
847 if (profile_path.BaseName().MaybeAsASCII() == last_used_profile) 848 if (profile_path.BaseName().MaybeAsASCII() == last_used_profile)
848 last_active_profile_deleted = true; 849 last_active_profile_deleted = true;
849 } else if (new_profile_path.empty()) { 850 } else if (new_profile_path.empty()) {
850 new_profile_path = profile_path; 851 new_profile_path = profile_path;
851 } 852 }
852 } 853 }
853 854
854 // If the last active profile was ephemeral, set a new one. 855 // If the last active profile was ephemeral, set a new one.
855 if (last_active_profile_deleted) { 856 if (last_active_profile_deleted) {
856 if (new_profile_path.empty()) 857 if (new_profile_path.empty())
857 new_profile_path = GenerateNextProfileDirectoryPath(); 858 new_profile_path = GenerateNextProfileDirectoryPath();
858 859
859 profiles::SetLastUsedProfile(new_profile_path.BaseName().MaybeAsASCII()); 860 profiles::SetLastUsedProfile(new_profile_path.BaseName().MaybeAsASCII());
860 } 861 }
861 862
862 // This uses a separate loop, because deleting the profile from the 863 // This uses a separate loop, because deleting the profile from the
863 // ProfileInfoCache will modify indices. 864 // ProfileInfoCache will modify indices.
864 for (const base::FilePath& profile_path : profiles_to_delete) { 865 for (const base::FilePath& profile_path : profiles_to_delete) {
865 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 866 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
866 base::Bind(&NukeProfileFromDisk, profile_path)); 867 base::Bind(&NukeProfileFromDisk, profile_path));
867 868
868 profile_cache.DeleteProfileFromCache(profile_path); 869 storage.RemoveProfile(profile_path);
869 } 870 }
870 } 871 }
871 872
872 void ProfileManager::InitProfileUserPrefs(Profile* profile) { 873 void ProfileManager::InitProfileUserPrefs(Profile* profile) {
873 TRACE_EVENT0("browser", "ProfileManager::InitProfileUserPrefs"); 874 TRACE_EVENT0("browser", "ProfileManager::InitProfileUserPrefs");
874 ProfileInfoCache& cache = GetProfileInfoCache(); 875 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
875 876
876 if (profile->GetPath().DirName() != cache.GetUserDataDir()) 877 // TODO(anthonyvd) : monitor the histogram below to see whether the code path
Mike Lerman 2016/04/13 15:07:41 Don't need this TODO.
lwchkg 2016/04/13 16:50:57 Done.
878 // is used.
879 if (profile->GetPath().DirName() != user_data_dir()) {
880 UMA_HISTOGRAM_BOOLEAN("Profile.InitProfileUserPrefs.OutsideUserDir", true);
877 return; 881 return;
882 }
883 UMA_HISTOGRAM_BOOLEAN("Profile.InitProfileUserPrefs.OutsideUserDir", false);
Mike Lerman 2016/04/13 15:07:41 don't log the false.
lwchkg 2016/04/13 16:50:57 Done.
878 884
879 size_t avatar_index; 885 size_t avatar_index;
880 std::string profile_name; 886 std::string profile_name;
881 std::string supervised_user_id; 887 std::string supervised_user_id;
882 if (profile->IsGuestSession()) { 888 if (profile->IsGuestSession()) {
883 profile_name = l10n_util::GetStringUTF8(IDS_PROFILES_GUEST_PROFILE_NAME); 889 profile_name = l10n_util::GetStringUTF8(IDS_PROFILES_GUEST_PROFILE_NAME);
884 avatar_index = 0; 890 avatar_index = 0;
885 } else { 891 } else {
886 size_t profile_cache_index = 892 ProfileAttributesEntry* entry;
887 cache.GetIndexOfProfileWithPath(profile->GetPath()); 893 bool has_entry = storage.GetProfileAttributesWithPath(profile->GetPath(),
888 // If the cache has an entry for this profile, use the cache data. 894 &entry);
889 if (profile_cache_index != std::string::npos) { 895 // If the profile attributes storage has an entry for this profile, use the
890 avatar_index = 896 // data in the profile attributes storage.
891 cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index); 897 if (has_entry) {
892 profile_name = 898 avatar_index = entry->GetAvatarIconIndex();
893 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index)); 899 profile_name = base::UTF16ToUTF8(entry->GetName());
894 supervised_user_id = 900 supervised_user_id = entry->GetSupervisedUserId();
895 cache.GetSupervisedUserIdOfProfileAtIndex(profile_cache_index);
896 } else if (profile->GetPath() == 901 } else if (profile->GetPath() ==
897 profiles::GetDefaultProfileDir(cache.GetUserDataDir())) { 902 profiles::GetDefaultProfileDir(user_data_dir())) {
898 avatar_index = profiles::GetPlaceholderAvatarIndex(); 903 avatar_index = profiles::GetPlaceholderAvatarIndex();
899 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) 904 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
900 profile_name = 905 profile_name =
901 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); 906 base::UTF16ToUTF8(storage.ChooseNameForNewProfile(avatar_index));
902 #else 907 #else
903 profile_name = l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME); 908 profile_name = l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME);
904 #endif 909 #endif
905 } else { 910 } else {
906 avatar_index = cache.ChooseAvatarIconIndexForNewProfile(); 911 avatar_index = storage.ChooseAvatarIconIndexForNewProfile();
907 profile_name = 912 profile_name =
908 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); 913 base::UTF16ToUTF8(storage.ChooseNameForNewProfile(avatar_index));
909 } 914 }
910 } 915 }
911 916
912 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex)) 917 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex))
913 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index); 918 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index);
914 919
915 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileName)) 920 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileName))
916 profile->GetPrefs()->SetString(prefs::kProfileName, profile_name); 921 profile->GetPrefs()->SetString(prefs::kProfileName, profile_name);
917 922
918 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 923 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
919 bool force_supervised_user_id = 924 bool force_supervised_user_id =
920 #if defined(OS_CHROMEOS) 925 #if defined(OS_CHROMEOS)
921 g_browser_process->platform_part() 926 g_browser_process->platform_part()
922 ->profile_helper() 927 ->profile_helper()
923 ->GetSigninProfileDir() != profile->GetPath() && 928 ->GetSigninProfileDir() != profile->GetPath() &&
924 #endif 929 #endif
925 command_line->HasSwitch(switches::kSupervisedUserId); 930 command_line->HasSwitch(switches::kSupervisedUserId);
926 if (force_supervised_user_id) { 931 if (force_supervised_user_id) {
927 supervised_user_id = 932 supervised_user_id =
928 command_line->GetSwitchValueASCII(switches::kSupervisedUserId); 933 command_line->GetSwitchValueASCII(switches::kSupervisedUserId);
929 } 934 }
930 if (force_supervised_user_id || 935 if (force_supervised_user_id ||
931 !profile->GetPrefs()->HasPrefPath(prefs::kSupervisedUserId)) { 936 !profile->GetPrefs()->HasPrefPath(prefs::kSupervisedUserId)) {
932 profile->GetPrefs()->SetString(prefs::kSupervisedUserId, 937 profile->GetPrefs()->SetString(prefs::kSupervisedUserId,
933 supervised_user_id); 938 supervised_user_id);
934 } 939 }
935 } 940 }
936 941
937 void ProfileManager::RegisterTestingProfile(Profile* profile, 942 void ProfileManager::RegisterTestingProfile(Profile* profile,
938 bool add_to_cache, 943 bool add_to_storage,
939 bool start_deferred_task_runners) { 944 bool start_deferred_task_runners) {
940 RegisterProfile(profile, true); 945 RegisterProfile(profile, true);
941 if (add_to_cache) { 946 if (add_to_storage) {
942 InitProfileUserPrefs(profile); 947 InitProfileUserPrefs(profile);
943 AddProfileToCache(profile); 948 AddProfileToStorage(profile);
944 } 949 }
945 if (start_deferred_task_runners) { 950 if (start_deferred_task_runners) {
946 StartupTaskRunnerServiceFactory::GetForProfile(profile)-> 951 StartupTaskRunnerServiceFactory::GetForProfile(profile)->
947 StartDeferredTaskRunners(); 952 StartDeferredTaskRunners();
948 } 953 }
949 } 954 }
950 955
951 void ProfileManager::Observe( 956 void ProfileManager::Observe(
952 int type, 957 int type,
953 const content::NotificationSource& source, 958 const content::NotificationSource& source,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 RunCallbacks(callbacks, profile, 1110 RunCallbacks(callbacks, profile,
1106 profile ? Profile::CREATE_STATUS_INITIALIZED : 1111 profile ? Profile::CREATE_STATUS_INITIALIZED :
1107 Profile::CREATE_STATUS_LOCAL_FAIL); 1112 Profile::CREATE_STATUS_LOCAL_FAIL);
1108 } 1113 }
1109 1114
1110 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) { 1115 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) {
1111 TRACE_EVENT0("browser", "ProfileManager::DoFinalInit"); 1116 TRACE_EVENT0("browser", "ProfileManager::DoFinalInit");
1112 TRACK_SCOPED_REGION("Startup", "ProfileManager::DoFinalInit"); 1117 TRACK_SCOPED_REGION("Startup", "ProfileManager::DoFinalInit");
1113 1118
1114 DoFinalInitForServices(profile, go_off_the_record); 1119 DoFinalInitForServices(profile, go_off_the_record);
1115 AddProfileToCache(profile); 1120 AddProfileToStorage(profile);
1116 DoFinalInitLogging(profile); 1121 DoFinalInitLogging(profile);
1117 1122
1118 content::NotificationService::current()->Notify( 1123 content::NotificationService::current()->Notify(
1119 chrome::NOTIFICATION_PROFILE_ADDED, 1124 chrome::NOTIFICATION_PROFILE_ADDED,
1120 content::Source<Profile>(profile), 1125 content::Source<Profile>(profile),
1121 content::NotificationService::NoDetails()); 1126 content::NotificationService::NoDetails());
1122 1127
1123 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) 1128 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
1124 // Record statistics to ProfileInfoCache if statistics were not recorded 1129 // Record statistics to ProfileInfoCache if statistics were not recorded
1125 // during shutdown, i.e. the last shutdown was a system shutdown or a crash. 1130 // during shutdown, i.e. the last shutdown was a system shutdown or a crash.
1126 if (!profile->IsGuestSession() && !profile->IsSystemProfile() && 1131 if (!profile->IsGuestSession() && !profile->IsSystemProfile() &&
1127 !profile->IsNewProfile() && !go_off_the_record && 1132 !profile->IsNewProfile() && !go_off_the_record &&
1128 profile->GetLastSessionExitType() != Profile::EXIT_NORMAL) { 1133 profile->GetLastSessionExitType() != Profile::EXIT_NORMAL) {
1129 ProfileStatisticsFactory::GetForProfile(profile)->GatherStatistics( 1134 ProfileStatisticsFactory::GetForProfile(profile)->GatherStatistics(
1130 profiles::ProfileStatisticsCallback()); 1135 profiles::ProfileStatisticsCallback());
1131 } 1136 }
1132 #endif 1137 #endif
1133 } 1138 }
1134 1139
1135 void ProfileManager::DoFinalInitForServices(Profile* profile, 1140 void ProfileManager::DoFinalInitForServices(Profile* profile,
1136 bool go_off_the_record) { 1141 bool go_off_the_record) {
1137 TRACE_EVENT0("browser", "ProfileManager::DoFinalInitForServices"); 1142 TRACE_EVENT0("browser", "ProfileManager::DoFinalInitForServices");
1138 TRACK_SCOPED_REGION("Startup", "ProfileManager::DoFinalInitForServices"); 1143 TRACK_SCOPED_REGION("Startup", "ProfileManager::DoFinalInitForServices");
1139 1144
1140 #if defined(ENABLE_EXTENSIONS) 1145 #if defined(ENABLE_EXTENSIONS)
1141 ProfileInfoCache& cache = GetProfileInfoCache();
1142
1143 // Ensure that the HostContentSettingsMap has been created before the 1146 // Ensure that the HostContentSettingsMap has been created before the
1144 // ExtensionSystem is initialized otherwise the ExtensionSystem will be 1147 // ExtensionSystem is initialized otherwise the ExtensionSystem will be
1145 // registered twice 1148 // registered twice
1146 HostContentSettingsMap* content_settings_map = 1149 HostContentSettingsMap* content_settings_map =
1147 HostContentSettingsMapFactory::GetForProfile(profile); 1150 HostContentSettingsMapFactory::GetForProfile(profile);
1148 1151
1149 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( 1152 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile(
1150 !go_off_the_record); 1153 !go_off_the_record);
1151 // During tests, when |profile| is an instance of TestingProfile, 1154 // During tests, when |profile| is an instance of TestingProfile,
1152 // ExtensionSystem might not create an ExtensionService. 1155 // ExtensionSystem might not create an ExtensionService.
1153 // This block is duplicated in the HostContentSettingsMapFactory 1156 // This block is duplicated in the HostContentSettingsMapFactory
1154 // ::BuildServiceInstanceFor method, it should be called once when both the 1157 // ::BuildServiceInstanceFor method, it should be called once when both the
1155 // HostContentSettingsMap and the extension_service are set up. 1158 // HostContentSettingsMap and the extension_service are set up.
1156 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { 1159 if (extensions::ExtensionSystem::Get(profile)->extension_service()) {
1157 extensions::ExtensionSystem::Get(profile)->extension_service()-> 1160 extensions::ExtensionSystem::Get(profile)->extension_service()->
1158 RegisterContentSettings(content_settings_map); 1161 RegisterContentSettings(content_settings_map);
1159 } 1162 }
1160 // Set the block extensions bit on the ExtensionService. There likely are no 1163 // Set the block extensions bit on the ExtensionService. There likely are no
1161 // blockable extensions to block. 1164 // blockable extensions to block.
1162 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); 1165 ProfileAttributesEntry* entry;
1163 if (profile_index != std::string::npos && 1166 bool has_entry = GetProfileAttributesStorage().
1164 cache.ProfileIsSigninRequiredAtIndex(profile_index)) { 1167 GetProfileAttributesWithPath(profile->GetPath(), &entry);
1168 if (has_entry && entry->IsSigninRequired()) {
1165 extensions::ExtensionSystem::Get(profile) 1169 extensions::ExtensionSystem::Get(profile)
1166 ->extension_service() 1170 ->extension_service()
1167 ->BlockAllExtensions(); 1171 ->BlockAllExtensions();
1168 } 1172 }
1169 1173
1170 #endif 1174 #endif
1171 #if defined(ENABLE_SUPERVISED_USERS) 1175 #if defined(ENABLE_SUPERVISED_USERS)
1172 // Initialization needs to happen after extension system initialization (for 1176 // Initialization needs to happen after extension system initialization (for
1173 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the 1177 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the
1174 // initializing the supervised flag if necessary). 1178 // initializing the supervised flag if necessary).
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 1335
1332 #if !defined(OS_ANDROID) 1336 #if !defined(OS_ANDROID)
1333 void ProfileManager::FinishDeletingProfile( 1337 void ProfileManager::FinishDeletingProfile(
1334 const base::FilePath& profile_dir, 1338 const base::FilePath& profile_dir,
1335 const base::FilePath& new_active_profile_dir) { 1339 const base::FilePath& new_active_profile_dir) {
1336 // Update the last used profile pref before closing browser windows. This 1340 // Update the last used profile pref before closing browser windows. This
1337 // way the correct last used profile is set for any notification observers. 1341 // way the correct last used profile is set for any notification observers.
1338 profiles::SetLastUsedProfile( 1342 profiles::SetLastUsedProfile(
1339 new_active_profile_dir.BaseName().MaybeAsASCII()); 1343 new_active_profile_dir.BaseName().MaybeAsASCII());
1340 1344
1341 ProfileInfoCache& cache = GetProfileInfoCache(); 1345 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
1342 // TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we 1346 // TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we
1343 // start deleting the profile instance we need to close background apps too. 1347 // start deleting the profile instance we need to close background apps too.
1344 Profile* profile = GetProfileByPath(profile_dir); 1348 Profile* profile = GetProfileByPath(profile_dir);
1345 1349
1346 if (profile) { 1350 if (profile) {
1347 // TODO: Migrate additional code in this block to observe this notification 1351 // TODO: Migrate additional code in this block to observe this notification
1348 // instead of being implemented here. 1352 // instead of being implemented here.
1349 content::NotificationService::current()->Notify( 1353 content::NotificationService::current()->Notify(
1350 chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 1354 chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
1351 content::Source<Profile>(profile), 1355 content::Source<Profile>(profile),
1352 content::NotificationService::NoDetails()); 1356 content::NotificationService::NoDetails());
1353 1357
1354 // By this point, all in-progress downloads for the profile being deleted 1358 // By this point, all in-progress downloads for the profile being deleted
1355 // must have been canceled (crbug.com/336725). 1359 // must have been canceled (crbug.com/336725).
1356 DCHECK(DownloadServiceFactory::GetForBrowserContext(profile)-> 1360 DCHECK(DownloadServiceFactory::GetForBrowserContext(profile)->
1357 NonMaliciousDownloadCount() == 0); 1361 NonMaliciousDownloadCount() == 0);
1358 BrowserList::CloseAllBrowsersWithProfile(profile); 1362 BrowserList::CloseAllBrowsersWithProfile(profile);
1359 1363
1360 // Disable sync for doomed profile. 1364 // Disable sync for doomed profile.
1361 if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( 1365 if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService(
1362 profile)) { 1366 profile)) {
1363 ProfileSyncService* sync_service = 1367 ProfileSyncService* sync_service =
1364 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); 1368 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
1365 if (sync_service->IsSyncRequested()) { 1369 if (sync_service->IsSyncRequested()) {
1366 // Record sync stopped by profile destruction if it was on before. 1370 // Record sync stopped by profile destruction if it was on before.
1367 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", 1371 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource",
1368 syncer::PROFILE_DESTRUCTION, 1372 syncer::PROFILE_DESTRUCTION,
1369 syncer::STOP_SOURCE_LIMIT); 1373 syncer::STOP_SOURCE_LIMIT);
1370 } 1374 }
1371 // Ensure data is cleared even if sync was already off. 1375 // Ensure data is cleared even if sync was already off.
1372 ProfileSyncServiceFactory::GetInstance()->GetForProfile( 1376 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
1373 profile)->RequestStop(ProfileSyncService::CLEAR_DATA); 1377 profile)->RequestStop(ProfileSyncService::CLEAR_DATA);
1374 } 1378 }
1375 1379
1376 ProfileMetrics::LogProfileDelete(cache.ProfileIsAuthenticatedAtIndex( 1380 ProfileAttributesEntry* entry;
1377 cache.GetIndexOfProfileWithPath(profile_dir))); 1381 bool has_entry = storage.GetProfileAttributesWithPath(profile_dir, &entry);
1382 DCHECK(has_entry);
1383 ProfileMetrics::LogProfileDelete(entry->IsAuthenticated());
1378 // Some platforms store passwords in keychains. They should be removed. 1384 // Some platforms store passwords in keychains. They should be removed.
1379 scoped_refptr<password_manager::PasswordStore> password_store = 1385 scoped_refptr<password_manager::PasswordStore> password_store =
1380 PasswordStoreFactory::GetForProfile( 1386 PasswordStoreFactory::GetForProfile(
1381 profile, ServiceAccessType::EXPLICIT_ACCESS).get(); 1387 profile, ServiceAccessType::EXPLICIT_ACCESS).get();
1382 if (password_store.get()) { 1388 if (password_store.get()) {
1383 password_store->RemoveLoginsCreatedBetween( 1389 password_store->RemoveLoginsCreatedBetween(
1384 base::Time(), base::Time::Max(), base::Closure()); 1390 base::Time(), base::Time::Max(), base::Closure());
1385 } 1391 }
1386 1392
1387 // The Profile Data doesn't get wiped until Chrome closes. Since we promised 1393 // The Profile Data doesn't get wiped until Chrome closes. Since we promised
1388 // that the user's data would be removed, do so immediately. 1394 // that the user's data would be removed, do so immediately.
1389 profiles::RemoveBrowsingDataForProfile(profile_dir); 1395 profiles::RemoveBrowsingDataForProfile(profile_dir);
1390 } else { 1396 } else {
1391 // It is safe to delete a not yet loaded Profile from disk. 1397 // It is safe to delete a not yet loaded Profile from disk.
1392 BrowserThread::PostTask( 1398 BrowserThread::PostTask(
1393 BrowserThread::FILE, FROM_HERE, 1399 BrowserThread::FILE, FROM_HERE,
1394 base::Bind(&NukeProfileFromDisk, profile_dir)); 1400 base::Bind(&NukeProfileFromDisk, profile_dir));
1395 } 1401 }
1396 1402
1397 // Queue even a profile that was nuked so it will be MarkedForDeletion and so 1403 // Queue even a profile that was nuked so it will be MarkedForDeletion and so
1398 // CreateProfileAsync can't create it. 1404 // CreateProfileAsync can't create it.
1399 QueueProfileDirectoryForDeletion(profile_dir); 1405 QueueProfileDirectoryForDeletion(profile_dir);
1400 cache.DeleteProfileFromCache(profile_dir); 1406 storage.RemoveProfile(profile_dir);
1401 ProfileMetrics::UpdateReportedProfilesStatistics(this); 1407 ProfileMetrics::UpdateReportedProfilesStatistics(this);
1402 } 1408 }
1403 #endif // !defined(OS_ANDROID) 1409 #endif // !defined(OS_ANDROID)
1404 1410
1405 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile( 1411 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile(
1406 Profile* profile, 1412 Profile* profile,
1407 bool created) { 1413 bool created) {
1408 TRACE_EVENT0("browser", "ProfileManager::RegisterProfile"); 1414 TRACE_EVENT0("browser", "ProfileManager::RegisterProfile");
1409 ProfileInfo* info = new ProfileInfo(profile, created); 1415 ProfileInfo* info = new ProfileInfo(profile, created);
1410 profiles_info_.insert( 1416 profiles_info_.insert(
1411 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info))); 1417 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info)));
1412 return info; 1418 return info;
1413 } 1419 }
1414 1420
1415 ProfileManager::ProfileInfo* ProfileManager::GetProfileInfoByPath( 1421 ProfileManager::ProfileInfo* ProfileManager::GetProfileInfoByPath(
1416 const base::FilePath& path) const { 1422 const base::FilePath& path) const {
1417 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path); 1423 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path);
1418 return (iter == profiles_info_.end()) ? NULL : iter->second.get(); 1424 return (iter == profiles_info_.end()) ? NULL : iter->second.get();
1419 } 1425 }
1420 1426
1421 void ProfileManager::AddProfileToCache(Profile* profile) { 1427 void ProfileManager::AddProfileToStorage(Profile* profile) {
1422 TRACE_EVENT0("browser", "ProfileManager::AddProfileToCache"); 1428 TRACE_EVENT0("browser", "ProfileManager::AddProfileToCache");
1423 if (profile->IsGuestSession() || profile->IsSystemProfile()) 1429 if (profile->IsGuestSession() || profile->IsSystemProfile())
1424 return; 1430 return;
1425 ProfileInfoCache& cache = GetProfileInfoCache(); 1431 // TODO(anthonyvd) : monitor the histogram below to see whether the code path
1426 if (profile->GetPath().DirName() != cache.GetUserDataDir()) 1432 // is used.
1433 if (profile->GetPath().DirName() != user_data_dir()) {
1434 UMA_HISTOGRAM_BOOLEAN("Profile.GetProfileInfoPath.OutsideUserDir", true);
Mike Lerman 2016/04/13 15:07:41 Same as above.
lwchkg 2016/04/13 16:50:57 Done.
1427 return; 1435 return;
1436 }
1437 UMA_HISTOGRAM_BOOLEAN("Profile.GetProfileInfoPath.OutsideUserDir", false);
1438
1428 1439
1429 SigninManagerBase* signin_manager = 1440 SigninManagerBase* signin_manager =
1430 SigninManagerFactory::GetForProfile(profile); 1441 SigninManagerFactory::GetForProfile(profile);
1431 AccountTrackerService* account_tracker = 1442 AccountTrackerService* account_tracker =
1432 AccountTrackerServiceFactory::GetForProfile(profile); 1443 AccountTrackerServiceFactory::GetForProfile(profile);
1433 AccountInfo account_info = account_tracker->GetAccountInfo( 1444 AccountInfo account_info = account_tracker->GetAccountInfo(
1434 signin_manager->GetAuthenticatedAccountId()); 1445 signin_manager->GetAuthenticatedAccountId());
1435 base::string16 username = base::UTF8ToUTF16(account_info.email); 1446 base::string16 username = base::UTF8ToUTF16(account_info.email);
1436 1447
1437 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); 1448 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
1438 if (profile_index != std::string::npos) { 1449 // |entry| and |has_entry| below are put inside a pair of brackets for
1439 // The ProfileInfoCache's info must match the Signin Manager. 1450 // scoping, to avoid potential clashes of variable names.
1440 cache.SetAuthInfoOfProfileAtIndex(profile_index, account_info.gaia, 1451 {
1441 username); 1452 ProfileAttributesEntry* entry;
1442 return; 1453 bool has_entry = storage.GetProfileAttributesWithPath(profile->GetPath(),
1454 &entry);
1455 if (has_entry) {
1456 // The ProfileAttributesStorage's info must match the Signin Manager.
1457 entry->SetAuthInfo(account_info.gaia, username);
1458 return;
1459 }
1443 } 1460 }
1444 1461
1445 // Profile name and avatar are set by InitProfileUserPrefs and stored in the 1462 // Profile name and avatar are set by InitProfileUserPrefs and stored in the
1446 // profile. Use those values to setup the cache entry. 1463 // profile. Use those values to setup the entry in profile attributes storage.
1447 base::string16 profile_name = 1464 base::string16 profile_name =
1448 base::UTF8ToUTF16(profile->GetPrefs()->GetString(prefs::kProfileName)); 1465 base::UTF8ToUTF16(profile->GetPrefs()->GetString(prefs::kProfileName));
1449 1466
1450 size_t icon_index = profile->GetPrefs()->GetInteger( 1467 size_t icon_index =
1451 prefs::kProfileAvatarIndex); 1468 profile->GetPrefs()->GetInteger(prefs::kProfileAvatarIndex);
1452 1469
1453 std::string supervised_user_id = 1470 std::string supervised_user_id =
1454 profile->GetPrefs()->GetString(prefs::kSupervisedUserId); 1471 profile->GetPrefs()->GetString(prefs::kSupervisedUserId);
1455 1472
1456 cache.AddProfileToCache(profile->GetPath(), 1473 storage.AddProfile(profile->GetPath(), profile_name, account_info.gaia,
1457 profile_name, 1474 username, icon_index, supervised_user_id);
1458 account_info.gaia,
1459 username,
1460 icon_index,
1461 supervised_user_id);
1462 1475
1463 if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) { 1476 if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) {
1464 cache.SetProfileIsEphemeralAtIndex( 1477 ProfileAttributesEntry* entry;
1465 cache.GetIndexOfProfileWithPath(profile->GetPath()), true); 1478 bool has_entry = storage.GetProfileAttributesWithPath(profile->GetPath(),
1479 &entry);
1480 DCHECK(has_entry);
1481 entry->SetIsEphemeral(true);
1466 } 1482 }
1467 } 1483 }
1468 1484
1469 void ProfileManager::SetNonPersonalProfilePrefs(Profile* profile) { 1485 void ProfileManager::SetNonPersonalProfilePrefs(Profile* profile) {
1470 PrefService* prefs = profile->GetPrefs(); 1486 PrefService* prefs = profile->GetPrefs();
1471 prefs->SetBoolean(prefs::kSigninAllowed, false); 1487 prefs->SetBoolean(prefs::kSigninAllowed, false);
1472 prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false); 1488 prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false);
1473 prefs->SetBoolean(bookmarks::prefs::kShowBookmarkBar, false); 1489 prefs->SetBoolean(bookmarks::prefs::kShowBookmarkBar, false);
1474 prefs->ClearPref(DefaultSearchManager::kDefaultSearchProviderDataPrefName); 1490 prefs->ClearPref(DefaultSearchManager::kDefaultSearchProviderDataPrefName);
1475 } 1491 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 DCHECK(local_state); 1523 DCHECK(local_state);
1508 // Only keep track of profiles that we are managing; tests may create others. 1524 // Only keep track of profiles that we are managing; tests may create others.
1509 // Also never consider the SystemProfile as "active". 1525 // Also never consider the SystemProfile as "active".
1510 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end() && 1526 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end() &&
1511 !last_active->IsSystemProfile()) { 1527 !last_active->IsSystemProfile()) {
1512 std::string profile_path_base = 1528 std::string profile_path_base =
1513 last_active->GetPath().BaseName().MaybeAsASCII(); 1529 last_active->GetPath().BaseName().MaybeAsASCII();
1514 if (profile_path_base != GetLastUsedProfileName()) 1530 if (profile_path_base != GetLastUsedProfileName())
1515 profiles::SetLastUsedProfile(profile_path_base); 1531 profiles::SetLastUsedProfile(profile_path_base);
1516 1532
1517 ProfileInfoCache& cache = GetProfileInfoCache(); 1533 ProfileAttributesEntry* entry;
1518 size_t profile_index = 1534 if (GetProfileAttributesStorage().
1519 cache.GetIndexOfProfileWithPath(last_active->GetPath()); 1535 GetProfileAttributesWithPath(last_active->GetPath(), &entry)) {
1520 if (profile_index != std::string::npos) {
1521 #if !defined(OS_CHROMEOS) 1536 #if !defined(OS_CHROMEOS)
1522 // Incognito Profiles don't have ProfileKeyedServices. 1537 // Incognito Profiles don't have ProfileKeyedServices.
1523 if (!last_active->IsOffTheRecord()) { 1538 if (!last_active->IsOffTheRecord()) {
1524 CrossDevicePromoFactory::GetForProfile(last_active) 1539 CrossDevicePromoFactory::GetForProfile(last_active)->
1525 ->MaybeBrowsingSessionStarted( 1540 MaybeBrowsingSessionStarted(entry->GetActiveTime());
1526 cache.GetProfileActiveTimeAtIndex(profile_index));
1527 } 1541 }
1528 #endif 1542 #endif
1529 cache.SetProfileActiveTimeAtIndex(profile_index); 1543 entry->SetActiveTimeToNow();
1530 } 1544 }
1531 } 1545 }
1532 } 1546 }
1533 1547
1534 ProfileManager::BrowserListObserver::BrowserListObserver( 1548 ProfileManager::BrowserListObserver::BrowserListObserver(
1535 ProfileManager* manager) 1549 ProfileManager* manager)
1536 : profile_manager_(manager) { 1550 : profile_manager_(manager) {
1537 BrowserList::AddObserver(this); 1551 BrowserList::AddObserver(this);
1538 } 1552 }
1539 1553
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 1630
1617 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); 1631 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path);
1618 if (!original_callback.is_null()) 1632 if (!original_callback.is_null())
1619 original_callback.Run(loaded_profile, status); 1633 original_callback.Run(loaded_profile, status);
1620 } 1634 }
1621 #endif // !defined(OS_ANDROID) 1635 #endif // !defined(OS_ANDROID)
1622 1636
1623 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1637 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1624 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1638 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1625 } 1639 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698