Chromium Code Reviews| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 */ | 50 */ |
| 51 open: function(site) { | 51 open: function(site) { |
| 52 this.site_ = site; | 52 this.site_ = site; |
| 53 this.populateDialog_(); | 53 this.populateDialog_(); |
| 54 this.listener_ = cr.addWebUIListener( | 54 this.listener_ = cr.addWebUIListener( |
| 55 'onTreeItemRemoved', this.onTreeItemRemoved_.bind(this)); | 55 'onTreeItemRemoved', this.onTreeItemRemoved_.bind(this)); |
| 56 this.$.dialog.showModal(); | 56 this.$.dialog.showModal(); |
| 57 }, | 57 }, |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * Closes the dialog, if open. | |
| 61 */ | |
| 62 close: function() { | |
| 63 var dialog = this.getDialog_(); | |
| 64 if (dialog.open) | |
| 65 dialog.close(); | |
| 66 }, | |
| 67 | |
| 68 /** | |
| 69 * @return {!CrDialogElement} | |
| 70 * @private | |
| 71 */ | |
| 72 getDialog_: function() { | |
| 73 return /** @type {!CrDialogElement} */ (this.$.dialog); | |
| 74 }, | |
|
Finnur
2016/09/29 15:54:01
This was also not mentioned in the bug, but discov
dschuyler
2016/09/29 19:40:27
I think this can be inlined above like:
var dia
Finnur
2016/09/30 09:19:43
Done, with minor modifications. :)
| |
| 75 | |
| 76 /** | |
| 60 * Populates the dialog with the data about the site. | 77 * Populates the dialog with the data about the site. |
| 61 * @private | 78 * @private |
| 62 */ | 79 */ |
| 63 populateDialog_: function() { | 80 populateDialog_: function() { |
| 64 this.title_ = loadTimeData.getStringF('siteSettingsCookieDialog', | 81 this.title_ = loadTimeData.getStringF('siteSettingsCookieDialog', |
| 65 this.site_.data_.title); | 82 this.site_.data_.title); |
| 66 | 83 |
| 67 this.entries_ = this.site_.getCookieList(); | 84 this.entries_ = this.site_.getCookieList(); |
| 68 if (this.entries_.length < 2) { | 85 if (this.entries_.length < 2) { |
| 69 // When there's only one item to show, hide the picker and change the | 86 // When there's only one item to show, hide the picker and change the |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 site.addCookieData(root, node); | 138 site.addCookieData(root, node); |
| 122 }, | 139 }, |
| 123 | 140 |
| 124 /** | 141 /** |
| 125 * Called when a single item has been removed. | 142 * Called when a single item has been removed. |
| 126 * @param {!CookieRemovePacket} args The details about what to remove. | 143 * @param {!CookieRemovePacket} args The details about what to remove. |
| 127 * @private | 144 * @private |
| 128 */ | 145 */ |
| 129 onTreeItemRemoved_: function(args) { | 146 onTreeItemRemoved_: function(args) { |
| 130 this.entries_ = this.site_.getCookieList(); | 147 this.entries_ = this.site_.getCookieList(); |
| 131 if (args.id == this.site_.data_.id || this.entries_.length == 0) { | 148 if (this.site_.children_.length == 0 || this.entries_.length == 0) { |
|
Finnur
2016/09/29 15:54:01
This is to fix the bug with the dialog closing pre
dschuyler
2016/09/29 19:40:27
Acknowledged.
| |
| 132 this.$.dialog.close(); | 149 this.close(); |
| 133 return; | 150 return; |
| 134 } | 151 } |
| 135 | 152 |
| 136 if (this.entries_.length <= this.lastSelectedIndex_) | 153 if (this.entries_.length <= this.lastSelectedIndex_) |
| 137 this.lastSelectedIndex_ = this.entries_.length - 1; | 154 this.lastSelectedIndex_ = this.entries_.length - 1; |
| 138 var selectedId = this.entries_[this.lastSelectedIndex_].id; | 155 var selectedId = this.entries_[this.lastSelectedIndex_].id; |
| 139 this.$.picker.selected = selectedId; | 156 this.$.picker.selected = selectedId; |
| 140 this.populateItem_(selectedId, this.site_); | 157 this.populateItem_(selectedId, this.site_); |
| 141 }, | 158 }, |
| 142 | 159 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 this.site_, this.site_.data_.id, this.$.picker.selected)); | 193 this.site_, this.site_.data_.id, this.$.picker.selected)); |
| 177 }, | 194 }, |
| 178 | 195 |
| 179 /** | 196 /** |
| 180 * A handler for when the user opts to remove all cookies. | 197 * A handler for when the user opts to remove all cookies. |
| 181 * @private | 198 * @private |
| 182 */ | 199 */ |
| 183 onRemoveAll_: function(event) { | 200 onRemoveAll_: function(event) { |
| 184 cr.removeWebUIListener(this.listener_); | 201 cr.removeWebUIListener(this.listener_); |
| 185 this.browserProxy.removeCookie(this.site_.data_.id); | 202 this.browserProxy.removeCookie(this.site_.data_.id); |
| 186 this.$.dialog.close(); | 203 this.close(); |
| 187 }, | 204 }, |
| 188 | 205 |
| 189 /** @private */ | 206 /** @private */ |
| 190 onCancelTap_: function() { | 207 onCancelTap_: function() { |
| 191 this.$.dialog.cancel(); | 208 this.$.dialog.cancel(); |
| 192 }, | 209 }, |
| 193 }); | 210 }); |
| OLD | NEW |