| 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..14fe40045d2a9e4745573489f7982c3f32064f5d 100644
|
| --- a/chrome/browser/resources/settings/site_settings/site_data.js
|
| +++ b/chrome/browser/resources/settings/site_settings/site_data.js
|
| @@ -33,20 +33,46 @@ Polymer({
|
| },
|
|
|
| ready: function() {
|
| - this.addWebUIListener('loadChildren', this.loadChildren_.bind(this));
|
| this.addWebUIListener('onTreeItemRemoved',
|
| this.onTreeItemRemoved_.bind(this));
|
| this.treeNodes_ = new settings.CookieTreeNode(null);
|
| // Start the initial request.
|
| - this.browserProxy.reloadCookies();
|
| - this.requests_ = 1;
|
| + this.reloadCookies_();
|
| },
|
|
|
| + /**
|
| + * Reloads the whole cookie list.
|
| + * @private
|
| + */
|
| + reloadCookies_: function() {
|
| + this.browserProxy.reloadCookies().then(function(list) {
|
| + this.loadChildren_(list);
|
| + }.bind(this));
|
| + },
|
| +
|
| + /**
|
| + * 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.
|
| + * @param {!CookieList} list The cookie list to show.
|
| + * @private
|
| + */
|
| loadChildren_: function(list) {
|
| - var parentId = list[0];
|
| - var data = list[1];
|
| + var parentId = list.id;
|
| + var data = list.children;
|
|
|
| if (parentId == null) {
|
| + // New root being added, clear the list and add the nodes.
|
| + this.sites = [];
|
| + this.requests_ = 0;
|
| this.treeNodes_.addChildNodes(this.treeNodes_, data);
|
| } else {
|
| this.treeNodes_.populateChildNodes(parentId, this.treeNodes_, data);
|
| @@ -55,25 +81,54 @@ Polymer({
|
| for (var i = 0; i < data.length; ++i) {
|
| var prefix = parentId == null ? '' : parentId + ', ';
|
| if (data[i].hasChildren) {
|
| - this.requests_ += 1;
|
| - this.browserProxy.loadCookieChildren(prefix + data[i].id);
|
| + ++this.requests_;
|
| + this.browserProxy.loadCookieChildren(
|
| + prefix + data[i].id).then(function(list) {
|
| + --this.requests_;
|
| + this.loadChildren_(list);
|
| + }.bind(this));
|
| }
|
| }
|
|
|
| - if (--this.requests_ == 0)
|
| + 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);
|
| },
|
|
|
| /**
|
| - * Called when an item is removed.
|
| + * Called when a single item has been removed (not during delete all).
|
| + * @param {!CookieRemovePacket} args The details about what to remove.
|
| */
|
| onTreeItemRemoved_: function(args) {
|
| - this.treeNodes_.removeByParentId(args[0], args[1], args[2]);
|
| + this.treeNodes_.removeByParentId(args.id, args.start, args.count);
|
| this.sites = this.treeNodes_.getSummaryList();
|
| },
|
|
|
| /**
|
| - * @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() {
|
| + this.browserProxy.removeAllCookies().then(function(list) {
|
| + this.loadChildren_(list);
|
| + }.bind(this));
|
| + },
|
| +
|
| + /**
|
| + * @param {!{model: !{item: CookieDataSummaryItem}}} event
|
| * @private
|
| */
|
| onSiteTap_: function(event) {
|
|
|