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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 for (it = active_profiles_.begin(); it != active_profiles_.end(); ++it) { | 741 for (it = active_profiles_.begin(); it != active_profiles_.end(); ++it) { |
742 std::string profile_path = (*it)->GetPath().BaseName().MaybeAsASCII(); | 742 std::string profile_path = (*it)->GetPath().BaseName().MaybeAsASCII(); |
743 if (profile_paths.find(profile_path) == profile_paths.end()) { | 743 if (profile_paths.find(profile_path) == profile_paths.end()) { |
744 profile_paths.insert(profile_path); | 744 profile_paths.insert(profile_path); |
745 profile_list->Append(new StringValue(profile_path)); | 745 profile_list->Append(new StringValue(profile_path)); |
746 } | 746 } |
747 } | 747 } |
748 } | 748 } |
749 } | 749 } |
750 | 750 |
751 // static | |
752 bool ProfileManager::IsImportProcess(const CommandLine& command_line) { | |
753 return (command_line.HasSwitch(switches::kImport) || | |
754 command_line.HasSwitch(switches::kImportFromFile)); | |
755 } | |
756 | |
757 void ProfileManager::SetWillImport() { | 751 void ProfileManager::SetWillImport() { |
758 will_import_ = true; | 752 will_import_ = true; |
759 } | 753 } |
760 | 754 |
761 void ProfileManager::OnImportFinished(Profile* profile) { | 755 void ProfileManager::OnImportFinished(Profile* profile) { |
762 will_import_ = false; | 756 will_import_ = false; |
763 DCHECK(profile); | 757 DCHECK(profile); |
764 | 758 |
765 #if !defined(OS_CHROMEOS) | 759 #if !defined(OS_CHROMEOS) |
766 // If the import process was not run, it means this branch was not called, | 760 // If the import process was not run, it means this branch was not called, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 ProfileMetrics::LogNumberOfProfiles(this); | 816 ProfileMetrics::LogNumberOfProfiles(this); |
823 content::NotificationService::current()->Notify( | 817 content::NotificationService::current()->Notify( |
824 chrome::NOTIFICATION_PROFILE_ADDED, | 818 chrome::NOTIFICATION_PROFILE_ADDED, |
825 content::Source<Profile>(profile), | 819 content::Source<Profile>(profile), |
826 content::NotificationService::NoDetails()); | 820 content::NotificationService::NoDetails()); |
827 } | 821 } |
828 | 822 |
829 void ProfileManager::DoFinalInitForServices(Profile* profile, | 823 void ProfileManager::DoFinalInitForServices(Profile* profile, |
830 bool go_off_the_record) { | 824 bool go_off_the_record) { |
831 #if defined(ENABLE_EXTENSIONS) | 825 #if defined(ENABLE_EXTENSIONS) |
832 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 826 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( |
833 if (!IsImportProcess(command_line)) { | 827 !go_off_the_record); |
834 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( | 828 // During tests, when |profile| is an instance of TestingProfile, |
835 !go_off_the_record); | 829 // ExtensionSystem might not create an ExtensionService. |
836 // During tests, when |profile| is an instance of TestingProfile, | 830 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { |
837 // ExtensionSystem might not create an ExtensionService. | 831 profile->GetHostContentSettingsMap()->RegisterExtensionService( |
838 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { | 832 extensions::ExtensionSystem::Get(profile)->extension_service()); |
839 profile->GetHostContentSettingsMap()->RegisterExtensionService( | |
840 extensions::ExtensionSystem::Get(profile)->extension_service()); | |
841 } | |
842 } | 833 } |
843 #endif | 834 #endif |
844 #if defined(ENABLE_MANAGED_USERS) | 835 #if defined(ENABLE_MANAGED_USERS) |
845 // Initialization needs to happen after extension system initialization (for | 836 // Initialization needs to happen after extension system initialization (for |
846 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the | 837 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the |
847 // initializing the managed flag if necessary). | 838 // initializing the managed flag if necessary). |
848 ManagedUserServiceFactory::GetForProfile(profile)->Init(); | 839 ManagedUserServiceFactory::GetForProfile(profile)->Init(); |
849 #endif | 840 #endif |
850 } | 841 } |
851 | 842 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 ProfileManager::ProfileInfo::ProfileInfo( | 1182 ProfileManager::ProfileInfo::ProfileInfo( |
1192 Profile* profile, | 1183 Profile* profile, |
1193 bool created) | 1184 bool created) |
1194 : profile(profile), | 1185 : profile(profile), |
1195 created(created) { | 1186 created(created) { |
1196 } | 1187 } |
1197 | 1188 |
1198 ProfileManager::ProfileInfo::~ProfileInfo() { | 1189 ProfileManager::ProfileInfo::~ProfileInfo() { |
1199 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1190 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
1200 } | 1191 } |
OLD | NEW |