Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 421653006: Update "Predict network actions" UI setting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "apps/app_window.h" 10 #include "apps/app_window.h"
(...skipping 14 matching lines...) Expand all
25 #include "base/values.h" 25 #include "base/values.h"
26 #include "chrome/browser/auto_launch_trial.h" 26 #include "chrome/browser/auto_launch_trial.h"
27 #include "chrome/browser/browser_process.h" 27 #include "chrome/browser/browser_process.h"
28 #include "chrome/browser/chrome_notification_types.h" 28 #include "chrome/browser/chrome_notification_types.h"
29 #include "chrome/browser/chrome_page_zoom.h" 29 #include "chrome/browser/chrome_page_zoom.h"
30 #include "chrome/browser/custom_home_pages_table_model.h" 30 #include "chrome/browser/custom_home_pages_table_model.h"
31 #include "chrome/browser/download/download_prefs.h" 31 #include "chrome/browser/download/download_prefs.h"
32 #include "chrome/browser/gpu/gpu_mode_manager.h" 32 #include "chrome/browser/gpu/gpu_mode_manager.h"
33 #include "chrome/browser/lifetime/application_lifetime.h" 33 #include "chrome/browser/lifetime/application_lifetime.h"
34 #include "chrome/browser/metrics/metrics_reporting_state.h" 34 #include "chrome/browser/metrics/metrics_reporting_state.h"
35 #include "chrome/browser/net/prediction_options.h"
35 #include "chrome/browser/prefs/session_startup_pref.h" 36 #include "chrome/browser/prefs/session_startup_pref.h"
36 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" 37 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
37 #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"
38 #include "chrome/browser/profile_resetter/automatic_profile_resetter.h" 39 #include "chrome/browser/profile_resetter/automatic_profile_resetter.h"
39 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h" 40 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
40 #include "chrome/browser/profiles/profile.h" 41 #include "chrome/browser/profiles/profile.h"
41 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 42 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
42 #include "chrome/browser/profiles/profile_info_cache.h" 43 #include "chrome/browser/profiles/profile_info_cache.h"
43 #include "chrome/browser/profiles/profile_manager.h" 44 #include "chrome/browser/profiles/profile_manager.h"
44 #include "chrome/browser/profiles/profile_metrics.h" 45 #include "chrome/browser/profiles/profile_metrics.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 #include "content/public/browser/user_metrics.h" 84 #include "content/public/browser/user_metrics.h"
84 #include "content/public/browser/web_contents.h" 85 #include "content/public/browser/web_contents.h"
85 #include "content/public/common/page_zoom.h" 86 #include "content/public/common/page_zoom.h"
86 #include "extensions/browser/extension_registry.h" 87 #include "extensions/browser/extension_registry.h"
87 #include "google_apis/gaia/gaia_auth_util.h" 88 #include "google_apis/gaia/gaia_auth_util.h"
88 #include "google_apis/gaia/google_service_auth_error.h" 89 #include "google_apis/gaia/google_service_auth_error.h"
89 #include "grit/chromium_strings.h" 90 #include "grit/chromium_strings.h"
90 #include "grit/generated_resources.h" 91 #include "grit/generated_resources.h"
91 #include "grit/locale_settings.h" 92 #include "grit/locale_settings.h"
92 #include "grit/theme_resources.h" 93 #include "grit/theme_resources.h"
94 #include "net/base/network_change_notifier.h"
93 #include "third_party/skia/include/core/SkBitmap.h" 95 #include "third_party/skia/include/core/SkBitmap.h"
94 #include "ui/base/l10n/l10n_util.h" 96 #include "ui/base/l10n/l10n_util.h"
95 #include "ui/base/webui/web_ui_util.h" 97 #include "ui/base/webui/web_ui_util.h"
96 98
97 #if !defined(OS_CHROMEOS) 99 #if !defined(OS_CHROMEOS)
98 #include "chrome/browser/ui/webui/options/advanced_options_utils.h" 100 #include "chrome/browser/ui/webui/options/advanced_options_utils.h"
99 #endif 101 #endif
100 102
101 #if defined(OS_CHROMEOS) 103 #if defined(OS_CHROMEOS)
102 #include "ash/ash_switches.h" 104 #include "ash/ash_switches.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 { "improveBrowsingExperience", IDS_OPTIONS_IMPROVE_BROWSING_EXPERIENCE }, 276 { "improveBrowsingExperience", IDS_OPTIONS_IMPROVE_BROWSING_EXPERIENCE },
275 { "languageAndSpellCheckSettingsButton", 277 { "languageAndSpellCheckSettingsButton",
276 IDS_OPTIONS_SETTINGS_LANGUAGE_AND_INPUT_SETTINGS }, 278 IDS_OPTIONS_SETTINGS_LANGUAGE_AND_INPUT_SETTINGS },
277 { "linkDoctorPref", IDS_OPTIONS_LINKDOCTOR_PREF }, 279 { "linkDoctorPref", IDS_OPTIONS_LINKDOCTOR_PREF },
278 { "manageAutofillSettings", IDS_OPTIONS_MANAGE_AUTOFILL_SETTINGS_LINK }, 280 { "manageAutofillSettings", IDS_OPTIONS_MANAGE_AUTOFILL_SETTINGS_LINK },
279 { "manageLanguages", IDS_OPTIONS_TRANSLATE_MANAGE_LANGUAGES }, 281 { "manageLanguages", IDS_OPTIONS_TRANSLATE_MANAGE_LANGUAGES },
280 { "managePasswords", IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK }, 282 { "managePasswords", IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK },
281 { "managedUserLabel", IDS_SUPERVISED_USER_AVATAR_LABEL }, 283 { "managedUserLabel", IDS_SUPERVISED_USER_AVATAR_LABEL },
282 { "networkPredictionEnabledDescription", 284 { "networkPredictionEnabledDescription",
283 IDS_NETWORK_PREDICTION_ENABLED_DESCRIPTION }, 285 IDS_NETWORK_PREDICTION_ENABLED_DESCRIPTION },
286 { "networkPredictionOptionsAlways", IDS_NETWORK_PREDICTION_OPTIONS_ALWAYS },
287 { "networkPredictionOptionsCheckboxDescription",
288 IDS_NETWORK_PREDICTION_OPTIONS_CHECKBOX_DESCRIPTION },
289 { "networkPredictionOptionsDropdownDescription",
290 IDS_NETWORK_PREDICTION_OPTIONS_DROPDOWN_DESCRIPTION },
291 { "networkPredictionOptionsNever", IDS_NETWORK_PREDICTION_OPTIONS_NEVER },
292 { "networkPredictionOptionsWifiOnly",
293 IDS_NETWORK_PREDICTION_OPTIONS_WIFI_ONLY },
284 { "passwordsAndAutofillGroupName", 294 { "passwordsAndAutofillGroupName",
285 IDS_OPTIONS_PASSWORDS_AND_FORMS_GROUP_NAME }, 295 IDS_OPTIONS_PASSWORDS_AND_FORMS_GROUP_NAME },
286 { "passwordManagerEnabled", IDS_OPTIONS_PASSWORD_MANAGER_ENABLE }, 296 { "passwordManagerEnabled", IDS_OPTIONS_PASSWORD_MANAGER_ENABLE },
287 { "privacyClearDataButton", IDS_OPTIONS_PRIVACY_CLEAR_DATA_BUTTON }, 297 { "privacyClearDataButton", IDS_OPTIONS_PRIVACY_CLEAR_DATA_BUTTON },
288 { "privacyContentSettingsButton", 298 { "privacyContentSettingsButton",
289 IDS_OPTIONS_PRIVACY_CONTENT_SETTINGS_BUTTON }, 299 IDS_OPTIONS_PRIVACY_CONTENT_SETTINGS_BUTTON },
290 { "profilesCreate", IDS_PROFILES_CREATE_BUTTON_LABEL }, 300 { "profilesCreate", IDS_PROFILES_CREATE_BUTTON_LABEL },
291 { "profilesDelete", IDS_PROFILES_DELETE_BUTTON_LABEL }, 301 { "profilesDelete", IDS_PROFILES_DELETE_BUTTON_LABEL },
292 { "profilesDeleteSingle", IDS_PROFILES_DELETE_SINGLE_BUTTON_LABEL }, 302 { "profilesDeleteSingle", IDS_PROFILES_DELETE_SINGLE_BUTTON_LABEL },
293 { "profilesListItemCurrent", IDS_PROFILES_LIST_ITEM_CURRENT }, 303 { "profilesListItemCurrent", IDS_PROFILES_LIST_ITEM_CURRENT },
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 auto_open_files_.Init( 834 auto_open_files_.Init(
825 prefs::kDownloadExtensionsToOpen, prefs, 835 prefs::kDownloadExtensionsToOpen, prefs,
826 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, 836 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes,
827 base::Unretained(this))); 837 base::Unretained(this)));
828 default_zoom_level_.Init( 838 default_zoom_level_.Init(
829 prefs::kDefaultZoomLevel, prefs, 839 prefs::kDefaultZoomLevel, prefs,
830 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, 840 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector,
831 base::Unretained(this))); 841 base::Unretained(this)));
832 profile_pref_registrar_.Init(prefs); 842 profile_pref_registrar_.Init(prefs);
833 profile_pref_registrar_.Add( 843 profile_pref_registrar_.Add(
844 prefs::kNetworkPredictionOptions,
845 base::Bind(&BrowserOptionsHandler::SetupNetworkPredictionControls,
846 base::Unretained(this)));
847 profile_pref_registrar_.Add(
834 prefs::kWebKitDefaultFontSize, 848 prefs::kWebKitDefaultFontSize,
835 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, 849 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector,
836 base::Unretained(this))); 850 base::Unretained(this)));
837 profile_pref_registrar_.Add( 851 profile_pref_registrar_.Add(
838 prefs::kWebKitDefaultFixedFontSize, 852 prefs::kWebKitDefaultFixedFontSize,
839 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, 853 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector,
840 base::Unretained(this))); 854 base::Unretained(this)));
841 profile_pref_registrar_.Add( 855 profile_pref_registrar_.Add(
842 prefs::kSupervisedUsers, 856 prefs::kSupervisedUsers,
843 base::Bind(&BrowserOptionsHandler::SetupManagingSupervisedUsers, 857 base::Bind(&BrowserOptionsHandler::SetupManagingSupervisedUsers,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 901
888 void BrowserOptionsHandler::InitializePage() { 902 void BrowserOptionsHandler::InitializePage() {
889 page_initialized_ = true; 903 page_initialized_ = true;
890 904
891 OnTemplateURLServiceChanged(); 905 OnTemplateURLServiceChanged();
892 906
893 ObserveThemeChanged(); 907 ObserveThemeChanged();
894 OnStateChanged(); 908 OnStateChanged();
895 UpdateDefaultBrowserState(); 909 UpdateDefaultBrowserState();
896 910
911 MigrateNetworkPredictionOptions();
912
897 SetupMetricsReportingSettingVisibility(); 913 SetupMetricsReportingSettingVisibility();
914 SetupNetworkPredictionControlsVisibility();
915 SetupNetworkPredictionControls();
898 SetupFontSizeSelector(); 916 SetupFontSizeSelector();
899 SetupPageZoomSelector(); 917 SetupPageZoomSelector();
900 SetupAutoOpenFileTypes(); 918 SetupAutoOpenFileTypes();
901 SetupProxySettingsSection(); 919 SetupProxySettingsSection();
902 SetupManageCertificatesSection(); 920 SetupManageCertificatesSection();
903 SetupManagingSupervisedUsers(); 921 SetupManagingSupervisedUsers();
904 SetupEasyUnlock(); 922 SetupEasyUnlock();
905 SetupExtensionControlledIndicators(); 923 SetupExtensionControlledIndicators();
906 924
907 #if defined(OS_CHROMEOS) 925 #if defined(OS_CHROMEOS)
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 void BrowserOptionsHandler::SetupAccessibilityFeatures() { 1632 void BrowserOptionsHandler::SetupAccessibilityFeatures() {
1615 PrefService* pref_service = g_browser_process->local_state(); 1633 PrefService* pref_service = g_browser_process->local_state();
1616 base::FundamentalValue virtual_keyboard_enabled( 1634 base::FundamentalValue virtual_keyboard_enabled(
1617 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled)); 1635 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled));
1618 web_ui()->CallJavascriptFunction( 1636 web_ui()->CallJavascriptFunction(
1619 "BrowserOptions.setVirtualKeyboardCheckboxState", 1637 "BrowserOptions.setVirtualKeyboardCheckboxState",
1620 virtual_keyboard_enabled); 1638 virtual_keyboard_enabled);
1621 } 1639 }
1622 #endif 1640 #endif
1623 1641
1642 void BrowserOptionsHandler::MigrateNetworkPredictionOptions() {
1643 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
1644 if (pref_service->GetInteger(prefs::kNetworkPredictionOptions) ==
1645 chrome_browser_net::NETWORK_PREDICTION_UNSET) {
1646 pref_service->SetInteger(
1647 prefs::kNetworkPredictionOptions,
1648 pref_service->GetBoolean(prefs::kNetworkPredictionEnabled)
1649 ? chrome_browser_net::NETWORK_PREDICTION_WIFI_ONLY
1650 : chrome_browser_net::NETWORK_PREDICTION_NEVER);
1651 }
1652 }
1653
1624 void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() { 1654 void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() {
1625 #if defined(GOOGLE_CHROME_BUILD) 1655 #if defined(GOOGLE_CHROME_BUILD)
1626 // Don't show the reporting setting if we are in the guest mode. 1656 // Don't show the reporting setting if we are in the guest mode.
1627 if (Profile::FromWebUI(web_ui())->IsGuestSession()) { 1657 if (Profile::FromWebUI(web_ui())->IsGuestSession()) {
1628 base::FundamentalValue visible(false); 1658 base::FundamentalValue visible(false);
1629 web_ui()->CallJavascriptFunction( 1659 web_ui()->CallJavascriptFunction(
1630 "BrowserOptions.setMetricsReportingSettingVisibility", visible); 1660 "BrowserOptions.setMetricsReportingSettingVisibility", visible);
1631 } 1661 }
1632 #endif 1662 #endif
1633 } 1663 }
1634 1664
1665 void BrowserOptionsHandler::SetupNetworkPredictionControlsVisibility() {
1666 base::DictionaryValue dict;
1667 dict.SetBoolean("onCellularNetwork",
1668 net::NetworkChangeNotifier::IsConnectionCellular(
1669 net::NetworkChangeNotifier::GetConnectionType()));
1670 web_ui()->CallJavascriptFunction(
1671 "BrowserOptions.setNetworkPredictionVisibility", dict);
1672 }
1673
1674 void BrowserOptionsHandler::SetupNetworkPredictionControls() {
1675 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
1676 const PrefService::Preference* network_prediction_options =
1677 pref_service->FindPreference(prefs::kNetworkPredictionOptions);
1678
1679 base::DictionaryValue dict;
1680 dict.SetInteger("value",
1681 pref_service->GetInteger(prefs::kNetworkPredictionOptions));
1682
1683 dict.SetBoolean("disabled", !network_prediction_options->IsUserModifiable());
1684
1685 web_ui()->CallJavascriptFunction("BrowserOptions.setNetworkPredictionValue",
1686 dict);
1687 }
1688
1635 void BrowserOptionsHandler::SetupFontSizeSelector() { 1689 void BrowserOptionsHandler::SetupFontSizeSelector() {
1636 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); 1690 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
1637 const PrefService::Preference* default_font_size = 1691 const PrefService::Preference* default_font_size =
1638 pref_service->FindPreference(prefs::kWebKitDefaultFontSize); 1692 pref_service->FindPreference(prefs::kWebKitDefaultFontSize);
1639 const PrefService::Preference* default_fixed_font_size = 1693 const PrefService::Preference* default_fixed_font_size =
1640 pref_service->FindPreference(prefs::kWebKitDefaultFixedFontSize); 1694 pref_service->FindPreference(prefs::kWebKitDefaultFixedFontSize);
1641 1695
1642 base::DictionaryValue dict; 1696 base::DictionaryValue dict;
1643 dict.SetInteger("value", 1697 dict.SetInteger("value",
1644 pref_service->GetInteger(prefs::kWebKitDefaultFontSize)); 1698 pref_service->GetInteger(prefs::kWebKitDefaultFontSize));
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 extension = extensions::GetExtensionOverridingProxy( 1867 extension = extensions::GetExtensionOverridingProxy(
1814 Profile::FromWebUI(web_ui())); 1868 Profile::FromWebUI(web_ui()));
1815 AppendExtensionData("proxy", extension, &extension_controlled); 1869 AppendExtensionData("proxy", extension, &extension_controlled);
1816 1870
1817 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", 1871 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators",
1818 extension_controlled); 1872 extension_controlled);
1819 #endif // defined(OS_WIN) 1873 #endif // defined(OS_WIN)
1820 } 1874 }
1821 1875
1822 } // namespace options 1876 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698