Index: chrome/browser/resources/settings/site_settings/site_list.js |
diff --git a/chrome/browser/resources/settings/site_settings/site_list.js b/chrome/browser/resources/settings/site_settings/site_list.js |
index b053707fcf76a370e5bbe0a7f6c442b2f1391a67..ee67ae7ebc1ca526caa0325fb590de1ea8ed8569 100644 |
--- a/chrome/browser/resources/settings/site_settings/site_list.js |
+++ b/chrome/browser/resources/settings/site_settings/site_list.js |
@@ -2,12 +2,6 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-// Define a global boolean for notifications (only enabled in the test class). |
-cr.exportPath('settings_test'); |
- |
-/** @type {boolean} */ |
-settings_test.siteListNotifyForTest; |
- |
/** |
* @fileoverview |
* 'settings-site-list' shows a list of Allowed and Blocked sites for a given |
@@ -39,11 +33,11 @@ Polymer({ |
/** |
* Array of sites to display in the widget. |
+ * @type {!Array<SiteException>} |
*/ |
sites: { |
type: Array, |
value: function() { return []; }, |
- notify: true, // !!settings_test.siteListNotifyForTest, |
}, |
/** |
@@ -155,14 +149,21 @@ Polymer({ |
// Block list should only be shown opened if there is nothing to show in |
// the allowed list. |
- var prefsProxy = settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); |
- prefsProxy.getExceptionList(this.category).then(function(exceptionList) { |
- for (var i = 0; i < exceptionList.length; ++i) { |
- if (exceptionList[i].setting == 'allow') |
- return; |
- } |
+ if (this.category != settings.INVALID_CATEGORY_SUBTYPE) { |
+ var browserProxy = |
dpapad
2016/03/31 17:37:07
Nit: Instead of calling getInstance() three times
Finnur
2016/04/04 13:59:24
Converted to this.browserProxy_.
|
+ settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); |
+ browserProxy.getExceptionList(this.category).then( |
+ function(exceptionList) { |
+ var allowExists = exceptionList.some(function(exception) { |
+ return exception.setting == settings.PermissionStringValues.ALLOW; |
+ }); |
+ if (allowExists) |
+ return; |
+ this.$.category.opened = true; |
+ }.bind(this)); |
+ } else { |
this.$.category.opened = true; |
- }.bind(this)); |
+ } |
}, |
/** |
@@ -196,9 +197,11 @@ Polymer({ |
this.processExceptions_(lists); |
}.bind(this)); |
} else { |
- var prefsProxy = settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); |
- prefsProxy.getExceptionList(this.category).then(function(exceptionList) { |
- this.processExceptions_([exceptionList]); |
+ var browserProxy = |
+ settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); |
+ browserProxy.getExceptionList(this.category).then( |
+ function(exceptionList) { |
+ this.processExceptions_([exceptionList]); |
}.bind(this)); |
} |
}, |
@@ -223,11 +226,11 @@ Polymer({ |
* @private |
*/ |
getAllSitesList_: function() { |
- var prefsProxy = settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); |
+ var browserProxy = settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); |
var promiseList = []; |
for (var type in settings.ContentSettingsTypes) { |
promiseList.push( |
- prefsProxy.getExceptionList(settings.ContentSettingsTypes[type])); |
+ browserProxy.getExceptionList(settings.ContentSettingsTypes[type])); |
} |
return Promise.all(promiseList); |
@@ -245,12 +248,12 @@ Polymer({ |
for (var i = 0; i < exceptionList.length; ++i) { |
if (this.category != settings.ALL_SITES) { |
// Filter out 'Block' values if this list is handling 'Allow' items. |
- if (exceptionList[i].setting == 'block' && |
+ if (exceptionList[i].setting == settings.PermissionStringValues.BLOCK && |
this.categorySubtype != settings.PermissionValues.BLOCK) { |
continue; |
} |
// Filter out 'Allow' values if this list is handling 'Block' items. |
- if (exceptionList[i].setting == 'allow' && |
+ if (exceptionList[i].setting == settings.PermissionStringValues.ALLOW && |
this.categorySubtype != settings.PermissionValues.ALLOW) { |
continue; |
} |