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/options2/advanced_options_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/advanced_options_handler2.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/options2/advanced_options_utils2.h" | 46 #include "chrome/browser/ui/webui/options2/advanced_options_utils2.h" |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } | 355 } |
356 | 356 |
357 void AdvancedOptionsHandler::HandleSelectDownloadLocation( | 357 void AdvancedOptionsHandler::HandleSelectDownloadLocation( |
358 const ListValue* args) { | 358 const ListValue* args) { |
359 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 359 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
360 select_folder_dialog_ = SelectFileDialog::Create(this); | 360 select_folder_dialog_ = SelectFileDialog::Create(this); |
361 select_folder_dialog_->SelectFile( | 361 select_folder_dialog_->SelectFile( |
362 SelectFileDialog::SELECT_FOLDER, | 362 SelectFileDialog::SELECT_FOLDER, |
363 l10n_util::GetStringUTF16(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE), | 363 l10n_util::GetStringUTF16(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE), |
364 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory), | 364 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory), |
365 NULL, 0, FILE_PATH_LITERAL(""), web_ui()->tab_contents(), | 365 NULL, 0, FILE_PATH_LITERAL(""), web_ui()->web_contents(), |
366 web_ui()->tab_contents()->GetView()->GetTopLevelNativeWindow(), NULL); | 366 web_ui()->web_contents()->GetView()->GetTopLevelNativeWindow(), NULL); |
367 } | 367 } |
368 | 368 |
369 void AdvancedOptionsHandler::FileSelected(const FilePath& path, int index, | 369 void AdvancedOptionsHandler::FileSelected(const FilePath& path, int index, |
370 void* params) { | 370 void* params) { |
371 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); | 371 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); |
372 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 372 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
373 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); | 373 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); |
374 } | 374 } |
375 | 375 |
376 void AdvancedOptionsHandler::OnCloudPrintSetupClosed() { | 376 void AdvancedOptionsHandler::OnCloudPrintSetupClosed() { |
377 #if !defined(OS_CHROMEOS) | 377 #if !defined(OS_CHROMEOS) |
378 if (cloud_print_connector_ui_enabled_) | 378 if (cloud_print_connector_ui_enabled_) |
379 SetupCloudPrintConnectorSection(); | 379 SetupCloudPrintConnectorSection(); |
380 #endif | 380 #endif |
381 } | 381 } |
382 | 382 |
383 void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) { | 383 void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) { |
384 content::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); | 384 content::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); |
385 DownloadManager* manager = | 385 DownloadManager* manager = |
386 web_ui()->tab_contents()->GetBrowserContext()->GetDownloadManager(); | 386 web_ui()->web_contents()->GetBrowserContext()->GetDownloadManager(); |
387 if (manager) | 387 if (manager) |
388 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); | 388 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); |
389 } | 389 } |
390 | 390 |
391 void AdvancedOptionsHandler::HandleMetricsReportingCheckbox( | 391 void AdvancedOptionsHandler::HandleMetricsReportingCheckbox( |
392 const ListValue* args) { | 392 const ListValue* args) { |
393 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) | 393 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) |
394 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); | 394 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); |
395 bool enabled = checked_str == "true"; | 395 bool enabled = checked_str == "true"; |
396 content::RecordAction( | 396 content::RecordAction( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 void AdvancedOptionsHandler::SetupBackgroundModeSettings() { | 446 void AdvancedOptionsHandler::SetupBackgroundModeSettings() { |
447 base::FundamentalValue checked(background_mode_enabled_.GetValue()); | 447 base::FundamentalValue checked(background_mode_enabled_.GetValue()); |
448 web_ui()->CallJavascriptFunction( | 448 web_ui()->CallJavascriptFunction( |
449 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked); | 449 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked); |
450 } | 450 } |
451 #endif | 451 #endif |
452 | 452 |
453 #if !defined(OS_CHROMEOS) | 453 #if !defined(OS_CHROMEOS) |
454 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { | 454 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { |
455 content::RecordAction(UserMetricsAction("Options_ShowProxySettings")); | 455 content::RecordAction(UserMetricsAction("Options_ShowProxySettings")); |
456 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui()->tab_contents()); | 456 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui()->web_contents()); |
457 } | 457 } |
458 #endif | 458 #endif |
459 | 459 |
460 #if !defined(USE_NSS) && !defined(USE_OPENSSL) | 460 #if !defined(USE_NSS) && !defined(USE_OPENSSL) |
461 void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) { | 461 void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) { |
462 content::RecordAction(UserMetricsAction("Options_ManageSSLCertificates")); | 462 content::RecordAction(UserMetricsAction("Options_ManageSSLCertificates")); |
463 AdvancedOptionsUtilities::ShowManageSSLCertificates(web_ui()->tab_contents()); | 463 AdvancedOptionsUtilities::ShowManageSSLCertificates(web_ui()->web_contents()); |
464 } | 464 } |
465 #endif | 465 #endif |
466 | 466 |
467 void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) { | 467 void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) { |
468 content::RecordAction(UserMetricsAction("Options_ManageCloudPrinters")); | 468 content::RecordAction(UserMetricsAction("Options_ManageCloudPrinters")); |
469 // Open a new tab in the current window for the management page. | 469 // Open a new tab in the current window for the management page. |
470 Profile* profile = Profile::FromWebUI(web_ui()); | 470 Profile* profile = Profile::FromWebUI(web_ui()); |
471 OpenURLParams params( | 471 OpenURLParams params( |
472 CloudPrintURL(profile).GetCloudPrintServiceManageURL(), Referrer(), | 472 CloudPrintURL(profile).GetCloudPrintServiceManageURL(), Referrer(), |
473 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); | 473 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); |
474 web_ui()->tab_contents()->OpenURL(params); | 474 web_ui()->web_contents()->OpenURL(params); |
475 } | 475 } |
476 | 476 |
477 #if !defined(OS_CHROMEOS) | 477 #if !defined(OS_CHROMEOS) |
478 void AdvancedOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) { | 478 void AdvancedOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) { |
479 content::RecordAction(UserMetricsAction("Options_EnableCloudPrintProxy")); | 479 content::RecordAction(UserMetricsAction("Options_EnableCloudPrintProxy")); |
480 // Open the connector enable page in the current tab. | 480 // Open the connector enable page in the current tab. |
481 Profile* profile = Profile::FromWebUI(web_ui()); | 481 Profile* profile = Profile::FromWebUI(web_ui()); |
482 OpenURLParams params( | 482 OpenURLParams params( |
483 CloudPrintURL(profile).GetCloudPrintServiceEnableURL( | 483 CloudPrintURL(profile).GetCloudPrintServiceEnableURL( |
484 CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()), | 484 CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()), |
485 Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); | 485 Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); |
486 web_ui()->tab_contents()->OpenURL(params); | 486 web_ui()->web_contents()->OpenURL(params); |
487 } | 487 } |
488 | 488 |
489 void AdvancedOptionsHandler::HandleDisableCloudPrintConnector( | 489 void AdvancedOptionsHandler::HandleDisableCloudPrintConnector( |
490 const ListValue* args) { | 490 const ListValue* args) { |
491 content::RecordAction( | 491 content::RecordAction( |
492 UserMetricsAction("Options_DisableCloudPrintProxy")); | 492 UserMetricsAction("Options_DisableCloudPrintProxy")); |
493 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> | 493 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> |
494 DisableForUser(); | 494 DisableForUser(); |
495 } | 495 } |
496 | 496 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 } | 606 } |
607 | 607 |
608 web_ui()->CallJavascriptFunction( | 608 web_ui()->CallJavascriptFunction( |
609 "options.AdvancedOptions.SetupPageZoomSelector", zoom_factors_value); | 609 "options.AdvancedOptions.SetupPageZoomSelector", zoom_factors_value); |
610 } | 610 } |
611 | 611 |
612 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { | 612 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { |
613 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. | 613 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. |
614 // We enable the button if the user has any auto-open file types registered. | 614 // We enable the button if the user has any auto-open file types registered. |
615 DownloadManager* manager = | 615 DownloadManager* manager = |
616 web_ui()->tab_contents()->GetBrowserContext()->GetDownloadManager(); | 616 web_ui()->web_contents()->GetBrowserContext()->GetDownloadManager(); |
617 bool disabled = !(manager && | 617 bool disabled = !(manager && |
618 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed()); | 618 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed()); |
619 base::FundamentalValue value(disabled); | 619 base::FundamentalValue value(disabled); |
620 web_ui()->CallJavascriptFunction( | 620 web_ui()->CallJavascriptFunction( |
621 "options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value); | 621 "options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value); |
622 } | 622 } |
623 | 623 |
624 void AdvancedOptionsHandler::SetupProxySettingsSection() { | 624 void AdvancedOptionsHandler::SetupProxySettingsSection() { |
625 #if !defined(OS_CHROMEOS) | 625 #if !defined(OS_CHROMEOS) |
626 // Disable the button if proxy settings are managed by a sysadmin or | 626 // Disable the button if proxy settings are managed by a sysadmin or |
(...skipping 26 matching lines...) Expand all Loading... |
653 { | 653 { |
654 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); | 654 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); |
655 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); | 655 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); |
656 web_ui()->CallJavascriptFunction( | 656 web_ui()->CallJavascriptFunction( |
657 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked, | 657 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked, |
658 disabled); | 658 disabled); |
659 } | 659 } |
660 } | 660 } |
661 | 661 |
662 } // namespace options2 | 662 } // namespace options2 |
OLD | NEW |