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