| 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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 for (it = active_profiles_.begin(); it != active_profiles_.end(); ++it) { | 728 for (it = active_profiles_.begin(); it != active_profiles_.end(); ++it) { |
| 729 std::string profile_path = (*it)->GetPath().BaseName().MaybeAsASCII(); | 729 std::string profile_path = (*it)->GetPath().BaseName().MaybeAsASCII(); |
| 730 if (profile_paths.find(profile_path) == profile_paths.end()) { | 730 if (profile_paths.find(profile_path) == profile_paths.end()) { |
| 731 profile_paths.insert(profile_path); | 731 profile_paths.insert(profile_path); |
| 732 profile_list->Append(new StringValue(profile_path)); | 732 profile_list->Append(new StringValue(profile_path)); |
| 733 } | 733 } |
| 734 } | 734 } |
| 735 } | 735 } |
| 736 } | 736 } |
| 737 | 737 |
| 738 // static | |
| 739 bool ProfileManager::IsImportProcess(const CommandLine& command_line) { | |
| 740 return (command_line.HasSwitch(switches::kImport) || | |
| 741 command_line.HasSwitch(switches::kImportFromFile)); | |
| 742 } | |
| 743 | |
| 744 void ProfileManager::SetWillImport() { | 738 void ProfileManager::SetWillImport() { |
| 745 will_import_ = true; | 739 will_import_ = true; |
| 746 } | 740 } |
| 747 | 741 |
| 748 void ProfileManager::OnImportFinished(Profile* profile) { | 742 void ProfileManager::OnImportFinished(Profile* profile) { |
| 749 will_import_ = false; | 743 will_import_ = false; |
| 750 DCHECK(profile); | 744 DCHECK(profile); |
| 751 | 745 |
| 752 #if !defined(OS_CHROMEOS) | 746 #if !defined(OS_CHROMEOS) |
| 753 // If the import process was not run, it means this branch was not called, | 747 // 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... |
| 809 ProfileMetrics::LogNumberOfProfiles(this); | 803 ProfileMetrics::LogNumberOfProfiles(this); |
| 810 content::NotificationService::current()->Notify( | 804 content::NotificationService::current()->Notify( |
| 811 chrome::NOTIFICATION_PROFILE_ADDED, | 805 chrome::NOTIFICATION_PROFILE_ADDED, |
| 812 content::Source<Profile>(profile), | 806 content::Source<Profile>(profile), |
| 813 content::NotificationService::NoDetails()); | 807 content::NotificationService::NoDetails()); |
| 814 } | 808 } |
| 815 | 809 |
| 816 void ProfileManager::DoFinalInitForServices(Profile* profile, | 810 void ProfileManager::DoFinalInitForServices(Profile* profile, |
| 817 bool go_off_the_record) { | 811 bool go_off_the_record) { |
| 818 #if defined(ENABLE_EXTENSIONS) | 812 #if defined(ENABLE_EXTENSIONS) |
| 819 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 813 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( |
| 820 if (!IsImportProcess(command_line)) { | 814 !go_off_the_record); |
| 821 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( | 815 // During tests, when |profile| is an instance of TestingProfile, |
| 822 !go_off_the_record); | 816 // ExtensionSystem might not create an ExtensionService. |
| 823 // During tests, when |profile| is an instance of TestingProfile, | 817 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { |
| 824 // ExtensionSystem might not create an ExtensionService. | 818 profile->GetHostContentSettingsMap()->RegisterExtensionService( |
| 825 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { | 819 extensions::ExtensionSystem::Get(profile)->extension_service()); |
| 826 profile->GetHostContentSettingsMap()->RegisterExtensionService( | |
| 827 extensions::ExtensionSystem::Get(profile)->extension_service()); | |
| 828 } | |
| 829 } | 820 } |
| 830 #endif | 821 #endif |
| 831 #if defined(ENABLE_MANAGED_USERS) | 822 #if defined(ENABLE_MANAGED_USERS) |
| 832 // Initialization needs to happen after extension system initialization (for | 823 // Initialization needs to happen after extension system initialization (for |
| 833 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the | 824 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the |
| 834 // initializing the managed flag if necessary). | 825 // initializing the managed flag if necessary). |
| 835 ManagedUserServiceFactory::GetForProfile(profile)->Init(); | 826 ManagedUserServiceFactory::GetForProfile(profile)->Init(); |
| 836 #endif | 827 #endif |
| 837 // Start the deferred task runners once the profile is loaded. | 828 // Start the deferred task runners once the profile is loaded. |
| 838 StartupTaskRunnerServiceFactory::GetForProfile(profile)-> | 829 StartupTaskRunnerServiceFactory::GetForProfile(profile)-> |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 ProfileManager::ProfileInfo::ProfileInfo( | 1177 ProfileManager::ProfileInfo::ProfileInfo( |
| 1187 Profile* profile, | 1178 Profile* profile, |
| 1188 bool created) | 1179 bool created) |
| 1189 : profile(profile), | 1180 : profile(profile), |
| 1190 created(created) { | 1181 created(created) { |
| 1191 } | 1182 } |
| 1192 | 1183 |
| 1193 ProfileManager::ProfileInfo::~ProfileInfo() { | 1184 ProfileManager::ProfileInfo::~ProfileInfo() { |
| 1194 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1185 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
| 1195 } | 1186 } |
| OLD | NEW |