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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 var OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
7 var ArrayDataModel = cr.ui.ArrayDataModel; | 7 var ArrayDataModel = cr.ui.ArrayDataModel; |
8 var RepeatingButton = cr.ui.RepeatingButton; | 8 var RepeatingButton = cr.ui.RepeatingButton; |
9 var HotwordSearchSettingIndicator = options.HotwordSearchSettingIndicator; | 9 var HotwordSearchSettingIndicator = options.HotwordSearchSettingIndicator; |
10 var NetworkPredictionOptions = { | |
11 ALWAYS: 0, | |
12 WIFI_ONLY: 1, | |
13 NEVER: 2, | |
14 UNSET: 3 | |
stevenjb
2014/07/30 18:03:29
Unused?
Bence
2014/08/01 14:36:46
Done.
| |
15 }; | |
10 | 16 |
11 // | 17 // |
12 // BrowserOptions class | 18 // BrowserOptions class |
13 // Encapsulated handling of browser options page. | 19 // Encapsulated handling of browser options page. |
14 // | 20 // |
15 function BrowserOptions() { | 21 function BrowserOptions() { |
16 OptionsPage.call(this, 'settings', loadTimeData.getString('settingsTitle'), | 22 OptionsPage.call(this, 'settings', loadTimeData.getString('settingsTitle'), |
17 'settings'); | 23 'settings'); |
18 } | 24 } |
19 | 25 |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 $('privacyClearDataButton').hidden = OptionsPage.isSettingsApp(); | 347 $('privacyClearDataButton').hidden = OptionsPage.isSettingsApp(); |
342 // 'metricsReportingEnabled' element is only present on Chrome branded | 348 // 'metricsReportingEnabled' element is only present on Chrome branded |
343 // builds, and the 'metricsReportingCheckboxAction' message is only | 349 // builds, and the 'metricsReportingCheckboxAction' message is only |
344 // handled on ChromeOS. | 350 // handled on ChromeOS. |
345 if ($('metricsReportingEnabled') && cr.isChromeOS) { | 351 if ($('metricsReportingEnabled') && cr.isChromeOS) { |
346 $('metricsReportingEnabled').onclick = function(event) { | 352 $('metricsReportingEnabled').onclick = function(event) { |
347 chrome.send('metricsReportingCheckboxAction', | 353 chrome.send('metricsReportingCheckboxAction', |
348 [String(event.currentTarget.checked)]); | 354 [String(event.currentTarget.checked)]); |
349 }; | 355 }; |
350 } | 356 } |
357 $('networkPredictionOptionsBool').onchange = function(event) { | |
358 var value = (event.target.checked ? | |
359 NetworkPredictionOptions.WIFI_ONLY : | |
360 NetworkPredictionOptions.NEVER); | |
361 var metric = event.target.metric; | |
362 Preferences.setIntegerPref( | |
363 'net.network_prediction_options', | |
364 value, | |
365 true, | |
366 metric); | |
367 }; | |
368 $('networkPredictionOptionsTristate').onchange = function(event) { | |
369 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
| |
370 var metric = event.target.metric; | |
371 Preferences.setIntegerPref( | |
372 'net.network_prediction_options', | |
373 value, | |
374 true, | |
375 metric); | |
376 }; | |
351 | 377 |
352 // Bluetooth (CrOS only). | 378 // Bluetooth (CrOS only). |
353 if (cr.isChromeOS) { | 379 if (cr.isChromeOS) { |
354 options.system.bluetooth.BluetoothDeviceList.decorate( | 380 options.system.bluetooth.BluetoothDeviceList.decorate( |
355 $('bluetooth-paired-devices-list')); | 381 $('bluetooth-paired-devices-list')); |
356 | 382 |
357 $('bluetooth-add-device').onclick = | 383 $('bluetooth-add-device').onclick = |
358 this.handleAddBluetoothDevice_.bind(this); | 384 this.handleAddBluetoothDevice_.bind(this); |
359 | 385 |
360 $('enable-bluetooth').onchange = function(event) { | 386 $('enable-bluetooth').onchange = function(event) { |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1449 * @private | 1475 * @private |
1450 */ | 1476 */ |
1451 setMetricsReportingSettingVisibility_: function(visible) { | 1477 setMetricsReportingSettingVisibility_: function(visible) { |
1452 if (visible) | 1478 if (visible) |
1453 $('metricsReportingSetting').style.display = 'block'; | 1479 $('metricsReportingSetting').style.display = 'block'; |
1454 else | 1480 else |
1455 $('metricsReportingSetting').style.display = 'none'; | 1481 $('metricsReportingSetting').style.display = 'none'; |
1456 }, | 1482 }, |
1457 | 1483 |
1458 /** | 1484 /** |
1485 * Set visibility of network prediction controls based on current connection | |
1486 * type. | |
1487 * | |
1488 * @param {Object} pref Information about network connection. | |
1489 * @param {boolean} pref.onCellularNetwork True if current network | |
1490 * connection is cellular. | |
1491 * @private | |
1492 */ | |
1493 setNetworkPredictionVisibility_: function(pref) { | |
1494 if (pref.onCellularNetwork) { | |
1495 $('networkPredictionOptionsBoolDiv').hidden = true; | |
1496 $('networkPredictionOptionsTristateDiv').hidden = false; | |
1497 } else { | |
1498 $('networkPredictionOptionsBoolDiv').hidden = false; | |
1499 $('networkPredictionOptionsTristateDiv').hidden = true; | |
1500 } | |
1501 }, | |
1502 | |
1503 /** | |
1504 * Set network prediction controls. There is a checkbox and a dropdown | |
1505 * menu, exactly one of which is visible. | |
1506 * | |
1507 * @param {Object} pref Information about network prediction options. | |
1508 * @param {number} pref.value The value of network prediction options. | |
1509 * @param {boolean} pref.disabled If the pref is not user modifiable. | |
1510 * @private | |
1511 */ | |
1512 setNetworkPredictionValue_: function(pref) { | |
1513 var checkbox = $('networkPredictionOptionsBool'); | |
1514 checkbox.disabled = pref.disabled; | |
1515 checkbox.checked = !(pref.value == NetworkPredictionOptions.NEVER); | |
1516 var dropdown = $('networkPredictionOptionsTristate'); | |
1517 dropdown.disabled = pref.disabled; | |
1518 dropdown.value = pref.value; | |
1519 }, | |
1520 | |
1521 /** | |
1459 * Set the font size selected item. This item actually reflects two | 1522 * Set the font size selected item. This item actually reflects two |
1460 * preferences: the default font size and the default fixed font size. | 1523 * preferences: the default font size and the default fixed font size. |
1461 * | 1524 * |
1462 * @param {Object} pref Information about the font size preferences. | 1525 * @param {Object} pref Information about the font size preferences. |
1463 * @param {number} pref.value The value of the default font size pref. | 1526 * @param {number} pref.value The value of the default font size pref. |
1464 * @param {boolean} pref.disabled True if either pref not user modifiable. | 1527 * @param {boolean} pref.disabled True if either pref not user modifiable. |
1465 * @param {string} pref.controlledBy The source of the pref value(s) if | 1528 * @param {string} pref.controlledBy The source of the pref value(s) if |
1466 * either pref is currently not controlled by the user. | 1529 * either pref is currently not controlled by the user. |
1467 * @private | 1530 * @private |
1468 */ | 1531 */ |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1831 'notifyInitializationComplete', | 1894 'notifyInitializationComplete', |
1832 'removeBluetoothDevice', | 1895 'removeBluetoothDevice', |
1833 'scrollToSection', | 1896 'scrollToSection', |
1834 'setAccountPictureManaged', | 1897 'setAccountPictureManaged', |
1835 'setWallpaperManaged', | 1898 'setWallpaperManaged', |
1836 'setAutoOpenFileTypesDisplayed', | 1899 'setAutoOpenFileTypesDisplayed', |
1837 'setBluetoothState', | 1900 'setBluetoothState', |
1838 'setCanSetTime', | 1901 'setCanSetTime', |
1839 'setFontSize', | 1902 'setFontSize', |
1840 'setNativeThemeButtonEnabled', | 1903 'setNativeThemeButtonEnabled', |
1904 'setNetworkPredictionValue', | |
1905 '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
| |
1841 'setHighContrastCheckboxState', | 1906 'setHighContrastCheckboxState', |
1842 'setMetricsReportingCheckboxState', | 1907 'setMetricsReportingCheckboxState', |
1843 'setMetricsReportingSettingVisibility', | 1908 'setMetricsReportingSettingVisibility', |
1844 'setProfilesInfo', | 1909 'setProfilesInfo', |
1845 'setSpokenFeedbackCheckboxState', | 1910 'setSpokenFeedbackCheckboxState', |
1846 'setThemesResetButtonEnabled', | 1911 'setThemesResetButtonEnabled', |
1847 'setVirtualKeyboardCheckboxState', | 1912 'setVirtualKeyboardCheckboxState', |
1848 'setupPageZoomSelector', | 1913 'setupPageZoomSelector', |
1849 'setupProxySettingsButton', | 1914 'setupProxySettingsButton', |
1850 'showBluetoothSettings', | 1915 'showBluetoothSettings', |
(...skipping 30 matching lines...) Expand all Loading... | |
1881 BrowserOptions.getLoggedInUsername = function() { | 1946 BrowserOptions.getLoggedInUsername = function() { |
1882 return BrowserOptions.getInstance().username_; | 1947 return BrowserOptions.getInstance().username_; |
1883 }; | 1948 }; |
1884 } | 1949 } |
1885 | 1950 |
1886 // Export | 1951 // Export |
1887 return { | 1952 return { |
1888 BrowserOptions: BrowserOptions | 1953 BrowserOptions: BrowserOptions |
1889 }; | 1954 }; |
1890 }); | 1955 }); |
OLD | NEW |