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

Side by Side Diff: chrome/browser/resources/settings/site_settings/site_data.js

Issue 2338283002: Site Settings Desktop: Implement Cookie Search. (Closed)
Patch Set: Address feedback Created 4 years, 3 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 12 matching lines...) Expand all
23 * The cookie tree with the details needed to display individual sites and 23 * The cookie tree with the details needed to display individual sites and
24 * their contained data. 24 * their contained data.
25 * @type {!settings.CookieTreeNode} 25 * @type {!settings.CookieTreeNode}
26 */ 26 */
27 treeNodes_: Object, 27 treeNodes_: Object,
28 28
29 /** 29 /**
30 * Keeps track of how many outstanding requests for more data there are. 30 * Keeps track of how many outstanding requests for more data there are.
31 */ 31 */
32 requests_: Number, 32 requests_: Number,
33
34 /**
35 * The current filter applied to the cookie data list.
36 */
37 filterString_: {
38 type: String,
39 value: '',
40 }
33 }, 41 },
34 42
35 ready: function() { 43 ready: function() {
36 this.addWebUIListener('onTreeItemRemoved', 44 this.addWebUIListener('onTreeItemRemoved',
37 this.onTreeItemRemoved_.bind(this)); 45 this.onTreeItemRemoved_.bind(this));
38 this.treeNodes_ = new settings.CookieTreeNode(null); 46 this.treeNodes_ = new settings.CookieTreeNode(null);
39 // Start the initial request. 47 // Start the initial request.
40 this.reloadCookies_(); 48 this.reloadCookies_();
41 }, 49 },
42 50
43 /** 51 /**
44 * Reloads the whole cookie list. 52 * Reloads the whole cookie list.
45 * @private 53 * @private
46 */ 54 */
47 reloadCookies_: function() { 55 reloadCookies_: function() {
48 this.browserProxy.reloadCookies().then(function(list) { 56 this.browserProxy.reloadCookies().then(function(list) {
49 this.loadChildren_(list); 57 this.loadChildren_(list);
50 }.bind(this)); 58 }.bind(this));
51 }, 59 },
52 60
53 /** 61 /**
62 * A filter function for the list.
63 * @param {!CookieDataSummaryItem} item The item to possibly filter out.
64 * @return {!boolean} Whether to show the item.
65 * @private
66 */
67 showItem_: function(item) {
68 if (this.filterString_.length == 0)
69 return true;
70 return item.site.indexOf(this.filterString_) > -1;
71 },
72
73 /** @private */
74 onSearchChanged_: function(e) {
75 this.filterString_ = e.detail;
76 this.$.list.render();
77 },
78
79 /**
54 * Returns whether remove all should be shown. 80 * Returns whether remove all should be shown.
55 * @param {Array<CookieDataSummaryItem>} sites The sites list to use to 81 * @param {!Array<!CookieDataSummaryItem>} sites The sites list to use to
56 * determine whether the button should be visible. 82 * determine whether the button should be visible.
57 * @private 83 * @private
58 */ 84 */
59 removeAllIsVisible_: function(sites) { 85 removeAllIsVisible_: function(sites) {
60 return sites.length > 0; 86 return sites.length > 0;
61 }, 87 },
62 88
63 /** 89 /**
90 * Returns the string to use for the Remove label.
91 * @return {!string} filterString The current filter string.
92 * @private
93 */
94 computeRemoveLabel_: function(filterString) {
95 if (filterString.length == 0)
96 return loadTimeData.getString('siteSettingsCookieRemoveAll');
97 return loadTimeData.getString('siteSettingsCookieRemoveAllShown');
98 },
99
100 /**
64 * Called when the cookie list is ready to be shown. 101 * Called when the cookie list is ready to be shown.
65 * @param {!CookieList} list The cookie list to show. 102 * @param {!CookieList} list The cookie list to show.
66 * @private 103 * @private
67 */ 104 */
68 loadChildren_: function(list) { 105 loadChildren_: function(list) {
69 var parentId = list.id; 106 var parentId = list.id;
70 var data = list.children; 107 var data = list.children;
71 108
72 if (parentId == null) { 109 if (parentId == null) {
73 // New root being added, clear the list and add the nodes. 110 // New root being added, clear the list and add the nodes.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 /** 148 /**
112 * Deletes all site data for a given site. 149 * Deletes all site data for a given site.
113 * @param {!{model: !{item: CookieDataSummaryItem}}} event 150 * @param {!{model: !{item: CookieDataSummaryItem}}} event
114 * @private 151 * @private
115 */ 152 */
116 onDeleteSite_: function(event) { 153 onDeleteSite_: function(event) {
117 this.browserProxy.removeCookie(event.model.item.id); 154 this.browserProxy.removeCookie(event.model.item.id);
118 }, 155 },
119 156
120 /** 157 /**
121 * Deletes site data for all sites. 158 * Deletes site data for multiple sites.
122 * @private 159 * @private
123 */ 160 */
124 onDeleteAllSites_: function() { 161 onDeleteMultipleSites_: function() {
125 this.browserProxy.removeAllCookies().then(function(list) { 162 if (this.filterString_.length == 0) {
126 this.loadChildren_(list); 163 this.browserProxy.removeAllCookies().then(function(list) {
127 }.bind(this)); 164 this.loadChildren_(list);
165 }.bind(this));
166 } else {
167 var items = this.$.list.items;
168 for (var i = 0; i < items.length; ++i) {
169 if (this.showItem_(items[i]))
170 this.browserProxy.removeCookie(items[i].id);
171 }
172 }
128 }, 173 },
129 174
130 /** 175 /**
131 * @param {!{model: !{item: CookieDataSummaryItem}}} event 176 * @param {!{model: !{item: CookieDataSummaryItem}}} event
132 * @private 177 * @private
133 */ 178 */
134 onSiteTap_: function(event) { 179 onSiteTap_: function(event) {
135 var dialog = document.createElement('site-data-details-dialog'); 180 var dialog = document.createElement('site-data-details-dialog');
136 dialog.category = this.category; 181 dialog.category = this.category;
137 this.shadowRoot.appendChild(dialog); 182 this.shadowRoot.appendChild(dialog);
138 183
139 var node = this.treeNodes_.fetchNodeById(event.model.item.id, false); 184 var node = this.treeNodes_.fetchNodeById(event.model.item.id, false);
140 dialog.open(node); 185 dialog.open(node);
141 186
142 dialog.addEventListener('close', function(event) { 187 dialog.addEventListener('close', function(event) {
143 dialog.remove(); 188 dialog.remove();
144 }); 189 });
145 }, 190 },
146 }); 191 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698