Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: chrome/browser/resources/settings/site_settings/site_list.js

Issue 1372053002: Flesh out the location-page class to make it more general. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback: CLs 4 through 7 (inclusive) Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview
7 * 'settings-site-list' is the widget that shows a list of Allowed and
8 * Blocked sites.
9 *
10 * Example:
11 * <settings-site-list prefs="{{prefs}}"
12 * category="[[category]]">
13 * </settings-site-list>
14 *
15 * @group Chrome Settings Elements
16 * @element settings-site-list
17 */
18 Polymer({
19 is: 'settings-site-list',
20 behaviors: [SiteSettingsBehavior],
21
22 properties: {
23 /**
24 * Preferences state.
25 */
26 prefs: {
27 type: Object,
28 notify: true,
29 },
30
31 /**
32 * Array of sites to display in the widget.
33 */
34 siteList_: {
35 type: Array,
36 value: [],
37 },
38
39 /**
40 * The ID of the category this widget is displaying data for.
41 * See |categories| for possible values.
42 */
43 category: {
44 type: Number,
45 },
46
47 /**
48 * The type of category this widget is displaying data for. Normally
49 * either ALLOW or BLOCK, representing which sites are allowed or blocked
50 * respectively.
51 */
52 categorySubtype: {
53 type: Number,
54 },
55
56 /**
57 * Represents the state of the main toggle shown for the category. For
58 * example, the Location category can be set to Block/Ask so false, in that
59 * case, represents Block and true represents Ask.
60 */
61 categoryEnabled: {
62 type: Boolean,
63 },
64
65 /**
66 * The site that was selected by the user in the dropdown list.
67 */
68 selectedOrigin: {
69 type: String,
70 notify: true,
71 },
72
73 /**
74 * Whether to show the Allow action in the action menu.
75 */
76 showAllowAction_: {
77 type: Boolean,
78 },
79
80 /**
81 * Whether to show the Block action in the action menu.
82 */
83 showBlockAction_: {
84 type: Boolean,
85 },
86
87 i18n_: {
88 readOnly: true,
89 type: Object,
90 value: function() {
91 return {
92 allowAction: loadTimeData.getString('siteSettingsActionAllow'),
93 blockAction: loadTimeData.getString('siteSettingsActionBlock'),
94 resetAction: loadTimeData.getString('siteSettingsActionReset'),
95 };
96 },
97 },
98 },
99
100 ready: function() {
101 CrSettingsPrefs.initialized.then(function() {
102 this.categoryEnabled = this.isPrefEnabled_(this.category);
103
Finnur 2015/10/15 15:46:34 If you are interested in testing this locally, add
104 this.setupActionMenu_();
105 this.$.category.hidden =
106 !this.showSiteList_(this.siteList_, this.categoryEnabled);
107 }.bind(this));
108 },
109
110 /**
111 * Setup the values to use for the action menu.
112 * @private
113 */
114 setupActionMenu_: function() {
115 this.showAllowAction_ =
116 this.categorySubtype == siteSettings.DefaultValues.BLOCK;
117 this.showBlockAction_ =
118 this.categorySubtype == siteSettings.DefaultValues.ALLOW &&
119 this.category != siteSettings.ContentSettingsTypes.FULLSCREEN;
120 },
121
122 /**
123 * A handler for selecting a site (by clicking on the origin).
124 * @private
125 */
126 onOriginClick_: function(event) {
127 this.selectedOrigin = event.model.item.url;
128 },
129
130 /**
131 * A handler for activating one of the menu action items.
132 * @private
133 */
134 onActionMenuIronSelect_: function(event) {
135 // TODO(finnur): Implement.
136 },
137
138 /**
139 * Returns the appropriate header value for display.
140 * @param {array<string>} siteList The list of all sites to display for this
141 * category subtype.
142 * @param {boolean} toggleState The state of the global toggle for this
143 * category.
144 * @private
145 */
146 computeSiteListHeader_: function(siteList, toggleState) {
147 if (this.categorySubtype == siteSettings.DefaultValues.ALLOW) {
148 return loadTimeData.getStringF(
149 'titleAndCount',
150 loadTimeData.getString(
151 toggleState ? 'siteSettingsAllow' : 'siteSettingsExceptions'),
152 siteList.length);
153 } else {
154 return loadTimeData.getStringF(
155 'titleAndCount',
156 loadTimeData.getString('siteSettingsBlock'),
157 siteList.length);
158 }
159 },
160
161 /**
162 * Returns true if this widget is showing the allow list.
163 * @private
164 */
165 isAllowList_: function() {
166 return this.categorySubtype == siteSettings.DefaultValues.ALLOW;
167 },
168
169 /**
170 * Returns whether to show the site list.
171 * @param {array} siteList The list of all sites to display for this category
172 * subtype.
173 * @param {boolean} toggleState The state of the global toggle for this
174 * category.
175 * @private
176 */
177 showSiteList_: function(siteList, toggleState) {
178 if (this.isAllowList_()) {
179 return siteList.length > 0;
180 } else {
181 return siteList.length > 0 && toggleState;
182 }
183 },
184
185 /**
186 * Returns the icon to use for a given site.
187 * @param {string} url The url of the site to fetch the icon for.
188 * @private
189 */
190 computeSiteIcon_: function(url) {
191 return 'communication:message'; // TODO(finnur): Implement actual favicons.
192 },
193 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698