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

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: unbreak rebase and added new static fn from trunk 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 20 matching lines...) Expand all
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_metrics.h" 39 #include "chrome/browser/profiles/profile_metrics.h"
40 #include "chrome/browser/profiles/profile_shortcut_manager.h" 40 #include "chrome/browser/profiles/profile_shortcut_manager.h"
41 #include "chrome/browser/profiles/profile_window.h"
42 #include "chrome/browser/profiles/profiles_state.h"
41 #include "chrome/browser/search/search.h" 43 #include "chrome/browser/search/search.h"
42 #include "chrome/browser/search_engines/template_url.h" 44 #include "chrome/browser/search_engines/template_url.h"
43 #include "chrome/browser/search_engines/template_url_service.h" 45 #include "chrome/browser/search_engines/template_url_service.h"
44 #include "chrome/browser/search_engines/template_url_service_factory.h" 46 #include "chrome/browser/search_engines/template_url_service_factory.h"
45 #include "chrome/browser/service/service_process_control.h" 47 #include "chrome/browser/service/service_process_control.h"
46 #include "chrome/browser/signin/signin_manager.h" 48 #include "chrome/browser/signin/signin_manager.h"
47 #include "chrome/browser/signin/signin_manager_factory.h" 49 #include "chrome/browser/signin/signin_manager_factory.h"
48 #include "chrome/browser/sync/profile_sync_service.h" 50 #include "chrome/browser/sync/profile_sync_service.h"
49 #include "chrome/browser/sync/profile_sync_service_factory.h" 51 #include "chrome/browser/sync/profile_sync_service_factory.h"
50 #include "chrome/browser/sync/sync_ui_util.h" 52 #include "chrome/browser/sync/sync_ui_util.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 127
126 namespace { 128 namespace {
127 129
128 bool ShouldShowMultiProfilesUserList(chrome::HostDesktopType desktop_type) { 130 bool ShouldShowMultiProfilesUserList(chrome::HostDesktopType desktop_type) {
129 #if defined(OS_CHROMEOS) 131 #if defined(OS_CHROMEOS)
130 // On Chrome OS we use different UI for multi-profiles. 132 // On Chrome OS we use different UI for multi-profiles.
131 return false; 133 return false;
132 #else 134 #else
133 if (desktop_type != chrome::HOST_DESKTOP_TYPE_NATIVE) 135 if (desktop_type != chrome::HOST_DESKTOP_TYPE_NATIVE)
134 return false; 136 return false;
135 return ProfileManager::IsMultipleProfilesEnabled(); 137 return profiles::IsMultipleProfilesEnabled();
136 #endif 138 #endif
137 } 139 }
138 140
139 void CreateDesktopShortcutForProfile(Profile* profile, 141 void CreateDesktopShortcutForProfile(Profile* profile,
140 Profile::CreateStatus status) { 142 Profile::CreateStatus status) {
141 ProfileShortcutManager* shortcut_manager = 143 ProfileShortcutManager* shortcut_manager =
142 g_browser_process->profile_manager()->profile_shortcut_manager(); 144 g_browser_process->profile_manager()->profile_shortcut_manager();
143 if (shortcut_manager) 145 if (shortcut_manager)
144 shortcut_manager->CreateProfileShortcut(profile->GetPath()); 146 shortcut_manager->CreateProfileShortcut(profile->GetPath());
145 } 147 }
146 148
147 void RunProfileCreationCallbacks( 149 void RunProfileCreationCallbacks(
148 const std::vector<ProfileManager::CreateCallback>& callbacks, 150 const std::vector<ProfileManager::CreateCallback>& callbacks,
149 Profile* profile, 151 Profile* profile,
150 Profile::CreateStatus status) { 152 Profile::CreateStatus status) {
151 std::vector<ProfileManager::CreateCallback>::const_iterator it; 153 std::vector<ProfileManager::CreateCallback>::const_iterator it;
152 for (it = callbacks.begin(); it != callbacks.end(); ++it) { 154 for (it = callbacks.begin(); it != callbacks.end(); ++it) {
153 it->Run(profile, status); 155 it->Run(profile, status);
154 } 156 }
155 } 157 }
156 158
157 void OpenNewWindowForProfile( 159 void OpenNewWindowForProfile(
158 chrome::HostDesktopType desktop_type, 160 chrome::HostDesktopType desktop_type,
159 Profile* profile, 161 Profile* profile,
160 Profile::CreateStatus status) { 162 Profile::CreateStatus status) {
161 if (status != Profile::CREATE_STATUS_INITIALIZED) 163 if (status != Profile::CREATE_STATUS_INITIALIZED)
162 return; 164 return;
163 165
164 ProfileManager::FindOrCreateNewWindowForProfile( 166 profiles::FindOrCreateNewWindowForProfile(
165 profile, 167 profile,
166 chrome::startup::IS_PROCESS_STARTUP, 168 chrome::startup::IS_PROCESS_STARTUP,
167 chrome::startup::IS_FIRST_RUN, 169 chrome::startup::IS_FIRST_RUN,
168 desktop_type, 170 desktop_type,
169 false); 171 false);
170 } 172 }
171 173
172 } // namespace 174 } // namespace
173 175
174 BrowserOptionsHandler::BrowserOptionsHandler() 176 BrowserOptionsHandler::BrowserOptionsHandler()
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 1086
1085 void BrowserOptionsHandler::CreateProfile(const ListValue* args) { 1087 void BrowserOptionsHandler::CreateProfile(const ListValue* args) {
1086 #if defined(ENABLE_MANAGED_USERS) 1088 #if defined(ENABLE_MANAGED_USERS)
1087 // This handler could have been called in managed mode, for example because 1089 // 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. 1090 // the user fiddled with the web inspector. Silently return in this case.
1089 Profile* current_profile = Profile::FromWebUI(web_ui()); 1091 Profile* current_profile = Profile::FromWebUI(web_ui());
1090 if (ManagedUserService::ProfileIsManaged(current_profile)) 1092 if (ManagedUserService::ProfileIsManaged(current_profile))
1091 return; 1093 return;
1092 #endif 1094 #endif
1093 1095
1094 if (!ProfileManager::IsMultipleProfilesEnabled()) 1096 if (!profiles::IsMultipleProfilesEnabled())
1095 return; 1097 return;
1096 1098
1097 DCHECK(profile_path_being_created_.empty()); 1099 DCHECK(profile_path_being_created_.empty());
1098 profile_creation_start_time_ = base::TimeTicks::Now(); 1100 profile_creation_start_time_ = base::TimeTicks::Now();
1099 1101
1100 string16 name; 1102 string16 name;
1101 string16 icon; 1103 string16 icon;
1102 bool create_shortcut = false; 1104 bool create_shortcut = false;
1103 bool managed_user = false; 1105 bool managed_user = false;
1104 if (args->GetString(0, &name) && args->GetString(1, &icon)) { 1106 if (args->GetString(0, &name) && args->GetString(1, &icon)) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 } 1240 }
1239 1241
1240 void BrowserOptionsHandler::DeleteProfileAtPath(base::FilePath file_path) { 1242 void BrowserOptionsHandler::DeleteProfileAtPath(base::FilePath file_path) {
1241 #if defined(ENABLE_MANAGED_USERS) 1243 #if defined(ENABLE_MANAGED_USERS)
1242 // This handler could have been called in managed mode, for example because 1244 // 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. 1245 // the user fiddled with the web inspector. Silently return in this case.
1244 if (ManagedUserService::ProfileIsManaged(Profile::FromWebUI(web_ui()))) 1246 if (ManagedUserService::ProfileIsManaged(Profile::FromWebUI(web_ui())))
1245 return; 1247 return;
1246 #endif 1248 #endif
1247 1249
1248 if (!ProfileManager::IsMultipleProfilesEnabled()) 1250 if (!profiles::IsMultipleProfilesEnabled())
1249 return; 1251 return;
1250 1252
1251 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED); 1253 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED);
1252 1254
1253 g_browser_process->profile_manager()->ScheduleProfileForDeletion( 1255 g_browser_process->profile_manager()->ScheduleProfileForDeletion(
1254 file_path, 1256 file_path,
1255 base::Bind(&OpenNewWindowForProfile, GetDesktopType())); 1257 base::Bind(&OpenNewWindowForProfile, GetDesktopType()));
1256 } 1258 }
1257 1259
1258 void BrowserOptionsHandler::HandleCancelProfileCreation(const ListValue* args) { 1260 void BrowserOptionsHandler::HandleCancelProfileCreation(const ListValue* args) {
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 base::FundamentalValue disabled(proxy_config && 1721 base::FundamentalValue disabled(proxy_config &&
1720 !proxy_config->IsUserModifiable()); 1722 !proxy_config->IsUserModifiable());
1721 base::FundamentalValue extension_controlled(is_extension_controlled); 1723 base::FundamentalValue extension_controlled(is_extension_controlled);
1722 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", 1724 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection",
1723 disabled, extension_controlled); 1725 disabled, extension_controlled);
1724 1726
1725 #endif // !defined(OS_CHROMEOS) 1727 #endif // !defined(OS_CHROMEOS)
1726 } 1728 }
1727 1729
1728 } // namespace options 1730 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.h ('k') | chrome/browser/ui/webui/options/manage_profile_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698