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

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

Issue 2731403005: MD Settings: Privacy: Show dialog when changing do-not-track (Closed)
Patch Set: Make dom-change handler id specific Created 3 years, 9 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 (function() { 10 (function() {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 safeBrowsingExtendedReportingPref_: { 70 safeBrowsingExtendedReportingPref_: {
71 type: Object, 71 type: Object,
72 value: function() { 72 value: function() {
73 return /** @type {chrome.settingsPrivate.PrefObject} */({}); 73 return /** @type {chrome.settingsPrivate.PrefObject} */({});
74 }, 74 },
75 }, 75 },
76 76
77 /** @private */ 77 /** @private */
78 showClearBrowsingDataDialog_: Boolean, 78 showClearBrowsingDataDialog_: Boolean,
79 79
80 /** @private */
81 showDoNotTrackDialog_: {
82 type: Boolean,
83 value: false,
84 },
85
80 /** 86 /**
81 * Used for HTML bindings. This is defined as a property rather than within 87 * Used for HTML bindings. This is defined as a property rather than within
82 * the ready callback, because the value needs to be available before 88 * the ready callback, because the value needs to be available before
83 * local DOM initialization - otherwise, the toggle has unexpected behavior. 89 * local DOM initialization - otherwise, the toggle has unexpected behavior.
84 * @private 90 * @private
85 */ 91 */
86 networkPredictionEnum_: { 92 networkPredictionEnum_: {
87 type: Object, 93 type: Object,
88 value: NetworkPredictionOptions, 94 value: NetworkPredictionOptions,
89 }, 95 },
90 }, 96 },
91 97
98 listeners: {
99 'doNotTrackDialogIf.dom-change': 'onDoNotTrackDomChange_',
100 },
101
92 ready: function() { 102 ready: function() {
93 this.ContentSettingsTypes = settings.ContentSettingsTypes; 103 this.ContentSettingsTypes = settings.ContentSettingsTypes;
94 104
95 this.browserProxy_ = settings.PrivacyPageBrowserProxyImpl.getInstance(); 105 this.browserProxy_ = settings.PrivacyPageBrowserProxyImpl.getInstance();
96 106
97 // <if expr="_google_chrome and not chromeos"> 107 // <if expr="_google_chrome and not chromeos">
98 var setMetricsReportingPref = this.setMetricsReportingPref_.bind(this); 108 var setMetricsReportingPref = this.setMetricsReportingPref_.bind(this);
99 this.addWebUIListener('metrics-reporting-change', setMetricsReportingPref); 109 this.addWebUIListener('metrics-reporting-change', setMetricsReportingPref);
100 this.browserProxy_.getMetricsReporting().then(setMetricsReportingPref); 110 this.browserProxy_.getMetricsReporting().then(setMetricsReportingPref);
101 // </if> 111 // </if>
102 112
103 var setSber = this.setSafeBrowsingExtendedReporting_.bind(this); 113 var setSber = this.setSafeBrowsingExtendedReporting_.bind(this);
104 this.addWebUIListener('safe-browsing-extended-reporting-change', setSber); 114 this.addWebUIListener('safe-browsing-extended-reporting-change', setSber);
105 this.browserProxy_.getSafeBrowsingExtendedReporting().then(setSber); 115 this.browserProxy_.getSafeBrowsingExtendedReporting().then(setSber);
106 }, 116 },
107 117
108 /** @protected */ 118 /** @protected */
109 currentRouteChanged: function() { 119 currentRouteChanged: function() {
110 this.showClearBrowsingDataDialog_ = 120 this.showClearBrowsingDataDialog_ =
111 settings.getCurrentRoute() == settings.Route.CLEAR_BROWSER_DATA; 121 settings.getCurrentRoute() == settings.Route.CLEAR_BROWSER_DATA;
112 }, 122 },
113 123
124 /**
125 * @param {Event} event
126 * @private
127 */
128 onDoNotTrackDomChange_: function(event) {
129 if (this.showDoNotTrackDialog_)
130 this.maybeShowDoNotTrackDialog_();
131 },
132
133 /**
134 * Handles the change event for the do-not-track toggle. Shows a
135 * confirmation dialog when enabling the setting.
136 * @param {{target: !SettingsToggleButtonElement}} event
Dan Beam 2017/03/14 04:59:19 I think this type is weird
stevenjb 2017/03/14 18:35:56 'weird' is not very helpful, please elaborate.
Dan Beam 2017/03/14 18:38:21 @param {Event} event var target = /** !SettingsTo
stevenjb 2017/03/14 19:18:23 Done.
137 * @private
138 */
139 onDoNotTrackChange_: function(event) {
140 if (!event.target.checked) {
141 // Always allow disabling the pref.
142 event.target.sendPrefChange();
143 return;
144 }
145 this.showDoNotTrackDialog_ = true;
146 // If the dialog has already been stamped, show it. Otherwise it will be
147 // shown in onDomChange_.
148 this.maybeShowDoNotTrackDialog_();
149 },
150
151 /** @private */
152 maybeShowDoNotTrackDialog_: function() {
153 var dialog = this.$$('#confirmDoNotTrackDialog');
154 if (dialog && !dialog.open)
155 dialog.showModal();
156 },
157
158 /** @private */
159 closeDoNotTrackDialog_: function() {
160 this.$$('#confirmDoNotTrackDialog').close();
161 this.showDoNotTrackDialog_ = false;
162 },
163
164 /**
165 * Handles the shared proxy confirmation dialog 'Confirm' button.
166 * @private
167 */
168 onDoNotTrackDialogConfirm_: function() {
169 /** @type {!SettingsToggleButtonElement} */ (this.$.doNotTrack)
170 .sendPrefChange();
171 this.closeDoNotTrackDialog_();
172 },
173
174 /**
175 * Handles the shared proxy confirmation dialog 'Cancel' button or a cancel
176 * event.
177 * @private
178 */
179 onDoNotTrackDialogCancel_: function() {
180 /** @type {!SettingsToggleButtonElement} */ (this.$.doNotTrack)
181 .resetToPrefValue();
182 this.closeDoNotTrackDialog_();
183 },
184
114 /** @private */ 185 /** @private */
115 onManageCertificatesTap_: function() { 186 onManageCertificatesTap_: function() {
116 // <if expr="use_nss_certs"> 187 // <if expr="use_nss_certs">
117 settings.navigateTo(settings.Route.CERTIFICATES); 188 settings.navigateTo(settings.Route.CERTIFICATES);
118 // </if> 189 // </if>
119 // <if expr="is_win or is_macosx"> 190 // <if expr="is_win or is_macosx">
120 this.browserProxy_.showManageSSLCertificates(); 191 this.browserProxy_.showManageSSLCertificates();
121 // </if> 192 // </if>
122 }, 193 },
123 194
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 : this.i18n('siteSettingsBlocked'); 312 : this.i18n('siteSettingsBlocked');
242 }, 313 },
243 314
244 /** @private */ 315 /** @private */
245 getProtectedContentIdentifiersLabel_: function(value) { 316 getProtectedContentIdentifiersLabel_: function(value) {
246 return value ? this.i18n('siteSettingsProtectedContentEnableIdentifiers') 317 return value ? this.i18n('siteSettingsProtectedContentEnableIdentifiers')
247 : this.i18n('siteSettingsBlocked'); 318 : this.i18n('siteSettingsBlocked');
248 }, 319 },
249 }); 320 });
250 })(); 321 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698