Chromium Code Reviews| Index: chrome/browser/resources/options/browser_options.js |
| diff --git a/chrome/browser/resources/options/browser_options.js b/chrome/browser/resources/options/browser_options.js |
| index 49ddceb11051ff7619330d037dbf8c48e17ce25b..c1f3e5f2817f19a6c74963a7793eae179de91520 100644 |
| --- a/chrome/browser/resources/options/browser_options.js |
| +++ b/chrome/browser/resources/options/browser_options.js |
| @@ -7,6 +7,12 @@ cr.define('options', function() { |
| var ArrayDataModel = cr.ui.ArrayDataModel; |
| var RepeatingButton = cr.ui.RepeatingButton; |
| var HotwordSearchSettingIndicator = options.HotwordSearchSettingIndicator; |
| + var NetworkPredictionOptions = { |
| + ALWAYS: 0, |
| + WIFI_ONLY: 1, |
| + NEVER: 2, |
| + UNSET: 3 |
|
stevenjb
2014/07/30 18:03:29
Unused?
Bence
2014/08/01 14:36:46
Done.
|
| + }; |
| // |
| // BrowserOptions class |
| @@ -348,6 +354,26 @@ cr.define('options', function() { |
| [String(event.currentTarget.checked)]); |
| }; |
| } |
| + $('networkPredictionOptionsBool').onchange = function(event) { |
| + var value = (event.target.checked ? |
| + NetworkPredictionOptions.WIFI_ONLY : |
| + NetworkPredictionOptions.NEVER); |
| + var metric = event.target.metric; |
| + Preferences.setIntegerPref( |
| + 'net.network_prediction_options', |
| + value, |
| + true, |
| + metric); |
| + }; |
| + $('networkPredictionOptionsTristate').onchange = function(event) { |
| + var value = event.target.options[event.target.selectedIndex].value; |
|
stevenjb
2014/07/30 18:03:29
nit: assert value <= NEVER
Bence
2014/08/01 14:36:47
Moot: this function is removed as a result of UI r
|
| + var metric = event.target.metric; |
| + Preferences.setIntegerPref( |
| + 'net.network_prediction_options', |
| + value, |
| + true, |
| + metric); |
| + }; |
| // Bluetooth (CrOS only). |
| if (cr.isChromeOS) { |
| @@ -1456,6 +1482,43 @@ cr.define('options', function() { |
| }, |
| /** |
| + * Set visibility of network prediction controls based on current connection |
| + * type. |
| + * |
| + * @param {Object} pref Information about network connection. |
| + * @param {boolean} pref.onCellularNetwork True if current network |
| + * connection is cellular. |
| + * @private |
| + */ |
| + setNetworkPredictionVisibility_: function(pref) { |
| + if (pref.onCellularNetwork) { |
| + $('networkPredictionOptionsBoolDiv').hidden = true; |
| + $('networkPredictionOptionsTristateDiv').hidden = false; |
| + } else { |
| + $('networkPredictionOptionsBoolDiv').hidden = false; |
| + $('networkPredictionOptionsTristateDiv').hidden = true; |
| + } |
| + }, |
| + |
| + /** |
| + * Set network prediction controls. There is a checkbox and a dropdown |
| + * menu, exactly one of which is visible. |
| + * |
| + * @param {Object} pref Information about network prediction options. |
| + * @param {number} pref.value The value of network prediction options. |
| + * @param {boolean} pref.disabled If the pref is not user modifiable. |
| + * @private |
| + */ |
| + setNetworkPredictionValue_: function(pref) { |
| + var checkbox = $('networkPredictionOptionsBool'); |
| + checkbox.disabled = pref.disabled; |
| + checkbox.checked = !(pref.value == NetworkPredictionOptions.NEVER); |
| + var dropdown = $('networkPredictionOptionsTristate'); |
| + dropdown.disabled = pref.disabled; |
| + dropdown.value = pref.value; |
| + }, |
| + |
| + /** |
| * Set the font size selected item. This item actually reflects two |
| * preferences: the default font size and the default fixed font size. |
| * |
| @@ -1838,6 +1901,8 @@ cr.define('options', function() { |
| 'setCanSetTime', |
| 'setFontSize', |
| 'setNativeThemeButtonEnabled', |
| + 'setNetworkPredictionValue', |
| + 'setNetworkPredictionVisibility', |
|
stevenjb
2014/07/30 18:03:29
Do we really need two API calls for this? It looks
Bence
2014/08/01 14:36:46
Moot: one function is removed as the result of UI
|
| 'setHighContrastCheckboxState', |
| 'setMetricsReportingCheckboxState', |
| 'setMetricsReportingSettingVisibility', |