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