| 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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 // Make sure that we're not loading a profile with the same ID as a profile | 545 // Make sure that we're not loading a profile with the same ID as a profile |
| 546 // that's already loaded. | 546 // that's already loaded. |
| 547 if (GetProfileByPath(profile->GetPath())) { | 547 if (GetProfileByPath(profile->GetPath())) { |
| 548 NOTREACHED() << "Attempted to add profile with the same path (" << | 548 NOTREACHED() << "Attempted to add profile with the same path (" << |
| 549 profile->GetPath().value() << | 549 profile->GetPath().value() << |
| 550 ") as an already-loaded profile."; | 550 ") as an already-loaded profile."; |
| 551 return false; | 551 return false; |
| 552 } | 552 } |
| 553 | 553 |
| 554 RegisterProfile(profile, true); | 554 RegisterProfile(profile, true); |
| 555 InitProfileUserPrefs(profile); |
| 555 DoFinalInit(profile, ShouldGoOffTheRecord(profile)); | 556 DoFinalInit(profile, ShouldGoOffTheRecord(profile)); |
| 556 return true; | 557 return true; |
| 557 } | 558 } |
| 558 | 559 |
| 559 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile( | 560 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile( |
| 560 Profile* profile, | 561 Profile* profile, |
| 561 bool created) { | 562 bool created) { |
| 562 ProfileInfo* info = new ProfileInfo(profile, created); | 563 ProfileInfo* info = new ProfileInfo(profile, created); |
| 563 profiles_info_.insert( | 564 profiles_info_.insert( |
| 564 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info))); | 565 std::make_pair(profile->GetPath(), linked_ptr<ProfileInfo>(info))); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 // Only keep track of profiles that we are managing; tests may create others. | 725 // Only keep track of profiles that we are managing; tests may create others. |
| 725 if (profile_manager_->profiles_info_.find( | 726 if (profile_manager_->profiles_info_.find( |
| 726 last_active->GetPath()) != profile_manager_->profiles_info_.end()) { | 727 last_active->GetPath()) != profile_manager_->profiles_info_.end()) { |
| 727 local_state->SetString(prefs::kProfileLastUsed, | 728 local_state->SetString(prefs::kProfileLastUsed, |
| 728 last_active->GetPath().BaseName().MaybeAsASCII()); | 729 last_active->GetPath().BaseName().MaybeAsASCII()); |
| 729 } | 730 } |
| 730 } | 731 } |
| 731 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 732 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 732 | 733 |
| 733 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) { | 734 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) { |
| 734 InitProfileUserPrefs(profile); | |
| 735 DoFinalInitForServices(profile, go_off_the_record); | 735 DoFinalInitForServices(profile, go_off_the_record); |
| 736 AddProfileToCache(profile); | 736 AddProfileToCache(profile); |
| 737 DoFinalInitLogging(profile); | 737 DoFinalInitLogging(profile); |
| 738 | 738 |
| 739 ProfileMetrics::LogNumberOfProfiles(this); | 739 ProfileMetrics::LogNumberOfProfiles(this); |
| 740 content::NotificationService::current()->Notify( | 740 content::NotificationService::current()->Notify( |
| 741 chrome::NOTIFICATION_PROFILE_ADDED, | 741 chrome::NOTIFICATION_PROFILE_ADDED, |
| 742 content::Source<Profile>(profile), | 742 content::Source<Profile>(profile), |
| 743 content::NotificationService::NoDetails()); | 743 content::NotificationService::NoDetails()); |
| 744 } | 744 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 profile_name = UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); | 1006 profile_name = UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); |
| 1007 } | 1007 } |
| 1008 } | 1008 } |
| 1009 | 1009 |
| 1010 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex)) | 1010 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex)) |
| 1011 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index); | 1011 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index); |
| 1012 | 1012 |
| 1013 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileName)) | 1013 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileName)) |
| 1014 profile->GetPrefs()->SetString(prefs::kProfileName, profile_name); | 1014 profile->GetPrefs()->SetString(prefs::kProfileName, profile_name); |
| 1015 | 1015 |
| 1016 if (!profile->GetPrefs()->HasPrefPath(prefs::kManagedUserId)) | 1016 if (!profile->GetPrefs()->HasPrefPath(prefs::kManagedUserId)) { |
| 1017 if (managed_user_id.empty() && |
| 1018 CommandLine::ForCurrentProcess()->HasSwitch( |
| 1019 switches::kNewProfileIsSupervised)) { |
| 1020 managed_user_id = "Test ID"; |
| 1021 } |
| 1017 profile->GetPrefs()->SetString(prefs::kManagedUserId, managed_user_id); | 1022 profile->GetPrefs()->SetString(prefs::kManagedUserId, managed_user_id); |
| 1023 } |
| 1018 } | 1024 } |
| 1019 | 1025 |
| 1020 void ProfileManager::SetGuestProfilePrefs(Profile* profile) { | 1026 void ProfileManager::SetGuestProfilePrefs(Profile* profile) { |
| 1021 IncognitoModePrefs::SetAvailability(profile->GetPrefs(), | 1027 IncognitoModePrefs::SetAvailability(profile->GetPrefs(), |
| 1022 IncognitoModePrefs::FORCED); | 1028 IncognitoModePrefs::FORCED); |
| 1023 profile->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, false); | 1029 profile->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, false); |
| 1024 } | 1030 } |
| 1025 | 1031 |
| 1026 bool ProfileManager::ShouldGoOffTheRecord(Profile* profile) { | 1032 bool ProfileManager::ShouldGoOffTheRecord(Profile* profile) { |
| 1027 bool go_off_the_record = false; | 1033 bool go_off_the_record = false; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 ProfileManager::ProfileInfo::ProfileInfo( | 1200 ProfileManager::ProfileInfo::ProfileInfo( |
| 1195 Profile* profile, | 1201 Profile* profile, |
| 1196 bool created) | 1202 bool created) |
| 1197 : profile(profile), | 1203 : profile(profile), |
| 1198 created(created) { | 1204 created(created) { |
| 1199 } | 1205 } |
| 1200 | 1206 |
| 1201 ProfileManager::ProfileInfo::~ProfileInfo() { | 1207 ProfileManager::ProfileInfo::~ProfileInfo() { |
| 1202 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1208 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
| 1203 } | 1209 } |
| OLD | NEW |