Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 9432003: Disable multi-profile UI in managed mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add notreached() Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 // Invoke INITIALIZED or FAIL for all profiles. 647 // Invoke INITIALIZED or FAIL for all profiles.
648 RunCallbacks(callbacks, profile, 648 RunCallbacks(callbacks, profile,
649 profile ? Profile::CREATE_STATUS_INITIALIZED : 649 profile ? Profile::CREATE_STATUS_INITIALIZED :
650 Profile::CREATE_STATUS_FAIL); 650 Profile::CREATE_STATUS_FAIL);
651 } 651 }
652 652
653 FilePath ProfileManager::GenerateNextProfileDirectoryPath() { 653 FilePath ProfileManager::GenerateNextProfileDirectoryPath() {
654 PrefService* local_state = g_browser_process->local_state(); 654 PrefService* local_state = g_browser_process->local_state();
655 DCHECK(local_state); 655 DCHECK(local_state);
656 656
657 DCHECK(!local_state->GetBoolean(prefs::kInManagedMode));
658
657 // Create the next profile in the next available directory slot. 659 // Create the next profile in the next available directory slot.
658 int next_directory = local_state->GetInteger(prefs::kProfilesNumCreated); 660 int next_directory = local_state->GetInteger(prefs::kProfilesNumCreated);
659 std::string profile_name = chrome::kMultiProfileDirPrefix; 661 std::string profile_name = chrome::kMultiProfileDirPrefix;
660 profile_name.append(base::IntToString(next_directory)); 662 profile_name.append(base::IntToString(next_directory));
661 FilePath new_path = user_data_dir_; 663 FilePath new_path = user_data_dir_;
662 #if defined(OS_WIN) 664 #if defined(OS_WIN)
663 new_path = new_path.Append(ASCIIToUTF16(profile_name)); 665 new_path = new_path.Append(ASCIIToUTF16(profile_name));
664 #else 666 #else
665 new_path = new_path.Append(profile_name); 667 new_path = new_path.Append(profile_name);
666 #endif 668 #endif
(...skipping 11 matching lines...) Expand all
678 680
679 profile_manager->CreateProfileAsync(new_path, 681 profile_manager->CreateProfileAsync(new_path,
680 base::Bind(&OnOpenWindowForNewProfile)); 682 base::Bind(&OnOpenWindowForNewProfile));
681 } 683 }
682 684
683 // static 685 // static
684 void ProfileManager::RegisterPrefs(PrefService* prefs) { 686 void ProfileManager::RegisterPrefs(PrefService* prefs) {
685 prefs->RegisterStringPref(prefs::kProfileLastUsed, ""); 687 prefs->RegisterStringPref(prefs::kProfileLastUsed, "");
686 prefs->RegisterIntegerPref(prefs::kProfilesNumCreated, 1); 688 prefs->RegisterIntegerPref(prefs::kProfilesNumCreated, 1);
687 prefs->RegisterListPref(prefs::kProfilesLastActive); 689 prefs->RegisterListPref(prefs::kProfilesLastActive);
690 prefs->RegisterBooleanPref(prefs::kInManagedMode, false);
688 } 691 }
689 692
690 size_t ProfileManager::GetNumberOfProfiles() { 693 size_t ProfileManager::GetNumberOfProfiles() {
691 return GetProfileInfoCache().GetNumberOfProfiles(); 694 return GetProfileInfoCache().GetNumberOfProfiles();
692 } 695 }
693 696
694 bool ProfileManager::CompareProfilePathAndName( 697 bool ProfileManager::CompareProfilePathAndName(
695 const ProfileManager::ProfilePathAndName& pair1, 698 const ProfileManager::ProfilePathAndName& pair1,
696 const ProfileManager::ProfilePathAndName& pair2) { 699 const ProfileManager::ProfilePathAndName& pair2) {
697 int name_compare = pair1.second.compare(pair2.second); 700 int name_compare = pair1.second.compare(pair2.second);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 if (!logged_in_ && 808 if (!logged_in_ &&
806 (!command_line.HasSwitch(switches::kTestType) || 809 (!command_line.HasSwitch(switches::kTestType) ||
807 command_line.HasSwitch(switches::kLoginProfile))) { 810 command_line.HasSwitch(switches::kLoginProfile))) {
808 go_off_the_record = true; 811 go_off_the_record = true;
809 } 812 }
810 #endif 813 #endif
811 return go_off_the_record; 814 return go_off_the_record;
812 } 815 }
813 816
814 void ProfileManager::ScheduleProfileForDeletion(const FilePath& profile_dir) { 817 void ProfileManager::ScheduleProfileForDeletion(const FilePath& profile_dir) {
818 PrefService* local_state = g_browser_process->local_state();
819 DCHECK(!local_state->GetBoolean(prefs::kInManagedMode));
820
815 // If we're deleting the last profile, then create a new profile in its 821 // If we're deleting the last profile, then create a new profile in its
816 // place. 822 // place.
817 ProfileInfoCache& cache = GetProfileInfoCache(); 823 ProfileInfoCache& cache = GetProfileInfoCache();
818 if (cache.GetNumberOfProfiles() == 1) { 824 if (cache.GetNumberOfProfiles() == 1) {
819 FilePath new_path = GenerateNextProfileDirectoryPath(); 825 FilePath new_path = GenerateNextProfileDirectoryPath();
820 826
821 CreateProfileAsync(new_path, base::Bind(&OnOpenWindowForNewProfile)); 827 CreateProfileAsync(new_path, base::Bind(&OnOpenWindowForNewProfile));
822 } 828 }
823 829
824 // Update the last used profile pref before closing browser windows. This way 830 // Update the last used profile pref before closing browser windows. This way
825 // the correct last used profile is set for any notification observers. 831 // the correct last used profile is set for any notification observers.
826 PrefService* local_state = g_browser_process->local_state();
827 std::string last_profile = local_state->GetString(prefs::kProfileLastUsed); 832 std::string last_profile = local_state->GetString(prefs::kProfileLastUsed);
828 if (profile_dir.BaseName().MaybeAsASCII() == last_profile) { 833 if (profile_dir.BaseName().MaybeAsASCII() == last_profile) {
829 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { 834 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
830 FilePath cur_path = cache.GetPathOfProfileAtIndex(i); 835 FilePath cur_path = cache.GetPathOfProfileAtIndex(i);
831 if (cur_path != profile_dir) { 836 if (cur_path != profile_dir) {
832 local_state->SetString( 837 local_state->SetString(
833 prefs::kProfileLastUsed, cur_path.BaseName().MaybeAsASCII()); 838 prefs::kProfileLastUsed, cur_path.BaseName().MaybeAsASCII());
834 break; 839 break;
835 } 840 }
836 } 841 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 ProfileMetrics::STARTUP_PROFILE_EVENT); 886 ProfileMetrics::STARTUP_PROFILE_EVENT);
882 } 887 }
883 888
884 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 889 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
885 const FilePath& user_data_dir) : ProfileManager(user_data_dir) { 890 const FilePath& user_data_dir) : ProfileManager(user_data_dir) {
886 } 891 }
887 892
888 void ProfileManager::RegisterTestingProfile(Profile* profile, 893 void ProfileManager::RegisterTestingProfile(Profile* profile,
889 bool add_to_cache) { 894 bool add_to_cache) {
890 RegisterProfile(profile, true); 895 RegisterProfile(profile, true);
891 if (add_to_cache){ 896 if (add_to_cache) {
892 InitProfileUserPrefs(profile); 897 InitProfileUserPrefs(profile);
893 AddProfileToCache(profile); 898 AddProfileToCache(profile);
894 } 899 }
895 } 900 }
896 901
897 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks, 902 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks,
898 Profile* profile, 903 Profile* profile,
899 Profile::CreateStatus status) { 904 Profile::CreateStatus status) {
900 for (size_t i = 0; i < callbacks.size(); ++i) 905 for (size_t i = 0; i < callbacks.size(); ++i)
901 callbacks[i].Run(profile, status); 906 callbacks[i].Run(profile, status);
902 } 907 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698