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