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

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

Issue 1882793002: Site Settings: Use only string values for permissions on the JS side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 8 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'settings-site-list' shows a list of Allowed and Blocked sites for a given 7 * 'settings-site-list' shows a list of Allowed and Blocked sites for a given
8 * category. 8 * category.
9 */ 9 */
10 Polymer({ 10 Polymer({
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 /** 43 /**
44 * Whether this list is for the All Sites category. 44 * Whether this list is for the All Sites category.
45 */ 45 */
46 allSites: { 46 allSites: {
47 type: Boolean, 47 type: Boolean,
48 value: false, 48 value: false,
49 }, 49 },
50 50
51 /** 51 /**
52 * The type of category this widget is displaying data for. Normally 52 * The type of category this widget is displaying data for. Normally
53 * either ALLOW or BLOCK, representing which sites are allowed or blocked 53 * either 'allow' or 'block', representing which sites are allowed or
54 * respectively. 54 * blocked respectively.
55 */ 55 */
56 categorySubtype: { 56 categorySubtype: {
57 type: Number, 57 type: String,
58 value: settings.INVALID_CATEGORY_SUBTYPE, 58 value: settings.INVALID_CATEGORY_SUBTYPE,
59 }, 59 },
60 60
61 /** 61 /**
62 * Represents the state of the main toggle shown for the category. For 62 * Represents the state of the main toggle shown for the category. For
63 * example, the Location category can be set to Block/Ask so false, in that 63 * example, the Location category can be set to Block/Ask so false, in that
64 * case, represents Block and true represents Ask. 64 * case, represents Block and true represents Ask.
65 */ 65 */
66 categoryEnabled: { 66 categoryEnabled: {
67 type: Boolean, 67 type: Boolean,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 this.$.category.opened = true; 153 this.$.category.opened = true;
154 return; 154 return;
155 } 155 }
156 156
157 // Block list should only be shown opened if there is nothing to show in 157 // Block list should only be shown opened if there is nothing to show in
158 // the allowed list. 158 // the allowed list.
159 if (this.category != settings.INVALID_CATEGORY_SUBTYPE) { 159 if (this.category != settings.INVALID_CATEGORY_SUBTYPE) {
160 this.browserProxy_.getExceptionList(this.category).then( 160 this.browserProxy_.getExceptionList(this.category).then(
161 function(exceptionList) { 161 function(exceptionList) {
162 var allowExists = exceptionList.some(function(exception) { 162 var allowExists = exceptionList.some(function(exception) {
163 return exception.setting == settings.PermissionStringValues.ALLOW; 163 return exception.setting == settings.PermissionValues.ALLOW;
164 }); 164 });
165 if (allowExists) 165 if (allowExists)
166 return; 166 return;
167 this.$.category.opened = true; 167 this.$.category.opened = true;
168 }.bind(this)); 168 }.bind(this));
169 } else { 169 } else {
170 this.$.category.opened = true; 170 this.$.category.opened = true;
171 } 171 }
172 }, 172 },
173 173
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 * Appends to |list| the sites for a given category and subtype. 243 * Appends to |list| the sites for a given category and subtype.
244 * @param {!Array<SiteException>} sites The site list to add to. 244 * @param {!Array<SiteException>} sites The site list to add to.
245 * @param {!Array<SiteException>} exceptionList List of sites (exceptions) to 245 * @param {!Array<SiteException>} exceptionList List of sites (exceptions) to
246 * add. 246 * add.
247 * @return {!Array<SiteException>} The list of sites. 247 * @return {!Array<SiteException>} The list of sites.
248 * @private 248 * @private
249 */ 249 */
250 appendSiteList_: function(sites, exceptionList) { 250 appendSiteList_: function(sites, exceptionList) {
251 for (var i = 0; i < exceptionList.length; ++i) { 251 for (var i = 0; i < exceptionList.length; ++i) {
252 if (this.category != settings.ALL_SITES) { 252 if (this.category != settings.ALL_SITES) {
253 if (exceptionList[i].setting == settings.PermissionValues.DEFAULT)
254 continue;
255
253 // Filter out 'Block' values if this list is handling 'Allow' items. 256 // Filter out 'Block' values if this list is handling 'Allow' items.
254 if (exceptionList[i].setting == settings.PermissionStringValues.BLOCK && 257 if (exceptionList[i].setting == settings.PermissionValues.BLOCK &&
255 this.categorySubtype != settings.PermissionValues.BLOCK) { 258 this.categorySubtype != settings.PermissionValues.BLOCK) {
256 continue; 259 continue;
257 } 260 }
258 // Filter out 'Allow' values if this list is handling 'Block' items. 261 // Filter out 'Allow' values if this list is handling 'Block' items.
259 if (exceptionList[i].setting == settings.PermissionStringValues.ALLOW && 262 if (exceptionList[i].setting == settings.PermissionValues.ALLOW &&
260 this.categorySubtype != settings.PermissionValues.ALLOW) { 263 this.categorySubtype != settings.PermissionValues.ALLOW) {
261 continue; 264 continue;
262 } 265 }
263 } 266 }
264 267
265 sites.push(exceptionList[i]); 268 sites.push(exceptionList[i]);
266 } 269 }
267 return sites; 270 return sites;
268 }, 271 },
269 272
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 } 312 }
310 } 313 }
311 } 314 }
312 return comparison; 315 return comparison;
313 }); 316 });
314 var results = []; 317 var results = [];
315 var lastOrigin = ''; 318 var lastOrigin = '';
316 var lastEmbeddingOrigin = ''; 319 var lastEmbeddingOrigin = '';
317 for (var i = 0; i < sites.length; ++i) { 320 for (var i = 0; i < sites.length; ++i) {
318 var origin = sites[i].origin; 321 var origin = sites[i].origin;
322 var originForDisplay = origin.replace('[*.]', '');
323
319 var embeddingOrigin = sites[i].embeddingOrigin; 324 var embeddingOrigin = sites[i].embeddingOrigin;
320 325 if (this.category == settings.ContentSettingsTypes.GEOLOCATION) {
321 var originForDisplay = origin.replace('[*.]', ''); 326 if (embeddingOrigin == '')
327 embeddingOrigin = '*';
328 }
322 var embeddingOriginForDisplay = ''; 329 var embeddingOriginForDisplay = '';
323 if (embeddingOrigin != '*' && origin != embeddingOrigin) 330 if (embeddingOrigin != '' && origin != embeddingOrigin) {
324 embeddingOriginForDisplay = embeddingOrigin; 331 embeddingOriginForDisplay =
332 loadTimeData.getStringF('embeddedOnHost', embeddingOrigin);
333 }
325 334
326 // The All Sites category can contain duplicates (from other categories). 335 // The All Sites category can contain duplicates (from other categories).
327 if (originForDisplay == lastOrigin && 336 if (originForDisplay == lastOrigin &&
328 embeddingOriginForDisplay == lastEmbeddingOrigin) { 337 embeddingOriginForDisplay == lastEmbeddingOrigin) {
329 continue; 338 continue;
330 } 339 }
331 340
332 results.push({ 341 results.push({
333 origin: origin, 342 origin: origin,
334 originForDisplay: originForDisplay, 343 originForDisplay: originForDisplay,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 var embeddingOrigin = event.model.item.embeddingOrigin; 391 var embeddingOrigin = event.model.item.embeddingOrigin;
383 var action = event.detail.item.textContent; 392 var action = event.detail.item.textContent;
384 if (action == this.i18n_.resetAction) { 393 if (action == this.i18n_.resetAction) {
385 this.resetCategoryPermissionForOrigin( 394 this.resetCategoryPermissionForOrigin(
386 origin, embeddingOrigin, this.category); 395 origin, embeddingOrigin, this.category);
387 } else { 396 } else {
388 var value = (action == this.i18n_.allowAction) ? 397 var value = (action == this.i18n_.allowAction) ?
389 settings.PermissionValues.ALLOW : 398 settings.PermissionValues.ALLOW :
390 settings.PermissionValues.BLOCK; 399 settings.PermissionValues.BLOCK;
391 this.setCategoryPermissionForOrigin( 400 this.setCategoryPermissionForOrigin(
392 origin, embeddingOrigin, value, this.category); 401 origin, embeddingOrigin, this.category, value);
393 } 402 }
394 }, 403 },
395 404
396 /** 405 /**
397 * Returns the appropriate header value for display. 406 * Returns the appropriate header value for display.
398 * @param {Array<string>} siteList The list of all sites to display for this 407 * @param {Array<string>} siteList The list of all sites to display for this
399 * category subtype. 408 * category subtype.
400 * @param {boolean} toggleState The state of the global toggle for this 409 * @param {boolean} toggleState The state of the global toggle for this
401 * category. 410 * category.
402 * @private 411 * @private
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 * Returns the icon to use for a given site. 457 * Returns the icon to use for a given site.
449 * @param {string} url The url of the site to fetch the icon for. 458 * @param {string} url The url of the site to fetch the icon for.
450 * @private 459 * @private
451 */ 460 */
452 computeSiteIcon_: function(url) { 461 computeSiteIcon_: function(url) {
453 // TODO(finnur): For now, we're returning a placeholder image for each site 462 // TODO(finnur): For now, we're returning a placeholder image for each site
454 // but the actual favicon for each site will need to be returned. 463 // but the actual favicon for each site will need to be returned.
455 return 'communication:message'; 464 return 'communication:message';
456 }, 465 },
457 }); 466 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698