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

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

Issue 2391253002: Site Settings Desktop: Polish the Site Data section. (Closed)
Patch Set: Address feedback Created 4 years, 2 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({
11 is: 'site-data', 11 is: 'site-data',
12 12
13 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], 13 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior],
14 14
15 properties: { 15 properties: {
16 /** 16 /**
17 * A summary list of all sites and how many entities each contain. 17 * A summary list of all sites and how many entities each contain.
18 * @type {Array<CookieDataSummaryItem>} 18 * @type {Array<CookieDataSummaryItem>}
19 */ 19 */
20 sites: Array, 20 sites: Array,
21 21
22 /** 22 /**
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 * @private
26 */ 27 */
27 treeNodes_: Object, 28 treeNodes_: Object,
28 29
29 /** 30 /**
30 * Keeps track of how many outstanding requests for more data there are. 31 * Keeps track of how many outstanding requests for more data there are.
32 * @private
31 */ 33 */
32 requests_: Number, 34 requests_: Number,
33 35
34 /** 36 /**
35 * The current filter applied to the cookie data list. 37 * The current filter applied to the cookie data list.
38 * @private
36 */ 39 */
37 filterString_: { 40 filterString_: {
38 type: String, 41 type: String,
39 value: '', 42 value: '',
40 } 43 },
44
45 /** @private */
46 confirmationDeleteMsg_: String,
47
48 /** @private */
49 idToDelete_: String,
41 }, 50 },
42 51
52 /** @override */
43 ready: function() { 53 ready: function() {
44 this.addWebUIListener('onTreeItemRemoved', 54 this.addWebUIListener('onTreeItemRemoved',
45 this.onTreeItemRemoved_.bind(this)); 55 this.onTreeItemRemoved_.bind(this));
46 this.treeNodes_ = new settings.CookieTreeNode(null); 56 this.treeNodes_ = new settings.CookieTreeNode(null);
47 // Start the initial request. 57 // Start the initial request.
48 this.reloadCookies_(); 58 this.reloadCookies_();
49 }, 59 },
50 60
51 /** 61 /**
52 * Reloads the whole cookie list. 62 * Reloads the whole cookie list.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 137
128 // If this reaches below zero then we're forgetting to increase the 138 // If this reaches below zero then we're forgetting to increase the
129 // outstanding request count and the summary list won't be updated at the 139 // outstanding request count and the summary list won't be updated at the
130 // end. 140 // end.
131 assert(this.requests_ >= 0); 141 assert(this.requests_ >= 0);
132 }, 142 },
133 143
134 /** 144 /**
135 * Called when a single item has been removed (not during delete all). 145 * Called when a single item has been removed (not during delete all).
136 * @param {!CookieRemovePacket} args The details about what to remove. 146 * @param {!CookieRemovePacket} args The details about what to remove.
147 * @private
137 */ 148 */
138 onTreeItemRemoved_: function(args) { 149 onTreeItemRemoved_: function(args) {
139 this.treeNodes_.removeByParentId(args.id, args.start, args.count); 150 this.treeNodes_.removeByParentId(args.id, args.start, args.count);
140 this.sites = this.treeNodes_.getSummaryList(); 151 this.sites = this.treeNodes_.getSummaryList();
141 }, 152 },
142 153
154 /** @private */
155 onCloseDialog_: function() {
156 this.$.confirmDeleteDialog.close();
157 },
158
143 /** 159 /**
144 * Deletes all site data for a given site. 160 * Shows a dialog to confirm the deletion of a site.
145 * @param {!{model: !{item: CookieDataSummaryItem}}} event 161 * @param {!{model: !{item: CookieDataSummaryItem}}} event
146 * @private 162 * @private
147 */ 163 */
148 onDeleteSite_: function(event) { 164 onConfirmDeleteSite_: function(event) {
149 this.browserProxy.removeCookie(event.model.item.id); 165 this.idToDelete_ = event.model.item.id;
166 this.confirmationDeleteMsg_ = loadTimeData.getStringF(
167 'siteSettingsCookieRemoveConfirmation', event.model.item.site);
168 this.$.confirmDeleteDialog.showModal();
150 }, 169 },
151 170
152 /** 171 /**
172 * Shows a dialog to confirm the deletion of multiple sites.
173 * @private
174 */
175 onConfirmDeleteMultipleSites_: function() {
176 this.idToDelete_ = ''; // Delete all.
177 this.confirmationDeleteMsg_ = loadTimeData.getString(
178 'siteSettingsCookieRemoveMultipleConfirmation');
179 this.$.confirmDeleteDialog.showModal();
180 },
181
182 /**
183 * Called when deletion for a single/multiple sites has been confirmed.
184 * @private
185 */
186 onConfirmDelete_: function() {
187 if (this.idToDelete_ != '')
188 this.onDeleteSite_();
189 else
190 this.onDeleteMultipleSites_();
191 this.$.confirmDeleteDialog.close();
192 },
193
194 /**
195 * Deletes all site data for a given site.
196 * @private
197 */
198 onDeleteSite_: function() {
199 this.browserProxy.removeCookie(this.idToDelete_);
200 },
201
202 /**
153 * Deletes site data for multiple sites. 203 * Deletes site data for multiple sites.
154 * @private 204 * @private
155 */ 205 */
156 onDeleteMultipleSites_: function() { 206 onDeleteMultipleSites_: function() {
157 if (this.filterString_.length == 0) { 207 if (this.filterString_.length == 0) {
158 this.browserProxy.removeAllCookies().then(function(list) { 208 this.browserProxy.removeAllCookies().then(function(list) {
159 this.loadChildren_(list); 209 this.loadChildren_(list);
160 }.bind(this)); 210 }.bind(this));
161 } else { 211 } else {
162 var items = this.$.list.items; 212 var items = this.$.list.items;
(...skipping 14 matching lines...) Expand all
177 this.shadowRoot.appendChild(dialog); 227 this.shadowRoot.appendChild(dialog);
178 228
179 var node = this.treeNodes_.fetchNodeById(event.model.item.id, false); 229 var node = this.treeNodes_.fetchNodeById(event.model.item.id, false);
180 dialog.open(node); 230 dialog.open(node);
181 231
182 dialog.addEventListener('close', function(event) { 232 dialog.addEventListener('close', function(event) {
183 dialog.remove(); 233 dialog.remove();
184 }); 234 });
185 }, 235 },
186 }); 236 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698