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

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

Issue 15734006: Restructure user-creation flow and surface errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Removed log; patch for commit. Created 7 years, 6 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 "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 16 matching lines...) Expand all
27 #include "chrome/browser/gpu/gpu_mode_manager.h" 27 #include "chrome/browser/gpu/gpu_mode_manager.h"
28 #include "chrome/browser/lifetime/application_lifetime.h" 28 #include "chrome/browser/lifetime/application_lifetime.h"
29 #include "chrome/browser/net/url_fixer_upper.h" 29 #include "chrome/browser/net/url_fixer_upper.h"
30 #include "chrome/browser/prefs/session_startup_pref.h" 30 #include "chrome/browser/prefs/session_startup_pref.h"
31 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" 31 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
32 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" 32 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h"
33 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" 33 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h"
34 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" 34 #include "chrome/browser/printing/cloud_print/cloud_print_url.h"
35 #include "chrome/browser/profiles/profile_info_cache.h" 35 #include "chrome/browser/profiles/profile_info_cache.h"
36 #include "chrome/browser/profiles/profile_info_util.h" 36 #include "chrome/browser/profiles/profile_info_util.h"
37 #include "chrome/browser/profiles/profile_manager.h"
38 #include "chrome/browser/profiles/profile_shortcut_manager.h" 37 #include "chrome/browser/profiles/profile_shortcut_manager.h"
39 #include "chrome/browser/search/search.h" 38 #include "chrome/browser/search/search.h"
40 #include "chrome/browser/search_engines/template_url.h" 39 #include "chrome/browser/search_engines/template_url.h"
41 #include "chrome/browser/search_engines/template_url_service.h" 40 #include "chrome/browser/search_engines/template_url_service.h"
42 #include "chrome/browser/search_engines/template_url_service_factory.h" 41 #include "chrome/browser/search_engines/template_url_service_factory.h"
43 #include "chrome/browser/service/service_process_control.h" 42 #include "chrome/browser/service/service_process_control.h"
44 #include "chrome/browser/signin/signin_manager.h" 43 #include "chrome/browser/signin/signin_manager.h"
45 #include "chrome/browser/signin/signin_manager_factory.h" 44 #include "chrome/browser/signin/signin_manager_factory.h"
46 #include "chrome/browser/sync/profile_sync_service.h" 45 #include "chrome/browser/sync/profile_sync_service.h"
47 #include "chrome/browser/sync/profile_sync_service_factory.h" 46 #include "chrome/browser/sync/profile_sync_service_factory.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 138 }
140 139
141 void CreateDesktopShortcutForProfile(Profile* profile, 140 void CreateDesktopShortcutForProfile(Profile* profile,
142 Profile::CreateStatus status) { 141 Profile::CreateStatus status) {
143 ProfileShortcutManager* shortcut_manager = 142 ProfileShortcutManager* shortcut_manager =
144 g_browser_process->profile_manager()->profile_shortcut_manager(); 143 g_browser_process->profile_manager()->profile_shortcut_manager();
145 if (shortcut_manager) 144 if (shortcut_manager)
146 shortcut_manager->CreateProfileShortcut(profile->GetPath()); 145 shortcut_manager->CreateProfileShortcut(profile->GetPath());
147 } 146 }
148 147
149 void OnProfileCreated(
150 const std::vector<ProfileManager::CreateCallback>& callbacks,
151 Profile* profile,
152 Profile::CreateStatus status) {
153 std::vector<ProfileManager::CreateCallback>::const_iterator it;
154 for (it = callbacks.begin(); it != callbacks.end(); ++it) {
155 it->Run(profile, status);
156 }
157 }
158
159 } // namespace 148 } // namespace
160 149
161 BrowserOptionsHandler::BrowserOptionsHandler() 150 BrowserOptionsHandler::BrowserOptionsHandler()
162 : page_initialized_(false), 151 : page_initialized_(false),
163 template_url_service_(NULL), 152 template_url_service_(NULL),
164 weak_ptr_factory_(this) { 153 weak_ptr_factory_(this) {
165 #if !defined(OS_MACOSX) 154 #if !defined(OS_MACOSX)
166 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); 155 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this);
167 #endif 156 #endif
168 #if(!defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) 157 #if(!defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN))
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 #if defined(ENABLE_MANAGED_USERS) 1105 #if defined(ENABLE_MANAGED_USERS)
1117 ManagedUserRegistrationService* registration_service = 1106 ManagedUserRegistrationService* registration_service =
1118 ManagedUserRegistrationServiceFactory::GetForProfile(profile); 1107 ManagedUserRegistrationServiceFactory::GetForProfile(profile);
1119 callbacks.push_back(registration_service->GetRegistrationAndInitCallback()); 1108 callbacks.push_back(registration_service->GetRegistrationAndInitCallback());
1120 #else 1109 #else
1121 NOTREACHED(); 1110 NOTREACHED();
1122 #endif 1111 #endif
1123 } 1112 }
1124 1113
1125 ProfileManager::CreateMultiProfileAsync( 1114 ProfileManager::CreateMultiProfileAsync(
1126 name, icon, base::Bind(&OnProfileCreated, callbacks), 1115 name, icon, base::Bind(&BrowserOptionsHandler::OnProfileCreated,
1127 desktop_type, managed_user); 1116 weak_ptr_factory_.GetWeakPtr(),
1117 desktop_type, managed_user, callbacks),
1118 managed_user);
1119 }
1120
1121 void BrowserOptionsHandler::OnProfileCreated(
1122 chrome::HostDesktopType desktop_type,
1123 bool is_managed,
1124 const std::vector<ProfileManager::CreateCallback>& callbacks,
1125 Profile* profile,
1126 Profile::CreateStatus status) {
1127 std::vector<ProfileManager::CreateCallback>::const_iterator it;
1128 for (it = callbacks.begin(); it != callbacks.end(); ++it) {
1129 it->Run(profile, status);
1130 }
1131
1132 switch (status) {
1133 case Profile::CREATE_STATUS_FAIL: {
1134 web_ui()->CallJavascriptFunction(
1135 "BrowserOptions.showCreateProfileLocalError");
1136 break;
1137 }
1138 case Profile::CREATE_STATUS_CREATED: {
1139 // Do nothing for an intermediate status.
1140 break;
1141 }
1142 case Profile::CREATE_STATUS_INITIALIZED: {
1143 base::FundamentalValue is_managed_value(is_managed);
1144 web_ui()->CallJavascriptFunction(
1145 "BrowserOptions.showCreateProfileSuccess",
1146 is_managed_value);
1147
1148 // Opening the new window must be the last action, after all callbacks
1149 // have been run, to give them a chance to initialize the profile.
1150 ProfileManager::FindOrCreateNewWindowForProfile(
1151 profile,
1152 chrome::startup::IS_PROCESS_STARTUP,
1153 chrome::startup::IS_FIRST_RUN,
1154 desktop_type,
1155 false);
1156 break;
1157 }
1158 }
1128 } 1159 }
1129 1160
1130 void BrowserOptionsHandler::ObserveThemeChanged() { 1161 void BrowserOptionsHandler::ObserveThemeChanged() {
1131 Profile* profile = Profile::FromWebUI(web_ui()); 1162 Profile* profile = Profile::FromWebUI(web_ui());
1132 #if defined(TOOLKIT_GTK) 1163 #if defined(TOOLKIT_GTK)
1133 GtkThemeService* theme_service = GtkThemeService::GetFrom(profile); 1164 GtkThemeService* theme_service = GtkThemeService::GetFrom(profile);
1134 bool is_gtk_theme = theme_service->UsingNativeTheme(); 1165 bool is_gtk_theme = theme_service->UsingNativeTheme();
1135 base::FundamentalValue gtk_enabled(!is_gtk_theme); 1166 base::FundamentalValue gtk_enabled(!is_gtk_theme);
1136 web_ui()->CallJavascriptFunction("BrowserOptions.setGtkThemeButtonEnabled", 1167 web_ui()->CallJavascriptFunction("BrowserOptions.setGtkThemeButtonEnabled",
1137 gtk_enabled); 1168 gtk_enabled);
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 base::FundamentalValue disabled(profile_pref_registrar_.IsManaged() || 1605 base::FundamentalValue disabled(profile_pref_registrar_.IsManaged() ||
1575 is_extension_controlled); 1606 is_extension_controlled);
1576 base::FundamentalValue extension_controlled(is_extension_controlled); 1607 base::FundamentalValue extension_controlled(is_extension_controlled);
1577 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", 1608 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection",
1578 disabled, extension_controlled); 1609 disabled, extension_controlled);
1579 1610
1580 #endif // !defined(OS_CHROMEOS) 1611 #endif // !defined(OS_CHROMEOS)
1581 } 1612 }
1582 1613
1583 } // namespace options 1614 } // 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