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

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: 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..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) {

Powered by Google App Engine
This is Rietveld 408576698