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

Side by Side Diff: chrome/browser/resources/settings/privacy_page/privacy_page.js

Issue 2684853003: MD Settings: change how tap is handled on custom toggle rows (Closed)
Patch Set: if the compiler ain't happy, ain't nobody happy Created 3 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'settings-privacy-page' is the settings page containing privacy and 7 * 'settings-privacy-page' is the settings page containing privacy and
8 * security settings. 8 * security settings.
9 */ 9 */
10 Polymer({ 10 Polymer({
(...skipping 13 matching lines...) Expand all
24 notify: true, 24 notify: true,
25 }, 25 },
26 26
27 /** 27 /**
28 * Dictionary defining page visibility. 28 * Dictionary defining page visibility.
29 * @type {!PrivacyPageVisibility} 29 * @type {!PrivacyPageVisibility}
30 */ 30 */
31 pageVisibility: Object, 31 pageVisibility: Object,
32 32
33 // <if expr="_google_chrome and not chromeos"> 33 // <if expr="_google_chrome and not chromeos">
34 /** @type {MetricsReporting} */ 34 /** @private {chrome.settingsPrivate.PrefObject} */
35 metricsReporting_: Object, 35 metricsReportingPref_: {
36 type: Object,
37 value: function() {
38 // TODO(dbeam): this is basically only to appease PrefControlBehavior.
39 // Maybe add a no-validate attribute instead? This makes little sense.
40 return /** @type {chrome.settingsPrivate.PrefObject} */({});
41 },
42 },
36 43
37 showRestart_: Boolean, 44 showRestart_: Boolean,
38 // </if> 45 // </if>
39 46
40 /** @private */ 47 /** @private {chrome.settingsPrivate.PrefObject} */
41 safeBrowsingExtendedReportingEnabled_: Boolean, 48 safeBrowsingExtendedReportingPref_: {
49 type: Object,
50 value: function() {
51 return /** @type {chrome.settingsPrivate.PrefObject} */({});
52 },
53 },
42 54
43 /** @private */ 55 /** @private */
44 showClearBrowsingDataDialog_: Boolean, 56 showClearBrowsingDataDialog_: Boolean,
45 }, 57 },
46 58
47 ready: function() { 59 ready: function() {
48 this.ContentSettingsTypes = settings.ContentSettingsTypes; 60 this.ContentSettingsTypes = settings.ContentSettingsTypes;
49 61
62 var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance();
63
50 // <if expr="_google_chrome and not chromeos"> 64 // <if expr="_google_chrome and not chromeos">
51 var boundSetMetricsReporting = this.setMetricsReporting_.bind(this); 65 var setMetricsReportingPref = this.setMetricsReportingPref_.bind(this);
52 this.addWebUIListener('metrics-reporting-change', boundSetMetricsReporting); 66 this.addWebUIListener('metrics-reporting-change', setMetricsReportingPref);
53 67 browserProxy.getMetricsReporting().then(setMetricsReportingPref);
54 var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance();
55 browserProxy.getMetricsReporting().then(boundSetMetricsReporting);
56 // </if> 68 // </if>
57 69
58 var boundSetSber = this.setSafeBrowsingExtendedReporting_.bind(this); 70 var setSber = this.setSafeBrowsingExtendedReporting_.bind(this);
59 this.addWebUIListener('safe-browsing-extended-reporting-change', 71 this.addWebUIListener('safe-browsing-extended-reporting-change', setSber);
60 boundSetSber); 72 browserProxy.getSafeBrowsingExtendedReporting().then(setSber);
61 settings.PrivacyPageBrowserProxyImpl.getInstance() 73
62 .getSafeBrowsingExtendedReporting().then(boundSetSber); 74 this.listen(this, 'iron-change', 'onIronChange_');
dpapad 2017/02/09 19:51:45 I recall an issue we discovered in the past, were
Dan Beam 2017/02/09 20:48:45 that bug talks about settings-*checkbox*, not sett
dpapad 2017/02/09 23:53:02 The related code linked in the bug is inside https
63 }, 75 },
64 76
65 /** @protected */ 77 /** @protected */
66 currentRouteChanged: function() { 78 currentRouteChanged: function() {
67 this.showClearBrowsingDataDialog_ = 79 this.showClearBrowsingDataDialog_ =
68 settings.getCurrentRoute() == settings.Route.CLEAR_BROWSER_DATA; 80 settings.getCurrentRoute() == settings.Route.CLEAR_BROWSER_DATA;
69 }, 81 },
70 82
71 /** @private */ 83 /** @private */
72 onManageCertificatesTap_: function() { 84 onManageCertificatesTap_: function() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 onDialogClosed_: function() { 116 onDialogClosed_: function() {
105 settings.navigateToPreviousRoute(); 117 settings.navigateToPreviousRoute();
106 }, 118 },
107 119
108 /** @private */ 120 /** @private */
109 onHelpTap_: function() { 121 onHelpTap_: function() {
110 window.open( 122 window.open(
111 'https://support.google.com/chrome/?p=settings_manage_exceptions'); 123 'https://support.google.com/chrome/?p=settings_manage_exceptions');
112 }, 124 },
113 125
126 /**
127 * @param {Event} e
128 * @private
129 */
130 onIronChange_: function(e) {
dpapad 2017/02/09 19:51:45 Can we not add dedicated listeners to each button?
Dan Beam 2017/02/09 20:48:45 you can but it doesn't buy much because you still
dpapad 2017/02/09 23:53:02 I am curious. Polymer.dom(e).localTarget gives you
Dan Beam 2017/02/09 23:57:53 because the localTarget is actually the paper-togg
131 if (e.path.indexOf(this.$.safeBrowsingExtendedReportingControl) >= 0) {
132 var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance();
dpapad 2017/02/09 19:51:45 Nit: PrivacyPageBrowserProxyImpl.getInstance() is
Dan Beam 2017/02/09 20:48:45 Done.
133 var enabled = this.$.safeBrowsingExtendedReportingControl.checked;
134 browserProxy.setSafeBrowsingExtendedReportingEnabled(enabled);
114 // <if expr="_google_chrome and not chromeos"> 135 // <if expr="_google_chrome and not chromeos">
115 /** @private */ 136 } else if (e.path.indexOf(this.$.metricsReportingControl) >= 0) {
116 onMetricsReportingControlTap_: function() { 137 var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance();
117 var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance(); 138 var enabled = this.$.metricsReportingControl.checked;
118 var enabled = this.$.metricsReportingControl.checked; 139 browserProxy.setMetricsReportingEnabled(enabled);
119 browserProxy.setMetricsReportingEnabled(enabled); 140 // </if>
141 }
120 }, 142 },
121 143
144 // <if expr="_google_chrome and not chromeos">
122 /** 145 /**
123 * @param {!MetricsReporting} metricsReporting 146 * @param {!MetricsReporting} metricsReporting
124 * @private 147 * @private
125 */ 148 */
126 setMetricsReporting_: function(metricsReporting) { 149 setMetricsReportingPref_: function(metricsReporting) {
150 var hadPreviousPref = this.metricsReportingPref_.value !== undefined;
151 var pref = {
152 key: '',
153 type: chrome.settingsPrivate.PrefType.BOOLEAN,
154 value: metricsReporting.enabled,
155 };
156 if (metricsReporting.managed) {
157 pref.enforcement = chrome.settingsPrivate.Enforcement.ENFORCED;
158 pref.controlledBy = chrome.settingsPrivate.ControlledBy.USER_POLICY;
159 }
160
161 this.unlisten(this, 'iron-change', 'onIronChange_');
162 this.metricsReportingPref_ = pref;
163 this.listen(this, 'iron-change', 'onIronChange_');
164
127 // TODO(dbeam): remember whether metrics reporting was enabled when Chrome 165 // TODO(dbeam): remember whether metrics reporting was enabled when Chrome
128 // started. 166 // started.
129 if (metricsReporting.managed) { 167 if (metricsReporting.managed)
130 this.showRestart_ = false; 168 this.showRestart_ = false;
131 } else if (this.metricsReporting_ && 169 else if (hadPreviousPref)
132 metricsReporting.enabled != this.metricsReporting_.enabled) {
133 this.showRestart_ = true; 170 this.showRestart_ = true;
134 }
135 this.metricsReporting_ = metricsReporting;
136 }, 171 },
137 172
138 /** @private */ 173 /**
139 onRestartTap_: function() { 174 * @param {Event} e
175 * @private
176 */
177 onRestartTap_: function(e) {
178 e.stopPropagation();
140 settings.LifetimeBrowserProxyImpl.getInstance().restart(); 179 settings.LifetimeBrowserProxyImpl.getInstance().restart();
141 }, 180 },
142 // </if> 181 // </if>
143 182
144 /** @private */ 183 /**
145 onSafeBrowsingExtendedReportingControlTap_: function() { 184 * @param {boolean} enabled Whether reporting is enabled or not.
146 var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance(); 185 * @private
147 var enabled = this.$.safeBrowsingExtendedReportingControl.checked; 186 */
148 browserProxy.setSafeBrowsingExtendedReportingEnabled(enabled);
149 },
150
151 /** @param {boolean} enabled Whether reporting is enabled or not.
152 * @private
153 */
154 setSafeBrowsingExtendedReporting_: function(enabled) { 187 setSafeBrowsingExtendedReporting_: function(enabled) {
155 this.safeBrowsingExtendedReportingEnabled_ = enabled; 188 this.unlisten(this, 'iron-change', 'onIronChange_');
dpapad 2017/02/09 19:51:45 This probably needs a comment explaining why are w
Dan Beam 2017/02/09 20:48:45 Done.
189 this.safeBrowsingExtendedReportingPref_ = {
190 key: '',
191 type: chrome.settingsPrivate.PrefType.BOOLEAN,
192 value: enabled,
193 };
194 this.listen(this, 'iron-change', 'onIronChange_');
156 }, 195 },
157 196
158 /** 197 /**
159 * The sub-page title for the site or content settings. 198 * The sub-page title for the site or content settings.
160 * @return {string} 199 * @return {string}
161 * @private 200 * @private
162 */ 201 */
163 siteSettingsPageTitle_: function() { 202 siteSettingsPageTitle_: function() {
164 return loadTimeData.getBoolean('enableSiteSettings') ? 203 return loadTimeData.getBoolean('enableSiteSettings') ?
165 loadTimeData.getString('siteSettings') : 204 loadTimeData.getString('siteSettings') :
(...skipping 12 matching lines...) Expand all
178 * Works like a ternary operator. E.g. (value ? trueLabel: falseLabel). 217 * Works like a ternary operator. E.g. (value ? trueLabel: falseLabel).
179 * @param {boolean} value 218 * @param {boolean} value
180 * @param {string} trueLabel True label (for example, 'Allow DRM'). 219 * @param {string} trueLabel True label (for example, 'Allow DRM').
181 * @param {string} falseLabel False label (for example, 'Blocked'). 220 * @param {string} falseLabel False label (for example, 'Blocked').
182 * @private 221 * @private
183 */ 222 */
184 getStringTernary_: function(value, trueLabel, falseLabel) { 223 getStringTernary_: function(value, trueLabel, falseLabel) {
185 return value ? trueLabel : falseLabel; 224 return value ? trueLabel : falseLabel;
186 }, 225 },
187 }); 226 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698