2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 WebInspector.StoragePanel = function(database)
32 WebInspector.Panel.call(this, "storage");
35 this.sidebarElement.addStyleClass("outline-disclosure filter-all children small");
36 this.sidebarTreeElement.removeStyleClass("sidebar-tree");
38 if (Preferences.networkPanelEnabled) {
39 this.resourcesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Frames"), "frame-storage-tree-item");
40 this.sidebarTree.appendChild(this.resourcesListTreeElement);
41 this.resourcesListTreeElement.expand();
42 this._treeElementForFrameId = {};
45 this.databasesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Databases"), "database-storage-tree-item");
46 this.sidebarTree.appendChild(this.databasesListTreeElement);
47 this.databasesListTreeElement.expand();
49 this.localStorageListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Local Storage"), "domstorage-storage-tree-item local-storage");
50 this.sidebarTree.appendChild(this.localStorageListTreeElement);
51 this.localStorageListTreeElement.expand();
53 this.sessionStorageListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Session Storage"), "domstorage-storage-tree-item session-storage");
54 this.sidebarTree.appendChild(this.sessionStorageListTreeElement);
55 this.sessionStorageListTreeElement.expand();
57 this.cookieListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Cookies"), "cookie-storage-tree-item");
58 this.sidebarTree.appendChild(this.cookieListTreeElement);
59 this.cookieListTreeElement.expand();
61 this.applicationCacheListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Application Cache"), "application-cache-storage-tree-item");
62 this.sidebarTree.appendChild(this.applicationCacheListTreeElement);
63 this.applicationCacheListTreeElement.expand();
65 this.storageViews = document.createElement("div");
66 this.storageViews.id = "storage-views";
67 this.element.appendChild(this.storageViews);
69 this.storageViewStatusBarItemsContainer = document.createElement("div");
70 this.storageViewStatusBarItemsContainer.className = "status-bar-items";
73 this._domStorage = [];
74 this._cookieViews = {};
77 WebInspector.StoragePanel.prototype = {
78 get toolbarItemLabel()
80 return Preferences.networkPanelEnabled ? WebInspector.UIString("Resources") : WebInspector.UIString("Storage");
85 return [this.storageViewStatusBarItemsContainer];
90 for (var i = 0; i < this._databases.length; ++i) {
91 var database = this._databases[i];
92 delete database._tableViews;
93 delete database._queryView;
97 var domStorageLength = this._domStorage.length;
98 for (var i = 0; i < this._domStorage.length; ++i) {
99 var domStorage = this._domStorage[i];
100 delete domStorage._domStorageView;
102 this._domStorage = [];
104 this._cookieViews = {};
106 this._applicationCacheView = null;
107 delete this._cachedApplicationCacheViewStatus;
109 this.databasesListTreeElement.removeChildren();
110 this.localStorageListTreeElement.removeChildren();
111 this.sessionStorageListTreeElement.removeChildren();
112 this.cookieListTreeElement.removeChildren();
113 this.applicationCacheListTreeElement.removeChildren();
115 this.storageViews.removeChildren();
117 this.storageViewStatusBarItemsContainer.removeChildren();
119 if (this.sidebarTree.selectedTreeElement)
120 this.sidebarTree.selectedTreeElement.deselect();
123 addOrUpdateFrame: function(parentFrameId, frameId, displayName)
125 var frameTreeElement = this._treeElementForFrameId[frameId];
126 if (frameTreeElement) {
127 frameTreeElement.displayName = displayName;
131 var parentTreeElement = parentFrameId ? this._treeElementForFrameId[parentFrameId] : this.resourcesListTreeElement;
132 if (!parentTreeElement) {
133 console.warning("No frame with id:" + parentFrameId + " to route " + displayName + " to.")
137 var frameTreeElement = new WebInspector.FrameTreeElement(this, frameId, displayName);
138 this._treeElementForFrameId[frameId] = frameTreeElement;
140 // Insert in the alphabetical order, first frames, then resources.
141 var children = parentTreeElement.children;
142 for (var i = 0; i < children.length; ++i) {
143 var child = children[i];
144 if (!(child instanceof WebInspector.FrameTreeElement)) {
145 parentTreeElement.insertChild(frameTreeElement, i);
148 if (child.displayName.localeCompare(frameTreeElement.displayName) > 0) {
149 parentTreeElement.insertChild(frameTreeElement, i);
153 parentTreeElement.appendChild(frameTreeElement);
156 removeFrame: function(frameId)
158 var frameTreeElement = this._treeElementForFrameId[frameId];
159 if (!frameTreeElement)
161 delete this._treeElementForFrameId[frameId];
162 if (frameTreeElement.parent)
163 frameTreeElement.parent.removeChild(frameTreeElement);
166 addResourceToFrame: function(frameId, resource)
168 var frameTreeElement = this._treeElementForFrameId[frameId];
169 if (!frameTreeElement) {
170 // This is a frame's main resource, it will be retained
171 // and re-added by the resource manager;
175 var resourceTreeElement = new WebInspector.FrameResourceTreeElement(this, resource);
177 // Insert in the alphabetical order, first frames, then resources. Document resource goes first.
178 var children = frameTreeElement.children;
179 for (var i = 0; i < children.length; ++i) {
180 var child = children[i];
181 if (!(child instanceof WebInspector.FrameResourceTreeElement))
184 if (resource.type === WebInspector.Resource.Type.Document ||
185 (child._resource.type !== WebInspector.Resource.Type.Document && child._resource.displayName.localeCompare(resource.displayName) > 0)) {
186 frameTreeElement.insertChild(resourceTreeElement, i);
190 frameTreeElement.appendChild(resourceTreeElement);
193 removeResourcesFromFrame: function(frameId)
195 var frameTreeElement = this._treeElementForFrameId[frameId];
196 if (frameTreeElement)
197 frameTreeElement.removeChildren();
200 addDatabase: function(database)
202 this._databases.push(database);
204 var databaseTreeElement = new WebInspector.DatabaseTreeElement(this, database);
205 database._databasesTreeElement = databaseTreeElement;
206 this.databasesListTreeElement.appendChild(databaseTreeElement);
209 addCookieDomain: function(domain)
211 var cookieDomainTreeElement = new WebInspector.CookieTreeElement(this, domain);
212 this.cookieListTreeElement.appendChild(cookieDomainTreeElement);
215 addDOMStorage: function(domStorage)
217 this._domStorage.push(domStorage);
218 var domStorageTreeElement = new WebInspector.DOMStorageTreeElement(this, domStorage, (domStorage.isLocalStorage ? "local-storage" : "session-storage"));
219 domStorage._domStorageTreeElement = domStorageTreeElement;
220 if (domStorage.isLocalStorage)
221 this.localStorageListTreeElement.appendChild(domStorageTreeElement);
223 this.sessionStorageListTreeElement.appendChild(domStorageTreeElement);
226 addApplicationCache: function(domain)
228 var applicationCacheTreeElement = new WebInspector.ApplicationCacheTreeElement(this, domain);
229 this.applicationCacheListTreeElement.appendChild(applicationCacheTreeElement);
232 selectDatabase: function(databaseId)
235 for (var i = 0, len = this._databases.length; i < len; ++i) {
236 database = this._databases[i];
237 if (database.id === databaseId) {
238 this.showDatabase(database);
239 database._databasesTreeElement.select();
245 selectDOMStorage: function(storageId)
247 var domStorage = this._domStorageForId(storageId);
249 this.showDOMStorage(domStorage);
250 domStorage._domStorageTreeElement.select();
254 canShowSourceLine: function(url, line)
256 return !!WebInspector.resourceManager.resourceForURL(url);
259 showSourceLine: function(url, line)
261 this.showResource(WebInspector.resourceManager.resourceForURL(url), line);
264 showResource: function(resource, line)
266 var resourceTreeElement = this._findTreeElementForResource(resource);
267 if (resourceTreeElement) {
268 resourceTreeElement.reveal();
269 resourceTreeElement.select();
273 var view = WebInspector.ResourceManager.resourceViewForResource(resource);
274 view.selectContentTab(true);
276 view.revealLine(line);
277 if (view.highlightLine)
278 view.highlightLine(line);
283 _showResourceView: function(resource)
285 var view = WebInspector.ResourceManager.resourceViewForResource(resource);
286 view.headersVisible = false;
287 this._innerShowView(view);
290 showDatabase: function(database, tableName)
297 if (!("_tableViews" in database))
298 database._tableViews = {};
299 view = database._tableViews[tableName];
301 view = new WebInspector.DatabaseTableView(database, tableName);
302 database._tableViews[tableName] = view;
305 view = database._queryView;
307 view = new WebInspector.DatabaseQueryView(database);
308 database._queryView = view;
312 this._innerShowView(view);
315 showDOMStorage: function(domStorage)
321 view = domStorage._domStorageView;
323 view = new WebInspector.DOMStorageItemsView(domStorage);
324 domStorage._domStorageView = view;
327 this._innerShowView(view);
330 showCookies: function(treeElement, cookieDomain)
332 var view = this._cookieViews[cookieDomain];
334 view = new WebInspector.CookieItemsView(treeElement, cookieDomain);
335 this._cookieViews[cookieDomain] = view;
338 this._innerShowView(view);
341 showApplicationCache: function(treeElement, appcacheDomain)
343 var view = this._applicationCacheView;
345 view = new WebInspector.ApplicationCacheItemsView(treeElement, appcacheDomain);
346 this._applicationCacheView = view;
349 this._innerShowView(view);
351 if ("_cachedApplicationCacheViewStatus" in this)
352 this._applicationCacheView.updateStatus(this._cachedApplicationCacheViewStatus);
355 showCategoryView: function(categoryName)
357 if (!this._categoryView)
358 this._categoryView = new WebInspector.StorageCategoryView();
359 this._categoryView.setText(categoryName);
360 this._innerShowView(this._categoryView);
363 _innerShowView: function(view)
365 if (this.visibleView)
366 this.visibleView.hide();
368 view.show(this.storageViews);
369 this.visibleView = view;
371 this.storageViewStatusBarItemsContainer.removeChildren();
372 var statusBarItems = view.statusBarItems || [];
373 for (var i = 0; i < statusBarItems.length; ++i)
374 this.storageViewStatusBarItemsContainer.appendChild(statusBarItems[i]);
377 closeVisibleView: function()
379 if (this.visibleView)
380 this.visibleView.hide();
381 delete this.visibleView;
384 updateDatabaseTables: function(database)
386 if (!database || !database._databasesTreeElement)
389 database._databasesTreeElement.shouldRefreshChildren = true;
391 if (!("_tableViews" in database))
394 var tableNamesHash = {};
396 function tableNamesCallback(tableNames)
398 var tableNamesLength = tableNames.length;
399 for (var i = 0; i < tableNamesLength; ++i)
400 tableNamesHash[tableNames[i]] = true;
402 for (var tableName in database._tableViews) {
403 if (!(tableName in tableNamesHash)) {
404 if (self.visibleView === database._tableViews[tableName])
405 self.closeVisibleView();
406 delete database._tableViews[tableName];
410 database.getTableNames(tableNamesCallback);
413 dataGridForResult: function(columnNames, values)
415 var numColumns = columnNames.length;
421 for (var i = 0; i < columnNames.length; ++i) {
423 column.width = columnNames[i].length;
424 column.title = columnNames[i];
425 column.sortable = true;
427 columns[columnNames[i]] = column;
431 for (var i = 0; i < values.length / numColumns; ++i) {
433 for (var j = 0; j < columnNames.length; ++j)
434 data[columnNames[j]] = values[numColumns * i + j];
436 var node = new WebInspector.DataGridNode(data, false);
437 node.selectable = false;
441 var dataGrid = new WebInspector.DataGrid(columns);
442 var length = nodes.length;
443 for (var i = 0; i < length; ++i)
444 dataGrid.appendChild(nodes[i]);
446 dataGrid.addEventListener("sorting changed", this._sortDataGrid.bind(this, dataGrid), this);
450 _sortDataGrid: function(dataGrid)
452 var nodes = dataGrid.children.slice();
453 var sortColumnIdentifier = dataGrid.sortColumnIdentifier;
454 var sortDirection = dataGrid.sortOrder === "ascending" ? 1 : -1;
455 var columnIsNumeric = true;
457 for (var i = 0; i < nodes.length; i++) {
458 if (isNaN(Number(nodes[i].data[sortColumnIdentifier])))
459 columnIsNumeric = false;
462 function comparator(dataGridNode1, dataGridNode2)
464 var item1 = dataGridNode1.data[sortColumnIdentifier];
465 var item2 = dataGridNode2.data[sortColumnIdentifier];
468 if (columnIsNumeric) {
469 // Sort numbers based on comparing their values rather than a lexicographical comparison.
470 var number1 = parseFloat(item1);
471 var number2 = parseFloat(item2);
472 comparison = number1 < number2 ? -1 : (number1 > number2 ? 1 : 0);
474 comparison = item1 < item2 ? -1 : (item1 > item2 ? 1 : 0);
476 return sortDirection * comparison;
479 nodes.sort(comparator);
480 dataGrid.removeChildren();
481 for (var i = 0; i < nodes.length; i++)
482 dataGrid.appendChild(nodes[i]);
485 updateDOMStorage: function(storageId)
487 var domStorage = this._domStorageForId(storageId);
491 var view = domStorage._domStorageView;
492 if (this.visibleView && view === this.visibleView)
493 domStorage._domStorageView.update();
496 updateApplicationCacheStatus: function(status)
498 this._cachedApplicationCacheViewStatus = status;
499 if (this._applicationCacheView && this._applicationCacheView === this.visibleView)
500 this._applicationCacheView.updateStatus(status);
503 updateNetworkState: function(isNowOnline)
505 if (this._applicationCacheView && this._applicationCacheView === this.visibleView)
506 this._applicationCacheView.updateNetworkState(isNowOnline);
509 updateManifest: function(manifest)
511 if (this._applicationCacheView && this._applicationCacheView === this.visibleView)
512 this._applicationCacheView.updateManifest(manifest);
515 _domStorageForId: function(storageId)
517 if (!this._domStorage)
519 var domStorageLength = this._domStorage.length;
520 for (var i = 0; i < domStorageLength; ++i) {
521 var domStorage = this._domStorage[i];
522 if (domStorage.id == storageId)
528 updateMainViewWidth: function(width)
530 this.storageViews.style.left = width + "px";
531 this.storageViewStatusBarItemsContainer.style.left = width + "px";
535 get searchableViews()
539 if (!Preferences.networkPanelEnabled)
542 const visibleView = this.visibleView;
543 if (visibleView instanceof WebInspector.ResourceView && visibleView.performSearch)
544 views.push(visibleView);
546 function callback(resourceTreeElement)
548 var resource = resourceTreeElement._resource;
549 var resourceView = WebInspector.ResourceManager.resourceViewForResource(resource);
550 if (resourceView.performSearch && resourceView !== visibleView)
551 views.push(resourceView);
553 this._forAllResourceTreeElements(callback);
557 _forAllResourceTreeElements: function(callback)
560 for (var treeElement = this.resourcesListTreeElement; !stop && treeElement; treeElement = treeElement.traverseNextTreeElement(false, this.resourcesListTreeElement, true)) {
561 if (treeElement instanceof WebInspector.FrameResourceTreeElement)
562 stop = callback(treeElement);
566 searchMatchFound: function(view, matches)
570 var treeElement = this._findTreeElementForResource(view.resource);
572 treeElement.searchMatchFound(matches);
575 _findTreeElementForResource: function(resource)
577 function isAncestor(ancestor, object)
579 console.error("There should be no calls to isAncestor, but there was one for ", object);
583 function getParent(object)
585 console.error("There should be no calls to getParent, but there was one for ", object);
589 return this.sidebarTree.findTreeElement(resource, isAncestor, getParent);
592 searchCanceled: function(startingNewSearch)
594 WebInspector.Panel.prototype.searchCanceled.call(this, startingNewSearch);
596 if (startingNewSearch)
599 function callback(resourceTreeElement)
601 resourceTreeElement._errorsWarningsUpdated();
603 this._forAllResourceTreeElements(callback);
606 performSearch: function(query)
608 function callback(resourceTreeElement)
610 resourceTreeElement._resetBubble();
612 this._forAllResourceTreeElements(callback);
613 WebInspector.Panel.prototype.performSearch.call(this, query);
616 showView: function(view)
619 this.showResource(view.resource);
623 WebInspector.StoragePanel.prototype.__proto__ = WebInspector.Panel.prototype;
625 WebInspector.BaseStorageTreeElement = function(storagePanel, representedObject, title, iconClass, hasChildren)
627 TreeElement.call(this, "", representedObject, hasChildren);
628 this._storagePanel = storagePanel;
629 this._titleText = title;
630 this._iconClass = iconClass;
633 WebInspector.BaseStorageTreeElement.prototype = {
636 this.listItemElement.removeChildren();
637 this.listItemElement.addStyleClass(this._iconClass);
639 var selectionElement = document.createElement("div");
640 selectionElement.className = "selection";
641 this.listItemElement.appendChild(selectionElement);
643 this.imageElement = document.createElement("img");
644 this.imageElement.className = "icon";
645 this.listItemElement.appendChild(this.imageElement);
647 this.titleElement = document.createElement("div");
648 this.titleElement.className = "base-storage-tree-element-title";
649 this.titleElement.textContent = this._titleText;
650 this.listItemElement.appendChild(this.titleElement);
655 if (this.listItemElement)
656 this.listItemElement.scrollIntoViewIfNeeded(false);
659 set titleText(titleText)
661 this._titleText = titleText;
662 this.titleElement.textContent = this._titleText;
665 isEventWithinDisclosureTriangle: function()
667 // Override it since we use margin-left in place of treeoutline's text-indent.
668 // Hence we need to take padding into consideration. This all is needed for leading
669 // icons in the tree.
670 const paddingLeft = 14;
671 var left = this.listItemElement.totalOffsetLeft + paddingLeft;
672 return event.pageX >= left && event.pageX <= left + this.arrowToggleWidth && this.hasChildren;
676 WebInspector.BaseStorageTreeElement.prototype.__proto__ = TreeElement.prototype;
678 WebInspector.StorageCategoryTreeElement = function(storagePanel, categoryName, iconClass)
680 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, categoryName, iconClass, true);
681 this._categoryName = categoryName;
684 WebInspector.StorageCategoryTreeElement.prototype = {
687 this._storagePanel.showCategoryView(this._categoryName);
690 WebInspector.StorageCategoryTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
692 WebInspector.FrameTreeElement = function(storagePanel, frameId, displayName)
694 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, displayName, "frame-storage-tree-item");
695 this._frameId = frameId;
696 this._displayName = displayName;
699 WebInspector.FrameTreeElement.prototype = {
702 this._storagePanel.showCategoryView(this._displayName);
707 return this._displayName;
710 set displayName(displayName)
712 this._displayName = displayName;
713 this.titleText = displayName;
716 WebInspector.FrameTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
718 WebInspector.FrameResourceTreeElement = function(storagePanel, resource)
720 WebInspector.BaseStorageTreeElement.call(this, storagePanel, resource, resource.displayName, "resource-sidebar-tree-item resources-category-" + resource.category.name);
721 this._resource = resource;
722 this._resource.addEventListener("errors-warnings-updated", this._errorsWarningsUpdated, this);
723 this.tooltip = resource.url;
726 WebInspector.FrameResourceTreeElement.prototype = {
729 this._storagePanel._showResourceView(this._resource);
732 ondblclick: function(event)
734 InspectorBackend.openInInspectedWindow(this._resource.url);
739 WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
741 if (this._resource.category === WebInspector.resourceCategories.images) {
742 var previewImage = document.createElement("img");
743 previewImage.className = "image-resource-icon-preview";
744 previewImage.src = this._resource.url;
746 var iconElement = document.createElement("div");
747 iconElement.className = "icon";
748 iconElement.appendChild(previewImage);
749 this.listItemElement.replaceChild(iconElement, this.imageElement);
752 this._statusElement = document.createElement("div");
753 this._statusElement.className = "status";
754 this.listItemElement.insertBefore(this._statusElement, this.titleElement);
756 this.listItemElement.draggable = true;
757 this.listItemElement.addEventListener("dragstart", this._ondragstart.bind(this), false);
760 _ondragstart: function(event)
762 event.dataTransfer.setData("text/plain", this._resource.url);
763 event.dataTransfer.setData("text/uri-list", this._resource.url + "\r\n");
764 event.dataTransfer.effectAllowed = "copy";
768 _setBubbleText: function(x)
770 if (!this._bubbleElement) {
771 this._bubbleElement = document.createElement("div");
772 this._bubbleElement.className = "bubble";
773 this._statusElement.appendChild(this._bubbleElement);
776 this._bubbleElement.textContent = x;
779 _resetBubble: function()
781 if (this._bubbleElement) {
782 this._bubbleElement.textContent = "";
783 this._bubbleElement.removeStyleClass("search-matches");
784 this._bubbleElement.removeStyleClass("warning");
785 this._bubbleElement.removeStyleClass("error");
789 searchMatchFound: function(matches)
793 this._setBubbleText(matches);
794 this._bubbleElement.addStyleClass("search-matches");
796 // Expand, do not scroll into view.
797 var currentAncestor = this.parent;
798 while (currentAncestor && !currentAncestor.root) {
799 if (!currentAncestor.expanded)
800 currentAncestor.expand();
801 currentAncestor = currentAncestor.parent;
805 _errorsWarningsUpdated: function()
807 // FIXME: move to the Script/SourceView.
808 if (!this._resource.warnings && !this._resource.errors) {
809 var view = WebInspector.ResourceManager.existingResourceViewForResource(this._resource);
810 if (view && view.clearMessages)
811 view.clearMessages();
814 if (this._storagePanel.currentQuery)
819 if (this._resource.warnings || this._resource.errors)
820 this._setBubbleText(this._resource.warnings + this._resource.errors);
822 if (this._resource.warnings)
823 this._bubbleElement.addStyleClass("warning");
825 if (this._resource.errors)
826 this._bubbleElement.addStyleClass("error");
830 WebInspector.FrameResourceTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
832 WebInspector.DatabaseTreeElement = function(storagePanel, database)
834 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, database.name, "database-storage-tree-item", true);
835 this._database = database;
838 WebInspector.DatabaseTreeElement.prototype = {
841 this._storagePanel.showDatabase(this._database);
844 oncollapse: function()
846 // Request a refresh after every collapse so the next
847 // expand will have an updated table list.
848 this.shouldRefreshChildren = true;
851 onpopulate: function()
853 this.removeChildren();
855 function tableNamesCallback(tableNames)
857 var tableNamesLength = tableNames.length;
858 for (var i = 0; i < tableNamesLength; ++i)
859 this.appendChild(new WebInspector.DatabaseTableTreeElement(this._storagePanel, this._database, tableNames[i]));
861 this._database.getTableNames(tableNamesCallback.bind(this));
865 WebInspector.DatabaseTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
867 WebInspector.DatabaseTableTreeElement = function(storagePanel, database, tableName)
869 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, tableName, "database-storage-tree-item");
870 this._database = database;
871 this._tableName = tableName;
874 WebInspector.DatabaseTableTreeElement.prototype = {
877 this._storagePanel.showDatabase(this._database, this._tableName);
880 WebInspector.DatabaseTableTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
882 WebInspector.DOMStorageTreeElement = function(storagePanel, domStorage, className)
884 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, domStorage.domain ? domStorage.domain : WebInspector.UIString("Local Files"), "domstorage-storage-tree-item " + className);
885 this._domStorage = domStorage;
888 WebInspector.DOMStorageTreeElement.prototype = {
891 this._storagePanel.showDOMStorage(this._domStorage);
894 WebInspector.DOMStorageTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
896 WebInspector.CookieTreeElement = function(storagePanel, cookieDomain)
898 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, cookieDomain ? cookieDomain : WebInspector.UIString("Local Files"), "cookie-storage-tree-item");
899 this._cookieDomain = cookieDomain;
902 WebInspector.CookieTreeElement.prototype = {
905 this._storagePanel.showCookies(this, this._cookieDomain);
908 WebInspector.CookieTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
910 WebInspector.ApplicationCacheTreeElement = function(storagePanel, appcacheDomain)
912 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, appcacheDomain ? appcacheDomain : WebInspector.UIString("Local Files"), "application-cache-storage-tree-item");
913 this._appcacheDomain = appcacheDomain;
916 WebInspector.ApplicationCacheTreeElement.prototype = {
919 this._storagePanel.showApplicationCache(this, this._appcacheDomain);
922 WebInspector.ApplicationCacheTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
924 WebInspector.StorageCategoryView = function()
926 WebInspector.View.call(this);
928 this.element.addStyleClass("storage-view");
930 this._emptyMsgElement = document.createElement("div");
931 this._emptyMsgElement.className = "storage-empty-view";
932 this.element.appendChild(this._emptyMsgElement);
935 WebInspector.StorageCategoryView.prototype = {
936 setText: function(text)
938 this._emptyMsgElement.textContent = text;
942 WebInspector.StorageCategoryView.prototype.__proto__ = WebInspector.View.prototype;