Changeset 99878 in webkit
- Timestamp:
- Nov 10, 2011 10:36:12 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r99877 r99878 1 2011-11-10 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: ApplicationCache UI is confusing and incorrect. 4 https://bugs.webkit.org/show_bug.cgi?id=64581 5 6 Reviewed by Pavel Feldman. 7 8 * http/tests/inspector/resource-tree/appcache-iframe-manifests-expected.txt: Added. 9 * http/tests/inspector/resource-tree/appcache-iframe-manifests.html: Added. 10 * http/tests/inspector/resource-tree/resources/manifest.php: Added. 11 * http/tests/inspector/resource-tree/resources/page-with-manifest.php: Added. 12 1 13 2011-11-10 Tony Gentilcore <tonyg@chromium.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r99873 r99878 1 2011-11-10 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: ApplicationCache UI is confusing and incorrect. 4 https://bugs.webkit.org/show_bug.cgi?id=64581 5 6 Reviewed by Pavel Feldman. 7 8 Fixed resources panel application cache UI. 9 Manifest urls are now shown under application cache tree element. 10 Under each manifest url tree element frames using relevant application 11 cache are listed. Application cache detailed views could be opened for each 12 frame. 13 14 Test: http/tests/inspector/resource-tree/appcache-iframe-manifests.html 15 16 * English.lproj/localizedStrings.js: 17 * inspector/Inspector.json: 18 * inspector/InspectorApplicationCacheAgent.cpp: 19 (WebCore::InspectorApplicationCacheAgent::InspectorApplicationCacheAgent): 20 (WebCore::InspectorApplicationCacheAgent::setFrontend): 21 (WebCore::InspectorApplicationCacheAgent::updateApplicationCacheStatus): 22 (WebCore::InspectorApplicationCacheAgent::networkStateChanged): 23 (WebCore::InspectorApplicationCacheAgent::enable): 24 (WebCore::InspectorApplicationCacheAgent::getFramesWithManifests): 25 (WebCore::InspectorApplicationCacheAgent::assertFrameWithDocumentLoader): 26 (WebCore::InspectorApplicationCacheAgent::getManifestForFrame): 27 (WebCore::InspectorApplicationCacheAgent::getApplicationCacheForFrame): 28 (WebCore::InspectorApplicationCacheAgent::buildObjectForApplicationCache): 29 (WebCore::InspectorApplicationCacheAgent::buildObjectForApplicationCacheResource): 30 * inspector/InspectorApplicationCacheAgent.h: 31 * inspector/InspectorController.cpp: 32 (WebCore::InspectorController::InspectorController): 33 * inspector/InspectorPageAgent.cpp: 34 (WebCore::InspectorPageAgent::resourceContent): 35 (WebCore::InspectorPageAgent::getResourceContent): 36 (WebCore::InspectorPageAgent::assertFrame): 37 (WebCore::InspectorPageAgent::assertDocumentLoader): 38 * inspector/InspectorPageAgent.h: 39 * inspector/InspectorStyleSheet.cpp: 40 (WebCore::InspectorStyleSheet::resourceStyleSheetText): 41 * inspector/front-end/ApplicationCacheItemsView.js: 42 (WebInspector.ApplicationCacheItemsView): 43 (WebInspector.ApplicationCacheItemsView.prototype._update): 44 (WebInspector.ApplicationCacheItemsView.prototype._updateCallback): 45 (WebInspector.ApplicationCacheItemsView.prototype._populateDataGrid): 46 * inspector/front-end/ApplicationCacheModel.js: 47 (WebInspector.ApplicationCacheModel): 48 (WebInspector.ApplicationCacheModel.prototype._frameNavigated): 49 (WebInspector.ApplicationCacheModel.prototype._frameDetached): 50 (WebInspector.ApplicationCacheModel.prototype._mainFrameNavigated): 51 (WebInspector.ApplicationCacheModel.prototype._manifestForFrameLoaded): 52 (WebInspector.ApplicationCacheModel.prototype._framesWithManifestsLoaded): 53 (WebInspector.ApplicationCacheModel.prototype._frameManifestUpdated): 54 (WebInspector.ApplicationCacheModel.prototype._frameManifestRemoved): 55 (WebInspector.ApplicationCacheModel.prototype.frameManifestURL): 56 (WebInspector.ApplicationCacheModel.prototype.frameManifestStatus): 57 (WebInspector.ApplicationCacheModel.prototype._statusUpdated): 58 (WebInspector.ApplicationCacheModel.prototype.requestApplicationCache): 59 (WebInspector.ApplicationCacheModel.prototype._networkStateUpdated): 60 (WebInspector.ApplicationCacheDispatcher.prototype.applicationCacheStatusUpdated): 61 (WebInspector.ApplicationCacheDispatcher.prototype.networkStateUpdated): 62 * inspector/front-end/ResourceTreeModel.js: 63 (WebInspector.ResourceTreeModel.prototype.frameForId): 64 * inspector/front-end/ResourcesPanel.js: 65 (WebInspector.ResourcesPanel.prototype.wasShown): 66 (WebInspector.ResourcesPanel.prototype.reset): 67 (WebInspector.ResourcesPanel.prototype._frameNavigated): 68 (WebInspector.ResourcesPanel.prototype.addDocumentURL): 69 (WebInspector.ResourcesPanel.prototype.showApplicationCache): 70 (WebInspector.ResourcesPanel.prototype._populateApplicationCacheTree): 71 (WebInspector.ResourcesPanel.prototype._applicationCacheFrameManifestAdded): 72 (WebInspector.ResourcesPanel.prototype._applicationCacheFrameManifestRemoved): 73 (WebInspector.ResourcesPanel.prototype._applicationCacheFrameManifestStatusChanged): 74 (WebInspector.ResourcesPanel.prototype._applicationCacheNetworkStateChanged): 75 (WebInspector.ApplicationCacheManifestTreeElement): 76 (WebInspector.ApplicationCacheManifestTreeElement.prototype.get itemURL): 77 (WebInspector.ApplicationCacheManifestTreeElement.prototype.get manifestURL): 78 (WebInspector.ApplicationCacheManifestTreeElement.prototype.onselect): 79 (WebInspector.ApplicationCacheFrameTreeElement): 80 (WebInspector.ApplicationCacheFrameTreeElement.prototype.get itemURL): 81 (WebInspector.ApplicationCacheFrameTreeElement.prototype.get frameId): 82 (WebInspector.ApplicationCacheFrameTreeElement.prototype.get manifestURL): 83 (WebInspector.ApplicationCacheFrameTreeElement.prototype._refreshTitles): 84 (WebInspector.ApplicationCacheFrameTreeElement.prototype.frameNavigated): 85 (WebInspector.ApplicationCacheFrameTreeElement.prototype.onselect): 86 1 87 2011-11-10 Andreas Kling <kling@webkit.org> 2 88 -
trunk/Source/WebCore/inspector/Inspector.json
r99849 r99878 926 926 "types": [ 927 927 { 928 "id": "AppCache", 929 "type": "object", 930 "description": "AppCache." 928 "id": "ApplicationCacheResource", 929 "type": "object", 930 "description": "Detailed application cache resource information.", 931 "properties": [ 932 { "name": "url", "type": "string", "description": "Resource url." }, 933 { "name": "size", "type": "string", "description": "Resource size." }, 934 { "name": "type", "type": "string", "description": "Resource type." } 935 ] 936 }, 937 { 938 "id": "ApplicationCache", 939 "type": "object", 940 "description": "Detailed application cache information.", 941 "properties": [ 942 { "name": "manifestURL", "type": "string", "description": "Manifest URL." }, 943 { "name": "size", "type": "number", "description": "Application cache size." }, 944 { "name": "creationTime", "type": "number", "description": "Application cache creation time." }, 945 { "name": "updateTime", "type": "number", "description": "Application cache update time." }, 946 { "name": "resources", "type": "array", "items": { "$ref": "ApplicationCacheResource" }, "description": "Application cache resources." } 947 ] 948 }, 949 { 950 "id": "FrameWithManifest", 951 "type": "object", 952 "description": "Frame identifier - manifest URL pair.", 953 "properties": [ 954 { "name": "frameId", "type": "string", "description": "Frame identifier." }, 955 { "name": "manifestURL", "type": "string", "description": "Manifest URL." }, 956 { "name": "status", "type": "integer", "description": "Application cache status." } 957 ] 931 958 } 932 959 ], 933 960 "commands": [ 934 961 { 935 "name": "getApplicationCaches", 936 "returns": [ 937 { "name": "applicationCaches", "$ref": "AppCache" } 938 ] 962 "name": "getFramesWithManifests", 963 "returns": [ 964 { "name": "frameIds", "type": "array", "items": { "$ref": "FrameWithManifest" }, "description": "Array of frame identifiers with manifest urls for each frame containing a document associated with some application cache." } 965 ], 966 "description": "Returns array of frame identifiers with manifest urls for each frame containing a document associated with some application cache." 967 }, 968 { 969 "name": "enable", 970 "description": "Enables application cache domain notifications." 971 }, 972 { 973 "name": "getManifestForFrame", 974 "parameters": [ 975 { "name": "frameId", "type": "string", "description": "Identifier of the frame containing document whose manifest is retrieved." } 976 ], 977 "returns": [ 978 { "name": "manifestURL", "type": "string", "description": "Manifest URL for document in the given frame." } 979 ], 980 "description": "Returns manifest URL for document in the given frame." 981 }, 982 { 983 "name": "getApplicationCacheForFrame", 984 "parameters": [ 985 { "name": "frameId", "type": "string", "description": "Identifier of the frame containing document whose application cache is retrieved." } 986 ], 987 "returns": [ 988 { "name": "applicationCache", "$ref": "ApplicationCache", "description": "Relevant application cache data for the document in given frame." } 989 ], 990 "description": "Returns relevant application cache data for the document in given frame." 939 991 } 940 992 ], 941 993 "events": [ 942 994 { 943 "name": "updateApplicationCacheStatus", 944 "parameters": [ 945 { "name": "status", "type": "integer" } 946 ] 947 }, 948 { 949 "name": "updateNetworkState", 995 "name": "applicationCacheStatusUpdated", 996 "parameters": [ 997 { "name": "frameId", "type": "string", "description": "Identifier of the frame containing document whose application cache updated status." }, 998 { "name": "manifestURL", "type": "string", "description": "Manifest URL." }, 999 { "name": "status", "type": "integer", "description": "Updated application cache status." } 1000 ] 1001 }, 1002 { 1003 "name": "networkStateUpdated", 950 1004 "parameters": [ 951 1005 { "name": "isNowOnline", "type": "boolean" } -
trunk/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp
r95919 r99878 35 35 #include "InspectorAgent.h" 36 36 #include "InspectorFrontend.h" 37 #include "InspectorPageAgent.h" 37 38 #include "InspectorValues.h" 38 39 #include "InstrumentingAgents.h" … … 43 44 namespace WebCore { 44 45 45 InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(InstrumentingAgents* instrumentingAgents, Page* inspectedPage)46 InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent) 46 47 : m_instrumentingAgents(instrumentingAgents) 47 , m_ inspectedPage(inspectedPage)48 , m_pageAgent(pageAgent) 48 49 , m_frontend(0) 49 50 { … … 53 54 { 54 55 m_frontend = frontend->applicationcache(); 55 m_instrumentingAgents->setInspectorApplicationCacheAgent(this);56 56 } 57 57 … … 64 64 void InspectorApplicationCacheAgent::updateApplicationCacheStatus(Frame* frame) 65 65 { 66 ApplicationCacheHost::Status status = frame->loader()->documentLoader()->applicationCacheHost()->status(); 67 m_frontend->updateApplicationCacheStatus(status); 66 DocumentLoader* documentLoader = frame->loader()->documentLoader(); 67 if (!documentLoader) 68 return; 69 70 ApplicationCacheHost* host = documentLoader->applicationCacheHost(); 71 ApplicationCacheHost::Status status = host->status(); 72 ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo(); 73 74 String manifestURL = info.m_manifest.string(); 75 m_frontend->applicationCacheStatusUpdated(m_pageAgent->frameId(frame), manifestURL, status); 68 76 } 69 77 … … 71 79 { 72 80 bool isNowOnline = networkStateNotifier().onLine(); 73 m_frontend-> updateNetworkState(isNowOnline);81 m_frontend->networkStateUpdated(isNowOnline); 74 82 } 75 83 76 void InspectorApplicationCacheAgent:: getApplicationCaches(ErrorString*, RefPtr<InspectorObject>* applicationCaches)84 void InspectorApplicationCacheAgent::enable(ErrorString*) 77 85 { 78 DocumentLoader* documentLoader = m_inspectedPage->mainFrame()->loader()->documentLoader(); 86 m_instrumentingAgents->setInspectorApplicationCacheAgent(this); 87 } 88 89 void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString*, RefPtr<InspectorArray>* result) 90 { 91 *result = InspectorArray::create(); 92 93 Frame* mainFrame = m_pageAgent->mainFrame(); 94 for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext(mainFrame)) { 95 DocumentLoader* documentLoader = frame->loader()->documentLoader(); 96 if (!documentLoader) 97 continue; 98 99 ApplicationCacheHost* host = documentLoader->applicationCacheHost(); 100 ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo(); 101 String manifestURL = info.m_manifest.string(); 102 if (!manifestURL.isEmpty()) { 103 RefPtr<InspectorObject> value = InspectorObject::create(); 104 value->setString("frameId", m_pageAgent->frameId(frame)); 105 value->setString("manifestURL", manifestURL); 106 value->setNumber("status", host->status()); 107 (*result)->pushObject(value); 108 } 109 } 110 } 111 112 DocumentLoader* InspectorApplicationCacheAgent::assertFrameWithDocumentLoader(ErrorString* errorString, String frameId) 113 { 114 Frame* frame = m_pageAgent->assertFrame(errorString, frameId); 115 if (!frame) 116 return 0; 117 118 return InspectorPageAgent::assertDocumentLoader(errorString, frame); 119 } 120 121 void InspectorApplicationCacheAgent::getManifestForFrame(ErrorString* errorString, const String& frameId, String* manifestURL) 122 { 123 DocumentLoader* documentLoader = assertFrameWithDocumentLoader(errorString, frameId); 79 124 if (!documentLoader) 80 125 return; 126 127 ApplicationCacheHost::CacheInfo info = documentLoader->applicationCacheHost()->applicationCacheInfo(); 128 *manifestURL = info.m_manifest.string(); 129 } 130 131 void InspectorApplicationCacheAgent::getApplicationCacheForFrame(ErrorString* errorString, const String& frameId, RefPtr<InspectorObject>* applicationCache) 132 { 133 DocumentLoader* documentLoader = assertFrameWithDocumentLoader(errorString, frameId); 134 if (!documentLoader) 135 return; 136 81 137 ApplicationCacheHost* host = documentLoader->applicationCacheHost(); 82 138 ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo(); … … 84 140 ApplicationCacheHost::ResourceInfoList resources; 85 141 host->fillResourceList(&resources); 86 *applicationCaches = buildObjectForApplicationCache(resources, info); 142 143 *applicationCache = buildObjectForApplicationCache(resources, info); 87 144 } 88 145 … … 91 148 RefPtr<InspectorObject> value = InspectorObject::create(); 92 149 value->setNumber("size", applicationCacheInfo.m_size); 93 value->setString("manifest", applicationCacheInfo.m_manifest.string()); 94 value->setString("lastPathComponent", applicationCacheInfo.m_manifest.lastPathComponent()); 150 value->setString("manifestURL", applicationCacheInfo.m_manifest.string()); 95 151 value->setNumber("creationTime", applicationCacheInfo.m_creationTime); 96 152 value->setNumber("updateTime", applicationCacheInfo.m_updateTime); … … 114 170 { 115 171 RefPtr<InspectorObject> value = InspectorObject::create(); 116 value->setString(" name", resourceInfo.m_resource.string());172 value->setString("url", resourceInfo.m_resource.string()); 117 173 value->setNumber("size", resourceInfo.m_size); 118 174 -
trunk/Source/WebCore/inspector/InspectorApplicationCacheAgent.h
r95919 r99878 40 40 class InspectorFrontend; 41 41 class InspectorObject; 42 class InspectorPageAgent; 42 43 class InspectorValue; 43 44 class InstrumentingAgents; … … 50 51 WTF_MAKE_NONCOPYABLE(InspectorApplicationCacheAgent); WTF_MAKE_FAST_ALLOCATED; 51 52 public: 52 InspectorApplicationCacheAgent(InstrumentingAgents*, Page*);53 InspectorApplicationCacheAgent(InstrumentingAgents*, InspectorPageAgent*); 53 54 ~InspectorApplicationCacheAgent() { } 54 55 56 // Inspector Controller API 55 57 void setFrontend(InspectorFrontend*); 56 58 void clearFrontend(); 57 59 58 // Backend to Frontend60 // InspectorInstrumentation API 59 61 void updateApplicationCacheStatus(Frame*); 60 62 void networkStateChanged(); 61 63 62 // From Frontend 63 void getApplicationCaches(ErrorString*, RefPtr<InspectorObject>* applicationCaches); 64 // ApplicationCache API for InspectorFrontend 65 void enable(ErrorString*); 66 void getFramesWithManifests(ErrorString*, RefPtr<InspectorArray>* result); 67 void getManifestForFrame(ErrorString*, const String& frameId, String* manifestURL); 68 void getApplicationCacheForFrame(ErrorString*, const String& frameId, RefPtr<InspectorObject>* applicationCache); 64 69 65 70 private: … … 68 73 PassRefPtr<InspectorObject> buildObjectForApplicationCacheResource(const ApplicationCacheHost::ResourceInfo&); 69 74 75 DocumentLoader* assertFrameWithDocumentLoader(ErrorString*, String frameId); 76 70 77 InstrumentingAgents* m_instrumentingAgents; 71 Page* m_inspectedPage;78 InspectorPageAgent* m_pageAgent; 72 79 InspectorFrontend::ApplicationCache* m_frontend; 73 80 }; -
trunk/Source/WebCore/inspector/InspectorController.cpp
r97611 r99878 107 107 , m_domStorageAgent(InspectorDOMStorageAgent::create(m_instrumentingAgents.get(), m_state.get())) 108 108 , m_timelineAgent(InspectorTimelineAgent::create(m_instrumentingAgents.get(), m_state.get())) 109 , m_applicationCacheAgent(adoptPtr(new InspectorApplicationCacheAgent(m_instrumentingAgents.get(), page)))109 , m_applicationCacheAgent(adoptPtr(new InspectorApplicationCacheAgent(m_instrumentingAgents.get(), m_pageAgent.get()))) 110 110 , m_resourceAgent(InspectorResourceAgent::create(m_instrumentingAgents.get(), m_pageAgent.get(), inspectorClient, m_state.get())) 111 111 , m_runtimeAgent(adoptPtr(new PageRuntimeAgent(m_instrumentingAgents.get(), m_injectedScriptManager.get(), page, m_pageAgent.get()))) -
trunk/Source/WebCore/inspector/InspectorPageAgent.cpp
r98328 r99878 187 187 void InspectorPageAgent::resourceContent(ErrorString* errorString, Frame* frame, const KURL& url, String* result, bool* base64Encoded) 188 188 { 189 if (!frame) {190 *errorString = "No frame to get resource content for";189 DocumentLoader* loader = assertDocumentLoader(errorString, frame); 190 if (!loader) 191 191 return; 192 }193 194 FrameLoader* frameLoader = frame->loader();195 DocumentLoader* loader = frameLoader->documentLoader();196 197 if (!loader) {198 *errorString = "No documentLoader for frame to get resource content for";199 return;200 }201 192 202 193 RefPtr<SharedBuffer> buffer; … … 482 473 void InspectorPageAgent::getResourceContent(ErrorString* errorString, const String& frameId, const String& url, String* content, bool* base64Encoded) 483 474 { 484 Frame* frame = frameForId(frameId); 485 if (!frame) { 486 *errorString = "No frame for given id found"; 475 Frame* frame = assertFrame(errorString, frameId); 476 if (!frame) 487 477 return; 488 } 478 489 479 resourceContent(errorString, frame, KURL(ParsedURLString, url), content, base64Encoded); 490 480 } … … 662 652 } 663 653 654 Frame* InspectorPageAgent::assertFrame(ErrorString* errorString, String frameId) 655 { 656 Frame* frame = frameForId(frameId); 657 if (!frame) 658 *errorString = "No frame for given id found"; 659 660 return frame; 661 } 662 663 // static 664 DocumentLoader* InspectorPageAgent::assertDocumentLoader(ErrorString* errorString, Frame* frame) 665 { 666 FrameLoader* frameLoader = frame->loader(); 667 DocumentLoader* documentLoader = frameLoader ? frameLoader->documentLoader() : 0; 668 if (!documentLoader) 669 *errorString = "No documentLoader for given frame found"; 670 671 return documentLoader; 672 } 673 664 674 void InspectorPageAgent::loaderDetachedFromFrame(DocumentLoader* loader) 665 675 { -
trunk/Source/WebCore/inspector/InspectorPageAgent.h
r98328 r99878 119 119 String frameId(Frame*); 120 120 String loaderId(DocumentLoader*); 121 Frame* assertFrame(ErrorString*, String frameId); 122 static DocumentLoader* assertDocumentLoader(ErrorString*, Frame*); 121 123 122 124 private: -
trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp
r99849 r99878 1085 1085 return false; 1086 1086 1087 if (!m_pageStyleSheet || !ownerDocument() )1087 if (!m_pageStyleSheet || !ownerDocument() || !ownerDocument()->frame()) 1088 1088 return false; 1089 1089 -
trunk/Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js
r99689 r99878 28 28 * @extends {WebInspector.View} 29 29 */ 30 WebInspector.ApplicationCacheItemsView = function(model, treeElement, appcacheDomain)30 WebInspector.ApplicationCacheItemsView = function(model, frameId, status) 31 31 { 32 32 WebInspector.View.call(this); … … 65 65 this.statusMessage.textContent = ""; 66 66 67 this._treeElement = treeElement; 68 this._appcacheDomain = appcacheDomain; 67 this._frameId = frameId; 69 68 70 69 this._emptyView = new WebInspector.EmptyView(WebInspector.UIString("No Application Cache information available.")); 71 70 this._emptyView.show(this.element); 72 71 73 this.updateStatus( applicationCache.UNCACHED);72 this.updateStatus(status); 74 73 75 74 // FIXME: Status bar items don't work well enough yet, so they are being hidden. … … 117 116 }, 118 117 118 /** 119 * @param {number} status 120 */ 119 121 updateStatus: function(status) 120 122 { … … 137 139 }, 138 140 141 /** 142 * @param {boolean} isNowOnline 143 */ 139 144 updateNetworkState: function(isNowOnline) 140 145 { … … 152 157 _update: function() 153 158 { 154 this._model.getApplicationCachesAsync(this._updateCallback.bind(this)); 155 }, 156 157 _updateCallback: function(applicationCaches) 158 { 159 // FIXME: applicationCaches is just one cache. 160 // FIXME: are these variables needed anywhere else? 161 this._manifest = applicationCaches.manifest; 162 this._creationTime = applicationCaches.creationTime; 163 this._updateTime = applicationCaches.updateTime; 164 this._size = applicationCaches.size; 165 this._resources = applicationCaches.resources; 166 var lastPathComponent = applicationCaches.lastPathComponent; 167 168 if (!this._manifest) { 159 this._model.requestApplicationCache(this._frameId, this._updateCallback.bind(this)); 160 }, 161 162 /** 163 * @param {Object} applicationCache 164 */ 165 _updateCallback: function(applicationCache) 166 { 167 if (!applicationCache || !applicationCache.manifestURL) { 169 168 this._emptyView.show(this.element); 170 169 this.deleteButton.visible = false; … … 174 173 } 175 174 175 // FIXME: applicationCaches is just one cache. 176 // FIXME: are these variables needed anywhere else? 177 this._manifest = applicationCache.manifestURL; 178 this._creationTime = applicationCache.creationTime; 179 this._updateTime = applicationCache.updateTime; 180 this._size = applicationCache.size; 181 this._resources = applicationCache.resources; 182 var lastPathComponent = applicationCache.lastPathComponent; 183 176 184 if (!this._dataGrid) 177 185 this._createDataGrid(); … … 182 190 this._emptyView.detach(); 183 191 this.deleteButton.visible = true; 184 185 var totalSizeString = Number.bytesToString(this._size);186 this._treeElement.subtitle = WebInspector.UIString("%s (%s)", lastPathComponent, totalSizeString);187 192 188 193 // FIXME: For Chrome, put creationTime and updateTime somewhere. … … 236 241 var data = {}; 237 242 var resource = this._resources[i]; 238 data[0] = resource. name;243 data[0] = resource.url; 239 244 data[1] = resource.type; 240 245 data[2] = Number.bytesToString(resource.size); … … 249 254 } 250 255 251 if (!nodeToSelect )256 if (!nodeToSelect && this._dataGrid.children.length) 252 257 this._dataGrid.children[0].selected = true; 253 258 }, -
trunk/Source/WebCore/inspector/front-end/ApplicationCacheModel.js
r99689 r99878 33 33 WebInspector.ApplicationCacheModel = function() 34 34 { 35 ApplicationCacheAgent.enable(); 35 36 InspectorBackend.registerApplicationCacheDispatcher(new WebInspector.ApplicationCacheDispatcher(this)); 37 38 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, this._frameNavigated, this); 39 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, this._frameDetached, this); 40 41 this._statuses = {}; 42 this._manifestURLsByFrame = {}; 43 44 this._mainFrameNavigated(); 45 } 46 47 WebInspector.ApplicationCacheModel.EventTypes = { 48 FrameManifestStatusUpdated: "FrameManifestStatusUpdated", 49 FrameManifestAdded: "FrameManifestAdded", 50 FrameManifestRemoved: "FrameManifestRemoved", 51 NetworkStateChanged: "NetworkStateChanged" 36 52 } 37 53 38 54 WebInspector.ApplicationCacheModel.prototype = { 39 getApplicationCachesAsync: function(callback) 40 { 41 function mycallback(error, applicationCaches) 55 _frameNavigated: function(event) 56 { 57 if (event.data.isMainFrame) { 58 this._mainFrameNavigated(); 59 return; 60 } 61 62 var frame = /** @type {PageAgent.Frame} */ event.data["frame"]; 63 var frameId = frame.id; 64 ApplicationCacheAgent.getManifestForFrame(frameId, this._manifestForFrameLoaded.bind(this, frameId)); 65 }, 66 67 _frameDetached: function(event) 68 { 69 var frameId = event.data; 70 this._frameManifestRemoved(frameId); 71 }, 72 73 _mainFrameNavigated: function() 74 { 75 ApplicationCacheAgent.getFramesWithManifests(this._framesWithManifestsLoaded.bind(this)); 76 }, 77 78 /** 79 * @param {string} frameId 80 * @param {string} error 81 * @param {string} manifestURL 82 */ 83 _manifestForFrameLoaded: function(frameId, error, manifestURL) 84 { 85 if (error) { 86 console.error(error); 87 return; 88 } 89 90 if (!manifestURL) 91 this._frameManifestRemoved(frameId); 92 }, 93 94 /** 95 * @param {string} error 96 * @param {Array.<ApplicationCacheAgent.FrameWithManifest>} framesWithManifests 97 */ 98 _framesWithManifestsLoaded: function(error, framesWithManifests) 99 { 100 if (error) { 101 console.error(error); 102 return; 103 } 104 105 for (var i = 0; i < framesWithManifests.length; ++i) 106 this._frameManifestUpdated(framesWithManifests[i].frameId, framesWithManifests[i].manifestURL, framesWithManifests[i].status); 107 }, 108 109 /** 110 * @param {string} frameId 111 * @param {string} manifestURL 112 * @param {number} status 113 */ 114 _frameManifestUpdated: function(frameId, manifestURL, status) 115 { 116 if (status === applicationCache.UNCACHED) { 117 this._frameManifestRemoved(frameId); 118 return; 119 } 120 121 if (!manifestURL) 122 return; 123 124 if (this._manifestURLsByFrame[frameId] && manifestURL !== this._manifestURLsByFrame[frameId]) 125 this._frameManifestRemoved(frameId); 126 127 var statusChanged = this._statuses[frameId] !== status; 128 this._statuses[frameId] = status; 129 130 if (!this._manifestURLsByFrame[frameId]) { 131 this._manifestURLsByFrame[frameId] = manifestURL; 132 this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestAdded, frameId); 133 } 134 135 if (statusChanged) 136 this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestStatusUpdated, frameId); 137 }, 138 139 /** 140 * @param {string} frameId 141 */ 142 _frameManifestRemoved: function(frameId) 143 { 144 if (!this._manifestURLsByFrame[frameId]) 145 return; 146 147 var manifestURL = this._manifestURLsByFrame[frameId]; 148 delete this._manifestURLsByFrame[frameId]; 149 delete this._statuses[frameId]; 150 151 this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestRemoved, frameId); 152 }, 153 154 /** 155 * @param {string} frameId 156 * @return {string} 157 */ 158 frameManifestURL: function(frameId) 159 { 160 return this._manifestURLsByFrame[frameId] || ""; 161 }, 162 163 /** 164 * @param {string} frameId 165 * @return {number} 166 */ 167 frameManifestStatus: function(frameId) 168 { 169 return this._statuses[frameId] || applicationCache.UNCACHED; 170 }, 171 172 /** 173 * @param {string} frameId 174 * @param {string} manifestURL 175 * @param {number} status 176 */ 177 _statusUpdated: function(frameId, manifestURL, status) 178 { 179 this._frameManifestUpdated(frameId, manifestURL, status); 180 }, 181 182 /** 183 * @param {string} frameId 184 * @param {function(Object)} callback 185 */ 186 requestApplicationCache: function(frameId, callback) 187 { 188 function callbackWrapper(error, applicationCache) 42 189 { 43 // FIXME: Currently, this list only returns a single application cache. 44 if (!error && applicationCaches) 45 callback(applicationCaches); 46 } 47 48 ApplicationCacheAgent.getApplicationCaches(mycallback); 190 if (error) { 191 console.error(error); 192 callback(null); 193 return; 194 } 195 196 callback(applicationCache); 197 } 198 199 ApplicationCacheAgent.getApplicationCacheForFrame(frameId, callbackWrapper.bind(this)); 200 }, 201 202 /** 203 * @param {boolean} isNowOnline 204 */ 205 _networkStateUpdated: function(isNowOnline) 206 { 207 this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.EventTypes.NetworkStateChanged, isNowOnline); 49 208 } 50 209 } … … 63 222 WebInspector.ApplicationCacheDispatcher.prototype = { 64 223 /** 224 * @param {string} frameId 225 * @param {string} manifestURL 65 226 * @param {number} status 66 227 */ 67 updateApplicationCacheStatus: function(status)68 { 69 WebInspector.panels.resources.updateApplicationCacheStatus(status);70 }, 71 228 applicationCacheStatusUpdated: function(frameId, manifestURL, status) 229 { 230 this._applicationCacheModel._statusUpdated(frameId, manifestURL, status); 231 }, 232 72 233 /** 73 234 * @param {boolean} isNowOnline 74 235 */ 75 updateNetworkState: function(isNowOnline)76 { 77 WebInspector.panels.resources.updateNetworkState(isNowOnline);78 } 79 } 236 networkStateUpdated: function(isNowOnline) 237 { 238 this._applicationCacheModel._networkStateUpdated(isNowOnline); 239 }, 240 } -
trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js
r98840 r99878 115 115 }, 116 116 117 frameForId: function(frameId) 118 { 119 return this._frameIds[frameId]; 120 }, 121 117 122 resources: function(frameId) 118 123 { -
trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js
r99689 r99878 78 78 this._domains = {}; 79 79 80 80 81 this.sidebarElement.addEventListener("mousemove", this._onmousemove.bind(this), false); 81 82 this.sidebarElement.addEventListener("mouseout", this._onmouseout.bind(this), false); … … 111 112 if (!this._initialized) { 112 113 this._populateResourceTree(); 113 this._initializeApplicationCacheModel(); 114 114 this._populateApplicationCacheTree(); 115 115 this._initDefaultSelection(); 116 116 117 117 this._initialized = true; 118 118 } … … 168 168 this._cookieViews = {}; 169 169 170 this._applicationCacheView = null;171 delete this._cachedApplicationCacheViewStatus;172 173 170 this.databasesListTreeElement.removeChildren(); 174 171 this.localStorageListTreeElement.removeChildren(); 175 172 this.sessionStorageListTreeElement.removeChildren(); 176 173 this.cookieListTreeElement.removeChildren(); 177 this.applicationCacheListTreeElement.removeChildren();178 174 179 175 if (this.visibleView) … … 263 259 if (frameTreeElement) 264 260 frameTreeElement.frameNavigated(event.data.frame); 261 262 var applicationCacheFrameTreeElement = this._applicationCacheFrameElements[frameId]; 263 if (applicationCacheFrameTreeElement) 264 applicationCacheFrameTreeElement.frameNavigated(event.data.frame); 265 265 }, 266 266 … … 291 291 var cookieDomainTreeElement = new WebInspector.CookieTreeElement(this, domain); 292 292 this.cookieListTreeElement.appendChild(cookieDomainTreeElement); 293 294 var applicationCacheTreeElement = new WebInspector.ApplicationCacheTreeElement(this, domain);295 this.applicationCacheListTreeElement.appendChild(applicationCacheTreeElement);296 293 } 297 294 }, … … 481 478 }, 482 479 483 showApplicationCache: function(treeElement, appcacheDomain) 484 { 485 var view = this._applicationCacheView; 486 if (!view) { 487 view = new WebInspector.ApplicationCacheItemsView(this._applicationCacheModel, treeElement, appcacheDomain); 488 this._applicationCacheView = view; 489 } 490 491 this._innerShowView(view); 492 493 if ("_cachedApplicationCacheViewStatus" in this) 494 this._applicationCacheView.updateStatus(this._cachedApplicationCacheViewStatus); 480 showApplicationCache: function(frameId) 481 { 482 var status = this._applicationCacheModel.frameManifestStatus(frameId) 483 484 if (!this._applicationCacheViews[frameId]) { 485 this._applicationCacheViews[frameId] = new WebInspector.ApplicationCacheItemsView(this._applicationCacheModel, frameId, status); 486 487 // FIXME: Make sure this._cachedApplicationCacheNetworkState is always set and is always up to date. 488 if (typeof(this._cachedApplicationCacheNetworkState) === "number") 489 this._applicationCacheViews[frameId].updateNetworkState(this._cachedApplicationCacheNetworkState); 490 } 491 492 this._innerShowView(this._applicationCacheViews[frameId]); 495 493 }, 496 494 … … 567 565 }, 568 566 569 _ initializeApplicationCacheModel: function()567 _populateApplicationCacheTree: function() 570 568 { 571 569 this._applicationCacheModel = new WebInspector.ApplicationCacheModel(); 572 }, 573 574 updateApplicationCacheStatus: function(status) 575 { 576 this._cachedApplicationCacheViewStatus = status; 577 if (this._applicationCacheView && this._applicationCacheView === this.visibleView) 578 this._applicationCacheView.updateStatus(status); 579 }, 580 581 updateNetworkState: function(isNowOnline) 582 { 583 if (this._applicationCacheView && this._applicationCacheView === this.visibleView) 584 this._applicationCacheView.updateNetworkState(isNowOnline); 585 }, 586 587 updateManifest: function(manifest) 588 { 589 if (this._applicationCacheView && this._applicationCacheView === this.visibleView) 590 this._applicationCacheView.updateManifest(manifest); 570 571 this._applicationCacheViews = {}; 572 this._applicationCacheFrameElements = {}; 573 this._applicationCacheManifestElements = {}; 574 575 this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestAdded, this._applicationCacheFrameManifestAdded, this); 576 this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestRemoved, this._applicationCacheFrameManifestRemoved, this); 577 578 this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestStatusUpdated, this._applicationCacheFrameManifestStatusChanged, this); 579 this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.NetworkStateChanged, this._applicationCacheNetworkStateChanged, this); 580 }, 581 582 _applicationCacheFrameManifestAdded: function(event) 583 { 584 var frameId = event.data; 585 var manifestURL = this._applicationCacheModel.frameManifestURL(frameId); 586 var status = this._applicationCacheModel.frameManifestStatus(frameId) 587 588 var manifestTreeElement = this._applicationCacheManifestElements[manifestURL] 589 if (!manifestTreeElement) { 590 manifestTreeElement = new WebInspector.ApplicationCacheManifestTreeElement(this, manifestURL); 591 this.applicationCacheListTreeElement.appendChild(manifestTreeElement); 592 this._applicationCacheManifestElements[manifestURL] = manifestTreeElement; 593 } 594 595 var frameTreeElement = new WebInspector.ApplicationCacheFrameTreeElement(this, frameId, manifestURL); 596 manifestTreeElement.appendChild(frameTreeElement); 597 manifestTreeElement.expand(); 598 this._applicationCacheFrameElements[frameId] = frameTreeElement; 599 }, 600 601 _applicationCacheFrameManifestRemoved: function(event) 602 { 603 var frameId = event.data; 604 var frameTreeElement = this._applicationCacheFrameElements[frameId]; 605 if (!frameTreeElement) 606 return; 607 608 var manifestURL = frameTreeElement.manifestURL; 609 delete this._applicationCacheFrameElements[frameId]; 610 delete this._applicationCacheViews[frameId]; 611 frameTreeElement.parent.removeChild(frameTreeElement); 612 613 var manifestTreeElement = this._applicationCacheManifestElements[manifestURL]; 614 if (manifestTreeElement.children.length !== 0) 615 return; 616 617 delete this._applicationCacheManifestElements[manifestURL]; 618 manifestTreeElement.parent.removeChild(manifestTreeElement); 619 }, 620 621 _applicationCacheFrameManifestStatusChanged: function(event) 622 { 623 var frameId = event.data; 624 var status = this._applicationCacheModel.frameManifestStatus(frameId) 625 626 if (this._applicationCacheViews[frameId]) 627 this._applicationCacheViews[frameId].updateStatus(status); 628 }, 629 630 _applicationCacheNetworkStateChanged: function(event) 631 { 632 var isNowOnline = event.data; 633 634 this._cachedApplicationCacheNetworkState = isNowOnline; 635 for (var manifestURL in this._applicationCacheViews) 636 this._applicationCacheViews[manifestURL].updateNetworkState(isNowOnline); 591 637 }, 592 638 … … 1503 1549 * @extends {WebInspector.BaseStorageTreeElement} 1504 1550 */ 1505 WebInspector.ApplicationCache TreeElement = function(storagePanel, appcacheDomain)1551 WebInspector.ApplicationCacheManifestTreeElement = function(storagePanel, manifestURL) 1506 1552 { 1507 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, appcacheDomain ? appcacheDomain : WebInspector.UIString("Local Files"), ["application-cache-storage-tree-item"]); 1508 this._appcacheDomain = appcacheDomain; 1509 } 1510 1511 WebInspector.ApplicationCacheTreeElement.prototype = { 1553 var title = WebInspector.Resource.displayName(manifestURL); 1554 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, ["application-cache-storage-tree-item"]); 1555 this.tooltip = manifestURL; 1556 this._manifestURL = manifestURL; 1557 } 1558 1559 WebInspector.ApplicationCacheManifestTreeElement.prototype = { 1512 1560 get itemURL() 1513 1561 { 1514 return "appcache://" + this._appcacheDomain; 1562 return "appcache://" + this._manifestURL; 1563 }, 1564 1565 get manifestURL() 1566 { 1567 return this._manifestURL; 1515 1568 }, 1516 1569 … … 1518 1571 { 1519 1572 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); 1520 this._storagePanel.show ApplicationCache(this, this._appcacheDomain);1573 this._storagePanel.showCategoryView(this._manifestURL); 1521 1574 } 1522 1575 } 1523 WebInspector.ApplicationCacheTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; 1576 WebInspector.ApplicationCacheManifestTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; 1577 1578 /** 1579 * @constructor 1580 * @extends {WebInspector.BaseStorageTreeElement} 1581 */ 1582 WebInspector.ApplicationCacheFrameTreeElement = function(storagePanel, frameId, manifestURL) 1583 { 1584 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, "", ["frame-storage-tree-item"]); 1585 this._frameId = frameId; 1586 this._manifestURL = manifestURL; 1587 this._refreshTitles(); 1588 } 1589 1590 WebInspector.ApplicationCacheFrameTreeElement.prototype = { 1591 get itemURL() 1592 { 1593 return "appcache://" + this._manifestURL + "/" + encodeURI(this.displayName); 1594 }, 1595 1596 get frameId() 1597 { 1598 return this._frameId; 1599 }, 1600 1601 get manifestURL() 1602 { 1603 return this._manifestURL; 1604 }, 1605 1606 _refreshTitles: function() 1607 { 1608 var frame = WebInspector.resourceTreeModel.frameForId(this._frameId); 1609 if (!frame) { 1610 this.subtitleText = WebInspector.UIString("new frame"); 1611 return; 1612 } 1613 this.titleText = frame.name; 1614 this.subtitleText = WebInspector.Resource.displayName(frame.url); 1615 }, 1616 1617 frameNavigated: function() 1618 { 1619 this._refreshTitles(); 1620 }, 1621 1622 onselect: function() 1623 { 1624 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); 1625 this._storagePanel.showApplicationCache(this._frameId); 1626 } 1627 } 1628 WebInspector.ApplicationCacheFrameTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; 1524 1629 1525 1630 /**
Note: See TracChangeset
for help on using the changeset viewer.