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

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

Issue 2354313002: Site Settings Desktop: Flesh out controlled exceptions a little more. (Closed)
Patch Set: Address feedback Created 4 years, 3 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 * Enumeration mapping all possible controlled-by values for exceptions to
7 * icons.
8 * @enum {string}
9 */
10 var iconControlledBy = {
11 'extension': 'cr:extension',
12 'HostedApp': 'cr:extension',
13 'platform_app': 'cr:extension',
14 'policy' : 'cr:domain',
15 };
16
17 /**
6 * @fileoverview 18 * @fileoverview
7 * 'site-list' shows a list of Allowed and Blocked sites for a given 19 * 'site-list' shows a list of Allowed and Blocked sites for a given
8 * category. 20 * category.
9 */ 21 */
10 Polymer({ 22 Polymer({
11 23
12 is: 'site-list', 24 is: 'site-list',
13 25
14 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], 26 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior],
15 27
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 if (othersExists) 191 if (othersExists)
180 return; 192 return;
181 this.$.category.opened = true; 193 this.$.category.opened = true;
182 }.bind(this)); 194 }.bind(this));
183 } else { 195 } else {
184 this.$.category.opened = true; 196 this.$.category.opened = true;
185 } 197 }
186 }, 198 },
187 199
188 /** 200 /**
189 * @param {string} source Where the setting came from. 201 * Returns which icon, if any, should represent the fact that this exception
190 * @return {boolean} 202 * is controlled.
191 * @private 203 * @param {!SiteException} item The item from the list we're computing the
204 * icon for.
205 * @return {string} The icon to show (or blank, if none).
192 */ 206 */
193 isPolicyControlled_: function(source) { 207 computeIconControlledBy_: function(item) {
194 return source == 'policy'; 208 return iconControlledBy[item.source] || '';
195 }, 209 },
196 210
197 /** 211 /**
198 * @param {string} source Where the setting came from. 212 * @param {string} source Where the setting came from.
199 * @return {boolean} 213 * @return {boolean}
200 * @private 214 * @private
201 */ 215 */
202 shouldShowMenu_: function(source) { 216 shouldShowMenu_: function(source) {
203 return !(this.isPolicyControlled_(source) || this.allSites); 217 return !(this.isExceptionControlled_(source) || this.allSites);
204 }, 218 },
205 219
206 /** 220 /**
207 * Makes sure the visibility is correct for this widget. 221 * Makes sure the visibility is correct for this widget.
208 * @private 222 * @private
209 */ 223 */
210 updateCategoryVisibility_: function() { 224 updateCategoryVisibility_: function() {
211 this.$.category.hidden = 225 this.$.category.hidden =
212 !this.showSiteList_(this.sites, this.categoryEnabled); 226 !this.showSiteList_(this.sites, this.categoryEnabled);
213 }, 227 },
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 410
397 return this.showSessionOnlyAction_; 411 return this.showSessionOnlyAction_;
398 }, 412 },
399 413
400 /** 414 /**
401 * A handler for selecting a site (by clicking on the origin). 415 * A handler for selecting a site (by clicking on the origin).
402 * @private 416 * @private
403 */ 417 */
404 onOriginTap_: function(event) { 418 onOriginTap_: function(event) {
405 this.selectedSite = event.model.item; 419 this.selectedSite = event.model.item;
406 if (this.isPolicyControlled_(this.selectedSite.source))
407 return;
408
409 settings.navigateTo(settings.Route.SITE_SETTINGS_SITE_DETAILS, 420 settings.navigateTo(settings.Route.SITE_SETTINGS_SITE_DETAILS,
410 new URLSearchParams('site=' + this.selectedSite.origin)); 421 new URLSearchParams('site=' + this.selectedSite.origin));
411 }, 422 },
412 423
413 /** 424 /**
414 * A handler for activating one of the menu action items. 425 * A handler for activating one of the menu action items.
415 * @param {!{model: !{item: !{origin: string}}, 426 * @param {!{model: !{item: !{origin: string}},
416 * detail: !{selected: string}}} event 427 * detail: !{selected: string}}} event
417 * @private 428 * @private
418 */ 429 */
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 // is redundant to also list all the sites that are blocked. 511 // is redundant to also list all the sites that are blocked.
501 if (this.isAllowList_()) 512 if (this.isAllowList_())
502 return true; 513 return true;
503 514
504 if (this.isSessionOnlyList_()) 515 if (this.isSessionOnlyList_())
505 return siteList.length > 0; 516 return siteList.length > 0;
506 517
507 return toggleState; 518 return toggleState;
508 }, 519 },
509 }); 520 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698