OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/profiles/profile_manager.h" | 5 #include "chrome/browser/profiles/profile_manager.h" |
6 | 6 |
7 #include <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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
544 // Make sure that we're not loading a profile with the same ID as a profile | 544 // Make sure that we're not loading a profile with the same ID as a profile |
545 // that's already loaded. | 545 // that's already loaded. |
546 if (GetProfileByPath(profile->GetPath())) { | 546 if (GetProfileByPath(profile->GetPath())) { |
547 NOTREACHED() << "Attempted to add profile with the same path (" << | 547 NOTREACHED() << "Attempted to add profile with the same path (" << |
548 profile->GetPath().value() << | 548 profile->GetPath().value() << |
549 ") as an already-loaded profile."; | 549 ") as an already-loaded profile."; |
550 return false; | 550 return false; |
551 } | 551 } |
552 | 552 |
553 RegisterProfile(profile, true); | 553 RegisterProfile(profile, true); |
554 InitProfileUserPrefs(profile); | |
rpetterson
2013/10/01 20:19:57
It doesn't really change the call flow, so I'm cur
Bernhard Bauer
2013/10/01 20:42:15
InitProfileUserPrefs() is where we mark a profile
rpetterson
2013/10/07 23:22:49
I understand better what's going on now. However,
Bernhard Bauer
2013/10/08 14:56:01
This CL actually does change the behavior for ever
rpetterson
2013/10/08 18:02:55
Yes. If we're changing it for everyone, there shou
| |
554 DoFinalInit(profile, ShouldGoOffTheRecord(profile)); | 555 DoFinalInit(profile, ShouldGoOffTheRecord(profile)); |
555 return true; | 556 return true; |
556 } | 557 } |
557 | 558 |
558 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile( | 559 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile( |
559 Profile* profile, | 560 Profile* profile, |
560 bool created) { | 561 bool created) { |
561 ProfileInfo* info = new ProfileInfo(profile, created); | 562 ProfileInfo* info = new ProfileInfo(profile, created); |
562 profiles_info_.insert( | 563 profiles_info_.insert( |
563 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info))); | 564 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info))); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
707 // Only keep track of profiles that we are managing; tests may create others. | 708 // Only keep track of profiles that we are managing; tests may create others. |
708 if (profile_manager_->profiles_info_.find( | 709 if (profile_manager_->profiles_info_.find( |
709 last_active->GetPath()) != profile_manager_->profiles_info_.end()) { | 710 last_active->GetPath()) != profile_manager_->profiles_info_.end()) { |
710 local_state->SetString(prefs::kProfileLastUsed, | 711 local_state->SetString(prefs::kProfileLastUsed, |
711 last_active->GetPath().BaseName().MaybeAsASCII()); | 712 last_active->GetPath().BaseName().MaybeAsASCII()); |
712 } | 713 } |
713 } | 714 } |
714 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 715 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
715 | 716 |
716 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) { | 717 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) { |
717 InitProfileUserPrefs(profile); | |
718 DoFinalInitForServices(profile, go_off_the_record); | 718 DoFinalInitForServices(profile, go_off_the_record); |
719 AddProfileToCache(profile); | 719 AddProfileToCache(profile); |
720 DoFinalInitLogging(profile); | 720 DoFinalInitLogging(profile); |
721 | 721 |
722 ProfileMetrics::LogNumberOfProfiles(this); | 722 ProfileMetrics::LogNumberOfProfiles(this); |
723 content::NotificationService::current()->Notify( | 723 content::NotificationService::current()->Notify( |
724 chrome::NOTIFICATION_PROFILE_ADDED, | 724 chrome::NOTIFICATION_PROFILE_ADDED, |
725 content::Source<Profile>(profile), | 725 content::Source<Profile>(profile), |
726 content::NotificationService::NoDetails()); | 726 content::NotificationService::NoDetails()); |
727 } | 727 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
798 return Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); | 798 return Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); |
799 } | 799 } |
800 | 800 |
801 Profile* ProfileManager::CreateProfileAsyncHelper(const base::FilePath& path, | 801 Profile* ProfileManager::CreateProfileAsyncHelper(const base::FilePath& path, |
802 Delegate* delegate) { | 802 Delegate* delegate) { |
803 return Profile::CreateProfile(path, | 803 return Profile::CreateProfile(path, |
804 delegate, | 804 delegate, |
805 Profile::CREATE_MODE_ASYNCHRONOUS); | 805 Profile::CREATE_MODE_ASYNCHRONOUS); |
806 } | 806 } |
807 | 807 |
808 void ProfileManager::OnPrefsLoaded(Profile* profile) { | |
809 InitProfileUserPrefs(profile); | |
810 } | |
811 | |
808 void ProfileManager::OnProfileCreated(Profile* profile, | 812 void ProfileManager::OnProfileCreated(Profile* profile, |
809 bool success, | 813 bool success, |
810 bool is_new_profile) { | 814 bool is_new_profile) { |
811 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 815 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
812 | 816 |
813 ProfilesInfoMap::iterator iter = profiles_info_.find(profile->GetPath()); | 817 ProfilesInfoMap::iterator iter = profiles_info_.find(profile->GetPath()); |
814 DCHECK(iter != profiles_info_.end()); | 818 DCHECK(iter != profiles_info_.end()); |
815 ProfileInfo* info = iter->second.get(); | 819 ProfileInfo* info = iter->second.get(); |
816 | 820 |
817 std::vector<CreateCallback> callbacks; | 821 std::vector<CreateCallback> callbacks; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
989 profile_name = UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); | 993 profile_name = UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); |
990 } | 994 } |
991 } | 995 } |
992 | 996 |
993 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex)) | 997 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex)) |
994 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index); | 998 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index); |
995 | 999 |
996 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileName)) | 1000 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileName)) |
997 profile->GetPrefs()->SetString(prefs::kProfileName, profile_name); | 1001 profile->GetPrefs()->SetString(prefs::kProfileName, profile_name); |
998 | 1002 |
999 if (!profile->GetPrefs()->HasPrefPath(prefs::kManagedUserId)) | 1003 if (!profile->GetPrefs()->HasPrefPath(prefs::kManagedUserId)) { |
1004 if (managed_user_id.empty() && | |
1005 CommandLine::ForCurrentProcess()->HasSwitch( | |
1006 switches::kNewProfileIsSupervised)) { | |
1007 managed_user_id = "Test ID"; | |
1008 } | |
1000 profile->GetPrefs()->SetString(prefs::kManagedUserId, managed_user_id); | 1009 profile->GetPrefs()->SetString(prefs::kManagedUserId, managed_user_id); |
1010 } | |
1001 } | 1011 } |
1002 | 1012 |
1003 void ProfileManager::SetGuestProfilePrefs(Profile* profile) { | 1013 void ProfileManager::SetGuestProfilePrefs(Profile* profile) { |
1004 IncognitoModePrefs::SetAvailability(profile->GetPrefs(), | 1014 IncognitoModePrefs::SetAvailability(profile->GetPrefs(), |
1005 IncognitoModePrefs::FORCED); | 1015 IncognitoModePrefs::FORCED); |
1006 profile->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, false); | 1016 profile->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, false); |
1007 } | 1017 } |
1008 | 1018 |
1009 bool ProfileManager::ShouldGoOffTheRecord(Profile* profile) { | 1019 bool ProfileManager::ShouldGoOffTheRecord(Profile* profile) { |
1010 bool go_off_the_record = false; | 1020 bool go_off_the_record = false; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1177 ProfileManager::ProfileInfo::ProfileInfo( | 1187 ProfileManager::ProfileInfo::ProfileInfo( |
1178 Profile* profile, | 1188 Profile* profile, |
1179 bool created) | 1189 bool created) |
1180 : profile(profile), | 1190 : profile(profile), |
1181 created(created) { | 1191 created(created) { |
1182 } | 1192 } |
1183 | 1193 |
1184 ProfileManager::ProfileInfo::~ProfileInfo() { | 1194 ProfileManager::ProfileInfo::~ProfileInfo() { |
1185 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1195 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
1186 } | 1196 } |
OLD | NEW |