OLD | NEW |
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 |
43 ready: function() { | 52 ready: function() { |
44 this.addWebUIListener('onTreeItemRemoved', | 53 this.addWebUIListener('onTreeItemRemoved', |
45 this.onTreeItemRemoved_.bind(this)); | 54 this.onTreeItemRemoved_.bind(this)); |
46 this.treeNodes_ = new settings.CookieTreeNode(null); | 55 this.treeNodes_ = new settings.CookieTreeNode(null); |
47 // Start the initial request. | 56 // Start the initial request. |
48 this.reloadCookies_(); | 57 this.reloadCookies_(); |
49 }, | 58 }, |
50 | 59 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 136 |
128 // If this reaches below zero then we're forgetting to increase the | 137 // 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 | 138 // outstanding request count and the summary list won't be updated at the |
130 // end. | 139 // end. |
131 assert(this.requests_ >= 0); | 140 assert(this.requests_ >= 0); |
132 }, | 141 }, |
133 | 142 |
134 /** | 143 /** |
135 * Called when a single item has been removed (not during delete all). | 144 * Called when a single item has been removed (not during delete all). |
136 * @param {!CookieRemovePacket} args The details about what to remove. | 145 * @param {!CookieRemovePacket} args The details about what to remove. |
| 146 * @private |
137 */ | 147 */ |
138 onTreeItemRemoved_: function(args) { | 148 onTreeItemRemoved_: function(args) { |
139 this.treeNodes_.removeByParentId(args.id, args.start, args.count); | 149 this.treeNodes_.removeByParentId(args.id, args.start, args.count); |
140 this.sites = this.treeNodes_.getSummaryList(); | 150 this.sites = this.treeNodes_.getSummaryList(); |
141 }, | 151 }, |
142 | 152 |
| 153 /** @private */ |
| 154 onCloseDialog_: function() { |
| 155 this.$.confirmDeleteDialog.close(); |
| 156 }, |
| 157 |
143 /** | 158 /** |
144 * Deletes all site data for a given site. | 159 * Confirms the deletion of a site. |
145 * @param {!{model: !{item: CookieDataSummaryItem}}} event | 160 * @param {!{model: !{item: CookieDataSummaryItem}}} event |
146 * @private | 161 * @private |
147 */ | 162 */ |
148 onDeleteSite_: function(event) { | 163 onConfirmDeleteSite_: function(event) { |
149 this.browserProxy.removeCookie(event.model.item.id); | 164 this.idToDelete_ = event.model.item.id; |
| 165 this.confirmationDeleteMsg_ = loadTimeData.getStringF( |
| 166 'siteSettingsCookieRemoveConfirmation', event.model.item.site); |
| 167 this.$.confirmDeleteDialog.showModal(); |
| 168 }, |
| 169 |
| 170 onConfirmDeleteMultipleSites_: function(event) { |
| 171 this.idToDelete_ = ''; // Delete all. |
| 172 this.confirmationDeleteMsg_ = loadTimeData.getString( |
| 173 'siteSettingsCookieRemoveMultipleConfirmation'); |
| 174 this.$.confirmDeleteDialog.showModal(); |
| 175 }, |
| 176 |
| 177 onConfirmDelete_: function(event) { |
| 178 if (this.idToDelete_ != '') |
| 179 this.onDeleteSite_(); |
| 180 else |
| 181 this.onDeleteMultipleSites_(); |
| 182 this.$.confirmDeleteDialog.close(); |
150 }, | 183 }, |
151 | 184 |
152 /** | 185 /** |
| 186 * Deletes all site data for a given site. |
| 187 * @private |
| 188 */ |
| 189 onDeleteSite_: function() { |
| 190 this.browserProxy.removeCookie(this.idToDelete_); |
| 191 }, |
| 192 |
| 193 /** |
153 * Deletes site data for multiple sites. | 194 * Deletes site data for multiple sites. |
154 * @private | 195 * @private |
155 */ | 196 */ |
156 onDeleteMultipleSites_: function() { | 197 onDeleteMultipleSites_: function() { |
157 if (this.filterString_.length == 0) { | 198 if (this.filterString_.length == 0) { |
158 this.browserProxy.removeAllCookies().then(function(list) { | 199 this.browserProxy.removeAllCookies().then(function(list) { |
159 this.loadChildren_(list); | 200 this.loadChildren_(list); |
160 }.bind(this)); | 201 }.bind(this)); |
161 } else { | 202 } else { |
162 var items = this.$.list.items; | 203 var items = this.$.list.items; |
(...skipping 14 matching lines...) Expand all Loading... |
177 this.shadowRoot.appendChild(dialog); | 218 this.shadowRoot.appendChild(dialog); |
178 | 219 |
179 var node = this.treeNodes_.fetchNodeById(event.model.item.id, false); | 220 var node = this.treeNodes_.fetchNodeById(event.model.item.id, false); |
180 dialog.open(node); | 221 dialog.open(node); |
181 | 222 |
182 dialog.addEventListener('close', function(event) { | 223 dialog.addEventListener('close', function(event) { |
183 dialog.remove(); | 224 dialog.remove(); |
184 }); | 225 }); |
185 }, | 226 }, |
186 }); | 227 }); |
OLD | NEW |