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

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

Issue 1838213002: Simplify Site Settings tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 // Define a global boolean for notifications (only enabled in the test class).
6 cr.exportPath('settings_test');
7
8 /** @type {boolean} */
9 settings_test.siteListNotifyForTest;
10
11 /** 5 /**
12 * @fileoverview 6 * @fileoverview
13 * '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
14 * category. 8 * category.
15 */ 9 */
16 Polymer({ 10 Polymer({
17 11
18 is: 'settings-site-list', 12 is: 'settings-site-list',
19 13
20 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], 14 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior],
(...skipping 10 matching lines...) Expand all
31 /** 25 /**
32 * The site that was selected by the user in the dropdown list. 26 * The site that was selected by the user in the dropdown list.
33 * @type {SiteException} 27 * @type {SiteException}
34 */ 28 */
35 selectedSite: { 29 selectedSite: {
36 type: Object, 30 type: Object,
37 notify: true, 31 notify: true,
38 }, 32 },
39 33
40 /** 34 /**
41 * Array of sites to display in the widget. 35 * Array of sites to display in the widget.
dpapad 2016/03/29 21:46:33 Could you add a type annotation for this? As a rea
Finnur 2016/03/30 11:22:43 Done. But this got me thinking about the next var.
michaelpg 2016/03/31 11:13:30 Nope, the Polymer pass in Closure automatically an
Finnur 2016/03/31 15:05:25 Good to know. Thanks!
42 */ 36 */
43 sites: { 37 sites: {
44 type: Array, 38 type: Array,
45 value: function() { return []; }, 39 value: function() { return []; },
46 notify: true, // !!settings_test.siteListNotifyForTest,
47 }, 40 },
48 41
49 /** 42 /**
50 * Whether this list is for the All Sites category. 43 * Whether this list is for the All Sites category.
51 */ 44 */
52 allSites: { 45 allSites: {
53 type: Boolean, 46 type: Boolean,
54 value: false, 47 value: false,
55 }, 48 },
56 49
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Allowed list is always shown opened by default and All Sites is presented 141 // Allowed list is always shown opened by default and All Sites is presented
149 // all in one list (nothing closed by default). 142 // all in one list (nothing closed by default).
150 if (this.allSites || 143 if (this.allSites ||
151 this.categorySubtype == settings.PermissionValues.ALLOW) { 144 this.categorySubtype == settings.PermissionValues.ALLOW) {
152 this.$.category.opened = true; 145 this.$.category.opened = true;
153 return; 146 return;
154 } 147 }
155 148
156 // Block list should only be shown opened if there is nothing to show in 149 // Block list should only be shown opened if there is nothing to show in
157 // the allowed list. 150 // the allowed list.
158 var prefsProxy = settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); 151 if (this.category != settings.INVALID_CATEGORY_SUBTYPE) {
159 prefsProxy.getExceptionList(this.category).then(function(exceptionList) { 152 var prefsProxy = settings.SiteSettingsPrefsBrowserProxyImpl.getInstance();
dpapad 2016/03/29 21:46:33 Nit(optional): You can simply name this browserPro
Finnur 2016/03/30 11:22:43 Done.
160 for (var i = 0; i < exceptionList.length; ++i) { 153 prefsProxy.getExceptionList(this.category).then(function(exceptionList) {
161 if (exceptionList[i].setting == 'allow') 154 for (var i = 0; i < exceptionList.length; ++i) {
dpapad 2016/03/29 21:46:33 Nit: You can use the Array#some() method instead,
Finnur 2016/03/30 11:22:43 Done.
162 return; 155 if (exceptionList[i].setting == 'allow')
dpapad 2016/03/29 21:46:33 Isn't there an enum or constant for the literal 'a
Finnur 2016/03/30 11:22:43 Done.
163 } 156 return;
157 }
158 this.$.category.opened = true;
159 }.bind(this));
160 } else {
164 this.$.category.opened = true; 161 this.$.category.opened = true;
165 }.bind(this)); 162 }
166 }, 163 },
167 164
168 /** 165 /**
169 * Makes sure the visibility is correct for this widget (e.g. hidden if the 166 * Makes sure the visibility is correct for this widget (e.g. hidden if the
170 * block list is empty). 167 * block list is empty).
171 * @private 168 * @private
172 */ 169 */
173 updateCategoryVisibility_: function() { 170 updateCategoryVisibility_: function() {
174 this.$.category.hidden = 171 this.$.category.hidden =
175 !this.showSiteList_(this.sites, this.categoryEnabled); 172 !this.showSiteList_(this.sites, this.categoryEnabled);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 * Returns the icon to use for a given site. 431 * Returns the icon to use for a given site.
435 * @param {string} url The url of the site to fetch the icon for. 432 * @param {string} url The url of the site to fetch the icon for.
436 * @private 433 * @private
437 */ 434 */
438 computeSiteIcon_: function(url) { 435 computeSiteIcon_: function(url) {
439 // TODO(finnur): For now, we're returning a placeholder image for each site 436 // TODO(finnur): For now, we're returning a placeholder image for each site
440 // but the actual favicon for each site will need to be returned. 437 // but the actual favicon for each site will need to be returned.
441 return 'communication:message'; 438 return 'communication:message';
442 }, 439 },
443 }); 440 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698