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 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; |
(...skipping 20 matching lines...) Expand all Loading... | |
31 /** | 31 /** |
32 * @param {HTMLElement} section The section to show or hide. | 32 * @param {HTMLElement} section The section to show or hide. |
33 * @return {boolean} Whether the section should be shown. | 33 * @return {boolean} Whether the section should be shown. |
34 * @private | 34 * @private |
35 */ | 35 */ |
36 BrowserOptions.shouldShowSection_ = function(section) { | 36 BrowserOptions.shouldShowSection_ = function(section) { |
37 // If the section is hidden or hiding, it should be shown. | 37 // If the section is hidden or hiding, it should be shown. |
38 return section.style.height == '' || section.style.height == '0px'; | 38 return section.style.height == '' || section.style.height == '0px'; |
39 }; | 39 }; |
40 | 40 |
41 BrowserOptions.setMetricsReportingJSCallback = function(success) { | |
Alexei Svitkine (slow)
2014/09/05 15:22:48
Please add a comment explaining this function and
gayane -on leave until 09-2017
2014/09/05 18:30:20
Description for the function added, but param remo
| |
42 // if no success then reverse the checkbox state. | |
43 if (!success) { | |
Alexei Svitkine (slow)
2014/09/05 15:22:48
If there's nothing to do when !success, how about
gayane -on leave until 09-2017
2014/09/05 18:30:20
Done.
| |
44 $('metricsReportingEnabled').checked = | |
45 !$('metricsReportingEnabled').checked; | |
46 } | |
47 }; | |
48 | |
41 BrowserOptions.prototype = { | 49 BrowserOptions.prototype = { |
42 __proto__: Page.prototype, | 50 __proto__: Page.prototype, |
43 | 51 |
44 /** | 52 /** |
45 * Keeps track of whether the user is signed in or not. | 53 * Keeps track of whether the user is signed in or not. |
46 * @type {boolean} | 54 * @type {boolean} |
47 * @private | 55 * @private |
48 */ | 56 */ |
49 signedIn_: false, | 57 signedIn_: false, |
50 | 58 |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 // text" where both starting text and ending text may or may not be | 389 // text" where both starting text and ending text may or may not be |
382 // present, but the split should always be in three pieces. | 390 // present, but the split should always be in three pieces. |
383 var restartElements = | 391 var restartElements = |
384 $('metrics-reporting-reset-restart').querySelectorAll('*'); | 392 $('metrics-reporting-reset-restart').querySelectorAll('*'); |
385 for (var i = 0; i < restartTextFragments.length; i++) { | 393 for (var i = 0; i < restartTextFragments.length; i++) { |
386 restartElements[i].textContent = restartTextFragments[i]; | 394 restartElements[i].textContent = restartTextFragments[i]; |
387 } | 395 } |
388 restartElements[1].onclick = function(event) { | 396 restartElements[1].onclick = function(event) { |
389 chrome.send('restartBrowser'); | 397 chrome.send('restartBrowser'); |
390 }; | 398 }; |
399 // Attach the listener for updating the checkbox and restart button. | |
391 var updateMetricsRestartButton = function() { | 400 var updateMetricsRestartButton = function() { |
392 $('metrics-reporting-reset-restart').hidden = | 401 $('metrics-reporting-reset-restart').hidden = |
393 loadTimeData.getBoolean('metricsReportingEnabledAtStart') == | 402 loadTimeData.getBoolean('metricsReportingEnabledAtStart') == |
394 $('metricsReportingEnabled').checked; | 403 $('metricsReportingEnabled').checked; |
395 }; | 404 }; |
396 Preferences.getInstance().addEventListener( | 405 $('metricsReportingEnabled').onclick = function(event) { |
397 $('metricsReportingEnabled').getAttribute('pref'), | 406 chrome.send('coreOptionsMetricsReportingChange', |
Alexei Svitkine (slow)
2014/09/05 15:22:48
I'd name this something more meaningful than coreO
gayane -on leave until 09-2017
2014/09/05 18:30:20
changed to metricsReportingCheckboxChanged
| |
398 updateMetricsRestartButton); | 407 [Boolean(event.currentTarget.checked)]); |
408 updateMetricsRestartButton(); | |
409 }; | |
410 $('metricsReportingEnabled').checked = | |
411 loadTimeData.getBoolean('metricsReportingEnabledAtStart'); | |
399 updateMetricsRestartButton(); | 412 updateMetricsRestartButton(); |
400 } | 413 } |
401 $('networkPredictionOptions').onchange = function(event) { | 414 $('networkPredictionOptions').onchange = function(event) { |
402 var value = (event.target.checked ? | 415 var value = (event.target.checked ? |
403 NetworkPredictionOptions.WIFI_ONLY : | 416 NetworkPredictionOptions.WIFI_ONLY : |
404 NetworkPredictionOptions.NEVER); | 417 NetworkPredictionOptions.NEVER); |
405 var metric = event.target.metric; | 418 var metric = event.target.metric; |
406 Preferences.setIntegerPref( | 419 Preferences.setIntegerPref( |
407 'net.network_prediction_options', | 420 'net.network_prediction_options', |
408 value, | 421 value, |
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1512 $('factory-reset-section').hidden = false; | 1525 $('factory-reset-section').hidden = false; |
1513 }, | 1526 }, |
1514 | 1527 |
1515 /** | 1528 /** |
1516 * Set the checked state of the metrics reporting checkbox. | 1529 * Set the checked state of the metrics reporting checkbox. |
1517 * @private | 1530 * @private |
1518 */ | 1531 */ |
1519 setMetricsReportingCheckboxState_: function(checked, disabled) { | 1532 setMetricsReportingCheckboxState_: function(checked, disabled) { |
1520 $('metricsReportingEnabled').checked = checked; | 1533 $('metricsReportingEnabled').checked = checked; |
1521 $('metricsReportingEnabled').disabled = disabled; | 1534 $('metricsReportingEnabled').disabled = disabled; |
1535 if (disabled) { | |
1536 $('metrics-reporting-disabled-icon').setAttribute('controlled-by', | |
1537 'policy'); | |
1538 } | |
1522 }, | 1539 }, |
1523 | 1540 |
1524 /** | 1541 /** |
1525 * @private | 1542 * @private |
1526 */ | 1543 */ |
1527 setMetricsReportingSettingVisibility_: function(visible) { | 1544 setMetricsReportingSettingVisibility_: function(visible) { |
1528 if (visible) | 1545 if (visible) |
1529 $('metricsReportingSetting').style.display = 'block'; | 1546 $('metricsReportingSetting').style.display = 'block'; |
1530 else | 1547 else |
1531 $('metricsReportingSetting').style.display = 'none'; | 1548 $('metricsReportingSetting').style.display = 'none'; |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1978 BrowserOptions.getLoggedInUsername = function() { | 1995 BrowserOptions.getLoggedInUsername = function() { |
1979 return BrowserOptions.getInstance().username_; | 1996 return BrowserOptions.getInstance().username_; |
1980 }; | 1997 }; |
1981 } | 1998 } |
1982 | 1999 |
1983 // Export | 2000 // Export |
1984 return { | 2001 return { |
1985 BrowserOptions: BrowserOptions | 2002 BrowserOptions: BrowserOptions |
1986 }; | 2003 }; |
1987 }); | 2004 }); |
OLD | NEW |