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

Unified Diff: chrome/browser/resources/settings/site_settings/site_data.js

Issue 2248683006: Site Settings Desktop: Implement individual cookie removal and RemoveAll. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
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..50005cb23bd8404e43fc4e488b03fef82fa93c6d 100644
--- a/chrome/browser/resources/settings/site_settings/site_data.js
+++ b/chrome/browser/resources/settings/site_settings/site_data.js
@@ -33,20 +33,45 @@ 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.
dschuyler 2016/08/18 22:51:10 nit: indent 'determine...'
Finnur 2016/08/19 12:18:32 Done.
+ * @private
+ */
+ removeAllIsVisible_: function(sites) {
+ return sites.length > 0;
+ },
+
+ /**
+ * Called when the cookie list is ready to be shown.
+ * @private
+ */
loadChildren_: function(list) {
dschuyler 2016/08/18 22:51:10 @param for 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.requests_ = 0;
this.treeNodes_.addChildNodes(this.treeNodes_, data);
} else {
this.treeNodes_.populateChildNodes(parentId, this.treeNodes_, data);
@@ -55,17 +80,26 @@ 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();
dschuyler 2016/08/18 22:51:10 It looks like this may be called more often than o
Finnur 2016/08/18 23:27:38 I don't think this is an issue, but will check tom
Finnur 2016/08/19 12:18:32 I verified this again and getSummaryList is called
+
+ // 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).
*/
onTreeItemRemoved_: function(args) {
dschuyler 2016/08/18 22:51:10 Can we @param the args?
Finnur 2016/08/18 23:27:38 Umm, yeah -- |we| probably can. :) I, however, alr
Finnur 2016/08/19 12:18:32 Actually, scratch that... Coming in this morning
this.treeNodes_.removeByParentId(args[0], args[1], args[2]);
@@ -73,7 +107,26 @@ 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() {
+ this.browserProxy.removeAllCookies().then(function(list) {
+ this.loadChildren_(list);
+ }.bind(this));
+ },
+
+ /**
+ * @param {!{model: !{item: CookieDataSummaryItem}}} event
* @private
*/
onSiteTap_: function(event) {

Powered by Google App Engine
This is Rietveld 408576698