| 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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #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" |
| 22 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 22 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
| 23 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 23 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/service/service_process_control.h" | 25 #include "chrome/browser/service/service_process_control.h" |
| 26 #include "chrome/browser/ui/options/options_util.h" | 26 #include "chrome/browser/ui/options/options_util.h" |
| 27 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 31 #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/public/browser/download_manager.h" | 32 #include "content/public/browser/download_manager.h" |
| 34 #include "content/public/browser/notification_details.h" | 33 #include "content/public/browser/notification_details.h" |
| 35 #include "content/public/browser/notification_types.h" | 34 #include "content/public/browser/notification_types.h" |
| 36 #include "content/public/browser/user_metrics.h" | 35 #include "content/public/browser/user_metrics.h" |
| 36 #include "content/public/browser/web_contents.h" |
| 37 #include "content/public/common/page_zoom.h" | 37 #include "content/public/common/page_zoom.h" |
| 38 #include "grit/chromium_strings.h" | 38 #include "grit/chromium_strings.h" |
| 39 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
| 40 #include "grit/locale_settings.h" | 40 #include "grit/locale_settings.h" |
| 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 43 | 43 |
| 44 #if !defined(OS_CHROMEOS) | 44 #if !defined(OS_CHROMEOS) |
| 45 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" | 45 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" |
| 46 #include "chrome/browser/ui/webui/options/advanced_options_utils.h" | 46 #include "chrome/browser/ui/webui/options/advanced_options_utils.h" |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 } | 353 } |
| 354 | 354 |
| 355 void AdvancedOptionsHandler::HandleSelectDownloadLocation( | 355 void AdvancedOptionsHandler::HandleSelectDownloadLocation( |
| 356 const ListValue* args) { | 356 const ListValue* args) { |
| 357 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 357 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 358 select_folder_dialog_ = SelectFileDialog::Create(this); | 358 select_folder_dialog_ = SelectFileDialog::Create(this); |
| 359 select_folder_dialog_->SelectFile( | 359 select_folder_dialog_->SelectFile( |
| 360 SelectFileDialog::SELECT_FOLDER, | 360 SelectFileDialog::SELECT_FOLDER, |
| 361 l10n_util::GetStringUTF16(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE), | 361 l10n_util::GetStringUTF16(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE), |
| 362 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory), | 362 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory), |
| 363 NULL, 0, FILE_PATH_LITERAL(""), web_ui()->tab_contents(), | 363 NULL, 0, FILE_PATH_LITERAL(""), web_ui()->web_contents(), |
| 364 web_ui()->tab_contents()->GetView()->GetTopLevelNativeWindow(), NULL); | 364 web_ui()->web_contents()->GetView()->GetTopLevelNativeWindow(), NULL); |
| 365 } | 365 } |
| 366 | 366 |
| 367 void AdvancedOptionsHandler::FileSelected(const FilePath& path, int index, | 367 void AdvancedOptionsHandler::FileSelected(const FilePath& path, int index, |
| 368 void* params) { | 368 void* params) { |
| 369 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); | 369 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); |
| 370 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 370 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 371 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); | 371 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); |
| 372 } | 372 } |
| 373 | 373 |
| 374 void AdvancedOptionsHandler::OnCloudPrintSetupClosed() { | 374 void AdvancedOptionsHandler::OnCloudPrintSetupClosed() { |
| 375 #if !defined(OS_CHROMEOS) | 375 #if !defined(OS_CHROMEOS) |
| 376 if (cloud_print_connector_ui_enabled_) | 376 if (cloud_print_connector_ui_enabled_) |
| 377 SetupCloudPrintConnectorSection(); | 377 SetupCloudPrintConnectorSection(); |
| 378 #endif | 378 #endif |
| 379 } | 379 } |
| 380 | 380 |
| 381 void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) { | 381 void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) { |
| 382 content::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); | 382 content::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); |
| 383 DownloadManager* manager = | 383 DownloadManager* manager = |
| 384 web_ui()->tab_contents()->GetBrowserContext()->GetDownloadManager(); | 384 web_ui()->web_contents()->GetBrowserContext()->GetDownloadManager(); |
| 385 if (manager) | 385 if (manager) |
| 386 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); | 386 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); |
| 387 } | 387 } |
| 388 | 388 |
| 389 void AdvancedOptionsHandler::HandleMetricsReportingCheckbox( | 389 void AdvancedOptionsHandler::HandleMetricsReportingCheckbox( |
| 390 const ListValue* args) { | 390 const ListValue* args) { |
| 391 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) | 391 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) |
| 392 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); | 392 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); |
| 393 bool enabled = checked_str == "true"; | 393 bool enabled = checked_str == "true"; |
| 394 content::RecordAction( | 394 content::RecordAction( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 void AdvancedOptionsHandler::SetupBackgroundModeSettings() { | 444 void AdvancedOptionsHandler::SetupBackgroundModeSettings() { |
| 445 base::FundamentalValue checked(background_mode_enabled_.GetValue()); | 445 base::FundamentalValue checked(background_mode_enabled_.GetValue()); |
| 446 web_ui()->CallJavascriptFunction( | 446 web_ui()->CallJavascriptFunction( |
| 447 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked); | 447 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked); |
| 448 } | 448 } |
| 449 #endif | 449 #endif |
| 450 | 450 |
| 451 #if !defined(OS_CHROMEOS) | 451 #if !defined(OS_CHROMEOS) |
| 452 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { | 452 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { |
| 453 content::RecordAction(UserMetricsAction("Options_ShowProxySettings")); | 453 content::RecordAction(UserMetricsAction("Options_ShowProxySettings")); |
| 454 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui()->tab_contents()); | 454 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui()->web_contents()); |
| 455 } | 455 } |
| 456 #endif | 456 #endif |
| 457 | 457 |
| 458 #if !defined(USE_NSS) && !defined(USE_OPENSSL) | 458 #if !defined(USE_NSS) && !defined(USE_OPENSSL) |
| 459 void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) { | 459 void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) { |
| 460 content::RecordAction(UserMetricsAction("Options_ManageSSLCertificates")); | 460 content::RecordAction(UserMetricsAction("Options_ManageSSLCertificates")); |
| 461 AdvancedOptionsUtilities::ShowManageSSLCertificates(web_ui()->tab_contents()); | 461 AdvancedOptionsUtilities::ShowManageSSLCertificates(web_ui()->web_contents()); |
| 462 } | 462 } |
| 463 #endif | 463 #endif |
| 464 | 464 |
| 465 void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) { | 465 void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) { |
| 466 content::RecordAction(UserMetricsAction("Options_ManageCloudPrinters")); | 466 content::RecordAction(UserMetricsAction("Options_ManageCloudPrinters")); |
| 467 // Open a new tab in the current window for the management page. | 467 // Open a new tab in the current window for the management page. |
| 468 Profile* profile = Profile::FromWebUI(web_ui()); | 468 Profile* profile = Profile::FromWebUI(web_ui()); |
| 469 OpenURLParams params( | 469 OpenURLParams params( |
| 470 CloudPrintURL(profile).GetCloudPrintServiceManageURL(), Referrer(), | 470 CloudPrintURL(profile).GetCloudPrintServiceManageURL(), Referrer(), |
| 471 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); | 471 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); |
| 472 web_ui()->tab_contents()->OpenURL(params); | 472 web_ui()->web_contents()->OpenURL(params); |
| 473 } | 473 } |
| 474 | 474 |
| 475 #if !defined(OS_CHROMEOS) | 475 #if !defined(OS_CHROMEOS) |
| 476 void AdvancedOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) { | 476 void AdvancedOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) { |
| 477 content::RecordAction(UserMetricsAction("Options_EnableCloudPrintProxy")); | 477 content::RecordAction(UserMetricsAction("Options_EnableCloudPrintProxy")); |
| 478 // Open the connector enable page in the current tab. | 478 // Open the connector enable page in the current tab. |
| 479 Profile* profile = Profile::FromWebUI(web_ui()); | 479 Profile* profile = Profile::FromWebUI(web_ui()); |
| 480 OpenURLParams params( | 480 OpenURLParams params( |
| 481 CloudPrintURL(profile).GetCloudPrintServiceEnableURL( | 481 CloudPrintURL(profile).GetCloudPrintServiceEnableURL( |
| 482 CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()), | 482 CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()), |
| 483 Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); | 483 Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); |
| 484 web_ui()->tab_contents()->OpenURL(params); | 484 web_ui()->web_contents()->OpenURL(params); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void AdvancedOptionsHandler::HandleDisableCloudPrintConnector( | 487 void AdvancedOptionsHandler::HandleDisableCloudPrintConnector( |
| 488 const ListValue* args) { | 488 const ListValue* args) { |
| 489 content::RecordAction( | 489 content::RecordAction( |
| 490 UserMetricsAction("Options_DisableCloudPrintProxy")); | 490 UserMetricsAction("Options_DisableCloudPrintProxy")); |
| 491 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> | 491 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> |
| 492 DisableForUser(); | 492 DisableForUser(); |
| 493 } | 493 } |
| 494 | 494 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 } | 604 } |
| 605 | 605 |
| 606 web_ui()->CallJavascriptFunction( | 606 web_ui()->CallJavascriptFunction( |
| 607 "options.AdvancedOptions.SetupPageZoomSelector", zoom_factors_value); | 607 "options.AdvancedOptions.SetupPageZoomSelector", zoom_factors_value); |
| 608 } | 608 } |
| 609 | 609 |
| 610 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { | 610 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { |
| 611 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. | 611 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. |
| 612 // We enable the button if the user has any auto-open file types registered. | 612 // We enable the button if the user has any auto-open file types registered. |
| 613 DownloadManager* manager = | 613 DownloadManager* manager = |
| 614 web_ui()->tab_contents()->GetBrowserContext()->GetDownloadManager(); | 614 web_ui()->web_contents()->GetBrowserContext()->GetDownloadManager(); |
| 615 bool disabled = !(manager && | 615 bool disabled = !(manager && |
| 616 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed()); | 616 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed()); |
| 617 base::FundamentalValue value(disabled); | 617 base::FundamentalValue value(disabled); |
| 618 web_ui()->CallJavascriptFunction( | 618 web_ui()->CallJavascriptFunction( |
| 619 "options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value); | 619 "options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value); |
| 620 } | 620 } |
| 621 | 621 |
| 622 void AdvancedOptionsHandler::SetupProxySettingsSection() { | 622 void AdvancedOptionsHandler::SetupProxySettingsSection() { |
| 623 #if !defined(OS_CHROMEOS) | 623 #if !defined(OS_CHROMEOS) |
| 624 // Disable the button if proxy settings are managed by a sysadmin or | 624 // Disable the button if proxy settings are managed by a sysadmin or |
| (...skipping 24 matching lines...) Expand all Loading... |
| 649 | 649 |
| 650 void AdvancedOptionsHandler::SetupSSLConfigSettings() { | 650 void AdvancedOptionsHandler::SetupSSLConfigSettings() { |
| 651 { | 651 { |
| 652 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); | 652 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); |
| 653 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); | 653 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); |
| 654 web_ui()->CallJavascriptFunction( | 654 web_ui()->CallJavascriptFunction( |
| 655 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked, | 655 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked, |
| 656 disabled); | 656 disabled); |
| 657 } | 657 } |
| 658 } | 658 } |
| OLD | NEW |