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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #include "chromeos/dbus/cryptohome_client.h" | 62 #include "chromeos/dbus/cryptohome_client.h" |
63 #include "chromeos/dbus/dbus_thread_manager.h" | 63 #include "chromeos/dbus/dbus_thread_manager.h" |
64 #include "chrome/browser/chromeos/login/user_manager.h" | 64 #include "chrome/browser/chromeos/login/user_manager.h" |
65 #endif | 65 #endif |
66 | 66 |
67 using content::BrowserThread; | 67 using content::BrowserThread; |
68 using content::UserMetricsAction; | 68 using content::UserMetricsAction; |
69 | 69 |
70 namespace { | 70 namespace { |
71 | 71 |
| 72 static bool did_perform_profile_import = false; |
| 73 |
72 // Profiles that should be deleted on shutdown. | 74 // Profiles that should be deleted on shutdown. |
73 std::vector<FilePath>& ProfilesToDelete() { | 75 std::vector<FilePath>& ProfilesToDelete() { |
74 CR_DEFINE_STATIC_LOCAL(std::vector<FilePath>, profiles_to_delete, ()); | 76 CR_DEFINE_STATIC_LOCAL(std::vector<FilePath>, profiles_to_delete, ()); |
75 return profiles_to_delete; | 77 return profiles_to_delete; |
76 } | 78 } |
77 | 79 |
78 // Checks if any user prefs for |profile| have default values. | 80 // Checks if any user prefs for |profile| have default values. |
79 bool HasAnyDefaultUserPrefs(Profile* profile) { | 81 bool HasAnyDefaultUserPrefs(Profile* profile) { |
80 const PrefService::Preference* avatar_index = | 82 const PrefService::Preference* avatar_index = |
81 profile->GetPrefs()->FindPreference(prefs::kProfileAvatarIndex); | 83 profile->GetPrefs()->FindPreference(prefs::kProfileAvatarIndex); |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 for (it = active_profiles_.begin(); it != active_profiles_.end(); ++it) { | 626 for (it = active_profiles_.begin(); it != active_profiles_.end(); ++it) { |
625 std::string profile_path = (*it)->GetPath().BaseName().MaybeAsASCII(); | 627 std::string profile_path = (*it)->GetPath().BaseName().MaybeAsASCII(); |
626 if (profile_paths.find(profile_path) == profile_paths.end()) { | 628 if (profile_paths.find(profile_path) == profile_paths.end()) { |
627 profile_paths.insert(profile_path); | 629 profile_paths.insert(profile_path); |
628 profile_list->Append(new StringValue(profile_path)); | 630 profile_list->Append(new StringValue(profile_path)); |
629 } | 631 } |
630 } | 632 } |
631 } | 633 } |
632 } | 634 } |
633 | 635 |
| 636 // static |
| 637 bool ProfileManager::IsImportProcess(const CommandLine& command_line) { |
| 638 return (command_line.HasSwitch(switches::kImport) || |
| 639 command_line.HasSwitch(switches::kImportFromFile)); |
| 640 } |
| 641 |
| 642 // static |
| 643 bool ProfileManager::DidPerformProfileImport() { |
| 644 return did_perform_profile_import; |
| 645 } |
| 646 |
634 void ProfileManager::SetWillImport() { | 647 void ProfileManager::SetWillImport() { |
635 will_import_ = true; | 648 will_import_ = true; |
636 } | 649 } |
637 | 650 |
638 void ProfileManager::OnImportFinished(Profile* profile) { | 651 void ProfileManager::OnImportFinished(Profile* profile) { |
639 will_import_ = false; | 652 will_import_ = false; |
| 653 did_perform_profile_import = true; |
640 DCHECK(profile); | 654 DCHECK(profile); |
641 content::NotificationService::current()->Notify( | 655 content::NotificationService::current()->Notify( |
642 chrome::NOTIFICATION_IMPORT_FINISHED, | 656 chrome::NOTIFICATION_IMPORT_FINISHED, |
643 content::Source<Profile>(profile), | 657 content::Source<Profile>(profile), |
644 content::NotificationService::NoDetails()); | 658 content::NotificationService::NoDetails()); |
645 } | 659 } |
646 | 660 |
647 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 661 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
648 ProfileManager::BrowserListObserver::BrowserListObserver( | 662 ProfileManager::BrowserListObserver::BrowserListObserver( |
649 ProfileManager* manager) | 663 ProfileManager* manager) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 chrome::NOTIFICATION_PROFILE_ADDED, | 707 chrome::NOTIFICATION_PROFILE_ADDED, |
694 content::Source<Profile>(profile), | 708 content::Source<Profile>(profile), |
695 content::NotificationService::NoDetails()); | 709 content::NotificationService::NoDetails()); |
696 | 710 |
697 } | 711 } |
698 | 712 |
699 void ProfileManager::DoFinalInitForServices(Profile* profile, | 713 void ProfileManager::DoFinalInitForServices(Profile* profile, |
700 bool go_off_the_record) { | 714 bool go_off_the_record) { |
701 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 715 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
702 #if defined(ENABLE_EXTENSIONS) | 716 #if defined(ENABLE_EXTENSIONS) |
703 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( | 717 if (!IsImportProcess(command_line)) { |
704 !go_off_the_record); | 718 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( |
705 // During tests, when |profile| is an instance of TestingProfile, | 719 !go_off_the_record); |
706 // ExtensionSystem might not create an ExtensionService. | 720 // During tests, when |profile| is an instance of TestingProfile, |
707 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { | 721 // ExtensionSystem might not create an ExtensionService. |
708 profile->GetHostContentSettingsMap()->RegisterExtensionService( | 722 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { |
709 extensions::ExtensionSystem::Get(profile)->extension_service()); | 723 profile->GetHostContentSettingsMap()->RegisterExtensionService( |
| 724 extensions::ExtensionSystem::Get(profile)->extension_service()); |
| 725 } |
710 } | 726 } |
711 #endif | 727 #endif |
712 if (!command_line.HasSwitch(switches::kDisableWebResources)) | 728 if (!command_line.HasSwitch(switches::kDisableWebResources)) |
713 profile->InitPromoResources(); | 729 profile->InitPromoResources(); |
714 } | 730 } |
715 | 731 |
716 void ProfileManager::DoFinalInitLogging(Profile* profile) { | 732 void ProfileManager::DoFinalInitLogging(Profile* profile) { |
717 // Count number of extensions in this profile. | 733 // Count number of extensions in this profile. |
718 int extension_count = -1; | 734 int extension_count = -1; |
719 #if defined(ENABLE_EXTENSIONS) | 735 #if defined(ENABLE_EXTENSIONS) |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 ProfileManager::ProfileInfo::ProfileInfo( | 1060 ProfileManager::ProfileInfo::ProfileInfo( |
1045 Profile* profile, | 1061 Profile* profile, |
1046 bool created) | 1062 bool created) |
1047 : profile(profile), | 1063 : profile(profile), |
1048 created(created) { | 1064 created(created) { |
1049 } | 1065 } |
1050 | 1066 |
1051 ProfileManager::ProfileInfo::~ProfileInfo() { | 1067 ProfileManager::ProfileInfo::~ProfileInfo() { |
1052 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1068 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
1053 } | 1069 } |
OLD | NEW |