| 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..69522d3cbe1b55f37e43e23c00ce85582cb2ab92 | 
| --- /dev/null | 
| +++ b/chrome/browser/resources/settings/site_settings/site_settings_category.js | 
| @@ -0,0 +1,139 @@ | 
| +// 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. | 
| +     */ | 
| +    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; | 
| + | 
| +    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); | 
| +  }, | 
| +}); | 
|  |