| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 this.site_.data_.title); | 74 this.site_.data_.title); |
| 75 | 75 |
| 76 this.entries_ = this.site_.getCookieList(); | 76 this.entries_ = this.site_.getCookieList(); |
| 77 if (this.entries_.length < 2) { | 77 if (this.entries_.length < 2) { |
| 78 // When there's only one item to show, hide the picker and change the | 78 // When there's only one item to show, hide the picker and change the |
| 79 // 'Remove All' button to read 'Remove' instead. | 79 // 'Remove All' button to read 'Remove' instead. |
| 80 this.$.container.hidden = true; | 80 this.$.container.hidden = true; |
| 81 this.$.clear.textContent = | 81 this.$.clear.textContent = |
| 82 loadTimeData.getString('siteSettingsCookieRemove'); | 82 loadTimeData.getString('siteSettingsCookieRemove'); |
| 83 } else { | 83 } else { |
| 84 this.$.picker.selected = this.entries_[0].id; | 84 this.$.picker.value = this.entries_[0].id; |
| 85 this.lastSelectedIndex_ = 0; | 85 this.lastSelectedIndex_ = 0; |
| 86 } | 86 } |
| 87 | 87 |
| 88 this.populateItem_(this.entries_[0].id, this.site_); | 88 this.populateItem_(this.entries_[0].id, this.site_); |
| 89 }, | 89 }, |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * Recursively look up a node path for a leaf node with a given id. | 92 * Recursively look up a node path for a leaf node with a given id. |
| 93 * @param {!settings.CookieTreeNode} node The node to start with. | 93 * @param {!settings.CookieTreeNode} node The node to start with. |
| 94 * @param {string} currentPath The path constructed so far. | 94 * @param {string} currentPath The path constructed so far. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) { |
| 141 this.close(); | 141 this.close(); |
| 142 return; | 142 return; |
| 143 } | 143 } |
| 144 | 144 |
| 145 if (this.entries_.length <= this.lastSelectedIndex_) | 145 if (this.entries_.length <= this.lastSelectedIndex_) |
| 146 this.lastSelectedIndex_ = this.entries_.length - 1; | 146 this.lastSelectedIndex_ = this.entries_.length - 1; |
| 147 var selectedId = this.entries_[this.lastSelectedIndex_].id; | 147 var selectedId = this.entries_[this.lastSelectedIndex_].id; |
| 148 this.$.picker.selected = selectedId; | 148 this.$.picker.value = selectedId; |
| 149 this.populateItem_(selectedId, this.site_); | 149 this.populateItem_(selectedId, this.site_); |
| 150 }, | 150 }, |
| 151 | 151 |
| 152 /** | 152 /** |
| 153 * A handler for when the user changes the dropdown box (switches cookies). | 153 * A handler for when the user changes the dropdown box (switches cookies). |
| 154 * @private | 154 * @private |
| 155 */ | 155 */ |
| 156 onItemSelected_: function(event) { | 156 onItemSelected_: function() { |
| 157 this.populateItem_(event.detail.selected, this.site_); | 157 var selectedItem = this.$.picker.value; |
| 158 this.populateItem_(selectedItem, this.site_); |
| 158 | 159 |
| 159 // Store the index of what was selected so we can re-select the next value | 160 // Store the index of what was selected so we can re-select the next value |
| 160 // when things get deleted. | 161 // when things get deleted. |
| 161 for (var i = 0; i < this.entries_.length; ++i) { | 162 for (var i = 0; i < this.entries_.length; ++i) { |
| 162 if (this.entries_[i].data.id == event.detail.selected) { | 163 if (this.entries_[i].data.id == selectedItem) { |
| 163 this.lastSelectedIndex_ = i; | 164 this.lastSelectedIndex_ = i; |
| 164 break; | 165 break; |
| 165 } | 166 } |
| 166 } | 167 } |
| 167 }, | 168 }, |
| 168 | 169 |
| 169 getEntryDescription: function(item) { | 170 getEntryDescription: function(item) { |
| 170 // 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 |
| 171 // 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 |
| 172 // cookie to differentiate them. | 173 // cookie to differentiate them. |
| 173 if (item.data.type == 'cookie') | 174 if (item.data.type == 'cookie') |
| 174 return item.title; | 175 return item.title; |
| 175 | 176 |
| 176 return getCookieDataCategoryText(item.data.type, item.data.totalUsage); | 177 return getCookieDataCategoryText(item.data.type, item.data.totalUsage); |
| 177 }, | 178 }, |
| 178 | 179 |
| 179 /** | 180 /** |
| 180 * 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. |
| 181 * @private | 182 * @private |
| 182 */ | 183 */ |
| 183 onRemove_: function(event) { | 184 onRemove_: function(event) { |
| 184 this.browserProxy.removeCookie(this.nodePath_( | 185 this.browserProxy.removeCookie(this.nodePath_( |
| 185 this.site_, this.site_.data_.id, this.$.picker.selected)); | 186 this.site_, this.site_.data_.id, this.$.picker.value)); |
| 186 }, | 187 }, |
| 187 | 188 |
| 188 /** | 189 /** |
| 189 * A handler for when the user opts to remove all cookies. | 190 * A handler for when the user opts to remove all cookies. |
| 190 * @private | 191 * @private |
| 191 */ | 192 */ |
| 192 onRemoveAll_: function(event) { | 193 onRemoveAll_: function(event) { |
| 193 cr.removeWebUIListener(this.listener_); | 194 cr.removeWebUIListener(this.listener_); |
| 194 this.browserProxy.removeCookie(this.site_.data_.id); | 195 this.browserProxy.removeCookie(this.site_.data_.id); |
| 195 this.close(); | 196 this.close(); |
| 196 }, | 197 }, |
| 197 | 198 |
| 198 /** @private */ | 199 /** @private */ |
| 199 onCancelTap_: function() { | 200 onCancelTap_: function() { |
| 200 this.$.dialog.cancel(); | 201 this.$.dialog.cancel(); |
| 201 }, | 202 }, |
| 202 }); | 203 }); |
| OLD | NEW |