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

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: fix tests 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 13 matching lines...) Expand all
24 notify: true, 24 notify: true,
25 }, 25 },
26 26
27 /** 27 /**
28 * Dictionary defining page visibility. 28 * Dictionary defining page visibility.
29 * @type {!PrivacyPageVisibility} 29 * @type {!PrivacyPageVisibility}
30 */ 30 */
31 pageVisibility: Object, 31 pageVisibility: Object,
32 32
33 // <if expr="_google_chrome and not chromeos"> 33 // <if expr="_google_chrome and not chromeos">
34 /** @type {MetricsReporting} */ 34 /** @private {chrome.settingsPrivate.PrefObject} */
35 metricsReporting_: Object, 35 metricsReportingPref_: {
36 type: Object,
37 value: function() {
38 // TODO(dbeam): this is basically only to appease PrefControlBehavior.
39 // Maybe add a no-validate attribute instead? This makes little sense.
40 return /** @type {chrome.settingsPrivate.PrefObject} */({});
41 },
42 },
36 43
37 showRestart_: Boolean, 44 showRestart_: Boolean,
38 // </if> 45 // </if>
39 46
40 /** @private */ 47 /** @private {chrome.settingsPrivate.PrefObject} */
41 safeBrowsingExtendedReportingEnabled_: Boolean, 48 safeBrowsingExtendedReportingPref_: {
49 type: Object,
50 value: function() {
51 return /** @type {chrome.settingsPrivate.PrefObject} */({});
52 },
53 },
42 54
43 /** @private */ 55 /** @private */
44 showClearBrowsingDataDialog_: Boolean, 56 showClearBrowsingDataDialog_: Boolean,
45 }, 57 },
46 58
47 ready: function() { 59 ready: function() {
48 this.ContentSettingsTypes = settings.ContentSettingsTypes; 60 this.ContentSettingsTypes = settings.ContentSettingsTypes;
49 61
62 this.browserProxy_ = settings.PrivacyPageBrowserProxyImpl.getInstance();
dpapad 2017/02/13 20:17:50 Can we also declare this before initializing it?
Dan Beam 2017/02/13 20:18:50 what benefit does that have?
63
50 // <if expr="_google_chrome and not chromeos"> 64 // <if expr="_google_chrome and not chromeos">
51 var boundSetMetricsReporting = this.setMetricsReporting_.bind(this); 65 var setMetricsReportingPref = this.setMetricsReportingPref_.bind(this);
52 this.addWebUIListener('metrics-reporting-change', boundSetMetricsReporting); 66 this.addWebUIListener('metrics-reporting-change', setMetricsReportingPref);
53 67 this.browserProxy_.getMetricsReporting().then(setMetricsReportingPref);
54 var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance();
55 browserProxy.getMetricsReporting().then(boundSetMetricsReporting);
56 // </if> 68 // </if>
57 69
58 var boundSetSber = this.setSafeBrowsingExtendedReporting_.bind(this); 70 var setSber = this.setSafeBrowsingExtendedReporting_.bind(this);
59 this.addWebUIListener('safe-browsing-extended-reporting-change', 71 this.addWebUIListener('safe-browsing-extended-reporting-change', setSber);
60 boundSetSber); 72 this.browserProxy_.getSafeBrowsingExtendedReporting().then(setSber);
61 settings.PrivacyPageBrowserProxyImpl.getInstance()
62 .getSafeBrowsingExtendedReporting().then(boundSetSber);
63 }, 73 },
64 74
65 /** @protected */ 75 /** @protected */
66 currentRouteChanged: function() { 76 currentRouteChanged: function() {
67 this.showClearBrowsingDataDialog_ = 77 this.showClearBrowsingDataDialog_ =
68 settings.getCurrentRoute() == settings.Route.CLEAR_BROWSER_DATA; 78 settings.getCurrentRoute() == settings.Route.CLEAR_BROWSER_DATA;
69 }, 79 },
70 80
71 /** @private */ 81 /** @private */
72 onManageCertificatesTap_: function() { 82 onManageCertificatesTap_: function() {
73 // <if expr="use_nss_certs"> 83 // <if expr="use_nss_certs">
74 settings.navigateTo(settings.Route.CERTIFICATES); 84 settings.navigateTo(settings.Route.CERTIFICATES);
75 // </if> 85 // </if>
76 // <if expr="is_win or is_macosx"> 86 // <if expr="is_win or is_macosx">
77 settings.PrivacyPageBrowserProxyImpl.getInstance(). 87 this.browserProxy_.showManageSSLCertificates();
78 showManageSSLCertificates();
79 // </if> 88 // </if>
80 }, 89 },
81 90
82 /** 91 /**
83 * This is a workaround to connect the remove all button to the subpage. 92 * This is a workaround to connect the remove all button to the subpage.
84 * @private 93 * @private
85 */ 94 */
86 onRemoveAllCookiesFromSite_: function() { 95 onRemoveAllCookiesFromSite_: function() {
87 var node = /** @type {?SiteDataDetailsSubpageElement} */(this.$$( 96 var node = /** @type {?SiteDataDetailsSubpageElement} */(this.$$(
88 'site-data-details-subpage')); 97 'site-data-details-subpage'));
(...skipping 15 matching lines...) Expand all
104 onDialogClosed_: function() { 113 onDialogClosed_: function() {
105 settings.navigateToPreviousRoute(); 114 settings.navigateToPreviousRoute();
106 }, 115 },
107 116
108 /** @private */ 117 /** @private */
109 onHelpTap_: function() { 118 onHelpTap_: function() {
110 window.open( 119 window.open(
111 'https://support.google.com/chrome/?p=settings_manage_exceptions'); 120 'https://support.google.com/chrome/?p=settings_manage_exceptions');
112 }, 121 },
113 122
123 /** @private */
124 onSberChange_: function() {
125 var enabled = this.$.safeBrowsingExtendedReportingControl.checked;
126 this.browserProxy_.setSafeBrowsingExtendedReportingEnabled(enabled);
127 },
128
114 // <if expr="_google_chrome and not chromeos"> 129 // <if expr="_google_chrome and not chromeos">
115 /** @private */ 130 /** @private */
116 onMetricsReportingControlTap_: function() { 131 onMetricsReportingChange_: function() {
117 var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance();
118 var enabled = this.$.metricsReportingControl.checked; 132 var enabled = this.$.metricsReportingControl.checked;
119 browserProxy.setMetricsReportingEnabled(enabled); 133 this.browserProxy_.setMetricsReportingEnabled(enabled);
120 }, 134 },
121 135
122 /** 136 /**
123 * @param {!MetricsReporting} metricsReporting 137 * @param {!MetricsReporting} metricsReporting
124 * @private 138 * @private
125 */ 139 */
126 setMetricsReporting_: function(metricsReporting) { 140 setMetricsReportingPref_: function(metricsReporting) {
141 var hadPreviousPref = this.metricsReportingPref_.value !== undefined;
142 var pref = {
143 key: '',
144 type: chrome.settingsPrivate.PrefType.BOOLEAN,
145 value: metricsReporting.enabled,
146 };
147 if (metricsReporting.managed) {
148 pref.enforcement = chrome.settingsPrivate.Enforcement.ENFORCED;
149 pref.controlledBy = chrome.settingsPrivate.ControlledBy.USER_POLICY;
150 }
151
152 // Ignore the next change because it will happen when we set the pref.
153 this.metricsReportingPref_ = pref;
154
127 // TODO(dbeam): remember whether metrics reporting was enabled when Chrome 155 // TODO(dbeam): remember whether metrics reporting was enabled when Chrome
128 // started. 156 // started.
129 if (metricsReporting.managed) { 157 if (metricsReporting.managed)
130 this.showRestart_ = false; 158 this.showRestart_ = false;
131 } else if (this.metricsReporting_ && 159 else if (hadPreviousPref)
132 metricsReporting.enabled != this.metricsReporting_.enabled) {
133 this.showRestart_ = true; 160 this.showRestart_ = true;
134 }
135 this.metricsReporting_ = metricsReporting;
136 }, 161 },
137 162
138 /** @private */ 163 /**
139 onRestartTap_: function() { 164 * @param {Event} e
165 * @private
166 */
167 onRestartTap_: function(e) {
168 e.stopPropagation();
140 settings.LifetimeBrowserProxyImpl.getInstance().restart(); 169 settings.LifetimeBrowserProxyImpl.getInstance().restart();
141 }, 170 },
142 // </if> 171 // </if>
143 172
144 /** @private */ 173 /**
145 onSafeBrowsingExtendedReportingControlTap_: function() { 174 * @param {boolean} enabled Whether reporting is enabled or not.
146 var browserProxy = settings.PrivacyPageBrowserProxyImpl.getInstance(); 175 * @private
147 var enabled = this.$.safeBrowsingExtendedReportingControl.checked; 176 */
148 browserProxy.setSafeBrowsingExtendedReportingEnabled(enabled);
149 },
150
151 /** @param {boolean} enabled Whether reporting is enabled or not.
152 * @private
153 */
154 setSafeBrowsingExtendedReporting_: function(enabled) { 177 setSafeBrowsingExtendedReporting_: function(enabled) {
155 this.safeBrowsingExtendedReportingEnabled_ = enabled; 178 // Ignore the next change because it will happen when we set the pref.
179 this.safeBrowsingExtendedReportingPref_ = {
180 key: '',
181 type: chrome.settingsPrivate.PrefType.BOOLEAN,
182 value: enabled,
183 };
156 }, 184 },
157 185
158 /** 186 /**
159 * The sub-page title for the site or content settings. 187 * The sub-page title for the site or content settings.
160 * @return {string} 188 * @return {string}
161 * @private 189 * @private
162 */ 190 */
163 siteSettingsPageTitle_: function() { 191 siteSettingsPageTitle_: function() {
164 return loadTimeData.getBoolean('enableSiteSettings') ? 192 return loadTimeData.getBoolean('enableSiteSettings') ?
165 loadTimeData.getString('siteSettings') : 193 loadTimeData.getString('siteSettings') :
(...skipping 12 matching lines...) Expand all
178 * Works like a ternary operator. E.g. (value ? trueLabel: falseLabel). 206 * Works like a ternary operator. E.g. (value ? trueLabel: falseLabel).
179 * @param {boolean} value 207 * @param {boolean} value
180 * @param {string} trueLabel True label (for example, 'Allow DRM'). 208 * @param {string} trueLabel True label (for example, 'Allow DRM').
181 * @param {string} falseLabel False label (for example, 'Blocked'). 209 * @param {string} falseLabel False label (for example, 'Blocked').
182 * @private 210 * @private
183 */ 211 */
184 getStringTernary_: function(value, trueLabel, falseLabel) { 212 getStringTernary_: function(value, trueLabel, falseLabel) {
185 return value ? trueLabel : falseLabel; 213 return value ? trueLabel : falseLabel;
186 }, 214 },
187 }); 215 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698