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

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

Issue 506663003: Consolidates accessing and setting the UMA pref to be within metrics code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: MetricsReporting handling moved to browser_options_handler. JS callback is not called if the… Created 6 years, 3 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;
(...skipping 20 matching lines...) Expand all
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 /**
42 * Callback function after status of MetricsReporting checkbox failed to be
43 * changed (for non ChromeOS).
44 */
45 BrowserOptions.reverseMetricsReportingState = function() {
46 $('metricsReportingEnabled').checked =
47 !$('metricsReportingEnabled').checked;
48 };
49
41 BrowserOptions.prototype = { 50 BrowserOptions.prototype = {
42 __proto__: Page.prototype, 51 __proto__: Page.prototype,
43 52
44 /** 53 /**
45 * Keeps track of whether the user is signed in or not. 54 * Keeps track of whether the user is signed in or not.
46 * @type {boolean} 55 * @type {boolean}
47 * @private 56 * @private
48 */ 57 */
49 signedIn_: false, 58 signedIn_: false,
50 59
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // text" where both starting text and ending text may or may not be 390 // text" where both starting text and ending text may or may not be
382 // present, but the split should always be in three pieces. 391 // present, but the split should always be in three pieces.
383 var restartElements = 392 var restartElements =
384 $('metrics-reporting-reset-restart').querySelectorAll('*'); 393 $('metrics-reporting-reset-restart').querySelectorAll('*');
385 for (var i = 0; i < restartTextFragments.length; i++) { 394 for (var i = 0; i < restartTextFragments.length; i++) {
386 restartElements[i].textContent = restartTextFragments[i]; 395 restartElements[i].textContent = restartTextFragments[i];
387 } 396 }
388 restartElements[1].onclick = function(event) { 397 restartElements[1].onclick = function(event) {
389 chrome.send('restartBrowser'); 398 chrome.send('restartBrowser');
390 }; 399 };
400 // Attach the listener for updating the checkbox and restart button.
391 var updateMetricsRestartButton = function() { 401 var updateMetricsRestartButton = function() {
392 $('metrics-reporting-reset-restart').hidden = 402 $('metrics-reporting-reset-restart').hidden =
393 loadTimeData.getBoolean('metricsReportingEnabledAtStart') == 403 loadTimeData.getBoolean('metricsReportingEnabledAtStart') ==
394 $('metricsReportingEnabled').checked; 404 $('metricsReportingEnabled').checked;
395 }; 405 };
396 Preferences.getInstance().addEventListener( 406 $('metricsReportingEnabled').onclick = function(event) {
397 $('metricsReportingEnabled').getAttribute('pref'), 407 chrome.send('metricsReportingCheckboxChanged',
398 updateMetricsRestartButton); 408 [Boolean(event.currentTarget.checked)]);
409 updateMetricsRestartButton();
410 };
411 $('metricsReportingEnabled').checked =
412 loadTimeData.getBoolean('metricsReportingEnabledAtStart');
399 updateMetricsRestartButton(); 413 updateMetricsRestartButton();
400 } 414 }
401 $('networkPredictionOptions').onchange = function(event) { 415 $('networkPredictionOptions').onchange = function(event) {
402 var value = (event.target.checked ? 416 var value = (event.target.checked ?
403 NetworkPredictionOptions.WIFI_ONLY : 417 NetworkPredictionOptions.WIFI_ONLY :
404 NetworkPredictionOptions.NEVER); 418 NetworkPredictionOptions.NEVER);
405 var metric = event.target.metric; 419 var metric = event.target.metric;
406 Preferences.setIntegerPref( 420 Preferences.setIntegerPref(
407 'net.network_prediction_options', 421 'net.network_prediction_options',
408 value, 422 value,
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 $('factory-reset-section').hidden = false; 1526 $('factory-reset-section').hidden = false;
1513 }, 1527 },
1514 1528
1515 /** 1529 /**
1516 * Set the checked state of the metrics reporting checkbox. 1530 * Set the checked state of the metrics reporting checkbox.
1517 * @private 1531 * @private
1518 */ 1532 */
1519 setMetricsReportingCheckboxState_: function(checked, disabled) { 1533 setMetricsReportingCheckboxState_: function(checked, disabled) {
1520 $('metricsReportingEnabled').checked = checked; 1534 $('metricsReportingEnabled').checked = checked;
1521 $('metricsReportingEnabled').disabled = disabled; 1535 $('metricsReportingEnabled').disabled = disabled;
1536 if (disabled) {
1537 $('metrics-reporting-disabled-icon').setAttribute('controlled-by',
1538 'policy');
1539 }
1522 }, 1540 },
1523 1541
1524 /** 1542 /**
1525 * @private 1543 * @private
1526 */ 1544 */
1527 setMetricsReportingSettingVisibility_: function(visible) { 1545 setMetricsReportingSettingVisibility_: function(visible) {
1528 if (visible) 1546 if (visible)
1529 $('metricsReportingSetting').style.display = 'block'; 1547 $('metricsReportingSetting').style.display = 'block';
1530 else 1548 else
1531 $('metricsReportingSetting').style.display = 'none'; 1549 $('metricsReportingSetting').style.display = 'none';
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 BrowserOptions.getLoggedInUsername = function() { 1996 BrowserOptions.getLoggedInUsername = function() {
1979 return BrowserOptions.getInstance().username_; 1997 return BrowserOptions.getInstance().username_;
1980 }; 1998 };
1981 } 1999 }
1982 2000
1983 // Export 2001 // Export
1984 return { 2002 return {
1985 BrowserOptions: BrowserOptions 2003 BrowserOptions: BrowserOptions
1986 }; 2004 };
1987 }); 2005 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698