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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a0678965c2d68fc8f9ebdf643bfeaa0ede006c2e |
| --- /dev/null |
| +++ b/chrome/browser/resources/settings/site_settings/site_settings_category.js |
| @@ -0,0 +1,140 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * @fileoverview |
| + * 'cr-site-settings-category' is the settings page for showing a certain |
| + * category under Site Settings. |
| + * |
| + * Example: |
| + * |
| + * <cr-site-settings-category prefs="{{prefs}}"> |
| + * </cr-site-settings-category> |
| + * ... other pages ... |
| + * |
| + * @group Chrome Settings Elements |
| + * @element cr-site-settings-category |
| + */ |
| +Polymer({ |
| + is: 'cr-site-settings-category', |
| + behaviors: [SiteSettingsBehavior], |
| + |
| + properties: { |
| + /** |
| + * Preferences state. |
| + */ |
| + prefs: { |
| + type: Object, |
| + notify: true, |
| + }, |
| + |
| + /** |
| + * Route for the page. |
| + */ |
| + route: String, |
| + |
| + /** |
| + * Whether the page is a subpage. |
| + */ |
| + subpage: { |
| + type: Boolean, |
| + value: true, |
| + readOnly: true, |
| + }, |
| + |
| + /** |
| + * ID of the page. |
| + */ |
| + PAGE_ID: { |
| + type: String, |
| + value: 'location', |
| + readOnly: true, |
| + }, |
| + |
| + /** |
| + * Title for the page header and navigation menu. |
| + */ |
| + pageTitle: { |
| + type: String, |
| + value: '', |
| + }, |
| + |
| + /** |
| + * Represents the state of the main toggle shown for the category. For |
| + * example, the Location category can be set to Block/Ask so false, in that |
| + * case, represents Block and true represents Ask. |
| + */ |
| + categoryEnabled: { |
| + type: Boolean, |
| + }, |
| + |
| + /** |
| + * The ID of the category this widget is displaying data for. |
| + * See |categories| for possible values. |
| + */ |
| + category: { |
| + type: Number, |
| + }, |
| + }, |
| + |
| + observers: [ |
| + 'categoryPrefChanged_(prefs.profile.default_content_setting_values.*)', |
| + ], |
| + |
| + ready: function() { |
| + this.$.blockList.categorySubtype = siteSettings.DefaultValues.BLOCK; |
| + this.$.allowList.categorySubtype = siteSettings.DefaultValues.ALLOW; |
|
Finnur
2015/10/15 15:46:34
If there's a way to use the consts in html, then t
Dan Beam
2015/10/19 07:24:27
I can see the benefit of this, though I'm not sure
Finnur
2015/10/19 13:53:58
Much appreciated. Look forward to hearing their an
|
| + |
| + CrSettingsPrefs.initialized.then(function() { |
| + this.categoryEnabled = this.isPrefEnabled_(this.category); |
| + }.bind(this)); |
| + }, |
| + |
| + /** |
| + * A handler for flipping the toggle value. |
| + * @private |
| + */ |
| + onToggleChange_: function(event) { |
| + assert(CrSettingsPrefs.isInitialized); |
| + |
| + switch (this.category) { |
| + case siteSettings.ContentSettingsTypes.COOKIES: |
| + case siteSettings.ContentSettingsTypes.JAVASCRIPT: |
| + case siteSettings.ContentSettingsTypes.POPUPS: |
| + // "Allowed" vs "Blocked". |
| + this.setPrefValue_(this.computePrefName_(this.category), |
| + this.categoryEnabled ? |
| + siteSettings.DefaultValues.ALLOW : |
| + siteSettings.DefaultValues.BLOCK); |
| + break; |
| + case siteSettings.ContentSettingsTypes.NOTIFICATION: |
| + case siteSettings.ContentSettingsTypes.GEOLOCATION: |
| + case siteSettings.ContentSettingsTypes.CAMERA: |
| + case siteSettings.ContentSettingsTypes.MIC: |
| + // "Ask" vs "Blocked". |
| + this.setPrefValue_(this.computePrefName_(this.category), |
| + this.categoryEnabled ? |
| + siteSettings.DefaultValues.ASK : |
| + siteSettings.DefaultValues.BLOCK); |
| + break; |
| + case siteSettings.ContentSettingsTypes.FULLSCREEN: |
| + // "Allowed" vs. "Ask first". |
| + this.setPrefValue_(this.computePrefName_(this.category), |
| + this.categoryEnabled ? |
| + siteSettings.DefaultValues.ALLOW : |
| + siteSettings.DefaultValues.ASK); |
| + break; |
| + default: |
| + assertNotReached(); |
| + } |
| + }, |
| + |
| + /** |
| + * Handles when the global toggle changes. |
| + * @private |
| + */ |
| + categoryPrefChanged_: function() { |
| + this.categoryEnabled = this.isPrefEnabled_(this.category); |
| + }, |
| +}); |