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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 for (it = active_profiles_.begin(); it != active_profiles_.end(); ++it) { | 706 for (it = active_profiles_.begin(); it != active_profiles_.end(); ++it) { |
707 std::string profile_path = (*it)->GetPath().BaseName().MaybeAsASCII(); | 707 std::string profile_path = (*it)->GetPath().BaseName().MaybeAsASCII(); |
708 if (profile_paths.find(profile_path) == profile_paths.end()) { | 708 if (profile_paths.find(profile_path) == profile_paths.end()) { |
709 profile_paths.insert(profile_path); | 709 profile_paths.insert(profile_path); |
710 profile_list->Append(new StringValue(profile_path)); | 710 profile_list->Append(new StringValue(profile_path)); |
711 } | 711 } |
712 } | 712 } |
713 } | 713 } |
714 } | 714 } |
715 | 715 |
716 // static | |
717 bool ProfileManager::IsImportProcess(const CommandLine& command_line) { | |
718 return (command_line.HasSwitch(switches::kImport) || | |
719 command_line.HasSwitch(switches::kImportFromFile)); | |
720 } | |
721 | |
722 void ProfileManager::SetWillImport() { | 716 void ProfileManager::SetWillImport() { |
723 will_import_ = true; | 717 will_import_ = true; |
724 } | 718 } |
725 | 719 |
726 void ProfileManager::OnImportFinished(Profile* profile) { | 720 void ProfileManager::OnImportFinished(Profile* profile) { |
727 will_import_ = false; | 721 will_import_ = false; |
728 DCHECK(profile); | 722 DCHECK(profile); |
729 | 723 |
730 #if !defined(OS_CHROMEOS) | 724 #if !defined(OS_CHROMEOS) |
731 // If the import process was not run, it means this branch was not called, | 725 // 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... |
787 ProfileMetrics::LogNumberOfProfiles(this); | 781 ProfileMetrics::LogNumberOfProfiles(this); |
788 content::NotificationService::current()->Notify( | 782 content::NotificationService::current()->Notify( |
789 chrome::NOTIFICATION_PROFILE_ADDED, | 783 chrome::NOTIFICATION_PROFILE_ADDED, |
790 content::Source<Profile>(profile), | 784 content::Source<Profile>(profile), |
791 content::NotificationService::NoDetails()); | 785 content::NotificationService::NoDetails()); |
792 } | 786 } |
793 | 787 |
794 void ProfileManager::DoFinalInitForServices(Profile* profile, | 788 void ProfileManager::DoFinalInitForServices(Profile* profile, |
795 bool go_off_the_record) { | 789 bool go_off_the_record) { |
796 #if defined(ENABLE_EXTENSIONS) | 790 #if defined(ENABLE_EXTENSIONS) |
797 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 791 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( |
798 if (!IsImportProcess(command_line)) { | 792 !go_off_the_record); |
799 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( | 793 // During tests, when |profile| is an instance of TestingProfile, |
800 !go_off_the_record); | 794 // ExtensionSystem might not create an ExtensionService. |
801 // During tests, when |profile| is an instance of TestingProfile, | 795 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { |
802 // ExtensionSystem might not create an ExtensionService. | 796 profile->GetHostContentSettingsMap()->RegisterExtensionService( |
803 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { | 797 extensions::ExtensionSystem::Get(profile)->extension_service()); |
804 profile->GetHostContentSettingsMap()->RegisterExtensionService( | |
805 extensions::ExtensionSystem::Get(profile)->extension_service()); | |
806 } | |
807 } | 798 } |
808 #endif | 799 #endif |
809 #if defined(ENABLE_MANAGED_USERS) | 800 #if defined(ENABLE_MANAGED_USERS) |
810 // Initialization needs to happen after extension system initialization (for | 801 // Initialization needs to happen after extension system initialization (for |
811 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the | 802 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the |
812 // initializing the managed flag if necessary). | 803 // initializing the managed flag if necessary). |
813 ManagedUserServiceFactory::GetForProfile(profile)->Init(); | 804 ManagedUserServiceFactory::GetForProfile(profile)->Init(); |
814 #endif | 805 #endif |
815 // Start the deferred task runners once the profile is loaded. | 806 // Start the deferred task runners once the profile is loaded. |
816 StartupTaskRunnerServiceFactory::GetForProfile(profile)-> | 807 StartupTaskRunnerServiceFactory::GetForProfile(profile)-> |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 ProfileManager::ProfileInfo::ProfileInfo( | 1155 ProfileManager::ProfileInfo::ProfileInfo( |
1165 Profile* profile, | 1156 Profile* profile, |
1166 bool created) | 1157 bool created) |
1167 : profile(profile), | 1158 : profile(profile), |
1168 created(created) { | 1159 created(created) { |
1169 } | 1160 } |
1170 | 1161 |
1171 ProfileManager::ProfileInfo::~ProfileInfo() { | 1162 ProfileManager::ProfileInfo::~ProfileInfo() { |
1172 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1163 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
1173 } | 1164 } |
OLD | NEW |