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