Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 15 #include "base/metrics/histogram.h" | |
| 15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 16 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
| 17 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 18 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 20 #include "base/value_conversions.h" | 21 #include "base/value_conversions.h" |
| 21 #include "base/values.h" | 22 #include "base/values.h" |
| 22 #include "chrome/browser/auto_launch_trial.h" | 23 #include "chrome/browser/auto_launch_trial.h" |
| 23 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/chrome_page_zoom.h" | 25 #include "chrome/browser/chrome_page_zoom.h" |
| 25 #include "chrome/browser/custom_home_pages_table_model.h" | 26 #include "chrome/browser/custom_home_pages_table_model.h" |
| 26 #include "chrome/browser/download/download_prefs.h" | 27 #include "chrome/browser/download/download_prefs.h" |
| 27 #include "chrome/browser/gpu/gpu_mode_manager.h" | 28 #include "chrome/browser/gpu/gpu_mode_manager.h" |
| 28 #include "chrome/browser/lifetime/application_lifetime.h" | 29 #include "chrome/browser/lifetime/application_lifetime.h" |
| 29 #include "chrome/browser/net/url_fixer_upper.h" | 30 #include "chrome/browser/net/url_fixer_upper.h" |
| 30 #include "chrome/browser/prefs/session_startup_pref.h" | 31 #include "chrome/browser/prefs/session_startup_pref.h" |
| 31 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 32 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 32 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" | 33 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" |
| 33 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 34 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
| 34 #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" | |
| 35 #include "chrome/browser/profiles/profile_info_cache.h" | 37 #include "chrome/browser/profiles/profile_info_cache.h" |
| 36 #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" | |
| 37 #include "chrome/browser/profiles/profile_shortcut_manager.h" | 40 #include "chrome/browser/profiles/profile_shortcut_manager.h" |
| 38 #include "chrome/browser/search/search.h" | 41 #include "chrome/browser/search/search.h" |
| 39 #include "chrome/browser/search_engines/template_url.h" | 42 #include "chrome/browser/search_engines/template_url.h" |
| 40 #include "chrome/browser/search_engines/template_url_service.h" | 43 #include "chrome/browser/search_engines/template_url_service.h" |
| 41 #include "chrome/browser/search_engines/template_url_service_factory.h" | 44 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 42 #include "chrome/browser/service/service_process_control.h" | 45 #include "chrome/browser/service/service_process_control.h" |
| 43 #include "chrome/browser/signin/signin_manager.h" | 46 #include "chrome/browser/signin/signin_manager.h" |
| 44 #include "chrome/browser/signin/signin_manager_factory.h" | 47 #include "chrome/browser/signin/signin_manager_factory.h" |
| 45 #include "chrome/browser/sync/profile_sync_service.h" | 48 #include "chrome/browser/sync/profile_sync_service.h" |
| 46 #include "chrome/browser/sync/profile_sync_service_factory.h" | 49 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 } | 142 } |
| 140 | 143 |
| 141 void CreateDesktopShortcutForProfile(Profile* profile, | 144 void CreateDesktopShortcutForProfile(Profile* profile, |
| 142 Profile::CreateStatus status) { | 145 Profile::CreateStatus status) { |
| 143 ProfileShortcutManager* shortcut_manager = | 146 ProfileShortcutManager* shortcut_manager = |
| 144 g_browser_process->profile_manager()->profile_shortcut_manager(); | 147 g_browser_process->profile_manager()->profile_shortcut_manager(); |
| 145 if (shortcut_manager) | 148 if (shortcut_manager) |
| 146 shortcut_manager->CreateProfileShortcut(profile->GetPath()); | 149 shortcut_manager->CreateProfileShortcut(profile->GetPath()); |
| 147 } | 150 } |
| 148 | 151 |
| 152 void RunProfileCreationCallbacks( | |
| 153 const std::vector<ProfileManager::CreateCallback>& callbacks, | |
| 154 Profile* profile, | |
| 155 Profile::CreateStatus status) { | |
| 156 std::vector<ProfileManager::CreateCallback>::const_iterator it; | |
| 157 for (it = callbacks.begin(); it != callbacks.end(); ++it) { | |
| 158 it->Run(profile, status); | |
| 159 } | |
| 160 } | |
| 161 | |
| 162 void OpenNewWindowForProfile( | |
| 163 chrome::HostDesktopType desktop_type, | |
| 164 Profile* profile, | |
| 165 Profile::CreateStatus status) { | |
| 166 if (status != Profile::CREATE_STATUS_INITIALIZED) | |
| 167 return; | |
| 168 | |
| 169 ProfileManager::FindOrCreateNewWindowForProfile( | |
| 170 profile, | |
| 171 chrome::startup::IS_PROCESS_STARTUP, | |
| 172 chrome::startup::IS_FIRST_RUN, | |
| 173 desktop_type, | |
| 174 false); | |
| 175 } | |
| 176 | |
| 149 } // namespace | 177 } // namespace |
| 150 | 178 |
| 151 BrowserOptionsHandler::BrowserOptionsHandler() | 179 BrowserOptionsHandler::BrowserOptionsHandler() |
| 152 : page_initialized_(false), | 180 : page_initialized_(false), |
| 153 template_url_service_(NULL), | 181 template_url_service_(NULL), |
| 154 weak_ptr_factory_(this) { | 182 weak_ptr_factory_(this) { |
| 155 #if !defined(OS_MACOSX) | 183 #if !defined(OS_MACOSX) |
| 156 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); | 184 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); |
| 157 #endif | 185 #endif |
| 158 #if(!defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) | 186 #if(!defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 values->SetString("macPasswordsWarning", | 506 values->SetString("macPasswordsWarning", |
| 479 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MAC_WARNING)); | 507 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MAC_WARNING)); |
| 480 values->SetBoolean("multiple_profiles", | 508 values->SetBoolean("multiple_profiles", |
| 481 g_browser_process->profile_manager()->GetNumberOfProfiles() > 1); | 509 g_browser_process->profile_manager()->GetNumberOfProfiles() > 1); |
| 482 #endif | 510 #endif |
| 483 | 511 |
| 484 if (ShouldShowMultiProfilesUserList()) | 512 if (ShouldShowMultiProfilesUserList()) |
| 485 values->Set("profilesInfo", GetProfilesInfoList().release()); | 513 values->Set("profilesInfo", GetProfilesInfoList().release()); |
| 486 | 514 |
| 487 #if defined(ENABLE_MANAGED_USERS) | 515 #if defined(ENABLE_MANAGED_USERS) |
| 488 ManagedUserService* service = | 516 values->SetBoolean("profileIsManaged", |
| 489 ManagedUserServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())); | 517 ManagedUserService::ProfileIsManaged(Profile::FromWebUI(web_ui()))); |
| 490 values->SetBoolean("profileIsManaged", service->ProfileIsManaged()); | |
| 491 #endif | 518 #endif |
| 492 | 519 |
| 493 #if !defined(OS_CHROMEOS) | 520 #if !defined(OS_CHROMEOS) |
| 494 values->SetBoolean( | 521 values->SetBoolean( |
| 495 "gpuEnabledAtStart", | 522 "gpuEnabledAtStart", |
| 496 g_browser_process->gpu_mode_manager()->initial_gpu_mode_pref()); | 523 g_browser_process->gpu_mode_manager()->initial_gpu_mode_pref()); |
| 497 #endif | 524 #endif |
| 498 | 525 |
| 499 values->SetBoolean("enableResetProfileSettingsSection", | 526 values->SetBoolean("enableResetProfileSettingsSection", |
| 500 CommandLine::ForCurrentProcess()->HasSwitch( | 527 CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 base::Unretained(this))); | 559 base::Unretained(this))); |
| 533 web_ui()->RegisterMessageCallback( | 560 web_ui()->RegisterMessageCallback( |
| 534 "setDefaultSearchEngine", | 561 "setDefaultSearchEngine", |
| 535 base::Bind(&BrowserOptionsHandler::SetDefaultSearchEngine, | 562 base::Bind(&BrowserOptionsHandler::SetDefaultSearchEngine, |
| 536 base::Unretained(this))); | 563 base::Unretained(this))); |
| 537 web_ui()->RegisterMessageCallback( | 564 web_ui()->RegisterMessageCallback( |
| 538 "createProfile", | 565 "createProfile", |
| 539 base::Bind(&BrowserOptionsHandler::CreateProfile, | 566 base::Bind(&BrowserOptionsHandler::CreateProfile, |
| 540 base::Unretained(this))); | 567 base::Unretained(this))); |
| 541 web_ui()->RegisterMessageCallback( | 568 web_ui()->RegisterMessageCallback( |
| 569 "deleteProfile", | |
| 570 base::Bind(&BrowserOptionsHandler::DeleteProfile, | |
| 571 base::Unretained(this))); | |
| 572 web_ui()->RegisterMessageCallback( | |
| 542 "themesReset", | 573 "themesReset", |
| 543 base::Bind(&BrowserOptionsHandler::ThemesReset, | 574 base::Bind(&BrowserOptionsHandler::ThemesReset, |
| 544 base::Unretained(this))); | 575 base::Unretained(this))); |
| 545 #if defined(TOOLKIT_GTK) | 576 #if defined(TOOLKIT_GTK) |
| 546 web_ui()->RegisterMessageCallback( | 577 web_ui()->RegisterMessageCallback( |
| 547 "themesSetGTK", | 578 "themesSetGTK", |
| 548 base::Bind(&BrowserOptionsHandler::ThemesSetGTK, | 579 base::Bind(&BrowserOptionsHandler::ThemesSetGTK, |
| 549 base::Unretained(this))); | 580 base::Unretained(this))); |
| 550 #endif | 581 #endif |
| 551 web_ui()->RegisterMessageCallback( | 582 web_ui()->RegisterMessageCallback( |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1065 return; | 1096 return; |
| 1066 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo", | 1097 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo", |
| 1067 *GetProfilesInfoList()); | 1098 *GetProfilesInfoList()); |
| 1068 } | 1099 } |
| 1069 | 1100 |
| 1070 void BrowserOptionsHandler::CreateProfile(const ListValue* args) { | 1101 void BrowserOptionsHandler::CreateProfile(const ListValue* args) { |
| 1071 #if defined(ENABLE_MANAGED_USERS) | 1102 #if defined(ENABLE_MANAGED_USERS) |
| 1072 // This handler could have been called in managed mode, for example because | 1103 // This handler could have been called in managed mode, for example because |
| 1073 // the user fiddled with the web inspector. Silently return in this case. | 1104 // the user fiddled with the web inspector. Silently return in this case. |
| 1074 Profile* profile = Profile::FromWebUI(web_ui()); | 1105 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1075 ManagedUserService* service = | 1106 if (ManagedUserService::ProfileIsManaged(profile)) |
| 1076 ManagedUserServiceFactory::GetForProfile(profile); | |
| 1077 if (service->ProfileIsManaged()) | |
| 1078 return; | 1107 return; |
| 1079 #endif | 1108 #endif |
| 1080 | 1109 |
| 1081 if (!ProfileManager::IsMultipleProfilesEnabled()) | 1110 if (!ProfileManager::IsMultipleProfilesEnabled()) |
| 1082 return; | 1111 return; |
| 1083 | 1112 |
| 1084 Browser* browser = | 1113 Browser* browser = |
| 1085 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); | 1114 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
| 1086 chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE; | 1115 chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE; |
| 1087 if (browser) | 1116 if (browser) |
| 1088 desktop_type = browser->host_desktop_type(); | 1117 desktop_type = browser->host_desktop_type(); |
| 1089 | 1118 |
| 1090 string16 name; | 1119 string16 name; |
| 1091 string16 icon; | 1120 string16 icon; |
| 1092 std::vector<ProfileManager::CreateCallback> callbacks; | |
| 1093 bool create_shortcut = false; | 1121 bool create_shortcut = false; |
| 1094 bool managed_user = false; | 1122 bool managed_user = false; |
| 1095 if (args->GetString(0, &name) && args->GetString(1, &icon)) { | 1123 if (args->GetString(0, &name) && args->GetString(1, &icon)) { |
| 1096 if (args->GetBoolean(2, &create_shortcut)) { | 1124 if (args->GetBoolean(2, &create_shortcut)) { |
| 1097 bool success = args->GetBoolean(3, &managed_user); | 1125 bool success = args->GetBoolean(3, &managed_user); |
| 1098 DCHECK(success); | 1126 DCHECK(success); |
| 1099 } | 1127 } |
| 1100 } | 1128 } |
| 1101 | 1129 |
| 1130 std::vector<ProfileManager::CreateCallback> callbacks; | |
| 1102 if (create_shortcut) | 1131 if (create_shortcut) |
| 1103 callbacks.push_back(base::Bind(&CreateDesktopShortcutForProfile)); | 1132 callbacks.push_back(base::Bind(&CreateDesktopShortcutForProfile)); |
| 1104 | 1133 |
| 1134 ProfileManager::CreateCallback show_user_feedback = | |
| 1135 base::Bind(&BrowserOptionsHandler::ShowProfileCreationFeedback, | |
| 1136 weak_ptr_factory_.GetWeakPtr(), desktop_type, managed_user); | |
| 1137 | |
| 1105 if (managed_user && ManagedUserService::AreManagedUsersEnabled()) { | 1138 if (managed_user && ManagedUserService::AreManagedUsersEnabled()) { |
| 1106 #if defined(ENABLE_MANAGED_USERS) | 1139 #if defined(ENABLE_MANAGED_USERS) |
| 1107 ManagedUserRegistrationService* registration_service = | 1140 callbacks.push_back( |
| 1108 ManagedUserRegistrationServiceFactory::GetForProfile(profile); | 1141 base::Bind(&BrowserOptionsHandler::RegisterNewManagedUser, |
| 1109 callbacks.push_back(registration_service->GetRegistrationAndInitCallback()); | 1142 weak_ptr_factory_.GetWeakPtr(), show_user_feedback)); |
| 1110 #else | 1143 #else |
| 1111 NOTREACHED(); | 1144 NOTREACHED(); |
| 1112 #endif | 1145 #endif |
| 1146 } else { | |
| 1147 callbacks.push_back(show_user_feedback); | |
| 1113 } | 1148 } |
| 1114 | 1149 |
| 1150 ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_DIALOG); | |
| 1151 | |
| 1115 ProfileManager::CreateMultiProfileAsync( | 1152 ProfileManager::CreateMultiProfileAsync( |
| 1116 name, icon, base::Bind(&BrowserOptionsHandler::OnProfileCreated, | 1153 name, icon, base::Bind(&RunProfileCreationCallbacks, callbacks), |
| 1117 weak_ptr_factory_.GetWeakPtr(), | |
| 1118 desktop_type, managed_user, callbacks), | |
| 1119 managed_user); | 1154 managed_user); |
| 1120 } | 1155 } |
| 1121 | 1156 |
| 1122 void BrowserOptionsHandler::OnProfileCreated( | 1157 void BrowserOptionsHandler::RegisterNewManagedUser( |
| 1158 const ProfileManager::CreateCallback& callback, | |
| 1159 Profile* profile, | |
| 1160 Profile::CreateStatus status) { | |
| 1161 | |
|
James Hawkins
2013/06/03 18:43:45
nit: Remove blank line.
| |
| 1162 if (status != Profile::CREATE_STATUS_INITIALIZED) | |
| 1163 return; | |
| 1164 | |
| 1165 ManagedUserService* managed_user_service = | |
| 1166 ManagedUserServiceFactory::GetForProfile(profile); | |
| 1167 DCHECK(managed_user_service->ProfileIsManaged()); | |
| 1168 ManagedUserRegistrationService* registration_service = | |
| 1169 ManagedUserRegistrationServiceFactory::GetForProfile(profile); | |
| 1170 | |
| 1171 managed_user_service->RegisterAndInitSync(registration_service, callback); | |
| 1172 } | |
| 1173 | |
| 1174 void BrowserOptionsHandler::ShowProfileCreationFeedback( | |
| 1123 chrome::HostDesktopType desktop_type, | 1175 chrome::HostDesktopType desktop_type, |
| 1124 bool is_managed, | 1176 bool is_managed, |
| 1125 const std::vector<ProfileManager::CreateCallback>& callbacks, | |
| 1126 Profile* profile, | 1177 Profile* profile, |
| 1127 Profile::CreateStatus status) { | 1178 Profile::CreateStatus status) { |
| 1128 std::vector<ProfileManager::CreateCallback>::const_iterator it; | 1179 if (status != Profile::CREATE_STATUS_CREATED) { |
| 1129 for (it = callbacks.begin(); it != callbacks.end(); ++it) { | 1180 UMA_HISTOGRAM_ENUMERATION("Profile.CreateResult", |
| 1130 it->Run(profile, status); | 1181 status, |
| 1182 Profile::MAX_CREATE_STATUS); | |
| 1131 } | 1183 } |
| 1132 | 1184 |
| 1133 switch (status) { | 1185 switch (status) { |
| 1134 case Profile::CREATE_STATUS_FAIL: { | 1186 case Profile::CREATE_STATUS_LOCAL_FAIL: { |
| 1135 web_ui()->CallJavascriptFunction( | 1187 web_ui()->CallJavascriptFunction( |
| 1136 "BrowserOptions.showCreateProfileLocalError"); | 1188 "BrowserOptions.showCreateProfileLocalError"); |
| 1189 DeleteProfileAtPath(profile->GetPath()); | |
| 1190 break; | |
| 1191 } | |
| 1192 case Profile::CREATE_STATUS_REMOTE_FAIL: { | |
| 1193 web_ui()->CallJavascriptFunction( | |
| 1194 "BrowserOptions.showCreateProfileRemoteError"); | |
| 1195 DeleteProfileAtPath(profile->GetPath()); | |
| 1137 break; | 1196 break; |
| 1138 } | 1197 } |
| 1139 case Profile::CREATE_STATUS_CREATED: { | 1198 case Profile::CREATE_STATUS_CREATED: { |
| 1140 // Do nothing for an intermediate status. | 1199 // Do nothing for an intermediate status. |
| 1141 break; | 1200 break; |
| 1142 } | 1201 } |
| 1143 case Profile::CREATE_STATUS_INITIALIZED: { | 1202 case Profile::CREATE_STATUS_INITIALIZED: { |
| 1144 DictionaryValue dict; | 1203 DictionaryValue dict; |
| 1145 dict.SetString("name", | 1204 dict.SetString("name", |
| 1146 profile->GetPrefs()->GetString(prefs::kProfileName)); | 1205 profile->GetPrefs()->GetString(prefs::kProfileName)); |
| 1147 dict.Set("filePath", base::CreateFilePathValue(profile->GetPath())); | 1206 dict.Set("filePath", base::CreateFilePathValue(profile->GetPath())); |
| 1148 dict.SetBoolean("isManaged", is_managed); | 1207 dict.SetBoolean("isManaged", is_managed); |
| 1149 web_ui()->CallJavascriptFunction( | 1208 web_ui()->CallJavascriptFunction( |
| 1150 "BrowserOptions.showCreateProfileSuccess", dict); | 1209 "BrowserOptions.showCreateProfileSuccess", dict); |
| 1151 | 1210 |
| 1152 // If the new profile is a managed user, instead of opening a new window | 1211 // If the new profile is a managed user, instead of opening a new window |
| 1153 // right away, a confirmation overlay will be shown from the creation | 1212 // right away, a confirmation overlay will be shown from the creation |
| 1154 // dialog. | 1213 // dialog. |
| 1155 if (!is_managed) { | 1214 if (!is_managed) { |
| 1156 // Opening the new window must be the last action, after all callbacks | 1215 // Opening the new window must be the last action, after all callbacks |
| 1157 // have been run, to give them a chance to initialize the profile. | 1216 // have been run, to give them a chance to initialize the profile. |
| 1158 ProfileManager::FindOrCreateNewWindowForProfile( | 1217 OpenNewWindowForProfile(desktop_type, |
| 1159 profile, | 1218 profile, |
| 1160 chrome::startup::IS_PROCESS_STARTUP, | 1219 Profile::CREATE_STATUS_INITIALIZED); |
| 1161 chrome::startup::IS_FIRST_RUN, | |
| 1162 desktop_type, | |
| 1163 false); | |
| 1164 } | 1220 } |
| 1165 break; | 1221 break; |
| 1166 } | 1222 } |
| 1223 case Profile::MAX_CREATE_STATUS: { | |
| 1224 NOTREACHED(); | |
| 1225 break; | |
| 1226 } | |
| 1167 } | 1227 } |
| 1168 } | 1228 } |
| 1169 | 1229 |
| 1230 void BrowserOptionsHandler::DeleteProfile(const ListValue* args) { | |
| 1231 DCHECK(args); | |
| 1232 const Value* file_path_value; | |
| 1233 if (!args->Get(0, &file_path_value)) | |
| 1234 return; | |
| 1235 | |
| 1236 base::FilePath file_path; | |
| 1237 if (!base::GetValueAsFilePath(*file_path_value, &file_path)) | |
| 1238 return; | |
| 1239 DeleteProfileAtPath(file_path); | |
| 1240 } | |
| 1241 | |
| 1242 void BrowserOptionsHandler::DeleteProfileAtPath(base::FilePath file_path) { | |
| 1243 #if defined(ENABLE_MANAGED_USERS) | |
| 1244 // This handler could have been called in managed mode, for example because | |
| 1245 // the user fiddled with the web inspector. Silently return in this case. | |
| 1246 if (ManagedUserService::ProfileIsManaged(Profile::FromWebUI(web_ui()))) | |
| 1247 return; | |
| 1248 #endif | |
| 1249 | |
| 1250 if (!ProfileManager::IsMultipleProfilesEnabled()) | |
| 1251 return; | |
| 1252 | |
| 1253 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED); | |
| 1254 | |
| 1255 Browser* browser = | |
| 1256 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); | |
| 1257 chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE; | |
| 1258 if (browser) | |
| 1259 desktop_type = browser->host_desktop_type(); | |
| 1260 | |
| 1261 g_browser_process->profile_manager()->ScheduleProfileForDeletion( | |
| 1262 file_path, | |
| 1263 base::Bind(&OpenNewWindowForProfile, desktop_type)); | |
| 1264 } | |
| 1265 | |
| 1170 void BrowserOptionsHandler::ObserveThemeChanged() { | 1266 void BrowserOptionsHandler::ObserveThemeChanged() { |
| 1171 Profile* profile = Profile::FromWebUI(web_ui()); | 1267 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1172 #if defined(TOOLKIT_GTK) | 1268 #if defined(TOOLKIT_GTK) |
| 1173 GtkThemeService* theme_service = GtkThemeService::GetFrom(profile); | 1269 GtkThemeService* theme_service = GtkThemeService::GetFrom(profile); |
| 1174 bool is_gtk_theme = theme_service->UsingNativeTheme(); | 1270 bool is_gtk_theme = theme_service->UsingNativeTheme(); |
| 1175 base::FundamentalValue gtk_enabled(!is_gtk_theme); | 1271 base::FundamentalValue gtk_enabled(!is_gtk_theme); |
| 1176 web_ui()->CallJavascriptFunction("BrowserOptions.setGtkThemeButtonEnabled", | 1272 web_ui()->CallJavascriptFunction("BrowserOptions.setGtkThemeButtonEnabled", |
| 1177 gtk_enabled); | 1273 gtk_enabled); |
| 1178 #else | 1274 #else |
| 1179 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); | 1275 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1615 base::FundamentalValue disabled(profile_pref_registrar_.IsManaged() || | 1711 base::FundamentalValue disabled(profile_pref_registrar_.IsManaged() || |
| 1616 is_extension_controlled); | 1712 is_extension_controlled); |
| 1617 base::FundamentalValue extension_controlled(is_extension_controlled); | 1713 base::FundamentalValue extension_controlled(is_extension_controlled); |
| 1618 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", | 1714 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", |
| 1619 disabled, extension_controlled); | 1715 disabled, extension_controlled); |
| 1620 | 1716 |
| 1621 #endif // !defined(OS_CHROMEOS) | 1717 #endif // !defined(OS_CHROMEOS) |
| 1622 } | 1718 } |
| 1623 | 1719 |
| 1624 } // namespace options | 1720 } // namespace options |
| OLD | NEW |