Chromium Code Reviews| Index: chrome/browser/resources/settings/site_settings/site_settings_category.js |
| diff --git a/chrome/browser/resources/settings/site_settings/site_settings_category.js b/chrome/browser/resources/settings/site_settings/site_settings_category.js |
| index 63cc5ace2c53df64ad00e0278f10d3d4eb37921d..cd13ea2f72965e044b8237983489e35685fc9aa8 100644 |
| --- a/chrome/browser/resources/settings/site_settings/site_settings_category.js |
| +++ b/chrome/browser/resources/settings/site_settings/site_settings_category.js |
| @@ -20,6 +20,14 @@ Polymer({ |
| */ |
| categoryEnabled: Boolean, |
| + /** @private */ |
| + fakePref_: { |
| + type: Object, |
| + value: function() { |
| + return {}; |
| + }, |
|
Dan Beam
2016/11/17 22:33:38
does this need an initial value?
dschuyler
2016/11/18 02:11:56
If we want to default to showing a controlled by p
|
| + }, |
| + |
| /** |
| * The site that was selected by the user in the dropdown list. |
| * @type {SiteException} |
| @@ -31,6 +39,7 @@ Polymer({ |
| /** |
| * The description to be shown next to the slider. |
| + * @private |
| */ |
| sliderDescription_: String, |
| @@ -38,6 +47,7 @@ Polymer({ |
| * Used only for the Flash to persist the Ask First checkbox state. |
| * Defaults to true, as the checkbox should be checked unless the user |
| * has explicitly unchecked it or has the ALLOW setting on Flash. |
| + * @private |
| */ |
| flashAskFirst_: { |
| type: Boolean, |
| @@ -48,6 +58,7 @@ Polymer({ |
| * Used only for Cookies to keep track of the Session Only state. |
| * Defaults to true, as the checkbox should be checked unless the user |
| * has explicitly unchecked it or has the ALLOW setting on Cookies. |
| + * @private |
| */ |
| cookiesSessionOnly_: { |
| type: Boolean, |
| @@ -133,13 +144,44 @@ Polymer({ |
| }, |
| /** |
| + * Set the fake pref value from the content settings. |
| + * @param {!ContentCategorySetting} category |
| + * @private |
| + */ |
| + setFakePref_: function(category) { |
| + // TODO(dschuyler): The concept of using fake prefs (here and elsewhere) |
| + // should be rethought. This is considered okay in a pinch, but not a great |
| + // way to get the policy controls. See http://crbug.com/666164 |
| + var pref = { |
| + 'key': 'fakeContentSettingsCategoryPref', |
| + 'type': 'BOOLEAN', |
| + // This |value| is not observed. The real values come in via |
| + // this.categoryEnabled. |
| + 'value': this.computeIsSettingEnabled(category.setting), |
| + }; |
| + if (category.source != PolicySource.DEFAULT && |
| + category.source != PolicySource.PREFERENCE) { |
| + pref.enforcement = chrome.settingsPrivate.Enforcement.ENFORCED; |
| + if (category.source == PolicySource.EXTENSION) |
| + pref.controlledBy = chrome.settingsPrivate.ControlledBy.EXTENSION; |
| + else |
| + pref.controlledBy = chrome.settingsPrivate.ControlledBy.USER_POLICY; |
|
Dan Beam
2016/11/17 22:33:38
nit: ternary, maybe?
pref.controlledBy = category
dschuyler
2016/11/18 02:11:56
Done.
|
| + } |
| + // The fakePref_ must be replaced (rather than just value changs) so that |
| + // observers will be notified of the change. |
| + this.fakePref_ = pref; |
| + }, |
| + |
| + /** |
| * Handles changes to the category pref and the |category| member variable. |
| * @private |
| */ |
| onCategoryChanged_: function() { |
| settings.SiteSettingsPrefsBrowserProxyImpl.getInstance() |
| .getDefaultValueForContentType( |
| - this.category).then(function(setting) { |
| + this.category).then(function(categorySetting) { |
| + this.setFakePref_(categorySetting); |
| + var setting = categorySetting.setting; |
| this.categoryEnabled = this.computeIsSettingEnabled(setting); |
| // Flash only shows ALLOW or BLOCK descriptions on the slider. |