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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "base/value_conversions.h" | 23 #include "base/value_conversions.h" |
| 24 #include "base/values.h" | 24 #include "base/values.h" |
| 25 #include "chrome/browser/auto_launch_trial.h" | 25 #include "chrome/browser/auto_launch_trial.h" |
| 26 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
| 27 #include "chrome/browser/chrome_notification_types.h" | 27 #include "chrome/browser/chrome_notification_types.h" |
| 28 #include "chrome/browser/chrome_page_zoom.h" | 28 #include "chrome/browser/chrome_page_zoom.h" |
| 29 #include "chrome/browser/custom_home_pages_table_model.h" | 29 #include "chrome/browser/custom_home_pages_table_model.h" |
| 30 #include "chrome/browser/download/download_prefs.h" | 30 #include "chrome/browser/download/download_prefs.h" |
| 31 #include "chrome/browser/gpu/gpu_mode_manager.h" | 31 #include "chrome/browser/gpu/gpu_mode_manager.h" |
| 32 #include "chrome/browser/lifetime/application_lifetime.h" | 32 #include "chrome/browser/lifetime/application_lifetime.h" |
| 33 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | |
| 34 #include "chrome/browser/metrics/metrics_reporting_state.h" | |
| 33 #include "chrome/browser/net/prediction_options.h" | 35 #include "chrome/browser/net/prediction_options.h" |
| 34 #include "chrome/browser/prefs/session_startup_pref.h" | 36 #include "chrome/browser/prefs/session_startup_pref.h" |
| 35 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 37 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 36 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" | 38 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" |
| 37 #include "chrome/browser/profiles/profile.h" | 39 #include "chrome/browser/profiles/profile.h" |
| 38 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 40 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 39 #include "chrome/browser/profiles/profile_info_cache.h" | 41 #include "chrome/browser/profiles/profile_info_cache.h" |
| 40 #include "chrome/browser/profiles/profile_manager.h" | 42 #include "chrome/browser/profiles/profile_manager.h" |
| 41 #include "chrome/browser/profiles/profile_metrics.h" | 43 #include "chrome/browser/profiles/profile_metrics.h" |
| 42 #include "chrome/browser/profiles/profile_shortcut_manager.h" | 44 #include "chrome/browser/profiles/profile_shortcut_manager.h" |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 values->SetString("username", username); | 538 values->SetString("username", username); |
| 537 #endif | 539 #endif |
| 538 | 540 |
| 539 // Pass along sync status early so it will be available during page init. | 541 // Pass along sync status early so it will be available during page init. |
| 540 values->Set("syncData", GetSyncStateDictionary().release()); | 542 values->Set("syncData", GetSyncStateDictionary().release()); |
| 541 | 543 |
| 542 values->SetString("privacyLearnMoreURL", chrome::kPrivacyLearnMoreURL); | 544 values->SetString("privacyLearnMoreURL", chrome::kPrivacyLearnMoreURL); |
| 543 values->SetString("doNotTrackLearnMoreURL", chrome::kDoNotTrackLearnMoreURL); | 545 values->SetString("doNotTrackLearnMoreURL", chrome::kDoNotTrackLearnMoreURL); |
| 544 | 546 |
| 545 #if !defined(OS_CHROMEOS) | 547 #if !defined(OS_CHROMEOS) |
| 546 PrefService* pref_service = g_browser_process->local_state(); | 548 values->SetBoolean("metricsReportingEnabledAtStart", |
| 547 values->SetBoolean("metricsReportingEnabledAtStart", pref_service->GetBoolean( | 549 ChromeMetricsServiceAccessor::IsMetricsReportingEnabled()); |
| 548 prefs::kMetricsReportingEnabled)); | |
| 549 #endif | 550 #endif |
| 550 | 551 |
| 551 #if defined(OS_CHROMEOS) | 552 #if defined(OS_CHROMEOS) |
| 552 // TODO(pastarmovj): replace this with a call to the CrosSettings list | 553 // TODO(pastarmovj): replace this with a call to the CrosSettings list |
| 553 // handling functionality to come. | 554 // handling functionality to come. |
| 554 values->Set("timezoneList", chromeos::system::GetTimezoneList().release()); | 555 values->Set("timezoneList", chromeos::system::GetTimezoneList().release()); |
| 555 | 556 |
| 556 values->SetString("accessibilityLearnMoreURL", | 557 values->SetString("accessibilityLearnMoreURL", |
| 557 chrome::kChromeAccessibilityHelpURL); | 558 chrome::kChromeAccessibilityHelpURL); |
| 558 | 559 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 "launchEasyUnlockSetup", | 750 "launchEasyUnlockSetup", |
| 750 base::Bind(&BrowserOptionsHandler::HandleLaunchEasyUnlockSetup, | 751 base::Bind(&BrowserOptionsHandler::HandleLaunchEasyUnlockSetup, |
| 751 base::Unretained(this))); | 752 base::Unretained(this))); |
| 752 #if defined(OS_WIN) | 753 #if defined(OS_WIN) |
| 753 web_ui()->RegisterMessageCallback( | 754 web_ui()->RegisterMessageCallback( |
| 754 "refreshExtensionControlIndicators", | 755 "refreshExtensionControlIndicators", |
| 755 base::Bind( | 756 base::Bind( |
| 756 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators, | 757 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators, |
| 757 base::Unretained(this))); | 758 base::Unretained(this))); |
| 758 #endif // defined(OS_WIN) | 759 #endif // defined(OS_WIN) |
| 760 web_ui()->RegisterMessageCallback("metricsReportingCheckboxChanged", | |
| 761 base::Bind(&BrowserOptionsHandler::HandleMetricsReportingChange, | |
| 762 base::Unretained(this))); | |
| 759 } | 763 } |
| 760 | 764 |
| 761 void BrowserOptionsHandler::Uninitialize() { | 765 void BrowserOptionsHandler::Uninitialize() { |
| 762 registrar_.RemoveAll(); | 766 registrar_.RemoveAll(); |
| 763 #if defined(OS_WIN) | 767 #if defined(OS_WIN) |
| 764 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this); | 768 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this); |
| 765 #endif | 769 #endif |
| 766 #if defined(OS_CHROMEOS) | 770 #if defined(OS_CHROMEOS) |
| 767 policy::ConsumerManagementService* consumer_management = | 771 policy::ConsumerManagementService* consumer_management = |
| 768 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> | 772 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 917 void BrowserOptionsHandler::InitializePage() { | 921 void BrowserOptionsHandler::InitializePage() { |
| 918 page_initialized_ = true; | 922 page_initialized_ = true; |
| 919 | 923 |
| 920 OnTemplateURLServiceChanged(); | 924 OnTemplateURLServiceChanged(); |
| 921 | 925 |
| 922 ObserveThemeChanged(); | 926 ObserveThemeChanged(); |
| 923 OnStateChanged(); | 927 OnStateChanged(); |
| 924 UpdateDefaultBrowserState(); | 928 UpdateDefaultBrowserState(); |
| 925 | 929 |
| 926 SetupMetricsReportingSettingVisibility(); | 930 SetupMetricsReportingSettingVisibility(); |
| 931 SetupMetricsReportingCheckbox(); | |
| 927 SetupNetworkPredictionControl(); | 932 SetupNetworkPredictionControl(); |
| 928 SetupFontSizeSelector(); | 933 SetupFontSizeSelector(); |
| 929 SetupPageZoomSelector(); | 934 SetupPageZoomSelector(); |
| 930 SetupAutoOpenFileTypes(); | 935 SetupAutoOpenFileTypes(); |
| 931 SetupProxySettingsSection(); | 936 SetupProxySettingsSection(); |
| 932 SetupManageCertificatesSection(); | 937 SetupManageCertificatesSection(); |
| 933 SetupManagingSupervisedUsers(); | 938 SetupManagingSupervisedUsers(); |
| 934 SetupEasyUnlock(); | 939 SetupEasyUnlock(); |
| 935 SetupExtensionControlledIndicators(); | 940 SetupExtensionControlledIndicators(); |
| 936 | 941 |
| (...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1880 // Check if an extension is overwriting the proxy setting. | 1885 // Check if an extension is overwriting the proxy setting. |
| 1881 extension = extensions::GetExtensionOverridingProxy( | 1886 extension = extensions::GetExtensionOverridingProxy( |
| 1882 Profile::FromWebUI(web_ui())); | 1887 Profile::FromWebUI(web_ui())); |
| 1883 AppendExtensionData("proxy", extension, &extension_controlled); | 1888 AppendExtensionData("proxy", extension, &extension_controlled); |
| 1884 | 1889 |
| 1885 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", | 1890 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", |
| 1886 extension_controlled); | 1891 extension_controlled); |
| 1887 #endif // defined(OS_WIN) | 1892 #endif // defined(OS_WIN) |
| 1888 } | 1893 } |
| 1889 | 1894 |
| 1895 void BrowserOptionsHandler::SetupMetricsReportingCheckbox() { | |
| 1896 // This function does not work for ChromeOS, Android and non-official builds. | |
| 1897 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && defined(GOOGLE_CHROME_BUILD ) | |
|
Alexei Svitkine (slow)
2014/09/16 17:32:36
The !defined(OS_ANDROID) check isn't needed here,
| |
| 1898 bool checked = ChromeMetricsServiceAccessor::IsMetricsReportingEnabled(); | |
| 1899 bool disabled = !IsMetricsReportingUserChangable(); | |
| 1900 | |
| 1901 SetMetricsReportingCheckbox(checked, disabled); | |
| 1902 #endif | |
| 1903 } | |
| 1904 | |
| 1905 void BrowserOptionsHandler::HandleMetricsReportingChange( | |
| 1906 const base::ListValue* args) { | |
| 1907 bool enable; | |
| 1908 if (!args->GetBoolean(0, &enable)) | |
| 1909 return; | |
| 1910 | |
| 1911 InitiateMetricsReportingChange( | |
| 1912 enable, | |
| 1913 base::Bind(&BrowserOptionsHandler::MetricsReportingChangeCallback, | |
| 1914 base::Unretained(this))); | |
| 1915 } | |
| 1916 | |
| 1917 void BrowserOptionsHandler::MetricsReportingChangeCallback(bool enabled) { | |
| 1918 SetMetricsReportingCheckbox(enabled, !IsMetricsReportingUserChangable()); | |
| 1919 } | |
| 1920 | |
| 1921 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, | |
| 1922 bool disabled) { | |
| 1923 web_ui()->CallJavascriptFunction( | |
| 1924 "BrowserOptions.setMetricsReportingCheckboxState", | |
| 1925 base::FundamentalValue(checked), | |
| 1926 base::FundamentalValue(disabled)); | |
| 1927 } | |
| 1928 | |
| 1890 } // namespace options | 1929 } // namespace options |
| OLD | NEW |