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

Side by Side Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 18615010: Refactor utility methods out of the ProfileManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years, 5 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
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 "chrome/browser/ui/webui/options/browser_options_handler.h" 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 18 matching lines...) Expand all
29 #include "chrome/browser/gpu/gpu_mode_manager.h" 29 #include "chrome/browser/gpu/gpu_mode_manager.h"
30 #include "chrome/browser/lifetime/application_lifetime.h" 30 #include "chrome/browser/lifetime/application_lifetime.h"
31 #include "chrome/browser/net/url_fixer_upper.h" 31 #include "chrome/browser/net/url_fixer_upper.h"
32 #include "chrome/browser/prefs/session_startup_pref.h" 32 #include "chrome/browser/prefs/session_startup_pref.h"
33 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" 33 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
34 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" 34 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h"
35 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" 35 #include "chrome/browser/printing/cloud_print/cloud_print_url.h"
36 #include "chrome/browser/profiles/profile.h" 36 #include "chrome/browser/profiles/profile.h"
37 #include "chrome/browser/profiles/profile_info_cache.h" 37 #include "chrome/browser/profiles/profile_info_cache.h"
38 #include "chrome/browser/profiles/profile_info_util.h" 38 #include "chrome/browser/profiles/profile_info_util.h"
39 #include "chrome/browser/profiles/profile_manager_util.h"
39 #include "chrome/browser/profiles/profile_metrics.h" 40 #include "chrome/browser/profiles/profile_metrics.h"
40 #include "chrome/browser/profiles/profile_shortcut_manager.h" 41 #include "chrome/browser/profiles/profile_shortcut_manager.h"
41 #include "chrome/browser/search/search.h" 42 #include "chrome/browser/search/search.h"
42 #include "chrome/browser/search_engines/template_url.h" 43 #include "chrome/browser/search_engines/template_url.h"
43 #include "chrome/browser/search_engines/template_url_service.h" 44 #include "chrome/browser/search_engines/template_url_service.h"
44 #include "chrome/browser/search_engines/template_url_service_factory.h" 45 #include "chrome/browser/search_engines/template_url_service_factory.h"
45 #include "chrome/browser/service/service_process_control.h" 46 #include "chrome/browser/service/service_process_control.h"
46 #include "chrome/browser/signin/signin_manager.h" 47 #include "chrome/browser/signin/signin_manager.h"
47 #include "chrome/browser/signin/signin_manager_factory.h" 48 #include "chrome/browser/signin/signin_manager_factory.h"
48 #include "chrome/browser/sync/profile_sync_service.h" 49 #include "chrome/browser/sync/profile_sync_service.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 126
126 namespace { 127 namespace {
127 128
128 bool ShouldShowMultiProfilesUserList(chrome::HostDesktopType desktop_type) { 129 bool ShouldShowMultiProfilesUserList(chrome::HostDesktopType desktop_type) {
129 #if defined(OS_CHROMEOS) 130 #if defined(OS_CHROMEOS)
130 // On Chrome OS we use different UI for multi-profiles. 131 // On Chrome OS we use different UI for multi-profiles.
131 return false; 132 return false;
132 #else 133 #else
133 if (desktop_type != chrome::HOST_DESKTOP_TYPE_NATIVE) 134 if (desktop_type != chrome::HOST_DESKTOP_TYPE_NATIVE)
134 return false; 135 return false;
135 return ProfileManager::IsMultipleProfilesEnabled(); 136 return profiles::IsMultipleProfilesEnabled();
136 #endif 137 #endif
137 } 138 }
138 139
139 void CreateDesktopShortcutForProfile(Profile* profile, 140 void CreateDesktopShortcutForProfile(Profile* profile,
140 Profile::CreateStatus status) { 141 Profile::CreateStatus status) {
141 ProfileShortcutManager* shortcut_manager = 142 ProfileShortcutManager* shortcut_manager =
142 g_browser_process->profile_manager()->profile_shortcut_manager(); 143 g_browser_process->profile_manager()->profile_shortcut_manager();
143 if (shortcut_manager) 144 if (shortcut_manager)
144 shortcut_manager->CreateProfileShortcut(profile->GetPath()); 145 shortcut_manager->CreateProfileShortcut(profile->GetPath());
145 } 146 }
146 147
147 void RunProfileCreationCallbacks( 148 void RunProfileCreationCallbacks(
148 const std::vector<ProfileManager::CreateCallback>& callbacks, 149 const std::vector<ProfileManager::CreateCallback>& callbacks,
149 Profile* profile, 150 Profile* profile,
150 Profile::CreateStatus status) { 151 Profile::CreateStatus status) {
151 std::vector<ProfileManager::CreateCallback>::const_iterator it; 152 std::vector<ProfileManager::CreateCallback>::const_iterator it;
152 for (it = callbacks.begin(); it != callbacks.end(); ++it) { 153 for (it = callbacks.begin(); it != callbacks.end(); ++it) {
153 it->Run(profile, status); 154 it->Run(profile, status);
154 } 155 }
155 } 156 }
156 157
157 void OpenNewWindowForProfile( 158 void OpenNewWindowForProfile(
158 chrome::HostDesktopType desktop_type, 159 chrome::HostDesktopType desktop_type,
159 Profile* profile, 160 Profile* profile,
160 Profile::CreateStatus status) { 161 Profile::CreateStatus status) {
161 if (status != Profile::CREATE_STATUS_INITIALIZED) 162 if (status != Profile::CREATE_STATUS_INITIALIZED)
162 return; 163 return;
163 164
164 ProfileManager::FindOrCreateNewWindowForProfile( 165 profiles::FindOrCreateNewWindowForProfile(
165 profile, 166 profile,
166 chrome::startup::IS_PROCESS_STARTUP, 167 chrome::startup::IS_PROCESS_STARTUP,
167 chrome::startup::IS_FIRST_RUN, 168 chrome::startup::IS_FIRST_RUN,
168 desktop_type, 169 desktop_type,
169 false); 170 false);
170 } 171 }
171 172
172 } // namespace 173 } // namespace
173 174
174 BrowserOptionsHandler::BrowserOptionsHandler() 175 BrowserOptionsHandler::BrowserOptionsHandler()
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 1085
1085 void BrowserOptionsHandler::CreateProfile(const ListValue* args) { 1086 void BrowserOptionsHandler::CreateProfile(const ListValue* args) {
1086 #if defined(ENABLE_MANAGED_USERS) 1087 #if defined(ENABLE_MANAGED_USERS)
1087 // This handler could have been called in managed mode, for example because 1088 // This handler could have been called in managed mode, for example because
1088 // the user fiddled with the web inspector. Silently return in this case. 1089 // the user fiddled with the web inspector. Silently return in this case.
1089 Profile* current_profile = Profile::FromWebUI(web_ui()); 1090 Profile* current_profile = Profile::FromWebUI(web_ui());
1090 if (ManagedUserService::ProfileIsManaged(current_profile)) 1091 if (ManagedUserService::ProfileIsManaged(current_profile))
1091 return; 1092 return;
1092 #endif 1093 #endif
1093 1094
1094 if (!ProfileManager::IsMultipleProfilesEnabled()) 1095 if (!profiles::IsMultipleProfilesEnabled())
1095 return; 1096 return;
1096 1097
1097 DCHECK(profile_path_being_created_.empty()); 1098 DCHECK(profile_path_being_created_.empty());
1098 profile_creation_start_time_ = base::TimeTicks::Now(); 1099 profile_creation_start_time_ = base::TimeTicks::Now();
1099 1100
1100 string16 name; 1101 string16 name;
1101 string16 icon; 1102 string16 icon;
1102 bool create_shortcut = false; 1103 bool create_shortcut = false;
1103 bool managed_user = false; 1104 bool managed_user = false;
1104 if (args->GetString(0, &name) && args->GetString(1, &icon)) { 1105 if (args->GetString(0, &name) && args->GetString(1, &icon)) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 } 1239 }
1239 1240
1240 void BrowserOptionsHandler::DeleteProfileAtPath(base::FilePath file_path) { 1241 void BrowserOptionsHandler::DeleteProfileAtPath(base::FilePath file_path) {
1241 #if defined(ENABLE_MANAGED_USERS) 1242 #if defined(ENABLE_MANAGED_USERS)
1242 // This handler could have been called in managed mode, for example because 1243 // This handler could have been called in managed mode, for example because
1243 // the user fiddled with the web inspector. Silently return in this case. 1244 // the user fiddled with the web inspector. Silently return in this case.
1244 if (ManagedUserService::ProfileIsManaged(Profile::FromWebUI(web_ui()))) 1245 if (ManagedUserService::ProfileIsManaged(Profile::FromWebUI(web_ui())))
1245 return; 1246 return;
1246 #endif 1247 #endif
1247 1248
1248 if (!ProfileManager::IsMultipleProfilesEnabled()) 1249 if (!profiles::IsMultipleProfilesEnabled())
1249 return; 1250 return;
1250 1251
1251 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED); 1252 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED);
1252 1253
1253 g_browser_process->profile_manager()->ScheduleProfileForDeletion( 1254 g_browser_process->profile_manager()->ScheduleProfileForDeletion(
1254 file_path, 1255 file_path,
1255 base::Bind(&OpenNewWindowForProfile, GetDesktopType())); 1256 base::Bind(&OpenNewWindowForProfile, GetDesktopType()));
1256 } 1257 }
1257 1258
1258 void BrowserOptionsHandler::HandleCancelProfileCreation(const ListValue* args) { 1259 void BrowserOptionsHandler::HandleCancelProfileCreation(const ListValue* args) {
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 base::FundamentalValue disabled(proxy_config && 1720 base::FundamentalValue disabled(proxy_config &&
1720 !proxy_config->IsUserModifiable()); 1721 !proxy_config->IsUserModifiable());
1721 base::FundamentalValue extension_controlled(is_extension_controlled); 1722 base::FundamentalValue extension_controlled(is_extension_controlled);
1722 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", 1723 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection",
1723 disabled, extension_controlled); 1724 disabled, extension_controlled);
1724 1725
1725 #endif // !defined(OS_CHROMEOS) 1726 #endif // !defined(OS_CHROMEOS)
1726 } 1727 }
1727 1728
1728 } // namespace options 1729 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698