| 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
| 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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 // Only keep track of profiles that we are managing; tests may create others. | 716 // Only keep track of profiles that we are managing; tests may create others. |
| 717 if (profile_manager_->profiles_info_.find( | 717 if (profile_manager_->profiles_info_.find( |
| 718 last_active->GetPath()) != profile_manager_->profiles_info_.end()) { | 718 last_active->GetPath()) != profile_manager_->profiles_info_.end()) { |
| 719 local_state->SetString(prefs::kProfileLastUsed, | 719 local_state->SetString(prefs::kProfileLastUsed, |
| 720 last_active->GetPath().BaseName().MaybeAsASCII()); | 720 last_active->GetPath().BaseName().MaybeAsASCII()); |
| 721 } | 721 } |
| 722 } | 722 } |
| 723 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 723 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 724 | 724 |
| 725 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) { | 725 void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) { |
| 726 InitProfileUserPrefs(profile); |
| 726 DoFinalInitForServices(profile, go_off_the_record); | 727 DoFinalInitForServices(profile, go_off_the_record); |
| 727 InitProfileUserPrefs(profile); | |
| 728 AddProfileToCache(profile); | 728 AddProfileToCache(profile); |
| 729 DoFinalInitLogging(profile); | 729 DoFinalInitLogging(profile); |
| 730 | 730 |
| 731 ProfileMetrics::LogNumberOfProfiles(this, ProfileMetrics::ADD_PROFILE_EVENT); | 731 ProfileMetrics::LogNumberOfProfiles(this, ProfileMetrics::ADD_PROFILE_EVENT); |
| 732 content::NotificationService::current()->Notify( | 732 content::NotificationService::current()->Notify( |
| 733 chrome::NOTIFICATION_PROFILE_ADDED, | 733 chrome::NOTIFICATION_PROFILE_ADDED, |
| 734 content::Source<Profile>(profile), | 734 content::Source<Profile>(profile), |
| 735 content::NotificationService::NoDetails()); | 735 content::NotificationService::NoDetails()); |
| 736 | 736 |
| 737 } | 737 } |
| 738 | 738 |
| 739 void ProfileManager::DoFinalInitForServices(Profile* profile, | 739 void ProfileManager::DoFinalInitForServices(Profile* profile, |
| 740 bool go_off_the_record) { | 740 bool go_off_the_record) { |
| 741 #if defined(ENABLE_EXTENSIONS) | 741 #if defined(ENABLE_EXTENSIONS) |
| 742 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 742 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 743 if (!IsImportProcess(command_line)) { | 743 if (!IsImportProcess(command_line)) { |
| 744 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( | 744 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( |
| 745 !go_off_the_record); | 745 !go_off_the_record); |
| 746 // During tests, when |profile| is an instance of TestingProfile, | 746 // During tests, when |profile| is an instance of TestingProfile, |
| 747 // ExtensionSystem might not create an ExtensionService. | 747 // ExtensionSystem might not create an ExtensionService. |
| 748 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { | 748 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { |
| 749 profile->GetHostContentSettingsMap()->RegisterExtensionService( | 749 profile->GetHostContentSettingsMap()->RegisterExtensionService( |
| 750 extensions::ExtensionSystem::Get(profile)->extension_service()); | 750 extensions::ExtensionSystem::Get(profile)->extension_service()); |
| 751 } | 751 } |
| 752 } | 752 } |
| 753 #endif | 753 #endif |
| 754 #if defined(ENABLE_MANAGED_USERS) |
| 755 // Initialization needs to happen after extension system initialization (for |
| 756 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the |
| 757 // initializing the managed flag if necessary). |
| 758 ManagedUserServiceFactory::GetForProfile(profile)->Init(); |
| 759 #endif |
| 754 } | 760 } |
| 755 | 761 |
| 756 void ProfileManager::DoFinalInitLogging(Profile* profile) { | 762 void ProfileManager::DoFinalInitLogging(Profile* profile) { |
| 757 // Count number of extensions in this profile. | 763 // Count number of extensions in this profile. |
| 758 int extension_count = -1; | 764 int extension_count = -1; |
| 759 #if defined(ENABLE_EXTENSIONS) | 765 #if defined(ENABLE_EXTENSIONS) |
| 760 ExtensionService* extension_service = profile->GetExtensionService(); | 766 ExtensionService* extension_service = profile->GetExtensionService(); |
| 761 if (extension_service) | 767 if (extension_service) |
| 762 extension_count = extension_service->GetAppIds().size(); | 768 extension_count = extension_service->GetAppIds().size(); |
| 763 #endif | 769 #endif |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 avatar_index = cache.ChooseAvatarIconIndexForNewProfile(); | 958 avatar_index = cache.ChooseAvatarIconIndexForNewProfile(); |
| 953 profile_name = UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); | 959 profile_name = UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); |
| 954 } | 960 } |
| 955 | 961 |
| 956 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex)) | 962 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex)) |
| 957 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index); | 963 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index); |
| 958 | 964 |
| 959 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileName)) | 965 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileName)) |
| 960 profile->GetPrefs()->SetString(prefs::kProfileName, profile_name); | 966 profile->GetPrefs()->SetString(prefs::kProfileName, profile_name); |
| 961 | 967 |
| 962 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileIsManaged)) { | 968 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileIsManaged)) |
| 963 profile->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, is_managed); | 969 profile->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, is_managed); |
| 964 #if defined(ENABLE_MANAGED_USERS) | |
| 965 ManagedUserServiceFactory::GetForProfile(profile)->Init(); | |
| 966 #else | |
| 967 DCHECK(!is_managed); | |
| 968 #endif | |
| 969 } | |
| 970 } | 970 } |
| 971 | 971 |
| 972 bool ProfileManager::ShouldGoOffTheRecord() { | 972 bool ProfileManager::ShouldGoOffTheRecord() { |
| 973 bool go_off_the_record = false; | 973 bool go_off_the_record = false; |
| 974 #if defined(OS_CHROMEOS) | 974 #if defined(OS_CHROMEOS) |
| 975 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 975 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 976 if (!logged_in_ && | 976 if (!logged_in_ && |
| 977 (!command_line.HasSwitch(switches::kTestType) || | 977 (!command_line.HasSwitch(switches::kTestType) || |
| 978 command_line.HasSwitch(switches::kLoginProfile))) { | 978 command_line.HasSwitch(switches::kLoginProfile))) { |
| 979 go_off_the_record = true; | 979 go_off_the_record = true; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 ProfileManager::ProfileInfo::ProfileInfo( | 1106 ProfileManager::ProfileInfo::ProfileInfo( |
| 1107 Profile* profile, | 1107 Profile* profile, |
| 1108 bool created) | 1108 bool created) |
| 1109 : profile(profile), | 1109 : profile(profile), |
| 1110 created(created) { | 1110 created(created) { |
| 1111 } | 1111 } |
| 1112 | 1112 |
| 1113 ProfileManager::ProfileInfo::~ProfileInfo() { | 1113 ProfileManager::ProfileInfo::~ProfileInfo() { |
| 1114 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1114 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
| 1115 } | 1115 } |
| OLD | NEW |