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

Side by Side Diff: chrome/browser/resources/options/browser_options.js

Issue 421653006: Update "Predict network actions" UI setting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update test cases and hack test. 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 cr.define('options', function() { 5 cr.define('options', function() {
6 var OptionsPage = options.OptionsPage; 6 var OptionsPage = options.OptionsPage;
7 var Page = cr.ui.pageManager.Page; 7 var Page = cr.ui.pageManager.Page;
8 var PageManager = cr.ui.pageManager.PageManager; 8 var PageManager = cr.ui.pageManager.PageManager;
9 var ArrayDataModel = cr.ui.ArrayDataModel; 9 var ArrayDataModel = cr.ui.ArrayDataModel;
10 var RepeatingButton = cr.ui.RepeatingButton; 10 var RepeatingButton = cr.ui.RepeatingButton;
11 var HotwordSearchSettingIndicator = options.HotwordSearchSettingIndicator; 11 var HotwordSearchSettingIndicator = options.HotwordSearchSettingIndicator;
12 var NetworkPredictionOptions = {
13 ALWAYS: 0,
14 WIFI_ONLY: 1,
15 NEVER: 2
16 };
12 17
13 // 18 //
14 // BrowserOptions class 19 // BrowserOptions class
15 // Encapsulated handling of browser options page. 20 // Encapsulated handling of browser options page.
16 // 21 //
17 function BrowserOptions() { 22 function BrowserOptions() {
18 Page.call(this, 'settings', loadTimeData.getString('settingsTitle'), 23 Page.call(this, 'settings', loadTimeData.getString('settingsTitle'),
19 'settings'); 24 'settings');
20 } 25 }
21 26
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 $('privacyClearDataButton').hidden = OptionsPage.isSettingsApp(); 348 $('privacyClearDataButton').hidden = OptionsPage.isSettingsApp();
344 // 'metricsReportingEnabled' element is only present on Chrome branded 349 // 'metricsReportingEnabled' element is only present on Chrome branded
345 // builds, and the 'metricsReportingCheckboxAction' message is only 350 // builds, and the 'metricsReportingCheckboxAction' message is only
346 // handled on ChromeOS. 351 // handled on ChromeOS.
347 if ($('metricsReportingEnabled') && cr.isChromeOS) { 352 if ($('metricsReportingEnabled') && cr.isChromeOS) {
348 $('metricsReportingEnabled').onclick = function(event) { 353 $('metricsReportingEnabled').onclick = function(event) {
349 chrome.send('metricsReportingCheckboxAction', 354 chrome.send('metricsReportingCheckboxAction',
350 [String(event.currentTarget.checked)]); 355 [String(event.currentTarget.checked)]);
351 }; 356 };
352 } 357 }
358 $('networkPredictionOptions').onchange = function(event) {
359 var value = (event.target.checked ?
360 NetworkPredictionOptions.WIFI_ONLY :
361 NetworkPredictionOptions.NEVER);
362 var metric = event.target.metric;
363 Preferences.setIntegerPref(
364 'net.network_prediction_options',
365 value,
366 true,
367 metric);
368 };
353 369
354 // Bluetooth (CrOS only). 370 // Bluetooth (CrOS only).
355 if (cr.isChromeOS) { 371 if (cr.isChromeOS) {
356 options.system.bluetooth.BluetoothDeviceList.decorate( 372 options.system.bluetooth.BluetoothDeviceList.decorate(
357 $('bluetooth-paired-devices-list')); 373 $('bluetooth-paired-devices-list'));
358 374
359 $('bluetooth-add-device').onclick = 375 $('bluetooth-add-device').onclick =
360 this.handleAddBluetoothDevice_.bind(this); 376 this.handleAddBluetoothDevice_.bind(this);
361 377
362 $('enable-bluetooth').onchange = function(event) { 378 $('enable-bluetooth').onchange = function(event) {
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 * @private 1467 * @private
1452 */ 1468 */
1453 setMetricsReportingSettingVisibility_: function(visible) { 1469 setMetricsReportingSettingVisibility_: function(visible) {
1454 if (visible) 1470 if (visible)
1455 $('metricsReportingSetting').style.display = 'block'; 1471 $('metricsReportingSetting').style.display = 'block';
1456 else 1472 else
1457 $('metricsReportingSetting').style.display = 'none'; 1473 $('metricsReportingSetting').style.display = 'none';
1458 }, 1474 },
1459 1475
1460 /** 1476 /**
1477 * Set network prediction checkbox value.
1478 *
1479 * @param {Object} pref Information about network prediction options.
1480 * @param {number} pref.value The value of network prediction options.
1481 * @param {boolean} pref.disabled If the pref is not user modifiable.
1482 * @private
1483 */
1484 setNetworkPredictionValue_: function(pref) {
1485 var checkbox = $('networkPredictionOptions');
1486 checkbox.disabled = pref.disabled;
1487 checkbox.checked = !(pref.value == NetworkPredictionOptions.NEVER);
1488 },
1489
1490 /**
1461 * Set the font size selected item. This item actually reflects two 1491 * Set the font size selected item. This item actually reflects two
1462 * preferences: the default font size and the default fixed font size. 1492 * preferences: the default font size and the default fixed font size.
1463 * 1493 *
1464 * @param {Object} pref Information about the font size preferences. 1494 * @param {Object} pref Information about the font size preferences.
1465 * @param {number} pref.value The value of the default font size pref. 1495 * @param {number} pref.value The value of the default font size pref.
1466 * @param {boolean} pref.disabled True if either pref not user modifiable. 1496 * @param {boolean} pref.disabled True if either pref not user modifiable.
1467 * @param {string} pref.controlledBy The source of the pref value(s) if 1497 * @param {string} pref.controlledBy The source of the pref value(s) if
1468 * either pref is currently not controlled by the user. 1498 * either pref is currently not controlled by the user.
1469 * @private 1499 * @private
1470 */ 1500 */
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 'notifyInitializationComplete', 1863 'notifyInitializationComplete',
1834 'removeBluetoothDevice', 1864 'removeBluetoothDevice',
1835 'scrollToSection', 1865 'scrollToSection',
1836 'setAccountPictureManaged', 1866 'setAccountPictureManaged',
1837 'setWallpaperManaged', 1867 'setWallpaperManaged',
1838 'setAutoOpenFileTypesDisplayed', 1868 'setAutoOpenFileTypesDisplayed',
1839 'setBluetoothState', 1869 'setBluetoothState',
1840 'setCanSetTime', 1870 'setCanSetTime',
1841 'setFontSize', 1871 'setFontSize',
1842 'setNativeThemeButtonEnabled', 1872 'setNativeThemeButtonEnabled',
1873 'setNetworkPredictionValue',
1843 'setHighContrastCheckboxState', 1874 'setHighContrastCheckboxState',
1844 'setMetricsReportingCheckboxState', 1875 'setMetricsReportingCheckboxState',
1845 'setMetricsReportingSettingVisibility', 1876 'setMetricsReportingSettingVisibility',
1846 'setProfilesInfo', 1877 'setProfilesInfo',
1847 'setSpokenFeedbackCheckboxState', 1878 'setSpokenFeedbackCheckboxState',
1848 'setThemesResetButtonEnabled', 1879 'setThemesResetButtonEnabled',
1849 'setVirtualKeyboardCheckboxState', 1880 'setVirtualKeyboardCheckboxState',
1850 'setupPageZoomSelector', 1881 'setupPageZoomSelector',
1851 'setupProxySettingsButton', 1882 'setupProxySettingsButton',
1852 'showBluetoothSettings', 1883 'showBluetoothSettings',
(...skipping 30 matching lines...) Expand all
1883 BrowserOptions.getLoggedInUsername = function() { 1914 BrowserOptions.getLoggedInUsername = function() {
1884 return BrowserOptions.getInstance().username_; 1915 return BrowserOptions.getInstance().username_;
1885 }; 1916 };
1886 } 1917 }
1887 1918
1888 // Export 1919 // Export
1889 return { 1920 return {
1890 BrowserOptions: BrowserOptions 1921 BrowserOptions: BrowserOptions
1891 }; 1922 };
1892 }); 1923 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698