Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / devtools / front_end / resources / ResourcesPanel.js
bloba39cfd4e439edabdf1184d136993080bde77dcdb
1 /*
2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro
4 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 /**
32 * @constructor
33 * @extends {WebInspector.PanelWithSidebar}
34 * @implements {WebInspector.TargetManager.Observer}
36 WebInspector.ResourcesPanel = function()
38 WebInspector.PanelWithSidebar.call(this, "resources");
39 this.registerRequiredCSS("resources/resourcesPanel.css");
41 this._resourcesLastSelectedItemSetting = WebInspector.settings.createSetting("resourcesLastSelectedItem", {});
43 this._sidebarTree = new TreeOutline();
44 this._sidebarTree.element.classList.add("filter-all", "children", "small", "outline-disclosure");
45 this.panelSidebarElement().appendChild(this._sidebarTree.element);
46 this.setDefaultFocusedElement(this._sidebarTree.element);
48 this.resourcesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Frames"), "Frames", ["frame-storage-tree-item"]);
49 this._sidebarTree.appendChild(this.resourcesListTreeElement);
51 this.databasesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Web SQL"), "Databases", ["database-storage-tree-item"]);
52 this._sidebarTree.appendChild(this.databasesListTreeElement);
54 this.indexedDBListTreeElement = new WebInspector.IndexedDBTreeElement(this);
55 this._sidebarTree.appendChild(this.indexedDBListTreeElement);
57 this.localStorageListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Local Storage"), "LocalStorage", ["domstorage-storage-tree-item", "local-storage"]);
58 this._sidebarTree.appendChild(this.localStorageListTreeElement);
60 this.sessionStorageListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Session Storage"), "SessionStorage", ["domstorage-storage-tree-item", "session-storage"]);
61 this._sidebarTree.appendChild(this.sessionStorageListTreeElement);
63 this.cookieListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Cookies"), "Cookies", ["cookie-storage-tree-item"]);
64 this._sidebarTree.appendChild(this.cookieListTreeElement);
66 this.applicationCacheListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Application Cache"), "ApplicationCache", ["application-cache-storage-tree-item"]);
67 this._sidebarTree.appendChild(this.applicationCacheListTreeElement);
69 this.cacheStorageListTreeElement = new WebInspector.ServiceWorkerCacheTreeElement(this);
70 this._sidebarTree.appendChild(this.cacheStorageListTreeElement);
72 if (Runtime.experiments.isEnabled("fileSystemInspection")) {
73 this.fileSystemListTreeElement = new WebInspector.FileSystemListTreeElement(this);
74 this._sidebarTree.appendChild(this.fileSystemListTreeElement);
77 var mainContainer = new WebInspector.VBox();
78 this.storageViews = mainContainer.element.createChild("div", "vbox flex-auto");
79 this._storageViewToolbar = new WebInspector.Toolbar(mainContainer.element);
80 this._storageViewToolbar.element.classList.add("resources-toolbar");
81 this.splitWidget().setMainWidget(mainContainer);
83 /** @type {!Map.<!WebInspector.Database, !Object.<string, !WebInspector.DatabaseTableView>>} */
84 this._databaseTableViews = new Map();
85 /** @type {!Map.<!WebInspector.Database, !WebInspector.DatabaseQueryView>} */
86 this._databaseQueryViews = new Map();
87 /** @type {!Map.<!WebInspector.Database, !WebInspector.DatabaseTreeElement>} */
88 this._databaseTreeElements = new Map();
89 /** @type {!Map.<!WebInspector.DOMStorage, !WebInspector.DOMStorageItemsView>} */
90 this._domStorageViews = new Map();
91 /** @type {!Map.<!WebInspector.DOMStorage, !WebInspector.DOMStorageTreeElement>} */
92 this._domStorageTreeElements = new Map();
93 /** @type {!Object.<string, !WebInspector.CookieItemsView>} */
94 this._cookieViews = {};
95 /** @type {!Object.<string, boolean>} */
96 this._domains = {};
98 this.panelSidebarElement().addEventListener("mousemove", this._onmousemove.bind(this), false);
99 this.panelSidebarElement().addEventListener("mouseleave", this._onmouseleave.bind(this), false);
102 * @this {WebInspector.ResourcesPanel}
103 * @return {?WebInspector.SourceFrame}
105 function sourceFrameGetter()
107 var view = this.visibleView;
108 if (view && view instanceof WebInspector.SourceFrame)
109 return /** @type {!WebInspector.SourceFrame} */ (view);
110 return null;
112 WebInspector.GoToLineDialog.install(this, sourceFrameGetter.bind(this));
114 WebInspector.targetManager.observeTargets(this);
117 WebInspector.ResourcesPanel.prototype = {
119 * @override
120 * @param {!WebInspector.Target} target
122 targetAdded: function(target)
124 if (this._target)
125 return;
126 this._target = target;
128 if (target.serviceWorkerManager && Runtime.experiments.isEnabled("serviceWorkersInResources")) {
129 this.serviceWorkersTreeElement = new WebInspector.ServiceWorkersTreeElement(this);
130 this._sidebarTree.appendChild(this.serviceWorkersTreeElement);
133 this._databaseModel = WebInspector.DatabaseModel.fromTarget(target);
134 this._domStorageModel = WebInspector.DOMStorageModel.fromTarget(target);
136 if (target.resourceTreeModel.cachedResourcesLoaded())
137 this._initialize();
139 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.Load, this._loadEventFired, this);
140 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded, this._initialize, this);
141 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.WillLoadCachedResources, this._resetWithFrames, this);
142 this._databaseModel.addEventListener(WebInspector.DatabaseModel.Events.DatabaseAdded, this._databaseAdded, this);
146 * @override
147 * @param {!WebInspector.Target} target
149 targetRemoved: function(target)
151 if (target !== this._target)
152 return;
153 delete this._target;
155 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeModel.EventTypes.Load, this._loadEventFired, this);
156 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded, this._initialize, this);
157 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeModel.EventTypes.WillLoadCachedResources, this._resetWithFrames, this);
158 this._databaseModel.removeEventListener(WebInspector.DatabaseModel.Events.DatabaseAdded, this._databaseAdded, this);
160 this._resetWithFrames();
163 _initialize: function()
165 this._databaseModel.enable();
166 this._domStorageModel.enable();
167 var indexedDBModel = WebInspector.IndexedDBModel.fromTarget(this._target);
168 if (indexedDBModel)
169 indexedDBModel.enable();
171 var cacheStorageModel = WebInspector.ServiceWorkerCacheModel.fromTarget(this._target);
172 if (cacheStorageModel)
173 cacheStorageModel.enable();
175 if (this._target.isPage())
176 this._populateResourceTree();
177 this._populateDOMStorageTree();
178 this._populateApplicationCacheTree();
179 this.indexedDBListTreeElement._initialize();
180 this.cacheStorageListTreeElement._initialize();
181 if (Runtime.experiments.isEnabled("fileSystemInspection"))
182 this.fileSystemListTreeElement._initialize();
183 this._initDefaultSelection();
184 this._initialized = true;
187 _loadEventFired: function()
189 this._initDefaultSelection();
192 _initDefaultSelection: function()
194 if (!this._initialized)
195 return;
197 var itemURL = this._resourcesLastSelectedItemSetting.get();
198 if (itemURL) {
199 var rootElement = this._sidebarTree.rootElement();
200 for (var treeElement = rootElement.firstChild(); treeElement; treeElement = treeElement.traverseNextTreeElement(false, rootElement, true)) {
201 if (treeElement.itemURL === itemURL) {
202 treeElement.revealAndSelect(true);
203 return;
208 var mainResource = this._target.resourceTreeModel.inspectedPageURL() && this.resourcesListTreeElement && this.resourcesListTreeElement.expanded
209 ? this._target.resourceTreeModel.resourceForURL(this._target.resourceTreeModel.inspectedPageURL())
210 : null;
211 if (mainResource)
212 this.showResource(mainResource);
215 _resetWithFrames: function()
217 this.resourcesListTreeElement.removeChildren();
218 this._treeElementForFrameId = {};
219 this._reset();
222 _reset: function()
224 this._domains = {};
225 var queryViews = this._databaseQueryViews.valuesArray();
226 for (var i = 0; i < queryViews.length; ++i)
227 queryViews[i].removeEventListener(WebInspector.DatabaseQueryView.Events.SchemaUpdated, this._updateDatabaseTables, this);
228 this._databaseTableViews.clear();
229 this._databaseQueryViews.clear();
230 this._databaseTreeElements.clear();
231 this._domStorageViews.clear();
232 this._domStorageTreeElements.clear();
233 this._cookieViews = {};
235 this.databasesListTreeElement.removeChildren();
236 this.localStorageListTreeElement.removeChildren();
237 this.sessionStorageListTreeElement.removeChildren();
238 this.cookieListTreeElement.removeChildren();
239 this.cacheStorageListTreeElement.removeChildren();
241 if (this.visibleView && !(this.visibleView instanceof WebInspector.StorageCategoryView))
242 this.visibleView.detach();
244 this._storageViewToolbar.removeToolbarItems();
246 if (this._sidebarTree.selectedTreeElement)
247 this._sidebarTree.selectedTreeElement.deselect();
250 _populateResourceTree: function()
252 this._treeElementForFrameId = {};
253 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameAdded, this._frameAdded, this);
254 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, this._frameNavigated, this);
255 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, this._frameDetached, this);
256 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, this._resourceAdded, this);
259 * @param {!WebInspector.ResourceTreeFrame} frame
260 * @this {WebInspector.ResourcesPanel}
262 function populateFrame(frame)
264 this._frameAdded({data:frame});
265 for (var i = 0; i < frame.childFrames.length; ++i)
266 populateFrame.call(this, frame.childFrames[i]);
268 var resources = frame.resources();
269 for (var i = 0; i < resources.length; ++i)
270 this._resourceAdded({data:resources[i]});
272 populateFrame.call(this, this._target.resourceTreeModel.mainFrame);
275 _frameAdded: function(event)
277 var frame = event.data;
278 var parentFrame = frame.parentFrame;
280 var parentTreeElement = parentFrame ? this._treeElementForFrameId[parentFrame.id] : this.resourcesListTreeElement;
281 if (!parentTreeElement) {
282 console.warn("No frame to route " + frame.url + " to.");
283 return;
286 var frameTreeElement = new WebInspector.FrameTreeElement(this, frame);
287 this._treeElementForFrameId[frame.id] = frameTreeElement;
288 parentTreeElement.appendChild(frameTreeElement);
291 _frameDetached: function(event)
293 var frame = event.data;
294 var frameTreeElement = this._treeElementForFrameId[frame.id];
295 if (!frameTreeElement)
296 return;
298 delete this._treeElementForFrameId[frame.id];
299 if (frameTreeElement.parent)
300 frameTreeElement.parent.removeChild(frameTreeElement);
303 _resourceAdded: function(event)
305 var resource = event.data;
306 var frameId = resource.frameId;
308 if (resource.statusCode >= 301 && resource.statusCode <= 303)
309 return;
311 var frameTreeElement = this._treeElementForFrameId[frameId];
312 if (!frameTreeElement) {
313 // This is a frame's main resource, it will be retained
314 // and re-added by the resource manager;
315 return;
318 frameTreeElement.appendResource(resource);
321 _frameNavigated: function(event)
323 var frame = event.data;
325 if (!frame.parentFrame)
326 this._reset();
328 var frameId = frame.id;
329 var frameTreeElement = this._treeElementForFrameId[frameId];
330 if (frameTreeElement)
331 frameTreeElement.frameNavigated(frame);
333 var applicationCacheFrameTreeElement = this._applicationCacheFrameElements[frameId];
334 if (applicationCacheFrameTreeElement)
335 applicationCacheFrameTreeElement.frameNavigated(frame);
339 * @param {!WebInspector.Event} event
341 _databaseAdded: function(event)
343 var database = /** @type {!WebInspector.Database} */ (event.data);
344 this._addDatabase(database);
348 * @param {!WebInspector.Database} database
350 _addDatabase: function(database)
352 var databaseTreeElement = new WebInspector.DatabaseTreeElement(this, database);
353 this._databaseTreeElements.set(database, databaseTreeElement);
354 this.databasesListTreeElement.appendChild(databaseTreeElement);
357 addDocumentURL: function(url)
359 var parsedURL = url.asParsedURL();
360 if (!parsedURL)
361 return;
363 var domain = parsedURL.host;
364 if (!this._domains[domain]) {
365 this._domains[domain] = true;
367 var cookieDomainTreeElement = new WebInspector.CookieTreeElement(this, domain);
368 this.cookieListTreeElement.appendChild(cookieDomainTreeElement);
373 * @param {!WebInspector.Event} event
375 _domStorageAdded: function(event)
377 var domStorage = /** @type {!WebInspector.DOMStorage} */ (event.data);
378 this._addDOMStorage(domStorage);
382 * @param {!WebInspector.DOMStorage} domStorage
384 _addDOMStorage: function(domStorage)
386 console.assert(!this._domStorageTreeElements.get(domStorage));
388 var domStorageTreeElement = new WebInspector.DOMStorageTreeElement(this, domStorage, (domStorage.isLocalStorage ? "local-storage" : "session-storage"));
389 this._domStorageTreeElements.set(domStorage, domStorageTreeElement);
390 if (domStorage.isLocalStorage)
391 this.localStorageListTreeElement.appendChild(domStorageTreeElement);
392 else
393 this.sessionStorageListTreeElement.appendChild(domStorageTreeElement);
397 * @param {!WebInspector.Event} event
399 _domStorageRemoved: function(event)
401 var domStorage = /** @type {!WebInspector.DOMStorage} */ (event.data);
402 this._removeDOMStorage(domStorage);
406 * @param {!WebInspector.DOMStorage} domStorage
408 _removeDOMStorage: function(domStorage)
410 var treeElement = this._domStorageTreeElements.get(domStorage);
411 if (!treeElement)
412 return;
413 var wasSelected = treeElement.selected;
414 var parentListTreeElement = treeElement.parent;
415 parentListTreeElement.removeChild(treeElement);
416 if (wasSelected)
417 parentListTreeElement.select();
418 this._domStorageTreeElements.remove(domStorage);
419 this._domStorageViews.remove(domStorage);
423 * @param {!WebInspector.Database} database
425 selectDatabase: function(database)
427 if (database) {
428 this._showDatabase(database);
429 this._databaseTreeElements.get(database).select();
434 * @param {!WebInspector.DOMStorage} domStorage
436 selectDOMStorage: function(domStorage)
438 if (domStorage) {
439 this._showDOMStorage(domStorage);
440 this._domStorageTreeElements.get(domStorage).select();
445 * @param {!WebInspector.Resource} resource
446 * @param {number=} line
447 * @param {number=} column
448 * @return {boolean}
450 showResource: function(resource, line, column)
452 var resourceTreeElement = this._findTreeElementForResource(resource);
453 if (resourceTreeElement)
454 resourceTreeElement.revealAndSelect(true);
456 if (typeof line === "number") {
457 var resourceSourceFrame = this._resourceSourceFrameViewForResource(resource);
458 if (resourceSourceFrame)
459 resourceSourceFrame.revealPosition(line, column, true);
461 return true;
464 _showResourceView: function(resource)
466 var view = this._resourceViewForResource(resource);
467 if (!view) {
468 this.visibleView.detach();
469 return;
471 this._innerShowView(view);
475 * @param {!WebInspector.Resource} resource
476 * @return {?WebInspector.Widget}
478 _resourceViewForResource: function(resource)
480 if (resource.hasTextContent()) {
481 var treeElement = this._findTreeElementForResource(resource);
482 if (!treeElement)
483 return null;
484 return treeElement.sourceView();
487 switch (resource.resourceType()) {
488 case WebInspector.resourceTypes.Image:
489 return new WebInspector.ImageView(resource.url, resource.mimeType, resource);
490 case WebInspector.resourceTypes.Font:
491 return new WebInspector.FontView(resource.url, resource.mimeType, resource);
492 default:
493 return new WebInspector.EmptyWidget(resource.url);
498 * @param {!WebInspector.Resource} resource
499 * @return {?WebInspector.ResourceSourceFrame}
501 _resourceSourceFrameViewForResource: function(resource)
503 var resourceView = this._resourceViewForResource(resource);
504 if (resourceView && resourceView instanceof WebInspector.ResourceSourceFrame)
505 return /** @type {!WebInspector.ResourceSourceFrame} */ (resourceView);
506 return null;
510 * @param {!WebInspector.Database} database
511 * @param {string=} tableName
513 _showDatabase: function(database, tableName)
515 if (!database)
516 return;
518 var view;
519 if (tableName) {
520 var tableViews = this._databaseTableViews.get(database);
521 if (!tableViews) {
522 tableViews = /** @type {!Object.<string, !WebInspector.DatabaseTableView>} */ ({});
523 this._databaseTableViews.set(database, tableViews);
525 view = tableViews[tableName];
526 if (!view) {
527 view = new WebInspector.DatabaseTableView(database, tableName);
528 tableViews[tableName] = view;
530 } else {
531 view = this._databaseQueryViews.get(database);
532 if (!view) {
533 view = new WebInspector.DatabaseQueryView(database);
534 this._databaseQueryViews.set(database, view);
535 view.addEventListener(WebInspector.DatabaseQueryView.Events.SchemaUpdated, this._updateDatabaseTables, this);
539 this._innerShowView(view);
543 * @param {!WebInspector.Widget} view
545 showIndexedDB: function(view)
547 this._innerShowView(view);
551 * @param {!WebInspector.Widget} view
553 showServiceWorkerCache: function(view)
555 this._innerShowView(view);
559 * @param {!WebInspector.Widget} view
561 showServiceWorkersView: function(view)
563 this._innerShowView(view);
567 * @param {!WebInspector.DOMStorage} domStorage
569 _showDOMStorage: function(domStorage)
571 if (!domStorage)
572 return;
574 var view;
575 view = this._domStorageViews.get(domStorage);
576 if (!view) {
577 view = new WebInspector.DOMStorageItemsView(domStorage);
578 this._domStorageViews.set(domStorage, view);
581 this._innerShowView(view);
585 * @param {!WebInspector.CookieTreeElement} treeElement
586 * @param {string} cookieDomain
588 showCookies: function(treeElement, cookieDomain)
590 var view = this._cookieViews[cookieDomain];
591 if (!view) {
592 view = new WebInspector.CookieItemsView(treeElement, cookieDomain);
593 this._cookieViews[cookieDomain] = view;
596 this._innerShowView(view);
600 * @param {string} cookieDomain
602 clearCookies: function(cookieDomain)
604 this._cookieViews[cookieDomain].clear();
607 showApplicationCache: function(frameId)
609 if (!this._applicationCacheViews[frameId])
610 this._applicationCacheViews[frameId] = new WebInspector.ApplicationCacheItemsView(this._applicationCacheModel, frameId);
612 this._innerShowView(this._applicationCacheViews[frameId]);
616 * @param {!WebInspector.Widget} view
618 showFileSystem: function(view)
620 this._innerShowView(view);
623 showCategoryView: function(categoryName)
625 if (!this._categoryView)
626 this._categoryView = new WebInspector.StorageCategoryView();
627 this._categoryView.setText(categoryName);
628 this._innerShowView(this._categoryView);
631 _innerShowView: function(view)
633 if (this.visibleView === view)
634 return;
636 if (this.visibleView)
637 this.visibleView.detach();
639 view.show(this.storageViews);
640 this.visibleView = view;
642 this._storageViewToolbar.removeToolbarItems();
643 var toolbarItems = view.toolbarItems ? view.toolbarItems() : null;
644 for (var i = 0; toolbarItems && i < toolbarItems.length; ++i)
645 this._storageViewToolbar.appendToolbarItem(toolbarItems[i]);
648 closeVisibleView: function()
650 if (!this.visibleView)
651 return;
652 this.visibleView.detach();
653 delete this.visibleView;
656 _updateDatabaseTables: function(event)
658 var database = event.data;
660 if (!database)
661 return;
663 var databasesTreeElement = this._databaseTreeElements.get(database);
664 if (!databasesTreeElement)
665 return;
667 databasesTreeElement.invalidateChildren();
668 var tableViews = this._databaseTableViews.get(database);
670 if (!tableViews)
671 return;
673 var tableNamesHash = {};
674 var self = this;
675 function tableNamesCallback(tableNames)
677 var tableNamesLength = tableNames.length;
678 for (var i = 0; i < tableNamesLength; ++i)
679 tableNamesHash[tableNames[i]] = true;
681 for (var tableName in tableViews) {
682 if (!(tableName in tableNamesHash)) {
683 if (self.visibleView === tableViews[tableName])
684 self.closeVisibleView();
685 delete tableViews[tableName];
689 database.getTableNames(tableNamesCallback);
692 _populateDOMStorageTree: function()
694 this._domStorageModel.storages().forEach(this._addDOMStorage.bind(this));
695 this._domStorageModel.addEventListener(WebInspector.DOMStorageModel.Events.DOMStorageAdded, this._domStorageAdded, this);
696 this._domStorageModel.addEventListener(WebInspector.DOMStorageModel.Events.DOMStorageRemoved, this._domStorageRemoved, this);
699 _populateApplicationCacheTree: function()
701 this._applicationCacheModel = new WebInspector.ApplicationCacheModel(this._target);
703 this._applicationCacheViews = {};
704 this._applicationCacheFrameElements = {};
705 this._applicationCacheManifestElements = {};
707 this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestAdded, this._applicationCacheFrameManifestAdded, this);
708 this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestRemoved, this._applicationCacheFrameManifestRemoved, this);
710 this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestStatusUpdated, this._applicationCacheFrameManifestStatusChanged, this);
711 this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.NetworkStateChanged, this._applicationCacheNetworkStateChanged, this);
714 _applicationCacheFrameManifestAdded: function(event)
716 var frameId = event.data;
717 var manifestURL = this._applicationCacheModel.frameManifestURL(frameId);
719 var manifestTreeElement = this._applicationCacheManifestElements[manifestURL];
720 if (!manifestTreeElement) {
721 manifestTreeElement = new WebInspector.ApplicationCacheManifestTreeElement(this, manifestURL);
722 this.applicationCacheListTreeElement.appendChild(manifestTreeElement);
723 this._applicationCacheManifestElements[manifestURL] = manifestTreeElement;
726 var frameTreeElement = new WebInspector.ApplicationCacheFrameTreeElement(this, frameId, manifestURL);
727 manifestTreeElement.appendChild(frameTreeElement);
728 manifestTreeElement.expand();
729 this._applicationCacheFrameElements[frameId] = frameTreeElement;
732 _applicationCacheFrameManifestRemoved: function(event)
734 var frameId = event.data;
735 var frameTreeElement = this._applicationCacheFrameElements[frameId];
736 if (!frameTreeElement)
737 return;
739 var manifestURL = frameTreeElement.manifestURL;
740 delete this._applicationCacheFrameElements[frameId];
741 delete this._applicationCacheViews[frameId];
742 frameTreeElement.parent.removeChild(frameTreeElement);
744 var manifestTreeElement = this._applicationCacheManifestElements[manifestURL];
745 if (manifestTreeElement.childCount())
746 return;
748 delete this._applicationCacheManifestElements[manifestURL];
749 manifestTreeElement.parent.removeChild(manifestTreeElement);
752 _applicationCacheFrameManifestStatusChanged: function(event)
754 var frameId = event.data;
755 var status = this._applicationCacheModel.frameManifestStatus(frameId);
757 if (this._applicationCacheViews[frameId])
758 this._applicationCacheViews[frameId].updateStatus(status);
761 _applicationCacheNetworkStateChanged: function(event)
763 var isNowOnline = event.data;
765 for (var manifestURL in this._applicationCacheViews)
766 this._applicationCacheViews[manifestURL].updateNetworkState(isNowOnline);
769 _findTreeElementForResource: function(resource)
771 return resource[WebInspector.FrameResourceTreeElement._symbol];
774 showView: function(view)
776 if (view)
777 this.showResource(view.resource);
780 _onmousemove: function(event)
782 var nodeUnderMouse = event.target;
783 if (!nodeUnderMouse)
784 return;
786 var listNode = nodeUnderMouse.enclosingNodeOrSelfWithNodeName("li");
787 if (!listNode)
788 return;
790 var element = listNode.treeElement;
791 if (this._previousHoveredElement === element)
792 return;
794 if (this._previousHoveredElement) {
795 this._previousHoveredElement.hovered = false;
796 delete this._previousHoveredElement;
799 if (element instanceof WebInspector.FrameTreeElement) {
800 this._previousHoveredElement = element;
801 element.hovered = true;
805 _onmouseleave: function(event)
807 if (this._previousHoveredElement) {
808 this._previousHoveredElement.hovered = false;
809 delete this._previousHoveredElement;
813 __proto__: WebInspector.PanelWithSidebar.prototype
817 * @constructor
818 * @implements {WebInspector.Revealer}
820 WebInspector.ResourcesPanel.ResourceRevealer = function()
824 WebInspector.ResourcesPanel.ResourceRevealer.prototype = {
826 * @override
827 * @param {!Object} resource
828 * @param {number=} lineNumber
829 * @return {!Promise}
831 reveal: function(resource, lineNumber)
833 if (!(resource instanceof WebInspector.Resource))
834 return Promise.reject(new Error("Internal error: not a resource"));
835 var panel = WebInspector.ResourcesPanel._instance();
836 WebInspector.inspectorView.setCurrentPanel(panel);
837 panel.showResource(resource, lineNumber);
838 return Promise.resolve();
843 * @constructor
844 * @extends {TreeElement}
845 * @param {!WebInspector.ResourcesPanel} storagePanel
846 * @param {string} title
847 * @param {?Array.<string>=} iconClasses
848 * @param {boolean=} expandable
849 * @param {boolean=} noIcon
851 WebInspector.BaseStorageTreeElement = function(storagePanel, title, iconClasses, expandable, noIcon)
853 TreeElement.call(this, "", expandable);
854 this._storagePanel = storagePanel;
855 this._titleText = title;
856 this._iconClasses = iconClasses;
857 this._noIcon = noIcon;
860 WebInspector.BaseStorageTreeElement.prototype = {
861 onattach: function()
863 this.listItemElement.removeChildren();
864 if (this._iconClasses) {
865 for (var i = 0; i < this._iconClasses.length; ++i)
866 this.listItemElement.classList.add(this._iconClasses[i]);
869 this.listItemElement.createChild("div", "selection");
871 if (!this._noIcon)
872 this.imageElement = this.listItemElement.createChild("img", "icon");
874 this.titleElement = this.listItemElement.createChild("div", "base-storage-tree-element-title");
875 this._titleTextNode = this.titleElement.createTextChild("");
876 this._updateTitle();
877 this._updateSubtitle();
880 get displayName()
882 return this._displayName;
885 _updateDisplayName: function()
887 this._displayName = this._titleText || "";
888 if (this._subtitleText)
889 this._displayName += " (" + this._subtitleText + ")";
892 _updateTitle: function()
894 this._updateDisplayName();
896 if (!this.titleElement)
897 return;
899 this._titleTextNode.textContent = this._titleText || "";
902 _updateSubtitle: function()
904 this._updateDisplayName();
906 if (!this.titleElement)
907 return;
909 if (this._subtitleText) {
910 if (!this._subtitleElement)
911 this._subtitleElement = this.titleElement.createChild("span", "base-storage-tree-element-subtitle");
912 this._subtitleElement.textContent = "(" + this._subtitleText + ")";
913 } else if (this._subtitleElement) {
914 this._subtitleElement.remove();
915 delete this._subtitleElement;
920 * @override
921 * @return {boolean}
923 onselect: function(selectedByUser)
925 if (!selectedByUser)
926 return false;
927 var itemURL = this.itemURL;
928 if (itemURL)
929 this._storagePanel._resourcesLastSelectedItemSetting.set(itemURL);
930 return false;
934 * @override
936 onreveal: function()
938 if (this.listItemElement)
939 this.listItemElement.scrollIntoViewIfNeeded(false);
942 get titleText()
944 return this._titleText;
947 set titleText(titleText)
949 this._titleText = titleText;
950 this._updateTitle();
953 get subtitleText()
955 return this._subtitleText;
958 set subtitleText(subtitleText)
960 this._subtitleText = subtitleText;
961 this._updateSubtitle();
964 __proto__: TreeElement.prototype
968 * @constructor
969 * @extends {WebInspector.BaseStorageTreeElement}
970 * @param {!WebInspector.ResourcesPanel} storagePanel
971 * @param {string} categoryName
972 * @param {string} settingsKey
973 * @param {?Array.<string>=} iconClasses
974 * @param {boolean=} noIcon
976 WebInspector.StorageCategoryTreeElement = function(storagePanel, categoryName, settingsKey, iconClasses, noIcon)
978 WebInspector.BaseStorageTreeElement.call(this, storagePanel, categoryName, iconClasses, false, noIcon);
979 this._expandedSetting = WebInspector.settings.createSetting("resources" + settingsKey + "Expanded", settingsKey === "Frames");
980 this._categoryName = categoryName;
983 WebInspector.StorageCategoryTreeElement.prototype = {
985 * @return {!WebInspector.Target}
987 target: function()
989 return this._storagePanel._target;
992 get itemURL()
994 return "category://" + this._categoryName;
998 * @override
999 * @return {boolean}
1001 onselect: function(selectedByUser)
1003 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
1004 this._storagePanel.showCategoryView(this._categoryName);
1005 return false;
1009 * @override
1011 onattach: function()
1013 WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
1014 if (this._expandedSetting.get())
1015 this.expand();
1019 * @override
1021 onexpand: function()
1023 this._expandedSetting.set(true);
1027 * @override
1029 oncollapse: function()
1031 this._expandedSetting.set(false);
1034 __proto__: WebInspector.BaseStorageTreeElement.prototype
1038 * @constructor
1039 * @extends {WebInspector.BaseStorageTreeElement}
1040 * @param {!WebInspector.ResourcesPanel} storagePanel
1041 * @param {!WebInspector.ResourceTreeFrame} frame
1043 WebInspector.FrameTreeElement = function(storagePanel, frame)
1045 WebInspector.BaseStorageTreeElement.call(this, storagePanel, "", ["frame-storage-tree-item"]);
1046 this._frame = frame;
1047 this.frameNavigated(frame);
1050 WebInspector.FrameTreeElement.prototype = {
1051 frameNavigated: function(frame)
1053 this.removeChildren();
1054 this._frameId = frame.id;
1056 this.titleText = frame.name;
1057 this.subtitleText = new WebInspector.ParsedURL(frame.url).displayName;
1059 this._categoryElements = {};
1060 this._treeElementForResource = {};
1062 this._storagePanel.addDocumentURL(frame.url);
1065 get itemURL()
1067 return "frame://" + encodeURI(this.displayName);
1071 * @override
1072 * @return {boolean}
1074 onselect: function(selectedByUser)
1076 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
1077 this._storagePanel.showCategoryView(this.displayName);
1079 this.listItemElement.classList.remove("hovered");
1080 WebInspector.DOMModel.hideDOMNodeHighlight();
1081 return false;
1084 set hovered(hovered)
1086 if (hovered) {
1087 this.listItemElement.classList.add("hovered");
1088 var domModel = WebInspector.DOMModel.fromTarget(this._frame.target());
1089 if (domModel)
1090 domModel.highlightFrame(this._frameId);
1091 } else {
1092 this.listItemElement.classList.remove("hovered");
1093 WebInspector.DOMModel.hideDOMNodeHighlight();
1098 * @param {!WebInspector.Resource} resource
1100 appendResource: function(resource)
1102 if (resource.isHidden())
1103 return;
1104 var resourceType = resource.resourceType();
1105 var categoryName = resourceType.name();
1106 var categoryElement = resourceType === WebInspector.resourceTypes.Document ? this : this._categoryElements[categoryName];
1107 if (!categoryElement) {
1108 categoryElement = new WebInspector.StorageCategoryTreeElement(this._storagePanel, resource.resourceType().category().title, categoryName, null, true);
1109 this._categoryElements[resourceType.name()] = categoryElement;
1110 this._insertInPresentationOrder(this, categoryElement);
1112 var resourceTreeElement = new WebInspector.FrameResourceTreeElement(this._storagePanel, resource);
1113 this._insertInPresentationOrder(categoryElement, resourceTreeElement);
1114 this._treeElementForResource[resource.url] = resourceTreeElement;
1118 * @param {string} url
1119 * @return {?WebInspector.Resource}
1121 resourceByURL: function(url)
1123 var treeElement = this._treeElementForResource[url];
1124 return treeElement ? treeElement._resource : null;
1127 appendChild: function(treeElement)
1129 this._insertInPresentationOrder(this, treeElement);
1132 _insertInPresentationOrder: function(parentTreeElement, childTreeElement)
1134 // Insert in the alphabetical order, first frames, then resources. Document resource goes last.
1135 function typeWeight(treeElement)
1137 if (treeElement instanceof WebInspector.StorageCategoryTreeElement)
1138 return 2;
1139 if (treeElement instanceof WebInspector.FrameTreeElement)
1140 return 1;
1141 return 3;
1144 function compare(treeElement1, treeElement2)
1146 var typeWeight1 = typeWeight(treeElement1);
1147 var typeWeight2 = typeWeight(treeElement2);
1149 var result;
1150 if (typeWeight1 > typeWeight2)
1151 result = 1;
1152 else if (typeWeight1 < typeWeight2)
1153 result = -1;
1154 else {
1155 var title1 = treeElement1.displayName || treeElement1.titleText;
1156 var title2 = treeElement2.displayName || treeElement2.titleText;
1157 result = title1.localeCompare(title2);
1159 return result;
1162 var childCount = parentTreeElement.childCount();
1163 var i;
1164 for (i = 0; i < childCount; ++i) {
1165 if (compare(childTreeElement, parentTreeElement.childAt(i)) < 0)
1166 break;
1168 parentTreeElement.insertChild(childTreeElement, i);
1171 __proto__: WebInspector.BaseStorageTreeElement.prototype
1175 * @constructor
1176 * @extends {WebInspector.BaseStorageTreeElement}
1177 * @param {!WebInspector.ResourcesPanel} storagePanel
1178 * @param {!WebInspector.Resource} resource
1180 WebInspector.FrameResourceTreeElement = function(storagePanel, resource)
1182 WebInspector.BaseStorageTreeElement.call(this, storagePanel, resource.displayName, ["resource-sidebar-tree-item", "resources-type-" + resource.resourceType().name()]);
1183 /** @type {!WebInspector.Resource} */
1184 this._resource = resource;
1185 this._resource.addEventListener(WebInspector.Resource.Events.MessageAdded, this._consoleMessageAdded, this);
1186 this._resource.addEventListener(WebInspector.Resource.Events.MessagesCleared, this._consoleMessagesCleared, this);
1187 this.tooltip = resource.url;
1188 this._resource[WebInspector.FrameResourceTreeElement._symbol] = this;
1191 WebInspector.FrameResourceTreeElement._symbol = Symbol("treeElement");
1193 WebInspector.FrameResourceTreeElement.prototype = {
1194 get itemURL()
1196 return this._resource.url;
1200 * @override
1201 * @return {boolean}
1203 onselect: function(selectedByUser)
1205 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
1206 this._storagePanel._showResourceView(this._resource);
1207 return false;
1211 * @override
1212 * @return {boolean}
1214 ondblclick: function(event)
1216 InspectorFrontendHost.openInNewTab(this._resource.url);
1217 return false;
1221 * @override
1223 onattach: function()
1225 WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
1227 if (this._resource.resourceType() === WebInspector.resourceTypes.Image) {
1228 var iconElement = createElementWithClass("div", "icon");
1229 var previewImage = iconElement.createChild("img", "image-resource-icon-preview");
1230 this._resource.populateImageSource(previewImage);
1231 this.listItemElement.replaceChild(iconElement, this.imageElement);
1234 this._statusElement = createElementWithClass("div", "status");
1235 this.listItemElement.insertBefore(this._statusElement, this.titleElement);
1237 this.listItemElement.draggable = true;
1238 this.listItemElement.addEventListener("dragstart", this._ondragstart.bind(this), false);
1239 this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
1241 this._updateErrorsAndWarningsBubbles();
1245 * @param {!MouseEvent} event
1246 * @return {boolean}
1248 _ondragstart: function(event)
1250 event.dataTransfer.setData("text/plain", this._resource.content || "");
1251 event.dataTransfer.effectAllowed = "copy";
1252 return true;
1255 _handleContextMenuEvent: function(event)
1257 var contextMenu = new WebInspector.ContextMenu(event);
1258 contextMenu.appendApplicableItems(this._resource);
1259 contextMenu.show();
1263 * @param {string} x
1265 _setBubbleText: function(x)
1267 if (!this._bubbleElement)
1268 this._bubbleElement = this._statusElement.createChild("div", "bubble-repeat-count");
1269 this._bubbleElement.textContent = x;
1272 _resetBubble: function()
1274 if (this._bubbleElement) {
1275 this._bubbleElement.textContent = "";
1276 this._bubbleElement.classList.remove("warning");
1277 this._bubbleElement.classList.remove("error");
1281 _updateErrorsAndWarningsBubbles: function()
1283 if (this._storagePanel.currentQuery)
1284 return;
1286 this._resetBubble();
1288 if (this._resource.warnings || this._resource.errors)
1289 this._setBubbleText(String(this._resource.warnings + this._resource.errors));
1291 if (this._resource.warnings)
1292 this._bubbleElement.classList.add("warning");
1294 if (this._resource.errors)
1295 this._bubbleElement.classList.add("error");
1298 _consoleMessagesCleared: function()
1300 // FIXME: move to the SourceFrame.
1301 if (this._sourceView)
1302 this._sourceView.clearMessages();
1304 this._updateErrorsAndWarningsBubbles();
1307 _consoleMessageAdded: function(event)
1309 var msg = event.data;
1310 if (this._sourceView)
1311 this._sourceView.addMessage(msg);
1312 this._updateErrorsAndWarningsBubbles();
1316 * @return {!WebInspector.ResourceSourceFrame}
1318 sourceView: function()
1320 if (!this._sourceView) {
1321 var sourceFrame = new WebInspector.ResourceSourceFrame(this._resource);
1322 sourceFrame.setHighlighterType(this._resource.canonicalMimeType());
1323 this._sourceView = sourceFrame;
1324 if (this._resource.messages) {
1325 for (var i = 0; i < this._resource.messages.length; i++)
1326 this._sourceView.addPersistentMessage(this._resource.messages[i]);
1329 return this._sourceView;
1332 __proto__: WebInspector.BaseStorageTreeElement.prototype
1336 * @constructor
1337 * @extends {WebInspector.BaseStorageTreeElement}
1338 * @param {!WebInspector.ResourcesPanel} storagePanel
1339 * @param {!WebInspector.Database} database
1341 WebInspector.DatabaseTreeElement = function(storagePanel, database)
1343 WebInspector.BaseStorageTreeElement.call(this, storagePanel, database.name, ["database-storage-tree-item"], true);
1344 this._database = database;
1347 WebInspector.DatabaseTreeElement.prototype = {
1348 get itemURL()
1350 return "database://" + encodeURI(this._database.name);
1354 * @override
1355 * @return {boolean}
1357 onselect: function(selectedByUser)
1359 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
1360 this._storagePanel._showDatabase(this._database);
1361 return false;
1365 * @override
1367 onexpand: function()
1369 this._updateChildren();
1372 _updateChildren: function()
1374 this.removeChildren();
1377 * @param {!Array.<string>} tableNames
1378 * @this {WebInspector.DatabaseTreeElement}
1380 function tableNamesCallback(tableNames)
1382 var tableNamesLength = tableNames.length;
1383 for (var i = 0; i < tableNamesLength; ++i)
1384 this.appendChild(new WebInspector.DatabaseTableTreeElement(this._storagePanel, this._database, tableNames[i]));
1386 this._database.getTableNames(tableNamesCallback.bind(this));
1389 __proto__: WebInspector.BaseStorageTreeElement.prototype
1393 * @constructor
1394 * @extends {WebInspector.BaseStorageTreeElement}
1396 WebInspector.DatabaseTableTreeElement = function(storagePanel, database, tableName)
1398 WebInspector.BaseStorageTreeElement.call(this, storagePanel, tableName, ["database-table-storage-tree-item"]);
1399 this._database = database;
1400 this._tableName = tableName;
1403 WebInspector.DatabaseTableTreeElement.prototype = {
1404 get itemURL()
1406 return "database://" + encodeURI(this._database.name) + "/" + encodeURI(this._tableName);
1410 * @override
1411 * @return {boolean}
1413 onselect: function(selectedByUser)
1415 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
1416 this._storagePanel._showDatabase(this._database, this._tableName);
1417 return false;
1420 __proto__: WebInspector.BaseStorageTreeElement.prototype
1425 * @constructor
1426 * @extends {WebInspector.StorageCategoryTreeElement}
1427 * @param {!WebInspector.ResourcesPanel} storagePanel
1429 WebInspector.ServiceWorkerCacheTreeElement = function(storagePanel)
1431 WebInspector.StorageCategoryTreeElement.call(this, storagePanel, WebInspector.UIString("Cache Storage"), "CacheStorage", ["service-worker-cache-storage-tree-item"]);
1434 WebInspector.ServiceWorkerCacheTreeElement.prototype = {
1435 _initialize: function()
1437 /** @type {!Array.<!WebInspector.SWCacheTreeElement>} */
1438 this._swCacheTreeElements = [];
1439 var target = this._storagePanel._target;
1440 if (target) {
1441 var model = WebInspector.ServiceWorkerCacheModel.fromTarget(target);
1442 var caches = model.caches();
1443 for (var cache of caches)
1444 this._addCache(model, cache);
1446 WebInspector.targetManager.addModelListener(WebInspector.ServiceWorkerCacheModel, WebInspector.ServiceWorkerCacheModel.EventTypes.CacheAdded, this._cacheAdded, this);
1447 WebInspector.targetManager.addModelListener(WebInspector.ServiceWorkerCacheModel, WebInspector.ServiceWorkerCacheModel.EventTypes.CacheRemoved, this._cacheRemoved, this);
1450 onattach: function()
1452 WebInspector.StorageCategoryTreeElement.prototype.onattach.call(this);
1453 this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
1456 _handleContextMenuEvent: function(event)
1458 var contextMenu = new WebInspector.ContextMenu(event);
1459 contextMenu.appendItem(WebInspector.UIString("Refresh Caches"), this._refreshCaches.bind(this));
1460 contextMenu.show();
1463 _refreshCaches: function()
1465 var target = this._storagePanel._target;
1466 if (target) {
1467 var model = WebInspector.ServiceWorkerCacheModel.fromTarget(target);
1468 model.refreshCacheNames();
1473 * @param {!WebInspector.Event} event
1475 _cacheAdded: function(event)
1477 var cache = /** @type {!WebInspector.ServiceWorkerCacheModel.Cache} */ (event.data);
1478 var model = /** @type {!WebInspector.ServiceWorkerCacheModel} */ (event.target);
1479 this._addCache(model, cache);
1483 * @param {!WebInspector.ServiceWorkerCacheModel} model
1484 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache
1486 _addCache: function(model, cache)
1488 var swCacheTreeElement = new WebInspector.SWCacheTreeElement(this._storagePanel, model, cache);
1489 this._swCacheTreeElements.push(swCacheTreeElement);
1490 this.appendChild(swCacheTreeElement);
1494 * @param {!WebInspector.Event} event
1496 _cacheRemoved: function(event)
1498 var cache = /** @type {!WebInspector.ServiceWorkerCacheModel.Cache} */ (event.data);
1499 var model = /** @type {!WebInspector.ServiceWorkerCacheModel} */ (event.target);
1501 var swCacheTreeElement = this._cacheTreeElement(model, cache);
1502 if (!swCacheTreeElement)
1503 return;
1505 swCacheTreeElement.clear();
1506 this.removeChild(swCacheTreeElement);
1507 this._swCacheTreeElements.remove(swCacheTreeElement);
1511 * @param {!WebInspector.ServiceWorkerCacheModel} model
1512 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache
1513 * @return {?WebInspector.SWCacheTreeElement}
1515 _cacheTreeElement: function(model, cache)
1517 var index = -1;
1518 for (var i = 0; i < this._swCacheTreeElements.length; ++i) {
1519 if (this._swCacheTreeElements[i]._cache.equals(cache) && this._swCacheTreeElements[i]._model === model) {
1520 index = i;
1521 break;
1524 if (index !== -1)
1525 return this._swCacheTreeElements[i];
1526 return null;
1529 __proto__: WebInspector.StorageCategoryTreeElement.prototype
1533 * @constructor
1534 * @extends {WebInspector.BaseStorageTreeElement}
1535 * @param {!WebInspector.ResourcesPanel} storagePanel
1536 * @param {!WebInspector.ServiceWorkerCacheModel} model
1537 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache
1539 WebInspector.SWCacheTreeElement = function(storagePanel, model, cache)
1541 WebInspector.BaseStorageTreeElement.call(this, storagePanel, cache.cacheName + " - " + cache.securityOrigin, ["service-worker-cache-tree-item"]);
1542 this._model = model;
1543 this._cache = cache;
1546 WebInspector.SWCacheTreeElement.prototype = {
1547 get itemURL()
1549 // I don't think this will work at all.
1550 return "cache://" + this._cache.cacheId;
1553 onattach: function()
1555 WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
1556 this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
1559 _handleContextMenuEvent: function(event)
1561 var contextMenu = new WebInspector.ContextMenu(event);
1562 contextMenu.appendItem(WebInspector.UIString("Delete"), this._clearCache.bind(this));
1563 contextMenu.show();
1566 _clearCache: function()
1568 this._model.deleteCache(this._cache);
1572 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache
1574 update: function(cache)
1576 this._cache = cache;
1577 if (this._view)
1578 this._view.update(cache);
1582 * @override
1583 * @return {boolean}
1585 onselect: function(selectedByUser)
1587 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
1588 if (!this._view)
1589 this._view = new WebInspector.ServiceWorkerCacheView(this._model, this._cache);
1591 this._storagePanel.showServiceWorkerCache(this._view);
1592 return false;
1595 clear: function()
1597 if (this._view)
1598 this._view.clear();
1601 __proto__: WebInspector.BaseStorageTreeElement.prototype
1606 * @constructor
1607 * @extends {WebInspector.StorageCategoryTreeElement}
1608 * @param {!WebInspector.ResourcesPanel} storagePanel
1610 WebInspector.ServiceWorkersTreeElement = function(storagePanel)
1612 WebInspector.StorageCategoryTreeElement.call(this, storagePanel, WebInspector.UIString("Service Workers"), "Service Workers", ["service-workers-tree-item"]);
1615 WebInspector.ServiceWorkersTreeElement.prototype = {
1617 * @override
1618 * @return {boolean}
1620 onselect: function(selectedByUser)
1622 WebInspector.StorageCategoryTreeElement.prototype.onselect.call(this, selectedByUser);
1623 if (!this._view)
1624 this._view = new WebInspector.ServiceWorkersView();
1625 this._storagePanel.showServiceWorkersView(this._view);
1626 return false;
1629 __proto__: WebInspector.StorageCategoryTreeElement.prototype
1634 * @constructor
1635 * @extends {WebInspector.StorageCategoryTreeElement}
1636 * @param {!WebInspector.ResourcesPanel} storagePanel
1638 WebInspector.IndexedDBTreeElement = function(storagePanel)
1640 WebInspector.StorageCategoryTreeElement.call(this, storagePanel, WebInspector.UIString("IndexedDB"), "IndexedDB", ["indexed-db-storage-tree-item"]);
1643 WebInspector.IndexedDBTreeElement.prototype = {
1644 _initialize: function()
1646 WebInspector.targetManager.addModelListener(WebInspector.IndexedDBModel, WebInspector.IndexedDBModel.EventTypes.DatabaseAdded, this._indexedDBAdded, this);
1647 WebInspector.targetManager.addModelListener(WebInspector.IndexedDBModel, WebInspector.IndexedDBModel.EventTypes.DatabaseRemoved, this._indexedDBRemoved, this);
1648 WebInspector.targetManager.addModelListener(WebInspector.IndexedDBModel, WebInspector.IndexedDBModel.EventTypes.DatabaseLoaded, this._indexedDBLoaded, this);
1649 /** @type {!Array.<!WebInspector.IDBDatabaseTreeElement>} */
1650 this._idbDatabaseTreeElements = [];
1652 var targets = WebInspector.targetManager.targets();
1653 for (var i = 0; i < targets.length; ++i) {
1654 var indexedDBModel = WebInspector.IndexedDBModel.fromTarget(targets[i]);
1655 var databases = indexedDBModel.databases();
1656 for (var j = 0; j < databases.length; ++j)
1657 this._addIndexedDB(indexedDBModel, databases[j]);
1661 onattach: function()
1663 WebInspector.StorageCategoryTreeElement.prototype.onattach.call(this);
1664 this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
1667 _handleContextMenuEvent: function(event)
1669 var contextMenu = new WebInspector.ContextMenu(event);
1670 contextMenu.appendItem(WebInspector.UIString("Refresh IndexedDB"), this.refreshIndexedDB.bind(this));
1671 contextMenu.show();
1674 refreshIndexedDB: function()
1676 var targets = WebInspector.targetManager.targets();
1677 for (var i = 0; i < targets.length; ++i)
1678 WebInspector.IndexedDBModel.fromTarget(targets[i]).refreshDatabaseNames();
1682 * @param {!WebInspector.Event} event
1684 _indexedDBAdded: function(event)
1686 var databaseId = /** @type {!WebInspector.IndexedDBModel.DatabaseId} */ (event.data);
1687 var model = /** @type {!WebInspector.IndexedDBModel} */ (event.target);
1688 this._addIndexedDB(model, databaseId);
1692 * @param {!WebInspector.IndexedDBModel} model
1693 * @param {!WebInspector.IndexedDBModel.DatabaseId} databaseId
1695 _addIndexedDB: function(model, databaseId)
1697 var idbDatabaseTreeElement = new WebInspector.IDBDatabaseTreeElement(this._storagePanel, model, databaseId);
1698 this._idbDatabaseTreeElements.push(idbDatabaseTreeElement);
1699 this.appendChild(idbDatabaseTreeElement);
1700 model.refreshDatabase(databaseId);
1704 * @param {!WebInspector.Event} event
1706 _indexedDBRemoved: function(event)
1708 var databaseId = /** @type {!WebInspector.IndexedDBModel.DatabaseId} */ (event.data);
1709 var model = /** @type {!WebInspector.IndexedDBModel} */ (event.target);
1711 var idbDatabaseTreeElement = this._idbDatabaseTreeElement(model, databaseId)
1712 if (!idbDatabaseTreeElement)
1713 return;
1715 idbDatabaseTreeElement.clear();
1716 this.removeChild(idbDatabaseTreeElement);
1717 this._idbDatabaseTreeElements.remove(idbDatabaseTreeElement);
1721 * @param {!WebInspector.Event} event
1723 _indexedDBLoaded: function(event)
1725 var database = /** @type {!WebInspector.IndexedDBModel.Database} */ (event.data);
1726 var model = /** @type {!WebInspector.IndexedDBModel} */ (event.target);
1728 var idbDatabaseTreeElement = this._idbDatabaseTreeElement(model, database.databaseId);
1729 if (!idbDatabaseTreeElement)
1730 return;
1732 idbDatabaseTreeElement.update(database);
1736 * @param {!WebInspector.IndexedDBModel.DatabaseId} databaseId
1737 * @param {!WebInspector.IndexedDBModel} model
1738 * @return {?WebInspector.IDBDatabaseTreeElement}
1740 _idbDatabaseTreeElement: function(model, databaseId)
1742 var index = -1;
1743 for (var i = 0; i < this._idbDatabaseTreeElements.length; ++i) {
1744 if (this._idbDatabaseTreeElements[i]._databaseId.equals(databaseId) && this._idbDatabaseTreeElements[i]._model === model) {
1745 index = i;
1746 break;
1749 if (index !== -1)
1750 return this._idbDatabaseTreeElements[i];
1751 return null;
1754 __proto__: WebInspector.StorageCategoryTreeElement.prototype
1758 * @constructor
1759 * @extends {WebInspector.StorageCategoryTreeElement}
1760 * @param {!WebInspector.ResourcesPanel} storagePanel
1762 WebInspector.FileSystemListTreeElement = function(storagePanel)
1764 WebInspector.StorageCategoryTreeElement.call(this, storagePanel, WebInspector.UIString("FileSystem"), "FileSystem", ["file-system-storage-tree-item"]);
1767 WebInspector.FileSystemListTreeElement.prototype = {
1768 _initialize: function()
1770 this._refreshFileSystem();
1773 onattach: function()
1775 WebInspector.StorageCategoryTreeElement.prototype.onattach.call(this);
1776 this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
1779 _handleContextMenuEvent: function(event)
1781 var contextMenu = new WebInspector.ContextMenu(event);
1782 contextMenu.appendItem(WebInspector.UIString.capitalize("Refresh FileSystem ^list"), this._refreshFileSystem.bind(this));
1783 contextMenu.show();
1786 _fileSystemAdded: function(event)
1788 var fileSystem = /** @type {!WebInspector.FileSystemModel.FileSystem} */ (event.data);
1789 var fileSystemTreeElement = new WebInspector.FileSystemTreeElement(this._storagePanel, fileSystem);
1790 this.appendChild(fileSystemTreeElement);
1793 _fileSystemRemoved: function(event)
1795 var fileSystem = /** @type {!WebInspector.FileSystemModel.FileSystem} */ (event.data);
1796 var fileSystemTreeElement = this._fileSystemTreeElementByName(fileSystem.name);
1797 if (!fileSystemTreeElement)
1798 return;
1799 fileSystemTreeElement.clear();
1800 this.removeChild(fileSystemTreeElement);
1803 _fileSystemTreeElementByName: function(fileSystemName)
1805 for (var child of this.children()) {
1806 var fschild = /** @type {!WebInspector.FileSystemTreeElement} */ (child);
1807 if (fschild.fileSystemName === fileSystemName)
1808 return fschild;
1810 return null;
1813 _refreshFileSystem: function()
1815 if (!this._fileSystemModel) {
1816 this._fileSystemModel = new WebInspector.FileSystemModel(this.target());
1817 this._fileSystemModel.addEventListener(WebInspector.FileSystemModel.EventTypes.FileSystemAdded, this._fileSystemAdded, this);
1818 this._fileSystemModel.addEventListener(WebInspector.FileSystemModel.EventTypes.FileSystemRemoved, this._fileSystemRemoved, this);
1821 this._fileSystemModel.refreshFileSystemList();
1824 __proto__: WebInspector.StorageCategoryTreeElement.prototype
1828 * @constructor
1829 * @extends {WebInspector.BaseStorageTreeElement}
1830 * @param {!WebInspector.ResourcesPanel} storagePanel
1831 * @param {!WebInspector.IndexedDBModel} model
1832 * @param {!WebInspector.IndexedDBModel.DatabaseId} databaseId
1834 WebInspector.IDBDatabaseTreeElement = function(storagePanel, model, databaseId)
1836 WebInspector.BaseStorageTreeElement.call(this, storagePanel, databaseId.name + " - " + databaseId.securityOrigin, ["indexed-db-storage-tree-item"]);
1837 this._model = model;
1838 this._databaseId = databaseId;
1839 this._idbObjectStoreTreeElements = {};
1842 WebInspector.IDBDatabaseTreeElement.prototype = {
1843 get itemURL()
1845 return "indexedDB://" + this._databaseId.securityOrigin + "/" + this._databaseId.name;
1848 onattach: function()
1850 WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
1851 this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
1854 _handleContextMenuEvent: function(event)
1856 var contextMenu = new WebInspector.ContextMenu(event);
1857 contextMenu.appendItem(WebInspector.UIString("Refresh IndexedDB"), this._refreshIndexedDB.bind(this));
1858 contextMenu.show();
1861 _refreshIndexedDB: function()
1863 this._model.refreshDatabaseNames();
1867 * @param {!WebInspector.IndexedDBModel.Database} database
1869 update: function(database)
1871 this._database = database;
1872 var objectStoreNames = {};
1873 for (var objectStoreName in this._database.objectStores) {
1874 var objectStore = this._database.objectStores[objectStoreName];
1875 objectStoreNames[objectStore.name] = true;
1876 if (!this._idbObjectStoreTreeElements[objectStore.name]) {
1877 var idbObjectStoreTreeElement = new WebInspector.IDBObjectStoreTreeElement(this._storagePanel, this._model, this._databaseId, objectStore);
1878 this._idbObjectStoreTreeElements[objectStore.name] = idbObjectStoreTreeElement;
1879 this.appendChild(idbObjectStoreTreeElement);
1881 this._idbObjectStoreTreeElements[objectStore.name].update(objectStore);
1883 for (var objectStoreName in this._idbObjectStoreTreeElements) {
1884 if (!objectStoreNames[objectStoreName])
1885 this._objectStoreRemoved(objectStoreName);
1888 if (this._view)
1889 this._view.update(database);
1891 this._updateTooltip();
1894 _updateTooltip: function()
1896 this.tooltip = WebInspector.UIString("Version") + ": " + this._database.version;
1900 * @override
1901 * @return {boolean}
1903 onselect: function(selectedByUser)
1905 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
1906 if (!this._view)
1907 this._view = new WebInspector.IDBDatabaseView(this._database);
1909 this._storagePanel.showIndexedDB(this._view);
1910 return false;
1914 * @param {string} objectStoreName
1916 _objectStoreRemoved: function(objectStoreName)
1918 var objectStoreTreeElement = this._idbObjectStoreTreeElements[objectStoreName];
1919 objectStoreTreeElement.clear();
1920 this.removeChild(objectStoreTreeElement);
1921 delete this._idbObjectStoreTreeElements[objectStoreName];
1924 clear: function()
1926 for (var objectStoreName in this._idbObjectStoreTreeElements)
1927 this._objectStoreRemoved(objectStoreName);
1930 __proto__: WebInspector.BaseStorageTreeElement.prototype
1934 * @constructor
1935 * @extends {WebInspector.BaseStorageTreeElement}
1936 * @param {!WebInspector.ResourcesPanel} storagePanel
1937 * @param {!WebInspector.IndexedDBModel} model
1938 * @param {!WebInspector.IndexedDBModel.DatabaseId} databaseId
1939 * @param {!WebInspector.IndexedDBModel.ObjectStore} objectStore
1941 WebInspector.IDBObjectStoreTreeElement = function(storagePanel, model, databaseId, objectStore)
1943 WebInspector.BaseStorageTreeElement.call(this, storagePanel, objectStore.name, ["indexed-db-object-store-storage-tree-item"]);
1944 this._model = model;
1945 this._databaseId = databaseId;
1946 this._idbIndexTreeElements = {};
1949 WebInspector.IDBObjectStoreTreeElement.prototype = {
1950 get itemURL()
1952 return "indexedDB://" + this._databaseId.securityOrigin + "/" + this._databaseId.name + "/" + this._objectStore.name;
1955 onattach: function()
1957 WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
1958 this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
1961 _handleContextMenuEvent: function(event)
1963 var contextMenu = new WebInspector.ContextMenu(event);
1964 contextMenu.appendItem(WebInspector.UIString("Clear"), this._clearObjectStore.bind(this));
1965 contextMenu.show();
1968 _clearObjectStore: function()
1971 * @this {WebInspector.IDBObjectStoreTreeElement}
1973 function callback() {
1974 this.update(this._objectStore);
1976 this._model.clearObjectStore(this._databaseId, this._objectStore.name, callback.bind(this));
1980 * @param {!WebInspector.IndexedDBModel.ObjectStore} objectStore
1982 update: function(objectStore)
1984 this._objectStore = objectStore;
1986 var indexNames = {};
1987 for (var indexName in this._objectStore.indexes) {
1988 var index = this._objectStore.indexes[indexName];
1989 indexNames[index.name] = true;
1990 if (!this._idbIndexTreeElements[index.name]) {
1991 var idbIndexTreeElement = new WebInspector.IDBIndexTreeElement(this._storagePanel, this._model, this._databaseId, this._objectStore, index);
1992 this._idbIndexTreeElements[index.name] = idbIndexTreeElement;
1993 this.appendChild(idbIndexTreeElement);
1995 this._idbIndexTreeElements[index.name].update(index);
1997 for (var indexName in this._idbIndexTreeElements) {
1998 if (!indexNames[indexName])
1999 this._indexRemoved(indexName);
2001 for (var indexName in this._idbIndexTreeElements) {
2002 if (!indexNames[indexName]) {
2003 this.removeChild(this._idbIndexTreeElements[indexName]);
2004 delete this._idbIndexTreeElements[indexName];
2008 if (this.childCount())
2009 this.expand();
2011 if (this._view)
2012 this._view.update(this._objectStore);
2014 this._updateTooltip();
2017 _updateTooltip: function()
2020 var keyPathString = this._objectStore.keyPathString;
2021 var tooltipString = keyPathString !== null ? (WebInspector.UIString("Key path: ") + keyPathString) : "";
2022 if (this._objectStore.autoIncrement)
2023 tooltipString += "\n" + WebInspector.UIString("autoIncrement");
2024 this.tooltip = tooltipString;
2028 * @override
2029 * @return {boolean}
2031 onselect: function(selectedByUser)
2033 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
2034 if (!this._view)
2035 this._view = new WebInspector.IDBDataView(this._model, this._databaseId, this._objectStore, null);
2037 this._storagePanel.showIndexedDB(this._view);
2038 return false;
2042 * @param {string} indexName
2044 _indexRemoved: function(indexName)
2046 var indexTreeElement = this._idbIndexTreeElements[indexName];
2047 indexTreeElement.clear();
2048 this.removeChild(indexTreeElement);
2049 delete this._idbIndexTreeElements[indexName];
2052 clear: function()
2054 for (var indexName in this._idbIndexTreeElements)
2055 this._indexRemoved(indexName);
2056 if (this._view)
2057 this._view.clear();
2060 __proto__: WebInspector.BaseStorageTreeElement.prototype
2064 * @constructor
2065 * @extends {WebInspector.BaseStorageTreeElement}
2066 * @param {!WebInspector.ResourcesPanel} storagePanel
2067 * @param {!WebInspector.IndexedDBModel} model
2068 * @param {!WebInspector.IndexedDBModel.DatabaseId} databaseId
2069 * @param {!WebInspector.IndexedDBModel.ObjectStore} objectStore
2070 * @param {!WebInspector.IndexedDBModel.Index} index
2072 WebInspector.IDBIndexTreeElement = function(storagePanel, model, databaseId, objectStore, index)
2074 WebInspector.BaseStorageTreeElement.call(this, storagePanel, index.name, ["indexed-db-index-storage-tree-item"]);
2075 this._model = model;
2076 this._databaseId = databaseId;
2077 this._objectStore = objectStore;
2078 this._index = index;
2081 WebInspector.IDBIndexTreeElement.prototype = {
2082 get itemURL()
2084 return "indexedDB://" + this._databaseId.securityOrigin + "/" + this._databaseId.name + "/" + this._objectStore.name + "/" + this._index.name;
2088 * @param {!WebInspector.IndexedDBModel.Index} index
2090 update: function(index)
2092 this._index = index;
2094 if (this._view)
2095 this._view.update(this._index);
2097 this._updateTooltip();
2100 _updateTooltip: function()
2102 var tooltipLines = [];
2103 var keyPathString = this._index.keyPathString;
2104 tooltipLines.push(WebInspector.UIString("Key path: ") + keyPathString);
2105 if (this._index.unique)
2106 tooltipLines.push(WebInspector.UIString("unique"));
2107 if (this._index.multiEntry)
2108 tooltipLines.push(WebInspector.UIString("multiEntry"));
2109 this.tooltip = tooltipLines.join("\n");
2113 * @override
2114 * @return {boolean}
2116 onselect: function(selectedByUser)
2118 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
2119 if (!this._view)
2120 this._view = new WebInspector.IDBDataView(this._model, this._databaseId, this._objectStore, this._index);
2122 this._storagePanel.showIndexedDB(this._view);
2123 return false;
2126 clear: function()
2128 if (this._view)
2129 this._view.clear();
2132 __proto__: WebInspector.BaseStorageTreeElement.prototype
2136 * @constructor
2137 * @extends {WebInspector.BaseStorageTreeElement}
2139 WebInspector.DOMStorageTreeElement = function(storagePanel, domStorage, className)
2141 WebInspector.BaseStorageTreeElement.call(this, storagePanel, domStorage.securityOrigin ? domStorage.securityOrigin : WebInspector.UIString("Local Files"), ["domstorage-storage-tree-item", className]);
2142 this._domStorage = domStorage;
2145 WebInspector.DOMStorageTreeElement.prototype = {
2146 get itemURL()
2148 return "storage://" + this._domStorage.securityOrigin + "/" + (this._domStorage.isLocalStorage ? "local" : "session");
2152 * @override
2153 * @return {boolean}
2155 onselect: function(selectedByUser)
2157 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
2158 this._storagePanel._showDOMStorage(this._domStorage);
2159 return false;
2162 __proto__: WebInspector.BaseStorageTreeElement.prototype
2166 * @constructor
2167 * @extends {WebInspector.BaseStorageTreeElement}
2169 WebInspector.CookieTreeElement = function(storagePanel, cookieDomain)
2171 WebInspector.BaseStorageTreeElement.call(this, storagePanel, cookieDomain ? cookieDomain : WebInspector.UIString("Local Files"), ["cookie-storage-tree-item"]);
2172 this._cookieDomain = cookieDomain;
2175 WebInspector.CookieTreeElement.prototype = {
2176 get itemURL()
2178 return "cookies://" + this._cookieDomain;
2181 onattach: function()
2183 WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
2184 this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
2188 * @param {!Event} event
2190 _handleContextMenuEvent: function(event)
2192 var contextMenu = new WebInspector.ContextMenu(event);
2193 contextMenu.appendItem(WebInspector.UIString("Clear"), this._clearCookies.bind(this));
2194 contextMenu.show();
2198 * @param {string} domain
2200 _clearCookies: function(domain)
2202 this._storagePanel.clearCookies(this._cookieDomain);
2206 * @override
2207 * @return {boolean}
2209 onselect: function(selectedByUser)
2211 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
2212 this._storagePanel.showCookies(this, this._cookieDomain);
2213 return false;
2216 __proto__: WebInspector.BaseStorageTreeElement.prototype
2220 * @constructor
2221 * @extends {WebInspector.BaseStorageTreeElement}
2223 WebInspector.ApplicationCacheManifestTreeElement = function(storagePanel, manifestURL)
2225 var title = new WebInspector.ParsedURL(manifestURL).displayName;
2226 WebInspector.BaseStorageTreeElement.call(this, storagePanel, title, ["application-cache-storage-tree-item"]);
2227 this.tooltip = manifestURL;
2228 this._manifestURL = manifestURL;
2231 WebInspector.ApplicationCacheManifestTreeElement.prototype = {
2232 get itemURL()
2234 return "appcache://" + this._manifestURL;
2237 get manifestURL()
2239 return this._manifestURL;
2243 * @override
2244 * @return {boolean}
2246 onselect: function(selectedByUser)
2248 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
2249 this._storagePanel.showCategoryView(this._manifestURL);
2250 return false;
2253 __proto__: WebInspector.BaseStorageTreeElement.prototype
2257 * @constructor
2258 * @extends {WebInspector.BaseStorageTreeElement}
2259 * @param {!WebInspector.ResourcesPanel} storagePanel
2260 * @param {!PageAgent.FrameId} frameId
2261 * @param {string} manifestURL
2263 WebInspector.ApplicationCacheFrameTreeElement = function(storagePanel, frameId, manifestURL)
2265 WebInspector.BaseStorageTreeElement.call(this, storagePanel, "", ["frame-storage-tree-item"]);
2266 this._frameId = frameId;
2267 this._manifestURL = manifestURL;
2268 this._refreshTitles();
2271 WebInspector.ApplicationCacheFrameTreeElement.prototype = {
2272 get itemURL()
2274 return "appcache://" + this._manifestURL + "/" + encodeURI(this.displayName);
2277 get frameId()
2279 return this._frameId;
2282 get manifestURL()
2284 return this._manifestURL;
2287 _refreshTitles: function()
2289 var frame = this._storagePanel._target.resourceTreeModel.frameForId(this._frameId);
2290 if (!frame) {
2291 this.subtitleText = WebInspector.UIString("new frame");
2292 return;
2294 this.titleText = frame.name;
2295 this.subtitleText = new WebInspector.ParsedURL(frame.url).displayName;
2298 frameNavigated: function()
2300 this._refreshTitles();
2304 * @override
2305 * @return {boolean}
2307 onselect: function(selectedByUser)
2309 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
2310 this._storagePanel.showApplicationCache(this._frameId);
2311 return false;
2314 __proto__: WebInspector.BaseStorageTreeElement.prototype
2318 * @constructor
2319 * @extends {WebInspector.BaseStorageTreeElement}
2320 * @param {!WebInspector.ResourcesPanel} storagePanel
2321 * @param {!WebInspector.FileSystemModel.FileSystem} fileSystem
2323 WebInspector.FileSystemTreeElement = function(storagePanel, fileSystem)
2325 var displayName = fileSystem.type + " - " + fileSystem.origin;
2326 WebInspector.BaseStorageTreeElement.call(this, storagePanel, displayName, ["file-system-storage-tree-item"]);
2327 this._fileSystem = fileSystem;
2330 WebInspector.FileSystemTreeElement.prototype = {
2331 get fileSystemName()
2333 return this._fileSystem.name;
2336 get itemURL()
2338 return "filesystem://" + this._fileSystem.name;
2342 * @override
2343 * @return {boolean}
2345 onselect: function(selectedByUser)
2347 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this, selectedByUser);
2348 this._fileSystemView = new WebInspector.FileSystemView(this._fileSystem);
2349 this._storagePanel.showFileSystem(this._fileSystemView);
2350 return false;
2353 clear: function()
2355 if (this.fileSystemView && this._storagePanel.visibleView === this.fileSystemView)
2356 this._storagePanel.closeVisibleView();
2359 __proto__: WebInspector.BaseStorageTreeElement.prototype
2363 * @constructor
2364 * @extends {WebInspector.VBox}
2366 WebInspector.StorageCategoryView = function()
2368 WebInspector.VBox.call(this);
2370 this.element.classList.add("storage-view");
2371 this._emptyWidget = new WebInspector.EmptyWidget("");
2372 this._emptyWidget.show(this.element);
2375 WebInspector.StorageCategoryView.prototype = {
2377 * @return {!Array.<!WebInspector.ToolbarItem>}
2379 toolbarItems: function()
2381 return [];
2384 setText: function(text)
2386 this._emptyWidget.text = text;
2389 __proto__: WebInspector.VBox.prototype
2392 WebInspector.ResourcesPanel.show = function()
2394 WebInspector.inspectorView.setCurrentPanel(WebInspector.ResourcesPanel._instance());
2398 * @return {!WebInspector.ResourcesPanel}
2400 WebInspector.ResourcesPanel._instance = function()
2402 if (!WebInspector.ResourcesPanel._instanceObject)
2403 WebInspector.ResourcesPanel._instanceObject = new WebInspector.ResourcesPanel();
2404 return WebInspector.ResourcesPanel._instanceObject;
2408 * @constructor
2409 * @implements {WebInspector.PanelFactory}
2411 WebInspector.ResourcesPanelFactory = function()
2415 WebInspector.ResourcesPanelFactory.prototype = {
2417 * @override
2418 * @return {!WebInspector.Panel}
2420 createPanel: function()
2422 return WebInspector.ResourcesPanel._instance();