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

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: Fix. Learn more 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 'dom-change': 'onDomChange_',
Dan Beam 2017/03/13 21:57:51 listeners: { 'doNotTrackDialogIf.dom-change': 'o
stevenjb 2017/03/13 23:29:02 Ah, I was not aware we could do that and didn't pa
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 onDomChange_: function(event) {
129 var elementId = event.path[0].id;
130 if (elementId == 'doNotTrackDialogIf') {
131 if (this.showDoNotTrackDialog_)
132 this.maybeShowDoNotTrackDialog_();
133 }
134 },
135
136 /**
137 * Handles the change event for the do-not-track toggle. Shows a
138 * confirmation dialog when enabling the setting.
139 * @param {{target: !SettingsToggleButtonElement}} event
140 * @private
141 */
142 onDoNotTrackChange_: function(event) {
143 if (!event.target.checked) {
144 // Always allow disabling the pref.
145 event.target.sendPrefChange();
146 return;
147 }
148 this.showDoNotTrackDialog_ = true;
149 // If the dialog has already been stamped, show it. Otherwise it will be
150 // shown in onDomChange_.
151 this.maybeShowDoNotTrackDialog_();
152 },
153
154 /** @private */
155 maybeShowDoNotTrackDialog_: function() {
156 var dialog = this.$$('#confirmDoNotTrackDialog');
157 if (dialog && !dialog.open)
158 dialog.showModal();
159 },
160
161 /** @private */
162 closeDoNotTrackDialog_: function() {
163 this.$$('#confirmDoNotTrackDialog').close();
164 this.showDoNotTrackDialog_ = false;
165 },
166
167 /**
168 * Handles the shared proxy confirmation dialog 'Confirm' button.
169 * @private
170 */
171 onDoNotTrackDialogConfirm_: function() {
172 /** @type {!SettingsToggleButtonElement} */ (this.$.doNotTrack)
173 .sendPrefChange();
174 this.closeDoNotTrackDialog_();
175 },
176
177 /**
178 * Handles the shared proxy confirmation dialog 'Cancel' button or a cancel
179 * event.
180 * @private
181 */
182 onDoNotTrackDialogCancel_: function() {
183 /** @type {!SettingsToggleButtonElement} */ (this.$.doNotTrack)
184 .resetToPrefValue();
185 this.closeDoNotTrackDialog_();
186 },
187
114 /** @private */ 188 /** @private */
115 onManageCertificatesTap_: function() { 189 onManageCertificatesTap_: function() {
116 // <if expr="use_nss_certs"> 190 // <if expr="use_nss_certs">
117 settings.navigateTo(settings.Route.CERTIFICATES); 191 settings.navigateTo(settings.Route.CERTIFICATES);
118 // </if> 192 // </if>
119 // <if expr="is_win or is_macosx"> 193 // <if expr="is_win or is_macosx">
120 this.browserProxy_.showManageSSLCertificates(); 194 this.browserProxy_.showManageSSLCertificates();
121 // </if> 195 // </if>
122 }, 196 },
123 197
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 : this.i18n('siteSettingsBlocked'); 315 : this.i18n('siteSettingsBlocked');
242 }, 316 },
243 317
244 /** @private */ 318 /** @private */
245 getProtectedContentIdentifiersLabel_: function(value) { 319 getProtectedContentIdentifiersLabel_: function(value) {
246 return value ? this.i18n('siteSettingsProtectedContentEnableIdentifiers') 320 return value ? this.i18n('siteSettingsProtectedContentEnableIdentifiers')
247 : this.i18n('siteSettingsBlocked'); 321 : this.i18n('siteSettingsBlocked');
248 }, 322 },
249 }); 323 });
250 })(); 324 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698