| Index: chrome/browser/resources/settings/location_page/site_list.js
|
| diff --git a/chrome/browser/resources/settings/location_page/site_list.js b/chrome/browser/resources/settings/location_page/site_list.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..873e77fe8a23bce68ea29ac3569d40fccebc94a5
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/settings/location_page/site_list.js
|
| @@ -0,0 +1,248 @@
|
| +// 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
|
| + * 'settings-site-list' is the widget that shows Allowed and Blocked sites.
|
| + *
|
| + * Example:
|
| + *
|
| + * <settings-site-list
|
| + * category="[[category]]"
|
| + * categories="[[categories]]"
|
| + * category-subtype="[[allowOrBlock.BLOCK]]"
|
| + * category-subtypes="[[allowOrBlock]]>
|
| + * </settings-site-list>
|
| + * ... other pages ...
|
| + *
|
| + * @group Chrome Settings Elements
|
| + * @element settings-site-list
|
| + */
|
| +Polymer({
|
| + is: 'settings-site-list',
|
| +
|
| + properties: {
|
| + /**
|
| + * Array of sites to display in the widget.
|
| + */
|
| + siteList_: {
|
| + type: Array,
|
| + },
|
| +
|
| + /**
|
| + * The ID of the category this widget is displaying data for.
|
| + * See |categories| for possible values.
|
| + */
|
| + category: {
|
| + type: Number,
|
| + },
|
| +
|
| + /**
|
| + * An enum containing all the possible category numbers. Corresponds to
|
| + * the values found in the ContentSettingsType.
|
| + */
|
| + categories: {
|
| + type: Object,
|
| + },
|
| +
|
| + /**
|
| + * The type of category this widget is displaying data for. Normally
|
| + * either ALLOW or BLOCK, representing which sites are allowed or blocked
|
| + * respectively.
|
| + */
|
| + categorySubtype: {
|
| + type: Number,
|
| + },
|
| +
|
| + /**
|
| + * An enum containing the list of all possible category subtypes.
|
| + */
|
| + categorySubtypes: {
|
| + type: Object,
|
| + },
|
| +
|
| + /**
|
| + * What the main toggle for the category is set to (the global default if
|
| + * no other policy is in effect).
|
| + */
|
| + toggleState_: {
|
| + type: Boolean,
|
| + value: false,
|
| + },
|
| +
|
| + /**
|
| + * The site that was selected by the user in the dropdown list.
|
| + */
|
| + selectedOrigin: {
|
| + type: String,
|
| + notify: true,
|
| + },
|
| +
|
| + /**
|
| + * Whether to show the Allow action in the action menu.
|
| + */
|
| + showAllowAction_: {
|
| + type: Boolean,
|
| + },
|
| +
|
| + /**
|
| + * Whether to show the Block action in the action menu.
|
| + */
|
| + showBlockAction_: {
|
| + type: Boolean,
|
| + },
|
| +
|
| + /**
|
| + * The label to show for the Allow action menu item.
|
| + */
|
| + allowActionLabel_: {
|
| + type: String,
|
| + },
|
| +
|
| + /**
|
| + * The label to show for the Block action menu item.
|
| + */
|
| + blockActionLabel_: {
|
| + type: String,
|
| + },
|
| +
|
| + /**
|
| + * The label to show for the Reset action menu item.
|
| + */
|
| + resetActionLabel_: {
|
| + type: String,
|
| + },
|
| + },
|
| +
|
| + ready: function() {
|
| + // By default we hide and only appear if there's something to show.
|
| + this.hidden = true;
|
| +
|
| + this.setupActionMenu_();
|
| + chrome.send('fetchContentSettingsData',
|
| + [this.category, this.categorySubtype == this.categorySubtypes.ALLOW]);
|
| + },
|
| +
|
| + attached: function() {
|
| + var self = this;
|
| + if (this.categorySubtype == this.categorySubtypes.ALLOW) {
|
| + cr.define('Settings', function() {
|
| + return {
|
| + receiveAllowedData: function() {
|
| + return self.receiveSiteList_.apply(self, arguments);
|
| + },
|
| + };
|
| + });
|
| + } else {
|
| + cr.define('Settings', function() {
|
| + return {
|
| + receiveBlockedData: function() {
|
| + return self.receiveSiteList_.apply(self, arguments);
|
| + },
|
| + };
|
| + });
|
| + }
|
| + },
|
| +
|
| + /**
|
| + * Setup the values to use for the action menu.
|
| + * @private
|
| + */
|
| + setupActionMenu_: function() {
|
| + this.showAllowAction_ = this.categorySubtype == this.categorySubtypes.BLOCK;
|
| + this.showBlockAction_ =
|
| + this.categorySubtype == this.categorySubtypes.ALLOW &&
|
| + this.category != this.categories.FULLSCREEN;
|
| +
|
| + this.allowActionLabel_ = loadTimeData.getString('siteSettingsActionAllow');
|
| + this.blockActionLabel_ = loadTimeData.getString('siteSettingsActionBlock');
|
| + this.resetActionLabel_ = loadTimeData.getString('siteSettingsActionReset');
|
| + },
|
| +
|
| + /**
|
| + * Receive the site list and the toggle state (from the native level).
|
| + * @param {array} siteList The list of all sites to display for this category
|
| + * subtype.
|
| + * @param {boolean} toggleState The state of the global toggle for this
|
| + * category.
|
| + * @private
|
| + */
|
| + receiveSiteList_: function(siteList, toggleState) {
|
| + this.siteList_ = siteList;
|
| + this.toggleState_ = toggleState;
|
| + this.hidden = !this.showSiteList_(siteList, toggleState);
|
| + },
|
| +
|
| + /**
|
| + * A handler for selecting a site (by clicking on the name).
|
| + * @private
|
| + */
|
| + handleClick_: function(event) {
|
| + this.selectedOrigin = event.model.item.url;
|
| + },
|
| +
|
| + /**
|
| + * A handler for activating one of the menu action items.
|
| + * @private
|
| + */
|
| + onActionMenuIronSelect_: function(event) {
|
| + // TODO(finnur): Implement.
|
| + },
|
| +
|
| + /**
|
| + * Returns the appropriate header value for display.
|
| + * @param {array} siteList The list of all sites to display for this category
|
| + * subtype.
|
| + * @param {boolean} toggleState The state of the global toggle for this
|
| + * category.
|
| + * @private
|
| + */
|
| + computeSiteListHeader_: function(siteList, toggleState) {
|
| + if (this.categorySubtype == this.categorySubtypes.ALLOW) {
|
| + return loadTimeData.getStringF(
|
| + 'titleAndCount',
|
| + loadTimeData.getString(
|
| + toggleState ? 'siteSettingsAllow' : 'siteSettingsExceptions'),
|
| + siteList.length);
|
| + } else {
|
| + return loadTimeData.getStringF(
|
| + 'titleAndCount',
|
| + loadTimeData.getString('siteSettingsBlock'),
|
| + siteList.length);
|
| + }
|
| + },
|
| +
|
| + /**
|
| + * Returns true if this widget is showing the allow list.
|
| + * @private
|
| + */
|
| + isAllowList_: function() {
|
| + return this.categorySubtype == this.categorySubtypes.ALLOW;
|
| + },
|
| +
|
| + /**
|
| + * Returns whether to show the site list.
|
| + * @param {array} siteList The list of all sites to display for this category
|
| + * subtype.
|
| + * @param {boolean} toggleState The state of the global toggle for this
|
| + * category.
|
| + * @private
|
| + */
|
| + showSiteList_: function(siteList, toggleState) {
|
| + if (this.isAllowList_())
|
| + return siteList.length > 0;
|
| + else
|
| + return siteList.length > 0 && toggleState;
|
| + },
|
| +
|
| + /**
|
| + * Returns the icon to use for a given site.
|
| + * @param {string} url The url of the site to fetch the icon for.
|
| + * @private
|
| + */
|
| + computeSiteIcon_: function(url) {
|
| + return 'communication:message'; // TODO(finnur): Implement actual favicons.
|
| + },
|
| +
|
| +});
|
|
|