| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 this._emptyWidget.show(this.element); | 64 this._emptyWidget.show(this.element); |
| 65 | 65 |
| 66 this.element.addEventListener('contextmenu', this._contextMenu.bind(this), t
rue); | 66 this.element.addEventListener('contextmenu', this._contextMenu.bind(this), t
rue); |
| 67 } | 67 } |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * @override | 70 * @override |
| 71 * @return {!Array.<!UI.ToolbarItem>} | 71 * @return {!Array.<!UI.ToolbarItem>} |
| 72 */ | 72 */ |
| 73 syncToolbarItems() { | 73 syncToolbarItems() { |
| 74 return [ | 74 return [this._refreshButton, this._clearButton, this._deleteButton, this._fi
lterSeparator, this._filterButton]; |
| 75 this._refreshButton, this._clearButton, this._deleteButton, | |
| 76 this._filterSeparator, this._filterButton | |
| 77 ]; | |
| 78 } | 75 } |
| 79 | 76 |
| 80 /** | 77 /** |
| 81 * @override | 78 * @override |
| 82 */ | 79 */ |
| 83 wasShown() { | 80 wasShown() { |
| 84 this._update(); | 81 this._update(); |
| 85 } | 82 } |
| 86 | 83 |
| 87 /** | 84 /** |
| (...skipping 28 matching lines...) Expand all Loading... |
| 116 this._filterButton.setEnabled(false); | 113 this._filterButton.setEnabled(false); |
| 117 this._clearButton.setEnabled(false); | 114 this._clearButton.setEnabled(false); |
| 118 this._deleteButton.setEnabled(false); | 115 this._deleteButton.setEnabled(false); |
| 119 if (this._cookiesTable) | 116 if (this._cookiesTable) |
| 120 this._cookiesTable.detach(); | 117 this._cookiesTable.detach(); |
| 121 return; | 118 return; |
| 122 } | 119 } |
| 123 | 120 |
| 124 if (!this._cookiesTable) { | 121 if (!this._cookiesTable) { |
| 125 this._cookiesTable = | 122 this._cookiesTable = |
| 126 new Components.CookiesTable(false, this._update.bind(this), this._enab
leDeleteButton.bind(this)); | 123 new CookieTable.CookiesTable(false, this._update.bind(this), this._ena
bleDeleteButton.bind(this)); |
| 127 } | 124 } |
| 128 | 125 |
| 129 var shownCookies = this._filterCookiesForFilters(this._cookies); | 126 var shownCookies = this._filterCookiesForFilters(this._cookies); |
| 130 this._cookiesTable.setCookies(shownCookies); | 127 this._cookiesTable.setCookies(shownCookies); |
| 131 this._emptyWidget.detach(); | 128 this._emptyWidget.detach(); |
| 132 this._cookiesTable.show(this.element); | 129 this._cookiesTable.show(this.element); |
| 133 this._filterBar.show(this.element); | 130 this._filterBar.show(this.element); |
| 134 this._treeElement.subtitle = | 131 this._treeElement.subtitle = |
| 135 String.sprintf(Common.UIString('%d cookies (%s)'), this._cookies.length,
Number.bytesToString(this._totalSize)); | 132 String.sprintf(Common.UIString('%d cookies (%s)'), this._cookies.length,
Number.bytesToString(this._totalSize)); |
| 136 this._filterButton.setEnabled(true); | 133 this._filterButton.setEnabled(true); |
| 137 this._clearButton.setEnabled(true); | 134 this._clearButton.setEnabled(true); |
| 138 this._deleteButton.setEnabled(!!this._cookiesTable.selectedCookie()); | 135 this._deleteButton.setEnabled(!!this._cookiesTable.selectedCookie()); |
| 139 } | 136 } |
| 140 | 137 |
| 141 /** | 138 /** |
| 142 * @param {!Array.<!SDK.Cookie>} cookies | 139 * @param {!Array.<!SDK.Cookie>} cookies |
| 143 */ | 140 */ |
| 144 _filterCookiesForFilters(cookies) { | 141 _filterCookiesForFilters(cookies) { |
| 145 if (!this._filterRegex) | 142 if (!this._filterRegex) |
| 146 return cookies; | 143 return cookies; |
| 147 | 144 |
| 148 return cookies.filter(cookie => { | 145 return cookies.filter(cookie => { |
| 149 const candidate = `${cookie.name()} ${cookie.value()} ${cookie.domain()}`; | 146 const candidate = `${cookie.name()} ${cookie.value()} ${cookie.domain()}`; |
| 150 return this._filterRegex.test(candidate); | 147 return this._filterRegex.test(candidate); |
| 151 }); | 148 }); |
| 152 } | 149 } |
| 153 | 150 |
| 154 /** | 151 /** |
| 155 * @param {!Array.<!SDK.Cookie>} allCookies | 152 * @param {!Array.<!SDK.Cookie>} allCookies |
| 156 */ | 153 */ |
| 157 _filterCookiesForDomain(allCookies) { | 154 _filterCookiesForDomain(allCookies) { |
| 158 var cookies = []; | 155 var cookies = []; |
| 159 var resourceURLsForDocumentURL = []; | 156 var resourceURLsForDocumentURL = []; |
| 160 this._totalSize = 0; | 157 this._totalSize = 0; |
| 161 | 158 |
| 162 /** | 159 /** |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 218 } |
| 222 | 219 |
| 223 _contextMenu(event) { | 220 _contextMenu(event) { |
| 224 if (!this._cookies.length) { | 221 if (!this._cookies.length) { |
| 225 var contextMenu = new UI.ContextMenu(event); | 222 var contextMenu = new UI.ContextMenu(event); |
| 226 contextMenu.appendItem(Common.UIString('Refresh'), this._update.bind(this)
); | 223 contextMenu.appendItem(Common.UIString('Refresh'), this._update.bind(this)
); |
| 227 contextMenu.show(); | 224 contextMenu.show(); |
| 228 } | 225 } |
| 229 } | 226 } |
| 230 }; | 227 }; |
| OLD | NEW |