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

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

Issue 2468363005: [MD settings] show blocked sites even when category is blocked (Closed)
Patch Set: fixes Created 4 years, 1 month 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 * Enumeration mapping all possible controlled-by values for exceptions to 6 * Enumeration mapping all possible controlled-by values for exceptions to
7 * icons. 7 * icons.
8 * @enum {string} 8 * @enum {string}
9 */ 9 */
10 var iconControlledBy = { 10 var iconControlledBy = {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 configureWidget_: function() { 169 configureWidget_: function() {
170 // The observer for All Sites fires before the attached/ready event, so 170 // The observer for All Sites fires before the attached/ready event, so
171 // initialize this here. 171 // initialize this here.
172 if (this.browserProxy_ === undefined) { 172 if (this.browserProxy_ === undefined) {
173 this.browserProxy_ = 173 this.browserProxy_ =
174 settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); 174 settings.SiteSettingsPrefsBrowserProxyImpl.getInstance();
175 } 175 }
176 176
177 this.setUpActionMenu_(); 177 this.setUpActionMenu_();
178 this.populateList_(); 178 this.populateList_();
179
180 // The Session permissions are only for cookies.
181 if (this.categorySubtype == settings.PermissionValues.SESSION_ONLY) {
182 this.$.category.hidden =
dpapad 2016/11/07 21:59:35 Could this be done with a data binding that depend
dschuyler 2016/11/07 23:54:04 There is a binding style handler setup on line 130
183 this.category != settings.ContentSettingsTypes.COOKIES;
184 }
179 }, 185 },
180 186
181 /** 187 /**
182 * Returns which icon, if any, should represent the fact that this exception 188 * Returns which icon, if any, should represent the fact that this exception
183 * is controlled. 189 * is controlled.
184 * @param {!SiteException} item The item from the list we're computing the 190 * @param {!SiteException} item The item from the list we're computing the
185 * icon for. 191 * icon for.
186 * @return {string} The icon to show (or blank, if none). 192 * @return {string} The icon to show (or blank, if none).
187 */ 193 */
188 computeIconControlledBy_: function(item) { 194 computeIconControlledBy_: function(item) {
189 if (this.allSites) 195 if (this.allSites)
190 return ''; 196 return '';
191 return iconControlledBy[item.source] || ''; 197 return iconControlledBy[item.source] || '';
192 }, 198 },
193 199
194 /** 200 /**
195 * @param {string} source Where the setting came from. 201 * @param {string} source Where the setting came from.
196 * @return {boolean} 202 * @return {boolean}
197 * @private 203 * @private
198 */ 204 */
199 shouldShowMenu_: function(source) { 205 shouldShowMenu_: function(source) {
200 return !(this.isExceptionControlled_(source) || this.allSites); 206 return !(this.isExceptionControlled_(source) || this.allSites);
201 }, 207 },
202 208
203 /** 209 /**
204 * Makes sure the visibility is correct for this widget.
205 * @private
206 */
207 updateCategoryVisibility_: function() {
208 this.$.category.hidden =
209 !this.showSiteList_(this.sites, this.categoryEnabled);
210 },
211
212 /**
213 * A handler for the Add Site button. 210 * A handler for the Add Site button.
214 * @private 211 * @private
215 */ 212 */
216 onAddSiteTap_: function() { 213 onAddSiteTap_: function() {
217 var dialog = document.createElement('add-site-dialog'); 214 var dialog = document.createElement('add-site-dialog');
dpapad 2016/11/07 21:59:35 Nit (optional): This function could be simplified
dschuyler 2016/11/07 23:54:04 Going by advice I got while visiting the Polymer f
dpapad 2016/11/08 00:12:32 SG. I would be positively surprised if the compil
218 dialog.category = this.category; 215 dialog.category = this.category;
216 dialog.contentSetting = this.categorySubtype;
219 this.shadowRoot.appendChild(dialog); 217 this.shadowRoot.appendChild(dialog);
220 218
221 dialog.open(this.categorySubtype); 219 dialog.open(this.categorySubtype);
222 220
223 dialog.addEventListener('close', function() { 221 dialog.addEventListener('close', function() {
224 dialog.remove(); 222 dialog.remove();
225 }); 223 });
226 }, 224 },
227 225
228 /** 226 /**
(...skipping 17 matching lines...) Expand all
246 * Process the exception list returned from the native layer. 244 * Process the exception list returned from the native layer.
247 * @param {!Array<!Array<SiteException>>} data List of sites (exceptions) to 245 * @param {!Array<!Array<SiteException>>} data List of sites (exceptions) to
248 * process. 246 * process.
249 * @private 247 * @private
250 */ 248 */
251 processExceptions_: function(data) { 249 processExceptions_: function(data) {
252 var sites = []; 250 var sites = [];
253 for (var i = 0; i < data.length; ++i) 251 for (var i = 0; i < data.length; ++i)
254 sites = this.appendSiteList_(sites, data[i]); 252 sites = this.appendSiteList_(sites, data[i]);
255 this.sites = this.toSiteArray_(sites); 253 this.sites = this.toSiteArray_(sites);
256 this.updateCategoryVisibility_();
257 }, 254 },
258 255
259 /** 256 /**
260 * Retrieves a list of all known sites (any category/setting). 257 * Retrieves a list of all known sites (any category/setting).
261 * @return {!Promise} 258 * @return {!Promise}
262 * @private 259 * @private
263 */ 260 */
264 getAllSitesList_: function() { 261 getAllSitesList_: function() {
265 var promiseList = []; 262 var promiseList = [];
266 for (var type in settings.ContentSettingsTypes) { 263 for (var type in settings.ContentSettingsTypes) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 345 }
349 346
350 results.push(siteException); 347 results.push(siteException);
351 lastOrigin = siteException.originForDisplay; 348 lastOrigin = siteException.originForDisplay;
352 lastEmbeddingOrigin = siteException.embeddingOriginForDisplay; 349 lastEmbeddingOrigin = siteException.embeddingOriginForDisplay;
353 } 350 }
354 return results; 351 return results;
355 }, 352 },
356 353
357 /** 354 /**
358 * Setup the values to use for the action menu. 355 * Set up the values to use for the action menu.
359 * @private 356 * @private
360 */ 357 */
361 setUpActionMenu_: function() { 358 setUpActionMenu_: function() {
362 this.showAllowAction_ = 359 this.showAllowAction_ =
363 this.categorySubtype != settings.PermissionValues.ALLOW; 360 this.categorySubtype != settings.PermissionValues.ALLOW;
364 this.showBlockAction_ = 361 this.showBlockAction_ =
365 this.categorySubtype != settings.PermissionValues.BLOCK; 362 this.categorySubtype != settings.PermissionValues.BLOCK;
366 this.showSessionOnlyAction_ = 363 this.showSessionOnlyAction_ =
367 this.categorySubtype != settings.PermissionValues.SESSION_ONLY && 364 this.categorySubtype != settings.PermissionValues.SESSION_ONLY &&
368 this.category == settings.ContentSettingsTypes.COOKIES; 365 this.category == settings.ContentSettingsTypes.COOKIES;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 return loadTimeData.getStringF('embeddedIncognitoSite', 448 return loadTimeData.getStringF('embeddedIncognitoSite',
452 item.embeddingOriginForDisplay); 449 item.embeddingOriginForDisplay);
453 } 450 }
454 451
455 if (item.incognito) 452 if (item.incognito)
456 return loadTimeData.getString('incognitoSite'); 453 return loadTimeData.getString('incognitoSite');
457 return item.embeddingOriginForDisplay; 454 return item.embeddingOriginForDisplay;
458 }, 455 },
459 456
460 /** 457 /**
461 * Returns true if this widget is showing the Allow list.
462 * @private
463 */
464 isAllowList_: function() {
465 return this.categorySubtype == settings.PermissionValues.ALLOW;
466 },
467
468 /**
469 * Returns true if this widget is showing the Session Only list.
470 * @private
471 */
472 isSessionOnlyList_: function() {
473 return this.categorySubtype == settings.PermissionValues.SESSION_ONLY;
474 },
475
476 /**
477 * Returns whether to show the site list.
478 * @param {Array} siteList The list of all sites to display for this category
479 * subtype.
480 * @param {boolean} toggleState The state of the global toggle for this
481 * category.
482 * @private
483 */
484 showSiteList_: function(siteList, toggleState) {
485 // The Block list is only shown when the category is set to Allow since it
486 // is redundant to also list all the sites that are blocked.
487 if (this.isAllowList_())
488 return true;
489
490 if (this.isSessionOnlyList_())
491 return siteList.length > 0;
492
493 return toggleState;
494 },
495
496 /**
497 * @param {!{model: !{item: !SiteException}}} e 458 * @param {!{model: !{item: !SiteException}}} e
498 * @private 459 * @private
499 */ 460 */
500 onShowActionMenuTap_: function(e) { 461 onShowActionMenuTap_: function(e) {
501 this.actionMenuSite_ = e.model.item; 462 this.actionMenuSite_ = e.model.item;
502 /** @type {!CrActionMenuElement} */ ( 463 /** @type {!CrActionMenuElement} */ (
503 this.$$('dialog[is=cr-action-menu]')).showAt( 464 this.$$('dialog[is=cr-action-menu]')).showAt(
504 /** @type {!Element} */ ( 465 /** @type {!Element} */ (
505 Polymer.dom(/** @type {!Event} */ (e)).localTarget)); 466 Polymer.dom(/** @type {!Event} */ (e)).localTarget));
506 }, 467 },
507 468
508 /** @private */ 469 /** @private */
509 closeActionMenu_: function() { 470 closeActionMenu_: function() {
510 this.actionMenuSite_ = null; 471 this.actionMenuSite_ = null;
511 /** @type {!CrActionMenuElement} */ ( 472 /** @type {!CrActionMenuElement} */ (
512 this.$$('dialog[is=cr-action-menu]')).close(); 473 this.$$('dialog[is=cr-action-menu]')).close();
513 }, 474 },
514 }); 475 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698