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

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: review Created 8 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options2/browser_options_handler2.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 // Invoke INITIALIZED or FAIL for all profiles. 678 // Invoke INITIALIZED or FAIL for all profiles.
679 RunCallbacks(callbacks, profile, 679 RunCallbacks(callbacks, profile,
680 profile ? Profile::CREATE_STATUS_INITIALIZED : 680 profile ? Profile::CREATE_STATUS_INITIALIZED :
681 Profile::CREATE_STATUS_FAIL); 681 Profile::CREATE_STATUS_FAIL);
682 } 682 }
683 683
684 FilePath ProfileManager::GenerateNextProfileDirectoryPath() { 684 FilePath ProfileManager::GenerateNextProfileDirectoryPath() {
685 PrefService* local_state = g_browser_process->local_state(); 685 PrefService* local_state = g_browser_process->local_state();
686 DCHECK(local_state); 686 DCHECK(local_state);
687 687
688 DCHECK(IsMultipleProfilesEnabled());
689
688 // Create the next profile in the next available directory slot. 690 // Create the next profile in the next available directory slot.
689 int next_directory = local_state->GetInteger(prefs::kProfilesNumCreated); 691 int next_directory = local_state->GetInteger(prefs::kProfilesNumCreated);
690 std::string profile_name = chrome::kMultiProfileDirPrefix; 692 std::string profile_name = chrome::kMultiProfileDirPrefix;
691 profile_name.append(base::IntToString(next_directory)); 693 profile_name.append(base::IntToString(next_directory));
692 FilePath new_path = user_data_dir_; 694 FilePath new_path = user_data_dir_;
693 #if defined(OS_WIN) 695 #if defined(OS_WIN)
694 new_path = new_path.Append(ASCIIToUTF16(profile_name)); 696 new_path = new_path.Append(ASCIIToUTF16(profile_name));
695 #else 697 #else
696 new_path = new_path.Append(profile_name); 698 new_path = new_path.Append(profile_name);
697 #endif 699 #endif
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 if (!logged_in_ && 839 if (!logged_in_ &&
838 (!command_line.HasSwitch(switches::kTestType) || 840 (!command_line.HasSwitch(switches::kTestType) ||
839 command_line.HasSwitch(switches::kLoginProfile))) { 841 command_line.HasSwitch(switches::kLoginProfile))) {
840 go_off_the_record = true; 842 go_off_the_record = true;
841 } 843 }
842 #endif 844 #endif
843 return go_off_the_record; 845 return go_off_the_record;
844 } 846 }
845 847
846 void ProfileManager::ScheduleProfileForDeletion(const FilePath& profile_dir) { 848 void ProfileManager::ScheduleProfileForDeletion(const FilePath& profile_dir) {
849 DCHECK(IsMultipleProfilesEnabled());
850
847 // If we're deleting the last profile, then create a new profile in its 851 // If we're deleting the last profile, then create a new profile in its
848 // place. 852 // place.
849 ProfileInfoCache& cache = GetProfileInfoCache(); 853 ProfileInfoCache& cache = GetProfileInfoCache();
850 if (cache.GetNumberOfProfiles() == 1) { 854 if (cache.GetNumberOfProfiles() == 1) {
851 FilePath new_path = GenerateNextProfileDirectoryPath(); 855 FilePath new_path = GenerateNextProfileDirectoryPath();
852 856
853 CreateProfileAsync(new_path, base::Bind(&OnOpenWindowForNewProfile)); 857 CreateProfileAsync(new_path, base::Bind(&OnOpenWindowForNewProfile));
854 } 858 }
855 859
856 // Update the last used profile pref before closing browser windows. This way 860 // Update the last used profile pref before closing browser windows. This way
(...skipping 28 matching lines...) Expand all
885 QueueProfileDirectoryForDeletion(profile_dir); 889 QueueProfileDirectoryForDeletion(profile_dir);
886 cache.DeleteProfileFromCache(profile_dir); 890 cache.DeleteProfileFromCache(profile_dir);
887 891
888 ProfileMetrics::LogNumberOfProfiles(this, 892 ProfileMetrics::LogNumberOfProfiles(this,
889 ProfileMetrics::DELETE_PROFILE_EVENT); 893 ProfileMetrics::DELETE_PROFILE_EVENT);
890 } 894 }
891 895
892 // static 896 // static
893 bool ProfileManager::IsMultipleProfilesEnabled() { 897 bool ProfileManager::IsMultipleProfilesEnabled() {
894 #if defined(OS_CHROMEOS) 898 #if defined(OS_CHROMEOS)
895 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); 899 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles))
896 #else 900 return false;
897 return true;
898 #endif 901 #endif
902 // |g_browser_process| can be NULL during startup.
903 if (!g_browser_process)
904 return true;
905 return !g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode);
899 } 906 }
900 907
901 void ProfileManager::AutoloadProfiles() { 908 void ProfileManager::AutoloadProfiles() {
902 ProfileInfoCache& cache = GetProfileInfoCache(); 909 ProfileInfoCache& cache = GetProfileInfoCache();
903 size_t number_of_profiles = cache.GetNumberOfProfiles(); 910 size_t number_of_profiles = cache.GetNumberOfProfiles();
904 for (size_t p = 0; p < number_of_profiles; ++p) { 911 for (size_t p = 0; p < number_of_profiles; ++p) {
905 if (cache.GetBackgroundStatusOfProfileAtIndex(p)) { 912 if (cache.GetBackgroundStatusOfProfileAtIndex(p)) {
906 // If status is true, that profile is running background apps. By calling 913 // If status is true, that profile is running background apps. By calling
907 // GetProfile, we automatically cause the profile to be loaded which will 914 // GetProfile, we automatically cause the profile to be loaded which will
908 // register it with the BackgroundModeManager. 915 // register it with the BackgroundModeManager.
(...skipping 16 matching lines...) Expand all
925 AddProfileToCache(profile); 932 AddProfileToCache(profile);
926 } 933 }
927 } 934 }
928 935
929 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks, 936 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks,
930 Profile* profile, 937 Profile* profile,
931 Profile::CreateStatus status) { 938 Profile::CreateStatus status) {
932 for (size_t i = 0; i < callbacks.size(); ++i) 939 for (size_t i = 0; i < callbacks.size(); ++i)
933 callbacks[i].Run(profile, status); 940 callbacks[i].Run(profile, status);
934 } 941 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options2/browser_options_handler2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698