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

Side by Side Diff: chrome/browser/resources/settings/location_page/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: Polish 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 Allowed and Blocked sites.
8 *
9 * Example:
10 *
11 * <settings-site-list
12 * category="[[category]]"
13 * categories="[[categories]]"
14 * category-subtype="[[allowOrBlock.BLOCK]]"
15 * category-subtypes="[[allowOrBlock]]>
16 * </settings-site-list>
17 * ... other pages ...
18 *
19 * @group Chrome Settings Elements
20 * @element settings-site-list
21 */
22 Polymer({
23 is: 'settings-site-list',
24
25 properties: {
26 /**
27 * Array of sites to display in the widget.
28 */
29 siteList_: {
Dan Beam 2015/10/19 07:18:06 why not sites_?
Finnur 2015/10/19 13:53:59 Yup. That works too. Done.
30 type: Array,
31 },
32
33 /**
34 * The ID of the category this widget is displaying data for.
35 * See |categories| for possible values.
36 */
37 category: {
38 type: Number,
39 },
40
41 /**
42 * An enum containing all the possible category numbers. Corresponds to
43 * the values found in the ContentSettingsType.
44 */
45 categories: {
46 type: Object,
47 },
48
49 /**
50 * The type of category this widget is displaying data for. Normally
51 * either ALLOW or BLOCK, representing which sites are allowed or blocked
52 * respectively.
53 */
54 categorySubtype: {
55 type: Number,
56 },
57
58 /**
59 * An enum containing the list of all possible category subtypes.
60 */
61 categorySubtypes: {
62 type: Object,
63 },
Dan Beam 2015/10/19 07:18:06 don't make variables names that are only separated
Finnur 2015/10/19 13:53:59 This has already been removed from the more up-to-
64
65 /**
66 * What the main toggle for the category is set to (the global default if
67 * no other policy is in effect).
68 */
69 toggleState_: {
Dan Beam 2015/10/19 07:18:06 this is a bad name why not something involving de
Finnur 2015/10/19 13:53:59 Already fixed (see previous comment, one up).
70 type: Boolean,
71 value: false,
72 },
73
74 /**
75 * The site that was selected by the user in the dropdown list.
76 */
77 selectedOrigin: {
78 type: String,
79 notify: true,
80 },
81
Dan Beam 2015/10/19 07:18:06 group by access (like in c++)
Finnur 2015/10/19 13:53:59 Moved alongside |prefs| (in the file that matters)
82 /**
83 * Whether to show the Allow action in the action menu.
84 */
85 showAllowAction_: {
86 type: Boolean,
87 },
88
89 /**
90 * Whether to show the Block action in the action menu.
91 */
92 showBlockAction_: {
93 type: Boolean,
94 },
95
96 /**
97 * The label to show for the Allow action menu item.
98 */
99 allowActionLabel_: {
100 type: String,
101 },
102
103 /**
104 * The label to show for the Block action menu item.
105 */
106 blockActionLabel_: {
107 type: String,
108 },
109
110 /**
111 * The label to show for the Reset action menu item.
112 */
113 resetActionLabel_: {
Dan Beam 2015/10/19 07:18:06 group all the labels together (and/or check out I1
Finnur 2015/10/19 13:53:59 Already fixed.
114 type: String,
115 },
116 },
117
118 ready: function() {
119 // By default we hide and only appear if there's something to show.
120 this.hidden = true;
Dan Beam 2015/10/19 07:18:06 move to the markup or CSS
Finnur 2015/10/19 13:53:59 Already fixed.
121
122 this.setupActionMenu_();
123 chrome.send('fetchContentSettingsData',
124 [this.category, this.categorySubtype == this.categorySubtypes.ALLOW]);
Dan Beam 2015/10/19 07:18:06 why are we not just sending the enum value?
Finnur 2015/10/19 13:53:59 Already removed.
125 },
126
127 attached: function() {
128 var self = this;
129 if (this.categorySubtype == this.categorySubtypes.ALLOW) {
130 cr.define('Settings', function() {
131 return {
132 receiveAllowedData: function() {
133 return self.receiveSiteList_.apply(self, arguments);
Dan Beam 2015/10/19 07:18:06 what's different?
Finnur 2015/10/19 13:53:59 Already removed.
134 },
135 };
136 });
137 } else {
138 cr.define('Settings', function() {
139 return {
140 receiveBlockedData: function() {
141 return self.receiveSiteList_.apply(self, arguments);
142 },
143 };
144 });
145 }
146 },
147
148 /**
149 * Setup the values to use for the action menu.
150 * @private
151 */
152 setupActionMenu_: function() {
153 this.showAllowAction_ = this.categorySubtype == this.categorySubtypes.BLOCK;
154 this.showBlockAction_ =
155 this.categorySubtype == this.categorySubtypes.ALLOW &&
156 this.category != this.categories.FULLSCREEN;
157
158 this.allowActionLabel_ = loadTimeData.getString('siteSettingsActionAllow');
159 this.blockActionLabel_ = loadTimeData.getString('siteSettingsActionBlock');
160 this.resetActionLabel_ = loadTimeData.getString('siteSettingsActionReset');
Dan Beam 2015/10/19 07:18:06 why is this being done here?
Finnur 2015/10/19 13:53:59 Already removed.
161 },
162
163 /**
164 * Receive the site list and the toggle state (from the native level).
165 * @param {array} siteList The list of all sites to display for this category
166 * subtype.
167 * @param {boolean} toggleState The state of the global toggle for this
168 * category.
169 * @private
170 */
171 receiveSiteList_: function(siteList, toggleState) {
172 this.siteList_ = siteList;
173 this.toggleState_ = toggleState;
174 this.hidden = !this.showSiteList_(siteList, toggleState);
175 },
176
177 /**
178 * A handler for selecting a site (by clicking on the name).
179 * @private
180 */
181 handleClick_: function(event) {
182 this.selectedOrigin = event.model.item.url;
183 },
184
185 /**
186 * A handler for activating one of the menu action items.
187 * @private
188 */
189 onActionMenuIronSelect_: function(event) {
190 // TODO(finnur): Implement.
191 },
192
193 /**
194 * Returns the appropriate header value for display.
195 * @param {array} siteList The list of all sites to display for this category
196 * subtype.
197 * @param {boolean} toggleState The state of the global toggle for this
198 * category.
199 * @private
200 */
201 computeSiteListHeader_: function(siteList, toggleState) {
202 if (this.categorySubtype == this.categorySubtypes.ALLOW) {
203 return loadTimeData.getStringF(
204 'titleAndCount',
205 loadTimeData.getString(
206 toggleState ? 'siteSettingsAllow' : 'siteSettingsExceptions'),
207 siteList.length);
208 } else {
209 return loadTimeData.getStringF(
210 'titleAndCount',
211 loadTimeData.getString('siteSettingsBlock'),
212 siteList.length);
213 }
214 },
215
216 /**
217 * Returns true if this widget is showing the allow list.
218 * @private
219 */
220 isAllowList_: function() {
221 return this.categorySubtype == this.categorySubtypes.ALLOW;
222 },
223
224 /**
225 * Returns whether to show the site list.
226 * @param {array} siteList The list of all sites to display for this category
227 * subtype.
228 * @param {boolean} toggleState The state of the global toggle for this
229 * category.
230 * @private
231 */
232 showSiteList_: function(siteList, toggleState) {
233 if (this.isAllowList_())
234 return siteList.length > 0;
235 else
236 return siteList.length > 0 && toggleState;
237 },
238
239 /**
240 * Returns the icon to use for a given site.
241 * @param {string} url The url of the site to fetch the icon for.
242 * @private
243 */
244 computeSiteIcon_: function(url) {
245 return 'communication:message'; // TODO(finnur): Implement actual favicons.
246 },
247
Dan Beam 2015/10/19 07:18:06 remove newline
Finnur 2015/10/19 13:53:59 Already removed.
248 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698