Commit 92dca0ea authored by Esmael El-Moslimany's avatar Esmael El-Moslimany Committed by Commit Bot

Settings: only update parts of the list that changed in site list

After removing a site, the next site is focused with a single tab press.


Bug: 740046
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Ifcd05b623e1f98361b9dc14e0ed2c41c4889f876
Reviewed-on: https://chromium-review.googlesource.com/1141360Reviewed-by: default avatarScott Chen <scottchen@chromium.org>
Commit-Queue: Esmael El-Moslimany <aee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576352}
parent 48fc6f8c
......@@ -196,6 +196,7 @@ js_library("site_list") {
"//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
"//ui/webui/resources/js:assert",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:list_property_update_behavior",
"//ui/webui/resources/js:web_ui_listener_behavior",
"//ui/webui/resources/js/cr/ui:focus_without_ink",
]
......
......@@ -6,6 +6,7 @@
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/html/list_property_update_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="../i18n_setup.html">
......@@ -59,7 +60,7 @@
</button>
</cr-action-menu>
<div class="list-frame" hidden$="[[hasSites_(sites)]]">
<div class="list-frame" hidden$="[[hasSites_(sites.*)]]">
<div class="list-item secondary">$i18n{noSitesAdded}</div>
</div>
<div class="list-frame menu-content vertical-list" id="listContainer">
......
......@@ -11,7 +11,11 @@ Polymer({
is: 'site-list',
behaviors: [SiteSettingsBehavior, WebUIListenerBehavior],
behaviors: [
SiteSettingsBehavior,
WebUIListenerBehavior,
ListPropertyUpdateBehavior,
],
properties: {
/** @private */
......@@ -233,53 +237,24 @@ Polymer({
*/
populateList_: function() {
this.browserProxy_.getExceptionList(this.category).then(exceptionList => {
this.processExceptions_([exceptionList]);
this.processExceptions_(exceptionList);
this.closeActionMenu_();
});
},
/**
* Process the exception list returned from the native layer.
* @param {!Array<!Array<RawSiteException>>} data List of sites (exceptions)
* to process.
* @param {!Array<RawSiteException>} exceptionList
* @private
*/
processExceptions_: function(data) {
const sites = /** @type {!Array<RawSiteException>} */ ([]);
for (let i = 0; i < data.length; ++i) {
const exceptionList = data[i];
for (let k = 0; k < exceptionList.length; ++k) {
if (exceptionList[k].setting == settings.ContentSetting.DEFAULT ||
exceptionList[k].setting != this.categorySubtype) {
continue;
}
sites.push(exceptionList[k]);
}
}
this.sites = this.toSiteArray_(sites);
},
/**
* Converts a list of exceptions received from the C++ handler to
* full SiteException objects.
* @param {!Array<RawSiteException>} sites A list of sites to convert.
* @return {!Array<SiteException>} A list of full SiteExceptions.
* @private
*/
toSiteArray_: function(sites) {
const results = /** @type {!Array<SiteException>} */ ([]);
let lastOrigin = '';
let lastEmbeddingOrigin = '';
for (let i = 0; i < sites.length; ++i) {
/** @type {!SiteException} */
const siteException = this.expandSiteException(sites[i]);
results.push(siteException);
lastOrigin = siteException.origin;
lastEmbeddingOrigin = siteException.embeddingOrigin;
}
return results;
processExceptions_: function(exceptionList) {
const sites =
exceptionList
.filter(
site => site.setting != settings.ContentSetting.DEFAULT &&
site.setting == this.categorySubtype)
.map(site => this.expandSiteException(site));
this.updateList('sites', x => x.origin, sites);
},
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment