| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/download/download_manager.h" | 15 #include "chrome/browser/download/download_manager.h" |
| 16 #include "chrome/browser/download/download_prefs.h" | 16 #include "chrome/browser/download/download_prefs.h" |
| 17 #include "chrome/browser/google/google_util.h" | 17 #include "chrome/browser/google/google_util.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 19 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 20 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 20 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
| 21 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 21 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/remoting/setup_flow.h" | |
| 24 #include "chrome/browser/service/service_process_control.h" | 23 #include "chrome/browser/service/service_process_control.h" |
| 25 #include "chrome/browser/service/service_process_control_manager.h" | 24 #include "chrome/browser/service/service_process_control_manager.h" |
| 26 #include "chrome/browser/ui/options/options_util.h" | 25 #include "chrome/browser/ui/options/options_util.h" |
| 27 #include "chrome/browser/ui/webui/options/options_managed_banner_handler.h" | 26 #include "chrome/browser/ui/webui/options/options_managed_banner_handler.h" |
| 28 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 31 #include "content/browser/tab_contents/tab_contents.h" | 30 #include "content/browser/tab_contents/tab_contents.h" |
| 32 #include "content/browser/tab_contents/tab_contents_view.h" | 31 #include "content/browser/tab_contents/tab_contents_view.h" |
| 33 #include "content/browser/user_metrics.h" | 32 #include "content/browser/user_metrics.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_LABEL }, | 155 IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_LABEL }, |
| 157 { "cloudPrintProxyDisabledButton", | 156 { "cloudPrintProxyDisabledButton", |
| 158 IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_BUTTON }, | 157 IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_BUTTON }, |
| 159 { "cloudPrintProxyEnabledButton", | 158 { "cloudPrintProxyEnabledButton", |
| 160 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_BUTTON }, | 159 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_BUTTON }, |
| 161 { "cloudPrintProxyEnabledManageButton", | 160 { "cloudPrintProxyEnabledManageButton", |
| 162 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_MANAGE_BUTTON }, | 161 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_MANAGE_BUTTON }, |
| 163 { "cloudPrintProxyEnablingButton", | 162 { "cloudPrintProxyEnablingButton", |
| 164 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLING_BUTTON }, | 163 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLING_BUTTON }, |
| 165 #endif | 164 #endif |
| 166 #if defined(ENABLE_REMOTING) | |
| 167 { "advancedSectionTitleRemoting", | |
| 168 IDS_OPTIONS_ADVANCED_SECTION_TITLE_REMOTING }, | |
| 169 { "remotingSetupButton", | |
| 170 IDS_OPTIONS_REMOTING_SETUP_BUTTON }, | |
| 171 { "remotingStopButton", | |
| 172 IDS_OPTIONS_REMOTING_STOP_BUTTON }, | |
| 173 #endif | |
| 174 }; | 165 }; |
| 175 | 166 |
| 176 RegisterStrings(localized_strings, resources, arraysize(resources)); | 167 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 177 RegisterTitle(localized_strings, "advancedPage", | 168 RegisterTitle(localized_strings, "advancedPage", |
| 178 IDS_OPTIONS_ADVANCED_TAB_LABEL); | 169 IDS_OPTIONS_ADVANCED_TAB_LABEL); |
| 179 | 170 |
| 180 localized_strings->SetString("privacyLearnMoreURL", | 171 localized_strings->SetString("privacyLearnMoreURL", |
| 181 google_util::AppendGoogleLocaleParam( | 172 google_util::AppendGoogleLocaleParam( |
| 182 GURL(chrome::kPrivacyLearnMoreURL)).spec()); | 173 GURL(chrome::kPrivacyLearnMoreURL)).spec()); |
| 183 } | 174 } |
| 184 | 175 |
| 185 void AdvancedOptionsHandler::Initialize() { | 176 void AdvancedOptionsHandler::Initialize() { |
| 186 DCHECK(web_ui_); | 177 DCHECK(web_ui_); |
| 187 SetupMetricsReportingCheckbox(); | 178 SetupMetricsReportingCheckbox(); |
| 188 SetupMetricsReportingSettingVisibility(); | 179 SetupMetricsReportingSettingVisibility(); |
| 189 SetupFontSizeLabel(); | 180 SetupFontSizeLabel(); |
| 190 SetupDownloadLocationPath(); | 181 SetupDownloadLocationPath(); |
| 191 SetupPromptForDownload(); | 182 SetupPromptForDownload(); |
| 192 SetupAutoOpenFileTypesDisabledAttribute(); | 183 SetupAutoOpenFileTypesDisabledAttribute(); |
| 193 SetupProxySettingsSection(); | 184 SetupProxySettingsSection(); |
| 194 SetupSSLConfigSettings(); | 185 SetupSSLConfigSettings(); |
| 195 #if !defined(OS_CHROMEOS) | 186 #if !defined(OS_CHROMEOS) |
| 196 if (cloud_print_proxy_ui_enabled_) { | 187 if (cloud_print_proxy_ui_enabled_) { |
| 197 SetupCloudPrintProxySection(); | 188 SetupCloudPrintProxySection(); |
| 198 RefreshCloudPrintStatusFromService(); | 189 RefreshCloudPrintStatusFromService(); |
| 199 } else { | 190 } else { |
| 200 RemoveCloudPrintProxySection(); | 191 RemoveCloudPrintProxySection(); |
| 201 } | 192 } |
| 202 #endif | 193 #endif |
| 203 #if defined(ENABLE_REMOTING) && !defined(OS_CHROMEOS) | |
| 204 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableRemoting)) { | |
| 205 RemoveRemotingSection(); | |
| 206 } else { | |
| 207 remoting_options_handler_.Init(web_ui_); | |
| 208 } | |
| 209 #endif | |
| 210 | 194 |
| 211 banner_handler_.reset( | 195 banner_handler_.reset( |
| 212 new OptionsManagedBannerHandler(web_ui_, | 196 new OptionsManagedBannerHandler(web_ui_, |
| 213 ASCIIToUTF16("AdvancedOptions"), | 197 ASCIIToUTF16("AdvancedOptions"), |
| 214 OPTIONS_PAGE_ADVANCED)); | 198 OPTIONS_PAGE_ADVANCED)); |
| 215 } | 199 } |
| 216 | 200 |
| 217 WebUIMessageHandler* AdvancedOptionsHandler::Attach(WebUI* web_ui) { | 201 WebUIMessageHandler* AdvancedOptionsHandler::Attach(WebUI* web_ui) { |
| 218 // Call through to superclass. | 202 // Call through to superclass. |
| 219 WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui); | 203 WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 NewCallback(this, | 267 NewCallback(this, |
| 284 &AdvancedOptionsHandler::HandleDisableCloudPrintProxy)); | 268 &AdvancedOptionsHandler::HandleDisableCloudPrintProxy)); |
| 285 web_ui_->RegisterMessageCallback("showCloudPrintManagePage", | 269 web_ui_->RegisterMessageCallback("showCloudPrintManagePage", |
| 286 NewCallback(this, | 270 NewCallback(this, |
| 287 &AdvancedOptionsHandler::ShowCloudPrintManagePage)); | 271 &AdvancedOptionsHandler::ShowCloudPrintManagePage)); |
| 288 } | 272 } |
| 289 web_ui_->RegisterMessageCallback("showNetworkProxySettings", | 273 web_ui_->RegisterMessageCallback("showNetworkProxySettings", |
| 290 NewCallback(this, | 274 NewCallback(this, |
| 291 &AdvancedOptionsHandler::ShowNetworkProxySettings)); | 275 &AdvancedOptionsHandler::ShowNetworkProxySettings)); |
| 292 #endif | 276 #endif |
| 293 #if defined(ENABLE_REMOTING) && !defined(OS_CHROMEOS) | |
| 294 web_ui_->RegisterMessageCallback("showRemotingSetupDialog", | |
| 295 NewCallback(this, | |
| 296 &AdvancedOptionsHandler::ShowRemotingSetupDialog)); | |
| 297 web_ui_->RegisterMessageCallback("disableRemoting", | |
| 298 NewCallback(this, | |
| 299 &AdvancedOptionsHandler::DisableRemoting)); | |
| 300 #endif | |
| 301 web_ui_->RegisterMessageCallback("checkRevocationCheckboxAction", | 277 web_ui_->RegisterMessageCallback("checkRevocationCheckboxAction", |
| 302 NewCallback(this, | 278 NewCallback(this, |
| 303 &AdvancedOptionsHandler::HandleCheckRevocationCheckbox)); | 279 &AdvancedOptionsHandler::HandleCheckRevocationCheckbox)); |
| 304 web_ui_->RegisterMessageCallback("useSSL3CheckboxAction", | 280 web_ui_->RegisterMessageCallback("useSSL3CheckboxAction", |
| 305 NewCallback(this, | 281 NewCallback(this, |
| 306 &AdvancedOptionsHandler::HandleUseSSL3Checkbox)); | 282 &AdvancedOptionsHandler::HandleUseSSL3Checkbox)); |
| 307 web_ui_->RegisterMessageCallback("useTLS1CheckboxAction", | 283 web_ui_->RegisterMessageCallback("useTLS1CheckboxAction", |
| 308 NewCallback(this, | 284 NewCallback(this, |
| 309 &AdvancedOptionsHandler::HandleUseTLS1Checkbox)); | 285 &AdvancedOptionsHandler::HandleUseTLS1Checkbox)); |
| 310 } | 286 } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 disabled, label, allowed); | 483 disabled, label, allowed); |
| 508 } | 484 } |
| 509 | 485 |
| 510 void AdvancedOptionsHandler::RemoveCloudPrintProxySection() { | 486 void AdvancedOptionsHandler::RemoveCloudPrintProxySection() { |
| 511 web_ui_->CallJavascriptFunction( | 487 web_ui_->CallJavascriptFunction( |
| 512 "options.AdvancedOptions.RemoveCloudPrintProxySection"); | 488 "options.AdvancedOptions.RemoveCloudPrintProxySection"); |
| 513 } | 489 } |
| 514 | 490 |
| 515 #endif | 491 #endif |
| 516 | 492 |
| 517 #if defined(ENABLE_REMOTING) && !defined(OS_CHROMEOS) | |
| 518 void AdvancedOptionsHandler::RemoveRemotingSection() { | |
| 519 web_ui_->CallJavascriptFunction( | |
| 520 "options.AdvancedOptions.RemoveRemotingSection"); | |
| 521 } | |
| 522 | |
| 523 void AdvancedOptionsHandler::ShowRemotingSetupDialog(const ListValue* args) { | |
| 524 remoting::SetupFlow::OpenSetupDialog(web_ui_->GetProfile()); | |
| 525 } | |
| 526 | |
| 527 void AdvancedOptionsHandler::DisableRemoting(const ListValue* args) { | |
| 528 ServiceProcessControl* process_control = | |
| 529 ServiceProcessControlManager::GetInstance()->GetProcessControl( | |
| 530 web_ui_->GetProfile()); | |
| 531 if (!process_control || !process_control->is_connected()) | |
| 532 return; | |
| 533 process_control->DisableRemotingHost(); | |
| 534 } | |
| 535 #endif | |
| 536 | |
| 537 void AdvancedOptionsHandler::SetupMetricsReportingCheckbox() { | 493 void AdvancedOptionsHandler::SetupMetricsReportingCheckbox() { |
| 538 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) | 494 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) |
| 539 FundamentalValue checked(enable_metrics_recording_.GetValue()); | 495 FundamentalValue checked(enable_metrics_recording_.GetValue()); |
| 540 FundamentalValue disabled(enable_metrics_recording_.IsManaged()); | 496 FundamentalValue disabled(enable_metrics_recording_.IsManaged()); |
| 541 web_ui_->CallJavascriptFunction( | 497 web_ui_->CallJavascriptFunction( |
| 542 "options.AdvancedOptions.SetMetricsReportingCheckboxState", checked, | 498 "options.AdvancedOptions.SetMetricsReportingCheckboxState", checked, |
| 543 disabled); | 499 disabled); |
| 544 #endif | 500 #endif |
| 545 } | 501 } |
| 546 | 502 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 web_ui_->CallJavascriptFunction( | 591 web_ui_->CallJavascriptFunction( |
| 636 "options.AdvancedOptions.SetUseSSL3CheckboxState", checked, disabled); | 592 "options.AdvancedOptions.SetUseSSL3CheckboxState", checked, disabled); |
| 637 } | 593 } |
| 638 { | 594 { |
| 639 FundamentalValue checked(tls1_enabled_.GetValue()); | 595 FundamentalValue checked(tls1_enabled_.GetValue()); |
| 640 FundamentalValue disabled(tls1_enabled_.IsManaged()); | 596 FundamentalValue disabled(tls1_enabled_.IsManaged()); |
| 641 web_ui_->CallJavascriptFunction( | 597 web_ui_->CallJavascriptFunction( |
| 642 "options.AdvancedOptions.SetUseTLS1CheckboxState", checked, disabled); | 598 "options.AdvancedOptions.SetUseTLS1CheckboxState", checked, disabled); |
| 643 } | 599 } |
| 644 } | 600 } |
| OLD | NEW |