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

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: . 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 }, 106 },
107 107
108 /** @private */ 108 /** @private */
109 onHelpTap_: function() { 109 onHelpTap_: function() {
110 window.open( 110 window.open(
111 'https://support.google.com/chrome/?p=settings_manage_exceptions'); 111 'https://support.google.com/chrome/?p=settings_manage_exceptions');
112 }, 112 },
113 113
114 // <if expr="_google_chrome and not chromeos"> 114 // <if expr="_google_chrome and not chromeos">
115 /** @private */ 115 /** @private */
116 onMetricsReportingControlTap_: function() { 116 onMetricsReportingTap_: function(e) {
117 // Both event types must match for stopPropagation() to work.
Dan Beam 2017/02/08 23:12:04 this is mildly unfortunate
dpapad 2017/02/08 23:46:05 This entire handler looks a bit unfortunate. I wou
Dan Beam 2017/02/09 00:27:40 <settings-toggle-button> assumes a settings pref o
Dan Beam 2017/02/09 00:50:02 let me try this ^ and see how it looks
118 assert(e.type == 'tap');
119
120 if (this.metricsReporting_.managed)
121 return;
122
117 var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance(); 123 var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance();
118 var enabled = this.$.metricsReportingControl.checked; 124 var control = this.$.metricsReportingControl;
125 var enabled = control.checked;
126
127 if (e.target == control) {
128 // Prevent the on-tap of the parent from double-changing the value.
Dan Beam 2017/02/08 23:12:04 also mildly unfortunate
129 e.stopPropagation();
130 } else {
131 // If the event came from somewhere other than the control, invert the
132 // value to toggle the control.
133 enabled = !enabled;
Dan Beam 2017/02/08 23:12:04 not amazing
scottchen 2017/02/09 00:56:43 Instead of checking for parent double-changing and
134 }
135
119 browserProxy.setMetricsReportingEnabled(enabled); 136 browserProxy.setMetricsReportingEnabled(enabled);
120 }, 137 },
121 138
122 /** 139 /**
123 * @param {!MetricsReporting} metricsReporting 140 * @param {!MetricsReporting} metricsReporting
124 * @private 141 * @private
125 */ 142 */
126 setMetricsReporting_: function(metricsReporting) { 143 setMetricsReporting_: function(metricsReporting) {
127 // TODO(dbeam): remember whether metrics reporting was enabled when Chrome 144 // TODO(dbeam): remember whether metrics reporting was enabled when Chrome
128 // started. 145 // started.
129 if (metricsReporting.managed) { 146 if (metricsReporting.managed) {
130 this.showRestart_ = false; 147 this.showRestart_ = false;
131 } else if (this.metricsReporting_ && 148 } else if (this.metricsReporting_ &&
132 metricsReporting.enabled != this.metricsReporting_.enabled) { 149 metricsReporting.enabled != this.metricsReporting_.enabled) {
133 this.showRestart_ = true; 150 this.showRestart_ = true;
134 } 151 }
135 this.metricsReporting_ = metricsReporting; 152 this.metricsReporting_ = metricsReporting;
136 }, 153 },
137 154
138 /** @private */ 155 /** @private */
139 onRestartTap_: function() { 156 onRestartTap_: function() {
140 settings.LifetimeBrowserProxyImpl.getInstance().restart(); 157 settings.LifetimeBrowserProxyImpl.getInstance().restart();
141 }, 158 },
142 // </if> 159 // </if>
143 160
144 /** @private */ 161 /** @private */
145 onSafeBrowsingExtendedReportingControlTap_: function() { 162 onSafeBrowsingExtendedReportingTap_: function(e) {
163 // Both event types must match for stopPropagation() to work.
164 assert(e.type == 'tap');
165
146 var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance(); 166 var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance();
147 var enabled = this.$.safeBrowsingExtendedReportingControl.checked; 167 var control = this.$.safeBrowsingExtendedReportingControl;
168 var enabled = control.checked;
169
170 if (e.target == control) {
171 // Prevent the on-tap of the parent from double-changing the value.
172 e.stopPropagation();
173 } else {
174 // If the event came from somewhere other than the control, invert the
175 // value to toggle the control.
176 enabled = !enabled;
177 }
Dan Beam 2017/02/08 23:12:04 the fact that all of this is copy pasta'd also isn
178
148 browserProxy.setSafeBrowsingExtendedReportingEnabled(enabled); 179 browserProxy.setSafeBrowsingExtendedReportingEnabled(enabled);
149 }, 180 },
150 181
151 /** @param {boolean} enabled Whether reporting is enabled or not. 182 /** @param {boolean} enabled Whether reporting is enabled or not.
152 * @private 183 * @private
153 */ 184 */
154 setSafeBrowsingExtendedReporting_: function(enabled) { 185 setSafeBrowsingExtendedReporting_: function(enabled) {
155 this.safeBrowsingExtendedReportingEnabled_ = enabled; 186 this.safeBrowsingExtendedReportingEnabled_ = enabled;
156 }, 187 },
157 188
(...skipping 20 matching lines...) Expand all
178 * Works like a ternary operator. E.g. (value ? trueLabel: falseLabel). 209 * Works like a ternary operator. E.g. (value ? trueLabel: falseLabel).
179 * @param {boolean} value 210 * @param {boolean} value
180 * @param {string} trueLabel True label (for example, 'Allow DRM'). 211 * @param {string} trueLabel True label (for example, 'Allow DRM').
181 * @param {string} falseLabel False label (for example, 'Blocked'). 212 * @param {string} falseLabel False label (for example, 'Blocked').
182 * @private 213 * @private
183 */ 214 */
184 getStringTernary_: function(value, trueLabel, falseLabel) { 215 getStringTernary_: function(value, trueLabel, falseLabel) {
185 return value ? trueLabel : falseLabel; 216 return value ? trueLabel : falseLabel;
186 }, 217 },
187 }); 218 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698