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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/privacy_page/privacy_page.js
diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page.js b/chrome/browser/resources/settings/privacy_page/privacy_page.js
index 8e0c4b029c5ad5253e57388a4c64b732355b14aa..67d1bc504f5f532ce5b051743cb8407633cdf82c 100644
--- a/chrome/browser/resources/settings/privacy_page/privacy_page.js
+++ b/chrome/browser/resources/settings/privacy_page/privacy_page.js
@@ -113,9 +113,26 @@ Polymer({
// <if expr="_google_chrome and not chromeos">
/** @private */
- onMetricsReportingControlTap_: function() {
+ onMetricsReportingTap_: function(e) {
+ // 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
+ assert(e.type == 'tap');
+
+ if (this.metricsReporting_.managed)
+ return;
+
var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance();
- var enabled = this.$.metricsReportingControl.checked;
+ var control = this.$.metricsReportingControl;
+ var enabled = control.checked;
+
+ if (e.target == control) {
+ // Prevent the on-tap of the parent from double-changing the value.
Dan Beam 2017/02/08 23:12:04 also mildly unfortunate
+ e.stopPropagation();
+ } else {
+ // If the event came from somewhere other than the control, invert the
+ // value to toggle the control.
+ 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
+ }
+
browserProxy.setMetricsReportingEnabled(enabled);
},
@@ -142,9 +159,23 @@ Polymer({
// </if>
/** @private */
- onSafeBrowsingExtendedReportingControlTap_: function() {
+ onSafeBrowsingExtendedReportingTap_: function(e) {
+ // Both event types must match for stopPropagation() to work.
+ assert(e.type == 'tap');
+
var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance();
- var enabled = this.$.safeBrowsingExtendedReportingControl.checked;
+ var control = this.$.safeBrowsingExtendedReportingControl;
+ var enabled = control.checked;
+
+ if (e.target == control) {
+ // Prevent the on-tap of the parent from double-changing the value.
+ e.stopPropagation();
+ } else {
+ // If the event came from somewhere other than the control, invert the
+ // value to toggle the control.
+ enabled = !enabled;
+ }
Dan Beam 2017/02/08 23:12:04 the fact that all of this is copy pasta'd also isn
+
browserProxy.setSafeBrowsingExtendedReportingEnabled(enabled);
},

Powered by Google App Engine
This is Rietveld 408576698