Chromium Code Reviews| Index: chrome/browser/resources/settings/site_settings/site_data.js |
| diff --git a/chrome/browser/resources/settings/site_settings/site_data.js b/chrome/browser/resources/settings/site_settings/site_data.js |
| index 157da97de06eed3e20c55240ffd5c4fef68c38ee..c994793025ff48a84bf6dac8c478e5a4a8ef3191 100644 |
| --- a/chrome/browser/resources/settings/site_settings/site_data.js |
| +++ b/chrome/browser/resources/settings/site_settings/site_data.js |
| @@ -38,15 +38,39 @@ Polymer({ |
| this.onTreeItemRemoved_.bind(this)); |
| this.treeNodes_ = new settings.CookieTreeNode(null); |
| // Start the initial request. |
| - this.browserProxy.reloadCookies(); |
| + this.reloadCookies_(); |
| + }, |
| + |
| + /** |
| + * Reloads the whole cookie list. |
| + * @private |
| + */ |
| + reloadCookies_: function() { |
| this.requests_ = 1; |
| + this.browserProxy.reloadCookies(); |
|
dschuyler
2016/08/18 00:44:03
Can we change reloadCookies() and removeAllCookies
Finnur
2016/08/18 16:20:30
I've converted to promises, but it still doesn't a
|
| }, |
| + /** |
| + * Returns whether remove all should be shown. |
| + * @param {Array<CookieDataSummaryItem>} sites The sites list to use to |
| + * determine whether the button should be visible. |
| + * @private |
| + */ |
| + removeAllIsVisible_: function(sites) { |
| + return sites.length > 0; |
| + }, |
| + |
| + /** |
| + * Called when the cookie list is ready to be shown. |
| + * @private |
| + */ |
| loadChildren_: function(list) { |
| var parentId = list[0]; |
| var data = list[1]; |
| if (parentId == null) { |
| + // New root being added, clear the list and add the nodes. |
| + this.sites = []; |
| this.treeNodes_.addChildNodes(this.treeNodes_, data); |
| } else { |
| this.treeNodes_.populateChildNodes(parentId, this.treeNodes_, data); |
| @@ -62,6 +86,11 @@ Polymer({ |
| if (--this.requests_ == 0) |
| this.sites = this.treeNodes_.getSummaryList(); |
| + |
| + // If this reaches below zero then we're forgetting to increase the |
| + // outstanding request count and the summary list won't be updated at the |
| + // end. |
| + assert(this.requests_ >= 0); |
| }, |
| /** |
| @@ -73,7 +102,27 @@ Polymer({ |
| }, |
| /** |
| - * @param {!{model: !{item: !{title: string, id: string}}}} event |
| + * Deletes all site data for a given site. |
| + * @param {!{model: !{item: CookieDataSummaryItem}}} event |
| + * @private |
| + */ |
| + onDeleteSite_: function(event) { |
| + this.browserProxy.removeCookie(event.model.item.id); |
| + }, |
| + |
| + /** |
| + * Deletes site data for all sites. |
| + * @private |
| + */ |
| + onDeleteAllSites_: function() { |
| + // removeAllCookies will result in the client list being updated, so update |
| + // the list of outstanding requests. |
| + this.requests_++; |
|
dschuyler
2016/08/18 00:44:03
nit: please use pre-increment unless post-incremen
Finnur
2016/08/18 16:20:30
Acknowledged.
|
| + this.browserProxy.removeAllCookies(); |
|
dschuyler
2016/08/18 00:44:03
Same comment:
Can we change reloadCookies() and r
|
| + }, |
| + |
| + /** |
| + * @param {!{model: !{item: CookieDataSummaryItem}}} event |
| * @private |
| */ |
| onSiteTap_: function(event) { |