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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'site-data' handles showing the local storage summary list for all sites. 7 * 'site-data' handles showing the local storage summary list for all sites.
8 */ 8 */
9 9
10 Polymer({ 10 Polymer({
(...skipping 20 matching lines...) Expand all
31 */ 31 */
32 requests_: Number, 32 requests_: Number,
33 }, 33 },
34 34
35 ready: function() { 35 ready: function() {
36 this.addWebUIListener('loadChildren', this.loadChildren_.bind(this)); 36 this.addWebUIListener('loadChildren', this.loadChildren_.bind(this));
37 this.addWebUIListener('onTreeItemRemoved', 37 this.addWebUIListener('onTreeItemRemoved',
38 this.onTreeItemRemoved_.bind(this)); 38 this.onTreeItemRemoved_.bind(this));
39 this.treeNodes_ = new settings.CookieTreeNode(null); 39 this.treeNodes_ = new settings.CookieTreeNode(null);
40 // Start the initial request. 40 // Start the initial request.
41 this.browserProxy.reloadCookies(); 41 this.reloadCookies_();
42 this.requests_ = 1;
43 }, 42 },
44 43
44 /**
45 * Reloads the whole cookie list.
46 * @private
47 */
48 reloadCookies_: function() {
49 this.requests_ = 1;
50 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
51 },
52
53 /**
54 * Returns whether remove all should be shown.
55 * @param {Array<CookieDataSummaryItem>} sites The sites list to use to
56 * determine whether the button should be visible.
57 * @private
58 */
59 removeAllIsVisible_: function(sites) {
60 return sites.length > 0;
61 },
62
63 /**
64 * Called when the cookie list is ready to be shown.
65 * @private
66 */
45 loadChildren_: function(list) { 67 loadChildren_: function(list) {
46 var parentId = list[0]; 68 var parentId = list[0];
47 var data = list[1]; 69 var data = list[1];
48 70
49 if (parentId == null) { 71 if (parentId == null) {
72 // New root being added, clear the list and add the nodes.
73 this.sites = [];
50 this.treeNodes_.addChildNodes(this.treeNodes_, data); 74 this.treeNodes_.addChildNodes(this.treeNodes_, data);
51 } else { 75 } else {
52 this.treeNodes_.populateChildNodes(parentId, this.treeNodes_, data); 76 this.treeNodes_.populateChildNodes(parentId, this.treeNodes_, data);
53 } 77 }
54 78
55 for (var i = 0; i < data.length; ++i) { 79 for (var i = 0; i < data.length; ++i) {
56 var prefix = parentId == null ? '' : parentId + ', '; 80 var prefix = parentId == null ? '' : parentId + ', ';
57 if (data[i].hasChildren) { 81 if (data[i].hasChildren) {
58 this.requests_ += 1; 82 this.requests_ += 1;
59 this.browserProxy.loadCookieChildren(prefix + data[i].id); 83 this.browserProxy.loadCookieChildren(prefix + data[i].id);
60 } 84 }
61 } 85 }
62 86
63 if (--this.requests_ == 0) 87 if (--this.requests_ == 0)
64 this.sites = this.treeNodes_.getSummaryList(); 88 this.sites = this.treeNodes_.getSummaryList();
89
90 // If this reaches below zero then we're forgetting to increase the
91 // outstanding request count and the summary list won't be updated at the
92 // end.
93 assert(this.requests_ >= 0);
65 }, 94 },
66 95
67 /** 96 /**
68 * Called when an item is removed. 97 * Called when an item is removed.
69 */ 98 */
70 onTreeItemRemoved_: function(args) { 99 onTreeItemRemoved_: function(args) {
71 this.treeNodes_.removeByParentId(args[0], args[1], args[2]); 100 this.treeNodes_.removeByParentId(args[0], args[1], args[2]);
72 this.sites = this.treeNodes_.getSummaryList(); 101 this.sites = this.treeNodes_.getSummaryList();
73 }, 102 },
74 103
75 /** 104 /**
76 * @param {!{model: !{item: !{title: string, id: string}}}} event 105 * Deletes all site data for a given site.
106 * @param {!{model: !{item: CookieDataSummaryItem}}} event
107 * @private
108 */
109 onDeleteSite_: function(event) {
110 this.browserProxy.removeCookie(event.model.item.id);
111 },
112
113 /**
114 * Deletes site data for all sites.
115 * @private
116 */
117 onDeleteAllSites_: function() {
118 // removeAllCookies will result in the client list being updated, so update
119 // the list of outstanding requests.
120 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.
121 this.browserProxy.removeAllCookies();
dschuyler 2016/08/18 00:44:03 Same comment: Can we change reloadCookies() and r
122 },
123
124 /**
125 * @param {!{model: !{item: CookieDataSummaryItem}}} event
77 * @private 126 * @private
78 */ 127 */
79 onSiteTap_: function(event) { 128 onSiteTap_: function(event) {
80 var dialog = document.createElement('site-data-details-dialog'); 129 var dialog = document.createElement('site-data-details-dialog');
81 dialog.category = this.category; 130 dialog.category = this.category;
82 this.shadowRoot.appendChild(dialog); 131 this.shadowRoot.appendChild(dialog);
83 132
84 var node = this.treeNodes_.fetchNodeById(event.model.item.id, false); 133 var node = this.treeNodes_.fetchNodeById(event.model.item.id, false);
85 dialog.open(node); 134 dialog.open(node);
86 135
87 dialog.addEventListener('close', function(event) { 136 dialog.addEventListener('close', function(event) {
88 dialog.remove(); 137 dialog.remove();
89 }); 138 });
90 }, 139 },
91 }); 140 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698