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-details-dialog' provides a dialog to show details of site data | 7 * 'site-data-details-dialog' provides a dialog to show details of site data |
8 * stored by a given site. | 8 * stored by a given site. |
9 */ | 9 */ |
10 Polymer({ | 10 Polymer({ |
(...skipping 15 matching lines...) Expand all Loading... |
26 site_: Object, | 26 site_: Object, |
27 | 27 |
28 /** | 28 /** |
29 * The cookie entries for the given site. | 29 * The cookie entries for the given site. |
30 * @type {!Array<!CookieDataItem>} | 30 * @type {!Array<!CookieDataItem>} |
31 * @private | 31 * @private |
32 */ | 32 */ |
33 entries_: Array, | 33 entries_: Array, |
34 | 34 |
35 /** | 35 /** |
| 36 * The cookie nodes to show in the dialog. |
| 37 * @type {!Array<CookieDataForDisplay>} |
| 38 * @private |
| 39 */ |
| 40 cookieNodes_: Object, |
| 41 |
| 42 /** |
36 * The index of the last selected item. | 43 * The index of the last selected item. |
37 */ | 44 */ |
38 lastSelectedIndex_: Number, | 45 lastSelectedIndex_: Number, |
39 | 46 |
40 /** | 47 /** |
41 * Our WebUI listener. | 48 * Our WebUI listener. |
42 * @type {?WebUIListener} | 49 * @type {?WebUIListener} |
43 */ | 50 */ |
44 listener_: Object, | 51 listener_: Object, |
45 }, | 52 }, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 return ''; | 118 return ''; |
112 }, | 119 }, |
113 | 120 |
114 /** | 121 /** |
115 * Add the cookie data to the content section of this dialog. | 122 * Add the cookie data to the content section of this dialog. |
116 * @param {string} id The id of the cookie node to display. | 123 * @param {string} id The id of the cookie node to display. |
117 * @param {!settings.CookieTreeNode} site The current site. | 124 * @param {!settings.CookieTreeNode} site The current site. |
118 * @private | 125 * @private |
119 */ | 126 */ |
120 populateItem_: function(id, site) { | 127 populateItem_: function(id, site) { |
121 // Out with the old... | |
122 var root = this.$.content; | |
123 while (root.lastChild) { | |
124 root.removeChild(root.lastChild); | |
125 } | |
126 | |
127 // In with the new... | |
128 var node = site.fetchNodeById(id, true); | 128 var node = site.fetchNodeById(id, true); |
129 if (node) | 129 if (node) |
130 site.addCookieData(root, node); | 130 this.cookieNodes_ = site.getCookieData(node); |
131 }, | 131 }, |
132 | 132 |
133 /** | 133 /** |
134 * Called when a single item has been removed. | 134 * Called when a single item has been removed. |
135 * @param {!CookieRemovePacket} args The details about what to remove. | 135 * @param {!CookieRemovePacket} args The details about what to remove. |
136 * @private | 136 * @private |
137 */ | 137 */ |
138 onTreeItemRemoved_: function(args) { | 138 onTreeItemRemoved_: function(args) { |
139 this.entries_ = this.site_.getCookieList(); | 139 this.entries_ = this.site_.getCookieList(); |
140 if (this.site_.children_.length == 0 || this.entries_.length == 0) { | 140 if (this.site_.children_.length == 0 || this.entries_.length == 0) { |
(...skipping 24 matching lines...) Expand all Loading... |
165 break; | 165 break; |
166 } | 166 } |
167 } | 167 } |
168 }, | 168 }, |
169 | 169 |
170 getEntryDescription: function(item) { | 170 getEntryDescription: function(item) { |
171 // Frequently there are multiple cookies per site. To avoid showing a list | 171 // Frequently there are multiple cookies per site. To avoid showing a list |
172 // of '1 cookie', '1 cookie', ... etc, it is better to show the title of the | 172 // of '1 cookie', '1 cookie', ... etc, it is better to show the title of the |
173 // cookie to differentiate them. | 173 // cookie to differentiate them. |
174 if (item.data.type == 'cookie') | 174 if (item.data.type == 'cookie') |
175 return item.title; | 175 return loadTimeData.getStringF('siteSettingsCookie', item.title); |
176 | 176 |
177 return getCookieDataCategoryText(item.data.type, item.data.totalUsage); | 177 return getCookieDataCategoryText(item.data.type, item.data.totalUsage); |
178 }, | 178 }, |
179 | 179 |
180 /** | 180 /** |
181 * A handler for when the user opts to remove a single cookie. | 181 * A handler for when the user opts to remove a single cookie. |
182 * @private | 182 * @private |
183 */ | 183 */ |
184 onRemove_: function(event) { | 184 onRemove_: function(event) { |
185 this.browserProxy.removeCookie(this.nodePath_( | 185 this.browserProxy.removeCookie(this.nodePath_( |
186 this.site_, this.site_.data_.id, this.$.picker.value)); | 186 this.site_, this.site_.data_.id, this.$.picker.value)); |
187 }, | 187 }, |
188 | 188 |
189 /** | 189 /** |
190 * A handler for when the user opts to remove all cookies. | 190 * A handler for when the user opts to remove all cookies. |
191 * @private | 191 * @private |
192 */ | 192 */ |
193 onRemoveAll_: function(event) { | 193 onRemoveAll_: function(event) { |
194 cr.removeWebUIListener(this.listener_); | 194 cr.removeWebUIListener(this.listener_); |
195 this.browserProxy.removeCookie(this.site_.data_.id); | 195 this.browserProxy.removeCookie(this.site_.data_.id); |
196 this.close(); | 196 this.close(); |
197 }, | 197 }, |
198 | 198 |
199 /** @private */ | 199 /** @private */ |
200 onCancelTap_: function() { | 200 onCancelTap_: function() { |
201 this.$.dialog.cancel(); | 201 this.$.dialog.cancel(); |
202 }, | 202 }, |
203 }); | 203 }); |
OLD | NEW |