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 20 matching lines...) Expand all Loading... |
31 * @constructor | 31 * @constructor |
32 * @extends {WebInspector.VBox} | 32 * @extends {WebInspector.VBox} |
33 */ | 33 */ |
34 WebInspector.CookieItemsView = function(treeElement, cookieDomain) | 34 WebInspector.CookieItemsView = function(treeElement, cookieDomain) |
35 { | 35 { |
36 WebInspector.VBox.call(this); | 36 WebInspector.VBox.call(this); |
37 | 37 |
38 this.element.classList.add("storage-view"); | 38 this.element.classList.add("storage-view"); |
39 | 39 |
40 this._deleteButton = new WebInspector.StatusBarButton(WebInspector.UIString(
"Delete"), "delete-storage-status-bar-item"); | 40 this._deleteButton = new WebInspector.StatusBarButton(WebInspector.UIString(
"Delete"), "delete-storage-status-bar-item"); |
41 this._deleteButton.visible = false; | 41 this._deleteButton.setVisible(false); |
42 this._deleteButton.addEventListener("click", this._deleteButtonClicked, this
); | 42 this._deleteButton.addEventListener("click", this._deleteButtonClicked, this
); |
43 | 43 |
44 this._clearButton = new WebInspector.StatusBarButton(WebInspector.UIString("
Clear"), "clear-storage-status-bar-item"); | 44 this._clearButton = new WebInspector.StatusBarButton(WebInspector.UIString("
Clear"), "clear-storage-status-bar-item"); |
45 this._clearButton.visible = false; | 45 this._clearButton.setVisible(false); |
46 this._clearButton.addEventListener("click", this._clearButtonClicked, this); | 46 this._clearButton.addEventListener("click", this._clearButtonClicked, this); |
47 | 47 |
48 this._refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString
("Refresh"), "refresh-storage-status-bar-item"); | 48 this._refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString
("Refresh"), "refresh-storage-status-bar-item"); |
49 this._refreshButton.addEventListener("click", this._refreshButtonClicked, th
is); | 49 this._refreshButton.addEventListener("click", this._refreshButtonClicked, th
is); |
50 | 50 |
51 this._treeElement = treeElement; | 51 this._treeElement = treeElement; |
52 this._cookieDomain = cookieDomain; | 52 this._cookieDomain = cookieDomain; |
53 | 53 |
54 this._emptyView = new WebInspector.EmptyView(WebInspector.UIString("This sit
e has no cookies.")); | 54 this._emptyView = new WebInspector.EmptyView(WebInspector.UIString("This sit
e has no cookies.")); |
55 this._emptyView.show(this.element); | 55 this._emptyView.show(this.element); |
56 | 56 |
57 this.element.addEventListener("contextmenu", this._contextMenu.bind(this), t
rue); | 57 this.element.addEventListener("contextmenu", this._contextMenu.bind(this), t
rue); |
58 } | 58 } |
59 | 59 |
60 WebInspector.CookieItemsView.prototype = { | 60 WebInspector.CookieItemsView.prototype = { |
61 get statusBarItems() | 61 get statusBarItems() |
62 { | 62 { |
63 return [this._refreshButton.element, this._clearButton.element, this._de
leteButton.element]; | 63 return [this._refreshButton.element, this._clearButton.element, this._de
leteButton.element]; |
64 }, | 64 }, |
65 | 65 |
66 wasShown: function() | 66 wasShown: function() |
67 { | 67 { |
68 this._update(); | 68 this._update(); |
69 }, | 69 }, |
70 | 70 |
71 willHide: function() | 71 willHide: function() |
72 { | 72 { |
73 this._deleteButton.visible = false; | 73 this._deleteButton.setVisible(false); |
74 }, | 74 }, |
75 | 75 |
76 _update: function() | 76 _update: function() |
77 { | 77 { |
78 WebInspector.Cookies.getCookiesAsync(this._updateWithCookies.bind(this))
; | 78 WebInspector.Cookies.getCookiesAsync(this._updateWithCookies.bind(this))
; |
79 }, | 79 }, |
80 | 80 |
81 /** | 81 /** |
82 * @param {!Array.<!WebInspector.Cookie>} allCookies | 82 * @param {!Array.<!WebInspector.Cookie>} allCookies |
83 */ | 83 */ |
84 _updateWithCookies: function(allCookies) | 84 _updateWithCookies: function(allCookies) |
85 { | 85 { |
86 this._cookies = this._filterCookiesForDomain(allCookies); | 86 this._cookies = this._filterCookiesForDomain(allCookies); |
87 | 87 |
88 if (!this._cookies.length) { | 88 if (!this._cookies.length) { |
89 // Nothing to show. | 89 // Nothing to show. |
90 this._emptyView.show(this.element); | 90 this._emptyView.show(this.element); |
91 this._clearButton.visible = false; | 91 this._clearButton.setVisible(false); |
92 this._deleteButton.visible = false; | 92 this._deleteButton.setVisible(false); |
93 if (this._cookiesTable) | 93 if (this._cookiesTable) |
94 this._cookiesTable.detach(); | 94 this._cookiesTable.detach(); |
95 return; | 95 return; |
96 } | 96 } |
97 | 97 |
98 if (!this._cookiesTable) | 98 if (!this._cookiesTable) |
99 this._cookiesTable = new WebInspector.CookiesTable(false, this._upda
te.bind(this), this._showDeleteButton.bind(this)); | 99 this._cookiesTable = new WebInspector.CookiesTable(false, this._upda
te.bind(this), this._showDeleteButton.bind(this)); |
100 | 100 |
101 this._cookiesTable.setCookies(this._cookies); | 101 this._cookiesTable.setCookies(this._cookies); |
102 this._emptyView.detach(); | 102 this._emptyView.detach(); |
103 this._cookiesTable.show(this.element); | 103 this._cookiesTable.show(this.element); |
104 this._treeElement.subtitle = String.sprintf(WebInspector.UIString("%d co
okies (%s)"), this._cookies.length, | 104 this._treeElement.subtitle = String.sprintf(WebInspector.UIString("%d co
okies (%s)"), this._cookies.length, |
105 Number.bytesToString(this._totalSize)); | 105 Number.bytesToString(this._totalSize)); |
106 this._clearButton.visible = true; | 106 this._clearButton.setVisible(true); |
107 this._deleteButton.visible = !!this._cookiesTable.selectedCookie(); | 107 this._deleteButton.setVisible(!!this._cookiesTable.selectedCookie()); |
108 }, | 108 }, |
109 | 109 |
110 /** | 110 /** |
111 * @param {!Array.<!WebInspector.Cookie>} allCookies | 111 * @param {!Array.<!WebInspector.Cookie>} allCookies |
112 */ | 112 */ |
113 _filterCookiesForDomain: function(allCookies) | 113 _filterCookiesForDomain: function(allCookies) |
114 { | 114 { |
115 var cookies = []; | 115 var cookies = []; |
116 var resourceURLsForDocumentURL = []; | 116 var resourceURLsForDocumentURL = []; |
117 this._totalSize = 0; | 117 this._totalSize = 0; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 this._update(); | 150 this._update(); |
151 }, | 151 }, |
152 | 152 |
153 _clearButtonClicked: function() | 153 _clearButtonClicked: function() |
154 { | 154 { |
155 this.clear(); | 155 this.clear(); |
156 }, | 156 }, |
157 | 157 |
158 _showDeleteButton: function() | 158 _showDeleteButton: function() |
159 { | 159 { |
160 this._deleteButton.visible = true; | 160 this._deleteButton.setVisible(true); |
161 }, | 161 }, |
162 | 162 |
163 _deleteButtonClicked: function() | 163 _deleteButtonClicked: function() |
164 { | 164 { |
165 var selectedCookie = this._cookiesTable.selectedCookie(); | 165 var selectedCookie = this._cookiesTable.selectedCookie(); |
166 if (selectedCookie) { | 166 if (selectedCookie) { |
167 selectedCookie.remove(); | 167 selectedCookie.remove(); |
168 this._update(); | 168 this._update(); |
169 } | 169 } |
170 }, | 170 }, |
171 | 171 |
172 _refreshButtonClicked: function(event) | 172 _refreshButtonClicked: function(event) |
173 { | 173 { |
174 this._update(); | 174 this._update(); |
175 }, | 175 }, |
176 | 176 |
177 _contextMenu: function(event) | 177 _contextMenu: function(event) |
178 { | 178 { |
179 if (!this._cookies.length) { | 179 if (!this._cookies.length) { |
180 var contextMenu = new WebInspector.ContextMenu(event); | 180 var contextMenu = new WebInspector.ContextMenu(event); |
181 contextMenu.appendItem(WebInspector.UIString("Refresh"), this._updat
e.bind(this)); | 181 contextMenu.appendItem(WebInspector.UIString("Refresh"), this._updat
e.bind(this)); |
182 contextMenu.show(); | 182 contextMenu.show(); |
183 } | 183 } |
184 }, | 184 }, |
185 | 185 |
186 __proto__: WebInspector.VBox.prototype | 186 __proto__: WebInspector.VBox.prototype |
187 } | 187 } |
OLD | NEW |