Index: chrome/browser/ui/webui/options/browser_options_handler.cc |
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc |
index c3b1e79fb9afbe55db6e0620f2c86bff9a602481..6f7f199d8d047e9125103cc3bc4310be7791ae94 100644 |
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc |
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc |
@@ -32,6 +32,7 @@ |
#include "chrome/browser/gpu/gpu_mode_manager.h" |
#include "chrome/browser/lifetime/application_lifetime.h" |
#include "chrome/browser/metrics/metrics_reporting_state.h" |
+#include "chrome/browser/net/prediction_options.h" |
#include "chrome/browser/prefs/session_startup_pref.h" |
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h" |
@@ -90,6 +91,7 @@ |
#include "grit/generated_resources.h" |
#include "grit/locale_settings.h" |
#include "grit/theme_resources.h" |
+#include "net/base/network_change_notifier.h" |
#include "third_party/skia/include/core/SkBitmap.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/webui/web_ui_util.h" |
@@ -281,6 +283,14 @@ void BrowserOptionsHandler::GetLocalizedValues(base::DictionaryValue* values) { |
{ "managedUserLabel", IDS_SUPERVISED_USER_AVATAR_LABEL }, |
{ "networkPredictionEnabledDescription", |
IDS_NETWORK_PREDICTION_ENABLED_DESCRIPTION }, |
+ { "networkPredictionOptionsAlways", IDS_NETWORK_PREDICTION_OPTIONS_ALWAYS }, |
+ { "networkPredictionOptionsCheckboxDescription", |
+ IDS_NETWORK_PREDICTION_OPTIONS_CHECKBOX_DESCRIPTION }, |
+ { "networkPredictionOptionsDropdownDescription", |
+ IDS_NETWORK_PREDICTION_OPTIONS_DROPDOWN_DESCRIPTION }, |
+ { "networkPredictionOptionsNever", IDS_NETWORK_PREDICTION_OPTIONS_NEVER }, |
+ { "networkPredictionOptionsWifiOnly", |
+ IDS_NETWORK_PREDICTION_OPTIONS_WIFI_ONLY }, |
{ "passwordsAndAutofillGroupName", |
IDS_OPTIONS_PASSWORDS_AND_FORMS_GROUP_NAME }, |
{ "passwordManagerEnabled", IDS_OPTIONS_PASSWORD_MANAGER_ENABLE }, |
@@ -831,6 +841,10 @@ void BrowserOptionsHandler::InitializeHandler() { |
base::Unretained(this))); |
profile_pref_registrar_.Init(prefs); |
profile_pref_registrar_.Add( |
+ prefs::kNetworkPredictionOptions, |
+ base::Bind(&BrowserOptionsHandler::SetupNetworkPredictionControls, |
+ base::Unretained(this))); |
+ profile_pref_registrar_.Add( |
prefs::kWebKitDefaultFontSize, |
base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, |
base::Unretained(this))); |
@@ -894,7 +908,11 @@ void BrowserOptionsHandler::InitializePage() { |
OnStateChanged(); |
UpdateDefaultBrowserState(); |
+ MigrateNetworkPredictionOptions(); |
+ |
SetupMetricsReportingSettingVisibility(); |
+ SetupNetworkPredictionControlsVisibility(); |
+ SetupNetworkPredictionControls(); |
SetupFontSizeSelector(); |
SetupPageZoomSelector(); |
SetupAutoOpenFileTypes(); |
@@ -1621,6 +1639,18 @@ void BrowserOptionsHandler::SetupAccessibilityFeatures() { |
} |
#endif |
+void BrowserOptionsHandler::MigrateNetworkPredictionOptions() { |
+ PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
+ if (pref_service->GetInteger(prefs::kNetworkPredictionOptions) == |
+ chrome_browser_net::NETWORK_PREDICTION_UNSET) { |
+ pref_service->SetInteger( |
+ prefs::kNetworkPredictionOptions, |
+ pref_service->GetBoolean(prefs::kNetworkPredictionEnabled) |
+ ? chrome_browser_net::NETWORK_PREDICTION_WIFI_ONLY |
+ : chrome_browser_net::NETWORK_PREDICTION_NEVER); |
+ } |
+} |
+ |
void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() { |
#if defined(GOOGLE_CHROME_BUILD) |
// Don't show the reporting setting if we are in the guest mode. |
@@ -1632,6 +1662,30 @@ void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() { |
#endif |
} |
+void BrowserOptionsHandler::SetupNetworkPredictionControlsVisibility() { |
+ base::DictionaryValue dict; |
+ dict.SetBoolean("onCellularNetwork", |
+ net::NetworkChangeNotifier::IsConnectionCellular( |
+ net::NetworkChangeNotifier::GetConnectionType())); |
+ web_ui()->CallJavascriptFunction( |
+ "BrowserOptions.setNetworkPredictionVisibility", dict); |
+} |
+ |
+void BrowserOptionsHandler::SetupNetworkPredictionControls() { |
+ PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
+ const PrefService::Preference* network_prediction_options = |
+ pref_service->FindPreference(prefs::kNetworkPredictionOptions); |
+ |
+ base::DictionaryValue dict; |
+ dict.SetInteger("value", |
+ pref_service->GetInteger(prefs::kNetworkPredictionOptions)); |
+ |
+ dict.SetBoolean("disabled", !network_prediction_options->IsUserModifiable()); |
+ |
+ web_ui()->CallJavascriptFunction("BrowserOptions.setNetworkPredictionValue", |
+ dict); |
+} |
+ |
void BrowserOptionsHandler::SetupFontSizeSelector() { |
PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
const PrefService::Preference* default_font_size = |