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

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

Issue 2946563002: Run clang-format on .js files in c/b/r/settings (Closed)
Patch Set: dschuyler@ review Created 3 years, 6 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() {
11 11
12 /** 12 /**
13 * Must be kept in sync with the C++ enum of the same name. 13 * Must be kept in sync with the C++ enum of the same name.
14 * @enum {number} 14 * @enum {number}
15 */ 15 */
16 var NetworkPredictionOptions = { 16 var NetworkPredictionOptions = {ALWAYS: 0, WIFI_ONLY: 1, NEVER: 2, DEFAULT: 1};
17 ALWAYS: 0,
18 WIFI_ONLY: 1,
19 NEVER: 2,
20 DEFAULT: 1
21 };
22 17
23 Polymer({ 18 Polymer({
24 is: 'settings-privacy-page', 19 is: 'settings-privacy-page',
25 20
26 behaviors: [ 21 behaviors: [
27 settings.RouteObserverBehavior, 22 settings.RouteObserverBehavior,
28 I18nBehavior, 23 I18nBehavior,
29 WebUIListenerBehavior, 24 WebUIListenerBehavior,
30 ], 25 ],
31 26
(...skipping 13 matching lines...) Expand all
45 pageVisibility: Object, 40 pageVisibility: Object,
46 41
47 /** @private */ 42 /** @private */
48 isGuest_: { 43 isGuest_: {
49 type: Boolean, 44 type: Boolean,
50 value: function() { 45 value: function() {
51 return loadTimeData.getBoolean('isGuest'); 46 return loadTimeData.getBoolean('isGuest');
52 } 47 }
53 }, 48 },
54 49
55 // <if expr="_google_chrome and not chromeos"> 50 // <if expr="_google_chrome and not chromeos">
56 // TODO(dbeam): make a virtual.* pref namespace and set/get this normally 51 // TODO(dbeam): make a virtual.* pref namespace and set/get this normally
57 // (but handled differently in C++). 52 // (but handled differently in C++).
58 /** @private {chrome.settingsPrivate.PrefObject} */ 53 /** @private {chrome.settingsPrivate.PrefObject} */
59 metricsReportingPref_: { 54 metricsReportingPref_: {
60 type: Object, 55 type: Object,
61 value: function() { 56 value: function() {
62 // TODO(dbeam): this is basically only to appease PrefControlBehavior. 57 // TODO(dbeam): this is basically only to appease PrefControlBehavior.
63 // Maybe add a no-validate attribute instead? This makes little sense. 58 // Maybe add a no-validate attribute instead? This makes little sense.
64 return /** @type {chrome.settingsPrivate.PrefObject} */({}); 59 return /** @type {chrome.settingsPrivate.PrefObject} */ ({});
65 }, 60 },
66 }, 61 },
67 62
68 showRestart_: Boolean, 63 showRestart_: Boolean,
69 // </if> 64 // </if>
70 65
71 /** @private {chrome.settingsPrivate.PrefObject} */ 66 /** @private {chrome.settingsPrivate.PrefObject} */
72 safeBrowsingExtendedReportingPref_: { 67 safeBrowsingExtendedReportingPref_: {
73 type: Object, 68 type: Object,
74 value: function() { 69 value: function() {
75 return /** @type {chrome.settingsPrivate.PrefObject} */({}); 70 return /** @type {chrome.settingsPrivate.PrefObject} */ ({});
76 }, 71 },
77 }, 72 },
78 73
79 /** @private */ 74 /** @private */
80 showClearBrowsingDataDialog_: Boolean, 75 showClearBrowsingDataDialog_: Boolean,
81 76
82 /** @private */ 77 /** @private */
83 showDoNotTrackDialog_: { 78 showDoNotTrackDialog_: {
84 type: Boolean, 79 type: Boolean,
85 value: false, 80 value: false,
(...skipping 16 matching lines...) Expand all
102 value: function() { 97 value: function() {
103 return loadTimeData.getBoolean('enableSafeBrowsingSubresourceFilter'); 98 return loadTimeData.getBoolean('enableSafeBrowsingSubresourceFilter');
104 } 99 }
105 }, 100 },
106 101
107 /** @private {!Map<string, string>} */ 102 /** @private {!Map<string, string>} */
108 focusConfig_: { 103 focusConfig_: {
109 type: Object, 104 type: Object,
110 value: function() { 105 value: function() {
111 var map = new Map(); 106 var map = new Map();
112 // <if expr="use_nss_certs"> 107 // <if expr="use_nss_certs">
113 map.set( 108 map.set(
114 settings.Route.CERTIFICATES.path, 109 settings.Route.CERTIFICATES.path,
115 '#manageCertificates .subpage-arrow'); 110 '#manageCertificates .subpage-arrow');
116 // </if> 111 // </if>
117 map.set( 112 map.set(
118 settings.Route.SITE_SETTINGS.path, 113 settings.Route.SITE_SETTINGS.path,
119 '#site-settings-subpage-trigger .subpage-arrow'); 114 '#site-settings-subpage-trigger .subpage-arrow');
120 return map; 115 return map;
121 }, 116 },
122 }, 117 },
123 }, 118 },
124 119
125 listeners: { 120 listeners: {
126 'doNotTrackDialogIf.dom-change': 'onDoNotTrackDomChange_', 121 'doNotTrackDialogIf.dom-change': 'onDoNotTrackDomChange_',
127 }, 122 },
128 123
129 /** @override */ 124 /** @override */
130 ready: function() { 125 ready: function() {
131 this.ContentSettingsTypes = settings.ContentSettingsTypes; 126 this.ContentSettingsTypes = settings.ContentSettingsTypes;
132 127
133 this.browserProxy_ = settings.PrivacyPageBrowserProxyImpl.getInstance(); 128 this.browserProxy_ = settings.PrivacyPageBrowserProxyImpl.getInstance();
134 129
135 // <if expr="_google_chrome and not chromeos"> 130 // <if expr="_google_chrome and not chromeos">
136 var setMetricsReportingPref = this.setMetricsReportingPref_.bind(this); 131 var setMetricsReportingPref = this.setMetricsReportingPref_.bind(this);
137 this.addWebUIListener('metrics-reporting-change', setMetricsReportingPref); 132 this.addWebUIListener('metrics-reporting-change', setMetricsReportingPref);
138 this.browserProxy_.getMetricsReporting().then(setMetricsReportingPref); 133 this.browserProxy_.getMetricsReporting().then(setMetricsReportingPref);
139 // </if> 134 // </if>
140 135
141 var setSber = this.setSafeBrowsingExtendedReporting_.bind(this); 136 var setSber = this.setSafeBrowsingExtendedReporting_.bind(this);
142 this.addWebUIListener('safe-browsing-extended-reporting-change', setSber); 137 this.addWebUIListener('safe-browsing-extended-reporting-change', setSber);
143 this.browserProxy_.getSafeBrowsingExtendedReporting().then(setSber); 138 this.browserProxy_.getSafeBrowsingExtendedReporting().then(setSber);
144 }, 139 },
145 140
146 /** @protected */ 141 /** @protected */
147 currentRouteChanged: function() { 142 currentRouteChanged: function() {
148 this.showClearBrowsingDataDialog_ = 143 this.showClearBrowsingDataDialog_ =
149 settings.getCurrentRoute() == settings.Route.CLEAR_BROWSER_DATA; 144 settings.getCurrentRoute() == settings.Route.CLEAR_BROWSER_DATA;
150 }, 145 },
151 146
152 /** 147 /**
153 * @param {Event} event 148 * @param {Event} event
154 * @private 149 * @private
155 */ 150 */
156 onDoNotTrackDomChange_: function(event) { 151 onDoNotTrackDomChange_: function(event) {
157 if (this.showDoNotTrackDialog_) 152 if (this.showDoNotTrackDialog_)
158 this.maybeShowDoNotTrackDialog_(); 153 this.maybeShowDoNotTrackDialog_();
159 }, 154 },
160 155
161 /** 156 /**
162 * Handles the change event for the do-not-track toggle. Shows a 157 * Handles the change event for the do-not-track toggle. Shows a
163 * confirmation dialog when enabling the setting. 158 * confirmation dialog when enabling the setting.
164 * @param {Event} event 159 * @param {Event} event
165 * @private 160 * @private
166 */ 161 */
167 onDoNotTrackChange_: function(event) { 162 onDoNotTrackChange_: function(event) {
168 var target = /** @type {!SettingsToggleButtonElement} */(event.target); 163 var target = /** @type {!SettingsToggleButtonElement} */ (event.target);
169 if (!target.checked) { 164 if (!target.checked) {
170 // Always allow disabling the pref. 165 // Always allow disabling the pref.
171 target.sendPrefChange(); 166 target.sendPrefChange();
172 return; 167 return;
173 } 168 }
174 this.showDoNotTrackDialog_ = true; 169 this.showDoNotTrackDialog_ = true;
175 // If the dialog has already been stamped, show it. Otherwise it will be 170 // If the dialog has already been stamped, show it. Otherwise it will be
176 // shown in onDomChange_. 171 // shown in onDomChange_.
177 this.maybeShowDoNotTrackDialog_(); 172 this.maybeShowDoNotTrackDialog_();
178 }, 173 },
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 * @private 206 * @private
212 */ 207 */
213 onDoNotTrackDialogCancel_: function() { 208 onDoNotTrackDialogCancel_: function() {
214 /** @type {!SettingsToggleButtonElement} */ (this.$.doNotTrack) 209 /** @type {!SettingsToggleButtonElement} */ (this.$.doNotTrack)
215 .resetToPrefValue(); 210 .resetToPrefValue();
216 this.closeDoNotTrackDialog_(); 211 this.closeDoNotTrackDialog_();
217 }, 212 },
218 213
219 /** @private */ 214 /** @private */
220 onManageCertificatesTap_: function() { 215 onManageCertificatesTap_: function() {
221 // <if expr="use_nss_certs"> 216 // <if expr="use_nss_certs">
222 settings.navigateTo(settings.Route.CERTIFICATES); 217 settings.navigateTo(settings.Route.CERTIFICATES);
223 // </if> 218 // </if>
224 // <if expr="is_win or is_macosx"> 219 // <if expr="is_win or is_macosx">
225 this.browserProxy_.showManageSSLCertificates(); 220 this.browserProxy_.showManageSSLCertificates();
226 // </if> 221 // </if>
227 }, 222 },
228 223
229 /** 224 /**
230 * This is a workaround to connect the remove all button to the subpage. 225 * This is a workaround to connect the remove all button to the subpage.
231 * @private 226 * @private
232 */ 227 */
233 onRemoveAllCookiesFromSite_: function() { 228 onRemoveAllCookiesFromSite_: function() {
234 var node = /** @type {?SiteDataDetailsSubpageElement} */(this.$$( 229 var node = /** @type {?SiteDataDetailsSubpageElement} */ (
235 'site-data-details-subpage')); 230 this.$$('site-data-details-subpage'));
236 if (node) 231 if (node)
237 node.removeAll(); 232 node.removeAll();
238 }, 233 },
239 234
240 /** @private */ 235 /** @private */
241 onSiteSettingsTap_: function() { 236 onSiteSettingsTap_: function() {
242 settings.navigateTo(settings.Route.SITE_SETTINGS); 237 settings.navigateTo(settings.Route.SITE_SETTINGS);
243 }, 238 },
244 239
245 /** @private */ 240 /** @private */
246 onClearBrowsingDataTap_: function() { 241 onClearBrowsingDataTap_: function() {
247 settings.navigateTo(settings.Route.CLEAR_BROWSER_DATA); 242 settings.navigateTo(settings.Route.CLEAR_BROWSER_DATA);
248 }, 243 },
249 244
250 /** @private */ 245 /** @private */
251 onDialogClosed_: function() { 246 onDialogClosed_: function() {
252 settings.navigateToPreviousRoute(); 247 settings.navigateToPreviousRoute();
253 cr.ui.focusWithoutInk(assert(this.$.clearBrowsingDataTrigger)); 248 cr.ui.focusWithoutInk(assert(this.$.clearBrowsingDataTrigger));
254 }, 249 },
255 250
256 /** @private */ 251 /** @private */
257 onSberChange_: function() { 252 onSberChange_: function() {
258 var enabled = this.$.safeBrowsingExtendedReportingControl.checked; 253 var enabled = this.$.safeBrowsingExtendedReportingControl.checked;
259 this.browserProxy_.setSafeBrowsingExtendedReportingEnabled(enabled); 254 this.browserProxy_.setSafeBrowsingExtendedReportingEnabled(enabled);
260 }, 255 },
261 256
262 // <if expr="_google_chrome and not chromeos"> 257 // <if expr="_google_chrome and not chromeos">
263 /** @private */ 258 /** @private */
264 onMetricsReportingChange_: function() { 259 onMetricsReportingChange_: function() {
265 var enabled = this.$.metricsReportingControl.checked; 260 var enabled = this.$.metricsReportingControl.checked;
266 this.browserProxy_.setMetricsReportingEnabled(enabled); 261 this.browserProxy_.setMetricsReportingEnabled(enabled);
267 }, 262 },
268 263
269 /** 264 /**
270 * @param {!MetricsReporting} metricsReporting 265 * @param {!MetricsReporting} metricsReporting
271 * @private 266 * @private
272 */ 267 */
(...skipping 21 matching lines...) Expand all
294 }, 289 },
295 290
296 /** 291 /**
297 * @param {Event} e 292 * @param {Event} e
298 * @private 293 * @private
299 */ 294 */
300 onRestartTap_: function(e) { 295 onRestartTap_: function(e) {
301 e.stopPropagation(); 296 e.stopPropagation();
302 settings.LifetimeBrowserProxyImpl.getInstance().restart(); 297 settings.LifetimeBrowserProxyImpl.getInstance().restart();
303 }, 298 },
304 // </if> 299 // </if>
305 300
306 /** 301 /**
307 * @param {boolean} enabled Whether reporting is enabled or not. 302 * @param {boolean} enabled Whether reporting is enabled or not.
308 * @private 303 * @private
309 */ 304 */
310 setSafeBrowsingExtendedReporting_: function(enabled) { 305 setSafeBrowsingExtendedReporting_: function(enabled) {
311 // Ignore the next change because it will happen when we set the pref. 306 // Ignore the next change because it will happen when we set the pref.
312 this.safeBrowsingExtendedReportingPref_ = { 307 this.safeBrowsingExtendedReportingPref_ = {
313 key: '', 308 key: '',
314 type: chrome.settingsPrivate.PrefType.BOOLEAN, 309 type: chrome.settingsPrivate.PrefType.BOOLEAN,
315 value: enabled, 310 value: enabled,
316 }; 311 };
317 }, 312 },
318 313
319 /** 314 /**
320 * The sub-page title for the site or content settings. 315 * The sub-page title for the site or content settings.
321 * @return {string} 316 * @return {string}
322 * @private 317 * @private
323 */ 318 */
324 siteSettingsPageTitle_: function() { 319 siteSettingsPageTitle_: function() {
325 return loadTimeData.getBoolean('enableSiteSettings') ? 320 return loadTimeData.getBoolean('enableSiteSettings') ?
326 loadTimeData.getString('siteSettings') : 321 loadTimeData.getString('siteSettings') :
327 loadTimeData.getString('contentSettings'); 322 loadTimeData.getString('contentSettings');
328 }, 323 },
329 324
330 /** @private */ 325 /** @private */
331 getProtectedContentLabel_: function(value) { 326 getProtectedContentLabel_: function(value) {
332 return value ? this.i18n('siteSettingsProtectedContentEnable') 327 return value ? this.i18n('siteSettingsProtectedContentEnable') :
333 : this.i18n('siteSettingsBlocked'); 328 this.i18n('siteSettingsBlocked');
334 }, 329 },
335 330
336 /** @private */ 331 /** @private */
337 getProtectedContentIdentifiersLabel_: function(value) { 332 getProtectedContentIdentifiersLabel_: function(value) {
338 return value ? this.i18n('siteSettingsProtectedContentEnableIdentifiers') 333 return value ? this.i18n('siteSettingsProtectedContentEnableIdentifiers') :
339 : this.i18n('siteSettingsBlocked'); 334 this.i18n('siteSettingsBlocked');
340 }, 335 },
341 }); 336 });
342 })(); 337 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698