Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/advanced_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/advanced_options_handler.h" |
| 6 | 6 |
| 7 #include <cmath> | |
| 7 #include <string> | 8 #include <string> |
| 8 | 9 |
| 9 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/download/download_prefs.h" | 17 #include "chrome/browser/download/download_prefs.h" |
| 17 #include "chrome/browser/google/google_util.h" | 18 #include "chrome/browser/google/google_util.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 20 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 20 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" | 21 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" |
| 21 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 22 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
| 22 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 23 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/service/service_process_control.h" | 25 #include "chrome/browser/service/service_process_control.h" |
| 25 #include "chrome/browser/ui/options/options_util.h" | 26 #include "chrome/browser/ui/options/options_util.h" |
| 26 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 30 #include "content/browser/download/download_manager.h" | 31 #include "content/browser/download/download_manager.h" |
| 31 #include "content/browser/tab_contents/tab_contents.h" | 32 #include "content/browser/tab_contents/tab_contents.h" |
| 32 #include "content/browser/tab_contents/tab_contents_view.h" | 33 #include "content/browser/tab_contents/tab_contents_view.h" |
| 33 #include "content/browser/user_metrics.h" | 34 #include "content/browser/user_metrics.h" |
| 34 #include "content/public/browser/notification_details.h" | 35 #include "content/public/browser/notification_details.h" |
| 35 #include "content/public/browser/notification_types.h" | 36 #include "content/public/browser/notification_types.h" |
| 37 #include "content/public/common/page_zoom.h" | |
| 36 #include "grit/chromium_strings.h" | 38 #include "grit/chromium_strings.h" |
| 37 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
| 38 #include "grit/locale_settings.h" | 40 #include "grit/locale_settings.h" |
| 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | |
| 39 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 40 | 43 |
| 41 #if !defined(OS_CHROMEOS) | 44 #if !defined(OS_CHROMEOS) |
| 42 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" | 45 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" |
| 43 #include "chrome/browser/ui/webui/options/advanced_options_utils.h" | 46 #include "chrome/browser/ui/webui/options/advanced_options_utils.h" |
| 44 #endif | 47 #endif |
| 45 | 48 |
| 46 AdvancedOptionsHandler::AdvancedOptionsHandler() { | 49 AdvancedOptionsHandler::AdvancedOptionsHandler() { |
| 47 | 50 |
| 48 #if(!defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) | 51 #if(!defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 { "privacyClearDataButton", | 110 { "privacyClearDataButton", |
| 108 IDS_OPTIONS_PRIVACY_CLEAR_DATA_BUTTON }, | 111 IDS_OPTIONS_PRIVACY_CLEAR_DATA_BUTTON }, |
| 109 { "linkDoctorPref", | 112 { "linkDoctorPref", |
| 110 IDS_OPTIONS_LINKDOCTOR_PREF }, | 113 IDS_OPTIONS_LINKDOCTOR_PREF }, |
| 111 { "suggestPref", | 114 { "suggestPref", |
| 112 IDS_OPTIONS_SUGGEST_PREF }, | 115 IDS_OPTIONS_SUGGEST_PREF }, |
| 113 { "tabsToLinksPref", | 116 { "tabsToLinksPref", |
| 114 IDS_OPTIONS_TABS_TO_LINKS_PREF }, | 117 IDS_OPTIONS_TABS_TO_LINKS_PREF }, |
| 115 { "fontSettingsInfo", | 118 { "fontSettingsInfo", |
| 116 IDS_OPTIONS_FONTSETTINGS_INFO }, | 119 IDS_OPTIONS_FONTSETTINGS_INFO }, |
| 117 { "defaultZoomLevelLabel", | 120 { "defaultZoomFactorLabel", |
| 118 IDS_OPTIONS_DEFAULT_ZOOM_LEVEL_LABEL }, | 121 IDS_OPTIONS_DEFAULT_ZOOM_LEVEL_LABEL }, |
| 119 { "defaultFontSizeLabel", | 122 { "defaultFontSizeLabel", |
| 120 IDS_OPTIONS_DEFAULT_FONT_SIZE_LABEL }, | 123 IDS_OPTIONS_DEFAULT_FONT_SIZE_LABEL }, |
| 121 { "fontSizeLabelVerySmall", | 124 { "fontSizeLabelVerySmall", |
| 122 IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL }, | 125 IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL }, |
| 123 { "fontSizeLabelSmall", | 126 { "fontSizeLabelSmall", |
| 124 IDS_OPTIONS_FONT_SIZE_LABEL_SMALL }, | 127 IDS_OPTIONS_FONT_SIZE_LABEL_SMALL }, |
| 125 { "fontSizeLabelMedium", | 128 { "fontSizeLabelMedium", |
| 126 IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM }, | 129 IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM }, |
| 127 { "fontSizeLabelLarge", | 130 { "fontSizeLabelLarge", |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 GURL(chrome::kPrivacyLearnMoreURL)).spec()); | 194 GURL(chrome::kPrivacyLearnMoreURL)).spec()); |
| 192 | 195 |
| 193 #if defined(OS_CHROMEOS) | 196 #if defined(OS_CHROMEOS) |
| 194 localized_strings->SetString("cloudPrintLearnMoreURL", | 197 localized_strings->SetString("cloudPrintLearnMoreURL", |
| 195 google_util::AppendGoogleLocaleParam( | 198 google_util::AppendGoogleLocaleParam( |
| 196 GURL(chrome::kCloudPrintLearnMoreURL)).spec()); | 199 GURL(chrome::kCloudPrintLearnMoreURL)).spec()); |
| 197 #endif | 200 #endif |
| 198 } | 201 } |
| 199 | 202 |
| 200 void AdvancedOptionsHandler::Initialize() { | 203 void AdvancedOptionsHandler::Initialize() { |
| 201 DCHECK(web_ui_); | 204 DCHECK(web_ui()); |
| 202 SetupMetricsReportingCheckbox(); | 205 SetupMetricsReportingCheckbox(); |
| 203 SetupMetricsReportingSettingVisibility(); | 206 SetupMetricsReportingSettingVisibility(); |
| 204 SetupFontSizeLabel(); | 207 SetupFontSizeSelector(); |
| 208 SetupPageZoomSelector(); | |
| 205 SetupAutoOpenFileTypesDisabledAttribute(); | 209 SetupAutoOpenFileTypesDisabledAttribute(); |
| 206 SetupProxySettingsSection(); | 210 SetupProxySettingsSection(); |
| 207 SetupSSLConfigSettings(); | 211 SetupSSLConfigSettings(); |
| 208 #if !defined(OS_CHROMEOS) | 212 #if !defined(OS_CHROMEOS) |
| 209 if (cloud_print_proxy_ui_enabled_) { | 213 if (cloud_print_proxy_ui_enabled_) { |
| 210 SetupCloudPrintProxySection(); | 214 SetupCloudPrintProxySection(); |
| 211 RefreshCloudPrintStatusFromService(); | 215 RefreshCloudPrintStatusFromService(); |
| 212 } else { | 216 } else { |
| 213 RemoveCloudPrintProxySection(); | 217 RemoveCloudPrintProxySection(); |
| 214 } | 218 } |
| 215 #endif | 219 #endif |
| 216 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | 220 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 217 SetupBackgroundModeSettings(); | 221 SetupBackgroundModeSettings(); |
| 218 #endif | 222 #endif |
| 219 | 223 |
| 220 } | 224 } |
| 221 | 225 |
| 222 WebUIMessageHandler* AdvancedOptionsHandler::Attach(WebUI* web_ui) { | 226 WebUIMessageHandler* AdvancedOptionsHandler::Attach(WebUI* web_ui) { |
| 223 // Call through to superclass. | 227 // Call through to superclass. |
| 224 WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui); | 228 WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui); |
| 225 | 229 |
| 226 // Register for preferences that we need to observe manually. These have | 230 // Register for preferences that we need to observe manually. These have |
| 227 // special behaviors that aren't handled by the standard prefs UI. | 231 // special behaviors that aren't handled by the standard prefs UI. |
| 228 DCHECK(web_ui_); | 232 PrefService* prefs = Profile::FromWebUI(web_ui)->GetPrefs(); |
| 229 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); | |
| 230 #if !defined(OS_CHROMEOS) | 233 #if !defined(OS_CHROMEOS) |
| 231 enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled, | 234 enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled, |
| 232 g_browser_process->local_state(), this); | 235 g_browser_process->local_state(), this); |
| 233 cloud_print_proxy_email_.Init(prefs::kCloudPrintEmail, prefs, this); | 236 cloud_print_proxy_email_.Init(prefs::kCloudPrintEmail, prefs, this); |
| 234 cloud_print_proxy_enabled_.Init(prefs::kCloudPrintProxyEnabled, prefs, this); | 237 cloud_print_proxy_enabled_.Init(prefs::kCloudPrintProxyEnabled, prefs, this); |
| 235 #endif | 238 #endif |
| 236 | 239 |
| 237 rev_checking_enabled_.Init(prefs::kCertRevocationCheckingEnabled, | 240 rev_checking_enabled_.Init(prefs::kCertRevocationCheckingEnabled, |
| 238 g_browser_process->local_state(), this); | 241 g_browser_process->local_state(), this); |
| 239 | 242 |
| 240 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | 243 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 241 background_mode_enabled_.Init(prefs::kBackgroundModeEnabled, | 244 background_mode_enabled_.Init(prefs::kBackgroundModeEnabled, |
| 242 g_browser_process->local_state(), | 245 g_browser_process->local_state(), |
| 243 this); | 246 this); |
| 244 #endif | 247 #endif |
| 245 | 248 |
| 246 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); | 249 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); |
| 247 default_font_size_.Init(prefs::kWebKitDefaultFontSize, prefs, this); | 250 default_font_size_.Init(prefs::kWebKitDefaultFontSize, prefs, this); |
| 251 default_zoom_level_.Init(prefs::kDefaultZoomLevel, prefs, this); | |
| 248 #if !defined(OS_CHROMEOS) | 252 #if !defined(OS_CHROMEOS) |
| 249 proxy_prefs_.reset( | 253 proxy_prefs_.reset( |
| 250 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); | 254 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); |
| 251 #endif // !defined(OS_CHROMEOS) | 255 #endif // !defined(OS_CHROMEOS) |
| 252 | 256 |
| 253 // Return result from the superclass. | 257 // Return result from the superclass. |
| 254 return handler; | 258 return handler; |
| 255 } | 259 } |
| 256 | 260 |
| 257 void AdvancedOptionsHandler::RegisterMessages() { | 261 void AdvancedOptionsHandler::RegisterMessages() { |
| 258 // Setup handlers specific to this panel. | 262 // Setup handlers specific to this panel. |
| 259 DCHECK(web_ui_); | 263 DCHECK(web_ui()); |
| 260 web_ui_->RegisterMessageCallback("selectDownloadLocation", | 264 web_ui()->RegisterMessageCallback("selectDownloadLocation", |
|
James Hawkins
2011/11/14 18:09:05
Ehhh I'm not really a fan of continuously calling
csilv
2011/11/15 02:26:49
I reverted this change here and below.
On 2011/11
| |
| 261 base::Bind(&AdvancedOptionsHandler::HandleSelectDownloadLocation, | 265 base::Bind(&AdvancedOptionsHandler::HandleSelectDownloadLocation, |
| 262 base::Unretained(this))); | 266 base::Unretained(this))); |
| 263 web_ui_->RegisterMessageCallback("autoOpenFileTypesAction", | 267 web_ui()->RegisterMessageCallback("autoOpenFileTypesAction", |
| 264 base::Bind(&AdvancedOptionsHandler::HandleAutoOpenButton, | 268 base::Bind(&AdvancedOptionsHandler::HandleAutoOpenButton, |
| 265 base::Unretained(this))); | 269 base::Unretained(this))); |
| 266 web_ui_->RegisterMessageCallback("defaultFontSizeAction", | 270 web_ui()->RegisterMessageCallback("defaultFontSizeAction", |
| 267 base::Bind(&AdvancedOptionsHandler::HandleDefaultFontSize, | 271 base::Bind(&AdvancedOptionsHandler::HandleDefaultFontSize, |
| 268 base::Unretained(this))); | 272 base::Unretained(this))); |
| 273 web_ui()->RegisterMessageCallback("defaultZoomFactorAction", | |
| 274 base::Bind(&AdvancedOptionsHandler::HandleDefaultZoomFactor, | |
| 275 base::Unretained(this))); | |
| 269 #if !defined(OS_CHROMEOS) | 276 #if !defined(OS_CHROMEOS) |
| 270 web_ui_->RegisterMessageCallback("metricsReportingCheckboxAction", | 277 web_ui()->RegisterMessageCallback("metricsReportingCheckboxAction", |
| 271 base::Bind(&AdvancedOptionsHandler::HandleMetricsReportingCheckbox, | 278 base::Bind(&AdvancedOptionsHandler::HandleMetricsReportingCheckbox, |
| 272 base::Unretained(this))); | 279 base::Unretained(this))); |
| 273 #endif | 280 #endif |
| 274 #if !defined(USE_NSS) && !defined(USE_OPENSSL) | 281 #if !defined(USE_NSS) && !defined(USE_OPENSSL) |
| 275 web_ui_->RegisterMessageCallback("showManageSSLCertificates", | 282 web_ui()->RegisterMessageCallback("showManageSSLCertificates", |
| 276 base::Bind(&AdvancedOptionsHandler::ShowManageSSLCertificates, | 283 base::Bind(&AdvancedOptionsHandler::ShowManageSSLCertificates, |
| 277 base::Unretained(this))); | 284 base::Unretained(this))); |
| 278 #endif | 285 #endif |
| 279 web_ui_->RegisterMessageCallback("showCloudPrintManagePage", | 286 web_ui()->RegisterMessageCallback("showCloudPrintManagePage", |
| 280 base::Bind(&AdvancedOptionsHandler::ShowCloudPrintManagePage, | 287 base::Bind(&AdvancedOptionsHandler::ShowCloudPrintManagePage, |
| 281 base::Unretained(this))); | 288 base::Unretained(this))); |
| 282 #if !defined(OS_CHROMEOS) | 289 #if !defined(OS_CHROMEOS) |
| 283 if (cloud_print_proxy_ui_enabled_) { | 290 if (cloud_print_proxy_ui_enabled_) { |
| 284 web_ui_->RegisterMessageCallback("showCloudPrintSetupDialog", | 291 web_ui()->RegisterMessageCallback("showCloudPrintSetupDialog", |
| 285 base::Bind(&AdvancedOptionsHandler::ShowCloudPrintSetupDialog, | 292 base::Bind(&AdvancedOptionsHandler::ShowCloudPrintSetupDialog, |
| 286 base::Unretained(this))); | 293 base::Unretained(this))); |
| 287 web_ui_->RegisterMessageCallback("disableCloudPrintProxy", | 294 web_ui()->RegisterMessageCallback("disableCloudPrintProxy", |
| 288 base::Bind(&AdvancedOptionsHandler::HandleDisableCloudPrintProxy, | 295 base::Bind(&AdvancedOptionsHandler::HandleDisableCloudPrintProxy, |
| 289 base::Unretained(this))); | 296 base::Unretained(this))); |
| 290 } | 297 } |
| 291 web_ui_->RegisterMessageCallback("showNetworkProxySettings", | 298 web_ui()->RegisterMessageCallback("showNetworkProxySettings", |
| 292 base::Bind(&AdvancedOptionsHandler::ShowNetworkProxySettings, | 299 base::Bind(&AdvancedOptionsHandler::ShowNetworkProxySettings, |
| 293 base::Unretained(this))); | 300 base::Unretained(this))); |
| 294 #endif | 301 #endif |
| 295 web_ui_->RegisterMessageCallback("checkRevocationCheckboxAction", | 302 web_ui()->RegisterMessageCallback("checkRevocationCheckboxAction", |
| 296 base::Bind(&AdvancedOptionsHandler::HandleCheckRevocationCheckbox, | 303 base::Bind(&AdvancedOptionsHandler::HandleCheckRevocationCheckbox, |
| 297 base::Unretained(this))); | 304 base::Unretained(this))); |
| 298 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | 305 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 299 web_ui_->RegisterMessageCallback("backgroundModeAction", | 306 web_ui()->RegisterMessageCallback("backgroundModeAction", |
| 300 base::Bind(&AdvancedOptionsHandler::HandleBackgroundModeCheckbox, | 307 base::Bind(&AdvancedOptionsHandler::HandleBackgroundModeCheckbox, |
| 301 base::Unretained(this))); | 308 base::Unretained(this))); |
| 302 #endif | 309 #endif |
| 303 } | 310 } |
| 304 | 311 |
| 305 void AdvancedOptionsHandler::Observe( | 312 void AdvancedOptionsHandler::Observe( |
| 306 int type, | 313 int type, |
| 307 const content::NotificationSource& source, | 314 const content::NotificationSource& source, |
| 308 const content::NotificationDetails& details) { | 315 const content::NotificationDetails& details) { |
| 309 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 316 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
| 310 std::string* pref_name = content::Details<std::string>(details).ptr(); | 317 std::string* pref_name = content::Details<std::string>(details).ptr(); |
| 311 if (*pref_name == prefs::kDownloadExtensionsToOpen) { | 318 if (*pref_name == prefs::kDownloadExtensionsToOpen) { |
| 312 SetupAutoOpenFileTypesDisabledAttribute(); | 319 SetupAutoOpenFileTypesDisabledAttribute(); |
| 313 #if !defined(OS_CHROMEOS) | 320 #if !defined(OS_CHROMEOS) |
| 314 } else if (proxy_prefs_->IsObserved(*pref_name)) { | 321 } else if (proxy_prefs_->IsObserved(*pref_name)) { |
| 315 SetupProxySettingsSection(); | 322 SetupProxySettingsSection(); |
| 316 #endif // !defined(OS_CHROMEOS) | 323 #endif // !defined(OS_CHROMEOS) |
| 317 } else if ((*pref_name == prefs::kCloudPrintEmail) || | 324 } else if ((*pref_name == prefs::kCloudPrintEmail) || |
| 318 (*pref_name == prefs::kCloudPrintProxyEnabled)) { | 325 (*pref_name == prefs::kCloudPrintProxyEnabled)) { |
| 319 #if !defined(OS_CHROMEOS) | 326 #if !defined(OS_CHROMEOS) |
| 320 if (cloud_print_proxy_ui_enabled_) | 327 if (cloud_print_proxy_ui_enabled_) |
| 321 SetupCloudPrintProxySection(); | 328 SetupCloudPrintProxySection(); |
| 322 #endif | 329 #endif |
| 323 } else if (*pref_name == prefs::kWebKitDefaultFontSize) { | 330 } else if (*pref_name == prefs::kWebKitDefaultFontSize) { |
| 324 SetupFontSizeLabel(); | 331 SetupFontSizeSelector(); |
| 332 } else if (*pref_name == prefs::kDefaultZoomLevel) { | |
| 333 SetupPageZoomSelector(); | |
| 325 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | 334 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 326 } else if (*pref_name == prefs::kBackgroundModeEnabled) { | 335 } else if (*pref_name == prefs::kBackgroundModeEnabled) { |
| 327 SetupBackgroundModeSettings(); | 336 SetupBackgroundModeSettings(); |
| 328 #endif | 337 #endif |
| 329 } | 338 } |
| 330 } | 339 } |
| 331 } | 340 } |
| 332 | 341 |
| 333 void AdvancedOptionsHandler::HandleSelectDownloadLocation( | 342 void AdvancedOptionsHandler::HandleSelectDownloadLocation( |
| 334 const ListValue* args) { | 343 const ListValue* args) { |
| 335 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs(); | 344 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 336 select_folder_dialog_ = SelectFileDialog::Create(this); | 345 select_folder_dialog_ = SelectFileDialog::Create(this); |
| 337 select_folder_dialog_->SelectFile( | 346 select_folder_dialog_->SelectFile( |
| 338 SelectFileDialog::SELECT_FOLDER, | 347 SelectFileDialog::SELECT_FOLDER, |
| 339 l10n_util::GetStringUTF16(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE), | 348 l10n_util::GetStringUTF16(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE), |
| 340 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory), | 349 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory), |
| 341 NULL, 0, FILE_PATH_LITERAL(""), web_ui_->tab_contents(), | 350 NULL, 0, FILE_PATH_LITERAL(""), web_ui()->tab_contents(), |
| 342 web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(), NULL); | 351 web_ui()->tab_contents()->view()->GetTopLevelNativeWindow(), NULL); |
| 343 } | 352 } |
| 344 | 353 |
| 345 void AdvancedOptionsHandler::FileSelected(const FilePath& path, int index, | 354 void AdvancedOptionsHandler::FileSelected(const FilePath& path, int index, |
| 346 void* params) { | 355 void* params) { |
| 347 UserMetrics::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); | 356 UserMetrics::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); |
| 348 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs(); | 357 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 349 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); | 358 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); |
| 350 } | 359 } |
| 351 | 360 |
| 352 void AdvancedOptionsHandler::OnCloudPrintSetupClosed() { | 361 void AdvancedOptionsHandler::OnCloudPrintSetupClosed() { |
| 353 #if !defined(OS_CHROMEOS) | 362 #if !defined(OS_CHROMEOS) |
| 354 if (cloud_print_proxy_ui_enabled_) | 363 if (cloud_print_proxy_ui_enabled_) |
| 355 SetupCloudPrintProxySection(); | 364 SetupCloudPrintProxySection(); |
| 356 #endif | 365 #endif |
| 357 } | 366 } |
| 358 | 367 |
| 359 void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) { | 368 void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) { |
| 360 UserMetrics::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); | 369 UserMetrics::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); |
| 361 DownloadManager* manager = | 370 DownloadManager* manager = |
| 362 web_ui_->tab_contents()->browser_context()->GetDownloadManager(); | 371 web_ui()->tab_contents()->browser_context()->GetDownloadManager(); |
| 363 if (manager) | 372 if (manager) |
| 364 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); | 373 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); |
| 365 } | 374 } |
| 366 | 375 |
| 367 void AdvancedOptionsHandler::HandleMetricsReportingCheckbox( | 376 void AdvancedOptionsHandler::HandleMetricsReportingCheckbox( |
| 368 const ListValue* args) { | 377 const ListValue* args) { |
| 369 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) | 378 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) |
| 370 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); | 379 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); |
| 371 bool enabled = checked_str == "true"; | 380 bool enabled = checked_str == "true"; |
| 372 UserMetrics::RecordAction( | 381 UserMetrics::RecordAction( |
| 373 enabled ? | 382 enabled ? |
| 374 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : | 383 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : |
| 375 UserMetricsAction("Options_MetricsReportingCheckbox_Disable")); | 384 UserMetricsAction("Options_MetricsReportingCheckbox_Disable")); |
| 376 bool is_enabled = OptionsUtil::ResolveMetricsReportingEnabled(enabled); | 385 bool is_enabled = OptionsUtil::ResolveMetricsReportingEnabled(enabled); |
| 377 enable_metrics_recording_.SetValue(is_enabled); | 386 enable_metrics_recording_.SetValue(is_enabled); |
| 378 SetupMetricsReportingCheckbox(); | 387 SetupMetricsReportingCheckbox(); |
| 379 #endif | 388 #endif |
| 380 } | 389 } |
| 381 | 390 |
| 382 void AdvancedOptionsHandler::HandleDefaultFontSize(const ListValue* args) { | 391 void AdvancedOptionsHandler::HandleDefaultFontSize(const ListValue* args) { |
| 383 int font_size; | 392 int font_size; |
| 384 if (ExtractIntegerValue(args, &font_size)) { | 393 if (ExtractIntegerValue(args, &font_size)) { |
| 385 if (font_size > 0) { | 394 if (font_size > 0) { |
| 386 default_font_size_.SetValue(font_size); | 395 default_font_size_.SetValue(font_size); |
| 387 SetupFontSizeLabel(); | 396 SetupFontSizeSelector(); |
| 388 } | 397 } |
| 389 } | 398 } |
| 390 } | 399 } |
| 391 | 400 |
| 401 void AdvancedOptionsHandler::HandleDefaultZoomFactor(const ListValue* args) { | |
| 402 double zoom_factor; | |
| 403 if (ExtractDoubleValue(args, &zoom_factor)) { | |
| 404 default_zoom_level_.SetValue( | |
| 405 WebKit::WebView::zoomFactorToZoomLevel(zoom_factor)); | |
| 406 } | |
| 407 } | |
| 408 | |
| 392 void AdvancedOptionsHandler::HandleCheckRevocationCheckbox( | 409 void AdvancedOptionsHandler::HandleCheckRevocationCheckbox( |
| 393 const ListValue* args) { | 410 const ListValue* args) { |
| 394 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); | 411 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); |
| 395 bool enabled = checked_str == "true"; | 412 bool enabled = checked_str == "true"; |
| 396 UserMetrics::RecordAction( | 413 UserMetrics::RecordAction( |
| 397 enabled ? | 414 enabled ? |
| 398 UserMetricsAction("Options_CheckCertRevocation_Enable") : | 415 UserMetricsAction("Options_CheckCertRevocation_Enable") : |
| 399 UserMetricsAction("Options_CheckCertRevocation_Disable")); | 416 UserMetricsAction("Options_CheckCertRevocation_Disable")); |
| 400 rev_checking_enabled_.SetValue(enabled); | 417 rev_checking_enabled_.SetValue(enabled); |
| 401 } | 418 } |
| 402 | 419 |
| 403 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | 420 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 404 void AdvancedOptionsHandler::HandleBackgroundModeCheckbox( | 421 void AdvancedOptionsHandler::HandleBackgroundModeCheckbox( |
| 405 const ListValue* args) { | 422 const ListValue* args) { |
| 406 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); | 423 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); |
| 407 bool enabled = checked_str == "true"; | 424 bool enabled = checked_str == "true"; |
| 408 UserMetrics::RecordAction(enabled ? | 425 UserMetrics::RecordAction(enabled ? |
| 409 UserMetricsAction("Options_BackgroundMode_Enable") : | 426 UserMetricsAction("Options_BackgroundMode_Enable") : |
| 410 UserMetricsAction("Options_BackgroundMode_Disable")); | 427 UserMetricsAction("Options_BackgroundMode_Disable")); |
| 411 background_mode_enabled_.SetValue(enabled); | 428 background_mode_enabled_.SetValue(enabled); |
| 412 } | 429 } |
| 413 | 430 |
| 414 void AdvancedOptionsHandler::SetupBackgroundModeSettings() { | 431 void AdvancedOptionsHandler::SetupBackgroundModeSettings() { |
| 415 base::FundamentalValue checked(background_mode_enabled_.GetValue()); | 432 base::FundamentalValue checked(background_mode_enabled_.GetValue()); |
| 416 web_ui_->CallJavascriptFunction( | 433 web_ui()->CallJavascriptFunction( |
| 417 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked); | 434 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked); |
| 418 } | 435 } |
| 419 #endif | 436 #endif |
| 420 | 437 |
| 421 #if !defined(OS_CHROMEOS) | 438 #if !defined(OS_CHROMEOS) |
| 422 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { | 439 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { |
| 423 UserMetrics::RecordAction(UserMetricsAction("Options_ShowProxySettings")); | 440 UserMetrics::RecordAction(UserMetricsAction("Options_ShowProxySettings")); |
| 424 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui_->tab_contents()); | 441 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui()->tab_contents()); |
| 425 } | 442 } |
| 426 #endif | 443 #endif |
| 427 | 444 |
| 428 #if !defined(USE_NSS) && !defined(USE_OPENSSL) | 445 #if !defined(USE_NSS) && !defined(USE_OPENSSL) |
| 429 void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) { | 446 void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) { |
| 430 UserMetrics::RecordAction(UserMetricsAction("Options_ManageSSLCertificates")); | 447 UserMetrics::RecordAction(UserMetricsAction("Options_ManageSSLCertificates")); |
| 431 AdvancedOptionsUtilities::ShowManageSSLCertificates(web_ui_->tab_contents()); | 448 AdvancedOptionsUtilities::ShowManageSSLCertificates(web_ui()->tab_contents()); |
| 432 } | 449 } |
| 433 #endif | 450 #endif |
| 434 | 451 |
| 435 void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) { | 452 void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) { |
| 436 UserMetrics::RecordAction(UserMetricsAction("Options_ManageCloudPrinters")); | 453 UserMetrics::RecordAction(UserMetricsAction("Options_ManageCloudPrinters")); |
| 437 // Open a new tab in the current window for the management page. | 454 // Open a new tab in the current window for the management page. |
| 438 Profile* profile = Profile::FromWebUI(web_ui_); | 455 Profile* profile = Profile::FromWebUI(web_ui()); |
| 439 web_ui_->tab_contents()->OpenURL( | 456 web_ui()->tab_contents()->OpenURL( |
| 440 CloudPrintURL(profile).GetCloudPrintServiceManageURL(), | 457 CloudPrintURL(profile).GetCloudPrintServiceManageURL(), |
| 441 GURL(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); | 458 GURL(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); |
| 442 } | 459 } |
| 443 | 460 |
| 444 #if !defined(OS_CHROMEOS) | 461 #if !defined(OS_CHROMEOS) |
| 445 void AdvancedOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) { | 462 void AdvancedOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) { |
| 446 UserMetrics::RecordAction(UserMetricsAction("Options_EnableCloudPrintProxy")); | 463 UserMetrics::RecordAction(UserMetricsAction("Options_EnableCloudPrintProxy")); |
| 447 // Open the connector enable page in the current tab. | 464 // Open the connector enable page in the current tab. |
| 448 Profile* profile = Profile::FromWebUI(web_ui_); | 465 Profile* profile = Profile::FromWebUI(web_ui()); |
| 449 web_ui_->tab_contents()->OpenURL( | 466 web_ui()->tab_contents()->OpenURL( |
| 450 CloudPrintURL(profile).GetCloudPrintServiceEnableURL( | 467 CloudPrintURL(profile).GetCloudPrintServiceEnableURL( |
| 451 CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()), | 468 CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()), |
| 452 GURL(), CURRENT_TAB, content::PAGE_TRANSITION_LINK); | 469 GURL(), CURRENT_TAB, content::PAGE_TRANSITION_LINK); |
| 453 } | 470 } |
| 454 | 471 |
| 455 void AdvancedOptionsHandler::HandleDisableCloudPrintProxy( | 472 void AdvancedOptionsHandler::HandleDisableCloudPrintProxy( |
| 456 const ListValue* args) { | 473 const ListValue* args) { |
| 457 UserMetrics::RecordAction( | 474 UserMetrics::RecordAction( |
| 458 UserMetricsAction("Options_DisableCloudPrintProxy")); | 475 UserMetricsAction("Options_DisableCloudPrintProxy")); |
| 459 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui_))-> | 476 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> |
| 460 DisableForUser(); | 477 DisableForUser(); |
| 461 } | 478 } |
| 462 | 479 |
| 463 void AdvancedOptionsHandler::RefreshCloudPrintStatusFromService() { | 480 void AdvancedOptionsHandler::RefreshCloudPrintStatusFromService() { |
| 464 DCHECK(web_ui_); | 481 DCHECK(web_ui()); |
| 465 if (cloud_print_proxy_ui_enabled_) | 482 if (cloud_print_proxy_ui_enabled_) |
| 466 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui_))-> | 483 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> |
| 467 RefreshStatusFromService(); | 484 RefreshStatusFromService(); |
| 468 } | 485 } |
| 469 | 486 |
| 470 void AdvancedOptionsHandler::SetupCloudPrintProxySection() { | 487 void AdvancedOptionsHandler::SetupCloudPrintProxySection() { |
| 471 Profile* profile = Profile::FromWebUI(web_ui_); | 488 Profile* profile = Profile::FromWebUI(web_ui()); |
| 472 if (!CloudPrintProxyServiceFactory::GetForProfile(profile)) { | 489 if (!CloudPrintProxyServiceFactory::GetForProfile(profile)) { |
| 473 cloud_print_proxy_ui_enabled_ = false; | 490 cloud_print_proxy_ui_enabled_ = false; |
| 474 RemoveCloudPrintProxySection(); | 491 RemoveCloudPrintProxySection(); |
| 475 return; | 492 return; |
| 476 } | 493 } |
| 477 | 494 |
| 478 bool cloud_print_proxy_allowed = | 495 bool cloud_print_proxy_allowed = |
| 479 !cloud_print_proxy_enabled_.IsManaged() || | 496 !cloud_print_proxy_enabled_.IsManaged() || |
| 480 cloud_print_proxy_enabled_.GetValue(); | 497 cloud_print_proxy_enabled_.GetValue(); |
| 481 base::FundamentalValue allowed(cloud_print_proxy_allowed); | 498 base::FundamentalValue allowed(cloud_print_proxy_allowed); |
| 482 | 499 |
| 483 std::string email; | 500 std::string email; |
| 484 if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) && | 501 if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) && |
| 485 cloud_print_proxy_allowed) { | 502 cloud_print_proxy_allowed) { |
| 486 email = profile->GetPrefs()->GetString(prefs::kCloudPrintEmail); | 503 email = profile->GetPrefs()->GetString(prefs::kCloudPrintEmail); |
| 487 } | 504 } |
| 488 base::FundamentalValue disabled(email.empty()); | 505 base::FundamentalValue disabled(email.empty()); |
| 489 | 506 |
| 490 string16 label_str; | 507 string16 label_str; |
| 491 if (email.empty()) { | 508 if (email.empty()) { |
| 492 label_str = l10n_util::GetStringUTF16( | 509 label_str = l10n_util::GetStringUTF16( |
| 493 IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_LABEL); | 510 IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_LABEL); |
| 494 } else { | 511 } else { |
| 495 label_str = l10n_util::GetStringFUTF16( | 512 label_str = l10n_util::GetStringFUTF16( |
| 496 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_LABEL, UTF8ToUTF16(email)); | 513 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_LABEL, UTF8ToUTF16(email)); |
| 497 } | 514 } |
| 498 StringValue label(label_str); | 515 StringValue label(label_str); |
| 499 | 516 |
| 500 web_ui_->CallJavascriptFunction( | 517 web_ui()->CallJavascriptFunction( |
| 501 "options.AdvancedOptions.SetupCloudPrintProxySection", | 518 "options.AdvancedOptions.SetupCloudPrintProxySection", |
| 502 disabled, label, allowed); | 519 disabled, label, allowed); |
| 503 } | 520 } |
| 504 | 521 |
| 505 void AdvancedOptionsHandler::RemoveCloudPrintProxySection() { | 522 void AdvancedOptionsHandler::RemoveCloudPrintProxySection() { |
| 506 web_ui_->CallJavascriptFunction( | 523 web_ui()->CallJavascriptFunction( |
| 507 "options.AdvancedOptions.RemoveCloudPrintProxySection"); | 524 "options.AdvancedOptions.RemoveCloudPrintProxySection"); |
| 508 } | 525 } |
| 509 | 526 |
| 510 #endif | 527 #endif |
| 511 | 528 |
| 512 void AdvancedOptionsHandler::SetupMetricsReportingCheckbox() { | 529 void AdvancedOptionsHandler::SetupMetricsReportingCheckbox() { |
| 513 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) | 530 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) |
| 514 base::FundamentalValue checked(enable_metrics_recording_.GetValue()); | 531 base::FundamentalValue checked(enable_metrics_recording_.GetValue()); |
| 515 base::FundamentalValue disabled(enable_metrics_recording_.IsManaged()); | 532 base::FundamentalValue disabled(enable_metrics_recording_.IsManaged()); |
| 516 web_ui_->CallJavascriptFunction( | 533 web_ui()->CallJavascriptFunction( |
| 517 "options.AdvancedOptions.SetMetricsReportingCheckboxState", checked, | 534 "options.AdvancedOptions.SetMetricsReportingCheckboxState", checked, |
| 518 disabled); | 535 disabled); |
| 519 #endif | 536 #endif |
| 520 } | 537 } |
| 521 | 538 |
| 522 void AdvancedOptionsHandler::SetupMetricsReportingSettingVisibility() { | 539 void AdvancedOptionsHandler::SetupMetricsReportingSettingVisibility() { |
| 523 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS) | 540 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS) |
| 524 // Don't show the reporting setting if we are in the guest mode. | 541 // Don't show the reporting setting if we are in the guest mode. |
| 525 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { | 542 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
| 526 base::FundamentalValue visible(false); | 543 base::FundamentalValue visible(false); |
| 527 web_ui_->CallJavascriptFunction( | 544 web_ui()->CallJavascriptFunction( |
| 528 "options.AdvancedOptions.SetMetricsReportingSettingVisibility", | 545 "options.AdvancedOptions.SetMetricsReportingSettingVisibility", |
| 529 visible); | 546 visible); |
| 530 } | 547 } |
| 531 #endif | 548 #endif |
| 532 } | 549 } |
| 533 | 550 |
| 534 void AdvancedOptionsHandler::SetupFontSizeLabel() { | 551 void AdvancedOptionsHandler::SetupFontSizeSelector() { |
| 535 // We're only interested in integer values, so convert to int. | 552 // We're only interested in integer values, so convert to int. |
| 536 base::FundamentalValue font_size(default_font_size_.GetValue()); | 553 base::FundamentalValue font_size(default_font_size_.GetValue()); |
| 537 web_ui_->CallJavascriptFunction( | 554 web_ui()->CallJavascriptFunction( |
| 538 "options.AdvancedOptions.SetFontSize", font_size); | 555 "options.AdvancedOptions.SetFontSize", font_size); |
| 539 } | 556 } |
| 540 | 557 |
| 558 void AdvancedOptionsHandler::SetupPageZoomSelector() { | |
| 559 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | |
| 560 double default_zoom_level = pref_service->GetDouble(prefs::kDefaultZoomLevel); | |
| 561 double default_zoom_factor = | |
| 562 WebKit::WebView::zoomLevelToZoomFactor(default_zoom_level); | |
| 563 | |
| 564 // Generate a vector of zoom factors from an array of known preset values. | |
|
James Hawkins
2011/11/14 18:09:05
:-/ This is very similar if not exactly like the c
csilv
2011/11/15 02:26:49
Done.
| |
| 565 // The values in content::kPresetZoomFactors will already be in sorted order. | |
| 566 std::vector<double> zoom_factors; | |
| 567 bool found_default = false; | |
| 568 for (int i = 0; i < content::kPresetZoomFactorsCount; i++) { | |
| 569 double zoom_factor = content::kPresetZoomFactors[i]; | |
| 570 if (std::fabs(zoom_factor - default_zoom_factor) <= | |
| 571 content::kPageZoomEpsilon) | |
| 572 found_default = true; | |
| 573 zoom_factors.push_back(zoom_factor); | |
| 574 } | |
| 575 // If the preset array did not contain the user's default zoom value, | |
| 576 // append it to the vector and then sort. | |
| 577 if (!found_default) { | |
| 578 zoom_factors.push_back(default_zoom_factor); | |
| 579 std::sort(zoom_factors.begin(), zoom_factors.end()); | |
| 580 } | |
| 581 | |
| 582 // Iterate through the zoom factors and and build the contents of the | |
| 583 // selector that will be sent to the javascript handler. | |
| 584 // Each item in the list has the following parameters: | |
| 585 // 1. Title (string). | |
| 586 // 2. Value (double). | |
| 587 // 3. Is selected? (bool). | |
| 588 ListValue zoom_factors_value; | |
| 589 for (std::vector<double>::const_iterator i = zoom_factors.begin(); | |
| 590 i != zoom_factors.end(); ++i) { | |
| 591 ListValue* option = new ListValue(); | |
| 592 double factor = *i; | |
| 593 int percent = static_cast<int>(factor * 100 + 0.5); | |
| 594 option->Append(Value::CreateStringValue( | |
| 595 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, percent))); | |
| 596 option->Append(Value::CreateDoubleValue(factor)); | |
| 597 bool selected = | |
| 598 (std::fabs(factor - default_zoom_factor) < content::kPageZoomEpsilon); | |
| 599 option->Append(Value::CreateBooleanValue(selected)); | |
| 600 zoom_factors_value.Append(option); | |
| 601 } | |
| 602 | |
| 603 web_ui()->CallJavascriptFunction( | |
| 604 "options.AdvancedOptions.SetupPageZoomSelector", zoom_factors_value); | |
| 605 } | |
| 606 | |
| 541 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { | 607 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { |
| 542 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. | 608 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. |
| 543 // We enable the button if the user has any auto-open file types registered. | 609 // We enable the button if the user has any auto-open file types registered. |
| 544 DownloadManager* manager = | 610 DownloadManager* manager = |
| 545 web_ui_->tab_contents()->browser_context()->GetDownloadManager(); | 611 web_ui()->tab_contents()->browser_context()->GetDownloadManager(); |
| 546 bool disabled = !(manager && | 612 bool disabled = !(manager && |
| 547 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed()); | 613 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed()); |
| 548 base::FundamentalValue value(disabled); | 614 base::FundamentalValue value(disabled); |
| 549 web_ui_->CallJavascriptFunction( | 615 web_ui()->CallJavascriptFunction( |
| 550 "options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value); | 616 "options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value); |
| 551 } | 617 } |
| 552 | 618 |
| 553 void AdvancedOptionsHandler::SetupProxySettingsSection() { | 619 void AdvancedOptionsHandler::SetupProxySettingsSection() { |
| 554 #if !defined(OS_CHROMEOS) | 620 #if !defined(OS_CHROMEOS) |
| 555 // Disable the button if proxy settings are managed by a sysadmin or | 621 // Disable the button if proxy settings are managed by a sysadmin or |
| 556 // overridden by an extension. | 622 // overridden by an extension. |
| 557 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs(); | 623 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 558 const PrefService::Preference* proxy_config = | 624 const PrefService::Preference* proxy_config = |
| 559 pref_service->FindPreference(prefs::kProxy); | 625 pref_service->FindPreference(prefs::kProxy); |
| 560 bool is_extension_controlled = (proxy_config && | 626 bool is_extension_controlled = (proxy_config && |
| 561 proxy_config->IsExtensionControlled()); | 627 proxy_config->IsExtensionControlled()); |
| 562 | 628 |
| 563 base::FundamentalValue disabled(proxy_prefs_->IsManaged() || | 629 base::FundamentalValue disabled(proxy_prefs_->IsManaged() || |
| 564 is_extension_controlled); | 630 is_extension_controlled); |
| 565 | 631 |
| 566 // Get the appropriate info string to describe the button. | 632 // Get the appropriate info string to describe the button. |
| 567 string16 label_str; | 633 string16 label_str; |
| 568 if (is_extension_controlled) { | 634 if (is_extension_controlled) { |
| 569 label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL); | 635 label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL); |
| 570 } else { | 636 } else { |
| 571 label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL, | 637 label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL, |
| 572 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 638 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 573 } | 639 } |
| 574 StringValue label(label_str); | 640 StringValue label(label_str); |
| 575 | 641 |
| 576 web_ui_->CallJavascriptFunction( | 642 web_ui()->CallJavascriptFunction( |
| 577 "options.AdvancedOptions.SetupProxySettingsSection", disabled, label); | 643 "options.AdvancedOptions.SetupProxySettingsSection", disabled, label); |
| 578 #endif // !defined(OS_CHROMEOS) | 644 #endif // !defined(OS_CHROMEOS) |
| 579 } | 645 } |
| 580 | 646 |
| 581 void AdvancedOptionsHandler::SetupSSLConfigSettings() { | 647 void AdvancedOptionsHandler::SetupSSLConfigSettings() { |
| 582 { | 648 { |
| 583 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); | 649 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); |
| 584 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); | 650 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); |
| 585 web_ui_->CallJavascriptFunction( | 651 web_ui()->CallJavascriptFunction( |
| 586 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked, | 652 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked, |
| 587 disabled); | 653 disabled); |
| 588 } | 654 } |
| 589 } | 655 } |
| OLD | NEW |