Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / ResourceTreeModel.js
1 /*
2  * Copyright (C) 2011 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 /**
32  * @constructor
33  * @extends {WebInspector.Object}
34  * @param {!WebInspector.Target} target
35  */
36 WebInspector.ResourceTreeModel = function(target)
37 {
38     target.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.RequestFinished, this._onRequestFinished, this);
39     target.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.RequestUpdateDropped, this._onRequestUpdateDropped, this);
40
41     target.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._consoleMessageAdded, this);
42     target.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this);
43
44     this._agent = target.pageAgent();
45     this._agent.enable();
46
47     this._fetchResourceTree();
48
49     target.registerPageDispatcher(new WebInspector.PageDispatcher(this));
50
51     this._pendingConsoleMessages = {};
52     this._securityOriginFrameCount = {};
53     this._inspectedPageURL = "";
54 }
55
56 WebInspector.ResourceTreeModel.EventTypes = {
57     FrameAdded: "FrameAdded",
58     FrameNavigated: "FrameNavigated",
59     FrameDetached: "FrameDetached",
60     FrameResized: "FrameResized",
61     MainFrameNavigated: "MainFrameNavigated",
62     MainFrameCreatedOrNavigated: "MainFrameCreatedOrNavigated",
63     ResourceAdded: "ResourceAdded",
64     WillLoadCachedResources: "WillLoadCachedResources",
65     CachedResourcesLoaded: "CachedResourcesLoaded",
66     DOMContentLoaded: "DOMContentLoaded",
67     Load: "Load",
68     WillReloadPage: "WillReloadPage",
69     InspectedURLChanged: "InspectedURLChanged",
70     SecurityOriginAdded: "SecurityOriginAdded",
71     SecurityOriginRemoved: "SecurityOriginRemoved",
72     ScreencastFrame: "ScreencastFrame",
73     ScreencastVisibilityChanged: "ScreencastVisibilityChanged"
74 }
75
76 WebInspector.ResourceTreeModel.prototype = {
77     _fetchResourceTree: function()
78     {
79         /** @type {!Object.<string, !WebInspector.ResourceTreeFrame>} */
80         this._frames = {};
81         delete this._cachedResourcesProcessed;
82         this._agent.getResourceTree(this._processCachedResources.bind(this));
83     },
84
85     _processCachedResources: function(error, mainFramePayload)
86     {
87         if (error) {
88             console.error(JSON.stringify(error));
89             return;
90         }
91
92         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.WillLoadCachedResources);
93         this._inspectedPageURL = mainFramePayload.frame.url;
94         this._addFramesRecursively(null, mainFramePayload);
95         this._dispatchInspectedURLChanged();
96         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded);
97         this._cachedResourcesProcessed = true;
98     },
99
100     /**
101      * @return {string}
102      */
103     inspectedPageURL: function()
104     {
105         return this._inspectedPageURL;
106     },
107
108     /**
109      * @return {string}
110      */
111     inspectedPageDomain: function()
112     {
113         var parsedURL = this._inspectedPageURL ? this._inspectedPageURL.asParsedURL() : null;
114         return parsedURL ? parsedURL.host : "";
115     },
116
117     /**
118      * @return {boolean}
119      */
120     cachedResourcesLoaded: function()
121     {
122         return this._cachedResourcesProcessed;
123     },
124
125     _dispatchInspectedURLChanged: function()
126     {
127         InspectorFrontendHost.inspectedURLChanged(this._inspectedPageURL);
128         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._inspectedPageURL);
129     },
130
131     /**
132      * @param {!WebInspector.ResourceTreeFrame} frame
133      * @param {boolean=} aboutToNavigate
134      */
135     _addFrame: function(frame, aboutToNavigate)
136     {
137         this._frames[frame.id] = frame;
138         if (frame.isMainFrame())
139             this.mainFrame = frame;
140         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameAdded, frame);
141         if (!aboutToNavigate)
142             this._addSecurityOrigin(frame.securityOrigin);
143         if (frame.isMainFrame())
144             this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameCreatedOrNavigated, frame);
145     },
146
147     /**
148      * @param {string} securityOrigin
149      */
150     _addSecurityOrigin: function(securityOrigin)
151     {
152         if (!this._securityOriginFrameCount[securityOrigin]) {
153             this._securityOriginFrameCount[securityOrigin] = 1;
154             this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.SecurityOriginAdded, securityOrigin);
155             return;
156         }
157         this._securityOriginFrameCount[securityOrigin] += 1;
158     },
159
160     /**
161      * @param {string|undefined} securityOrigin
162      */
163     _removeSecurityOrigin: function(securityOrigin)
164     {
165         if (typeof securityOrigin === "undefined")
166             return;
167         if (this._securityOriginFrameCount[securityOrigin] === 1) {
168             delete this._securityOriginFrameCount[securityOrigin];
169             this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.SecurityOriginRemoved, securityOrigin);
170             return;
171         }
172         this._securityOriginFrameCount[securityOrigin] -= 1;
173     },
174
175     /**
176      * @return {!Array.<string>}
177      */
178     securityOrigins: function()
179     {
180         return Object.keys(this._securityOriginFrameCount);
181     },
182
183     /**
184      * @param {!WebInspector.ResourceTreeFrame} mainFrame
185      */
186     _handleMainFrameDetached: function(mainFrame)
187     {
188         /**
189          * @param {!WebInspector.ResourceTreeFrame} frame
190          * @this {WebInspector.ResourceTreeModel}
191          */
192         function removeOriginForFrame(frame)
193         {
194             for (var i = 0; i < frame.childFrames.length; ++i)
195                 removeOriginForFrame.call(this, frame.childFrames[i]);
196             if (!frame.isMainFrame())
197                 this._removeSecurityOrigin(frame.securityOrigin);
198         }
199         removeOriginForFrame.call(this, WebInspector.resourceTreeModel.mainFrame);
200     },
201
202     /**
203      * @param {!PageAgent.FrameId} frameId
204      * @param {?PageAgent.FrameId} parentFrameId
205      * @return {?WebInspector.ResourceTreeFrame}
206      */
207     _frameAttached: function(frameId, parentFrameId)
208     {
209         // Do nothing unless cached resource tree is processed - it will overwrite everything.
210         if (!this._cachedResourcesProcessed)
211             return null;
212         if (this._frames[frameId])
213             return null;
214
215         var parentFrame = parentFrameId ? this._frames[parentFrameId] : null;
216         var frame = new WebInspector.ResourceTreeFrame(this, parentFrame, frameId);
217         if (frame.isMainFrame() && this.mainFrame) {
218             this._handleMainFrameDetached(this.mainFrame);
219             // Navigation to the new backend process.
220             this._frameDetached(this.mainFrame.id);
221         }
222         this._addFrame(frame, true);
223         return frame;
224     },
225
226     /**
227      * @param {!PageAgent.Frame} framePayload
228      */
229     _frameNavigated: function(framePayload)
230     {
231         // Do nothing unless cached resource tree is processed - it will overwrite everything.
232         if (!this._cachedResourcesProcessed)
233             return;
234         var frame = this._frames[framePayload.id];
235         if (!frame) {
236             // Simulate missed "frameAttached" for a main frame navigation to the new backend process.
237             console.assert(!framePayload.parentId, "Main frame shouldn't have parent frame id.");
238             frame = this._frameAttached(framePayload.id, framePayload.parentId || "");
239             console.assert(frame);
240         }
241         this._removeSecurityOrigin(frame.securityOrigin);
242         frame._navigate(framePayload);
243         var addedOrigin = frame.securityOrigin;
244
245         if (frame.isMainFrame())
246             this._inspectedPageURL = frame.url;
247
248         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, frame);
249         if (frame.isMainFrame()) {
250             this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, frame);
251             this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameCreatedOrNavigated, frame);
252         }
253         if (addedOrigin)
254             this._addSecurityOrigin(addedOrigin);
255
256         // Fill frame with retained resources (the ones loaded using new loader).
257         var resources = frame.resources();
258         for (var i = 0; i < resources.length; ++i)
259             this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, resources[i]);
260
261         if (frame.isMainFrame())
262             this._dispatchInspectedURLChanged();
263     },
264
265     /**
266      * @param {!PageAgent.FrameId} frameId
267      */
268     _frameDetached: function(frameId)
269     {
270         // Do nothing unless cached resource tree is processed - it will overwrite everything.
271         if (!this._cachedResourcesProcessed)
272             return;
273
274         var frame = this._frames[frameId];
275         if (!frame)
276             return;
277
278         this._removeSecurityOrigin(frame.securityOrigin);
279         if (frame.parentFrame)
280             frame.parentFrame._removeChildFrame(frame);
281         else
282             frame._remove();
283     },
284
285     /**
286      * @param {!WebInspector.Event} event
287      */
288     _onRequestFinished: function(event)
289     {
290         if (!this._cachedResourcesProcessed)
291             return;
292
293         var request = /** @type {!WebInspector.NetworkRequest} */ (event.data);
294         if (request.failed || request.type === WebInspector.resourceTypes.XHR)
295             return;
296
297         var frame = this._frames[request.frameId];
298         if (frame) {
299             var resource = frame._addRequest(request);
300             this._addPendingConsoleMessagesToResource(resource);
301         }
302     },
303
304     /**
305      * @param {!WebInspector.Event} event
306      */
307     _onRequestUpdateDropped: function(event)
308     {
309         if (!this._cachedResourcesProcessed)
310             return;
311
312         var frameId = event.data.frameId;
313         var frame = this._frames[frameId];
314         if (!frame)
315             return;
316
317         var url = event.data.url;
318         if (frame._resourcesMap[url])
319             return;
320
321         var resource = new WebInspector.Resource(null, url, frame.url, frameId, event.data.loaderId, WebInspector.resourceTypes[event.data.resourceType], event.data.mimeType);
322         frame.addResource(resource);
323     },
324
325     /**
326      * @param {!PageAgent.FrameId} frameId
327      * @return {!WebInspector.ResourceTreeFrame}
328      */
329     frameForId: function(frameId)
330     {
331         return this._frames[frameId];
332     },
333
334     /**
335      * @param {function(!WebInspector.Resource)} callback
336      * @return {boolean}
337      */
338     forAllResources: function(callback)
339     {
340         if (this.mainFrame)
341             return this.mainFrame._callForFrameResources(callback);
342         return false;
343     },
344
345     /**
346      * @return {!Array.<!WebInspector.ResourceTreeFrame>}
347      */
348     frames: function()
349     {
350         return Object.values(this._frames);
351     },
352
353     /**
354      * @param {!WebInspector.Event} event
355      */
356     _consoleMessageAdded: function(event)
357     {
358         var msg = /** @type {!WebInspector.ConsoleMessage} */ (event.data);
359         var resource = msg.url ? this.resourceForURL(msg.url) : null;
360         if (resource)
361             this._addConsoleMessageToResource(msg, resource);
362         else
363             this._addPendingConsoleMessage(msg);
364     },
365
366     /**
367      * @param {!WebInspector.ConsoleMessage} msg
368      */
369     _addPendingConsoleMessage: function(msg)
370     {
371         if (!msg.url)
372             return;
373         if (!this._pendingConsoleMessages[msg.url])
374             this._pendingConsoleMessages[msg.url] = [];
375         this._pendingConsoleMessages[msg.url].push(msg);
376     },
377
378     /**
379      * @param {!WebInspector.Resource} resource
380      */
381     _addPendingConsoleMessagesToResource: function(resource)
382     {
383         var messages = this._pendingConsoleMessages[resource.url];
384         if (messages) {
385             for (var i = 0; i < messages.length; i++)
386                 this._addConsoleMessageToResource(messages[i], resource);
387             delete this._pendingConsoleMessages[resource.url];
388         }
389     },
390
391     /**
392      * @param {!WebInspector.ConsoleMessage} msg
393      * @param {!WebInspector.Resource} resource
394      */
395     _addConsoleMessageToResource: function(msg, resource)
396     {
397         switch (msg.level) {
398         case WebInspector.ConsoleMessage.MessageLevel.Warning:
399             resource.warnings++;
400             break;
401         case WebInspector.ConsoleMessage.MessageLevel.Error:
402             resource.errors++;
403             break;
404         }
405         resource.addMessage(msg);
406     },
407
408     _consoleCleared: function()
409     {
410         function callback(resource)
411         {
412             resource.clearErrorsAndWarnings();
413         }
414
415         this._pendingConsoleMessages = {};
416         this.forAllResources(callback);
417     },
418
419     /**
420      * @param {string} url
421      * @return {?WebInspector.Resource}
422      */
423     resourceForURL: function(url)
424     {
425         // Workers call into this with no frames available.
426         return this.mainFrame ? this.mainFrame.resourceForURL(url) : null;
427     },
428
429     /**
430      * @param {?WebInspector.ResourceTreeFrame} parentFrame
431      * @param {!PageAgent.FrameResourceTree} frameTreePayload
432      */
433     _addFramesRecursively: function(parentFrame, frameTreePayload)
434     {
435         var framePayload = frameTreePayload.frame;
436         var frame = new WebInspector.ResourceTreeFrame(this, parentFrame, framePayload.id, framePayload);
437         this._addFrame(frame);
438
439         var frameResource = this._createResourceFromFramePayload(framePayload, framePayload.url, WebInspector.resourceTypes.Document, framePayload.mimeType);
440         if (frame.isMainFrame())
441             this._inspectedPageURL = frameResource.url;
442         frame.addResource(frameResource);
443
444         for (var i = 0; frameTreePayload.childFrames && i < frameTreePayload.childFrames.length; ++i)
445             this._addFramesRecursively(frame, frameTreePayload.childFrames[i]);
446
447         for (var i = 0; i < frameTreePayload.resources.length; ++i) {
448             var subresource = frameTreePayload.resources[i];
449             var resource = this._createResourceFromFramePayload(framePayload, subresource.url, WebInspector.resourceTypes[subresource.type], subresource.mimeType);
450             frame.addResource(resource);
451         }
452     },
453
454     /**
455      * @param {!PageAgent.Frame} frame
456      * @param {string} url
457      * @param {!WebInspector.ResourceType} type
458      * @param {string} mimeType
459      * @return {!WebInspector.Resource}
460      */
461     _createResourceFromFramePayload: function(frame, url, type, mimeType)
462     {
463         return new WebInspector.Resource(null, url, frame.url, frame.id, frame.loaderId, type, mimeType);
464     },
465
466     /**
467      * @param {boolean=} ignoreCache
468      * @param {string=} scriptToEvaluateOnLoad
469      * @param {string=} scriptPreprocessor
470      */
471     reloadPage: function(ignoreCache, scriptToEvaluateOnLoad, scriptPreprocessor)
472     {
473         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.WillReloadPage);
474         this._agent.reload(ignoreCache, scriptToEvaluateOnLoad, scriptPreprocessor);
475     },
476
477     __proto__: WebInspector.Object.prototype
478 }
479
480 /**
481  * @constructor
482  * @param {!WebInspector.ResourceTreeModel} model
483  * @param {?WebInspector.ResourceTreeFrame} parentFrame
484  * @param {!PageAgent.FrameId} frameId
485  * @param {!PageAgent.Frame=} payload
486  */
487 WebInspector.ResourceTreeFrame = function(model, parentFrame, frameId, payload)
488 {
489     this._model = model;
490     this._parentFrame = parentFrame;
491     this._id = frameId;
492     this._url = "";
493
494     if (payload) {
495         this._loaderId = payload.loaderId;
496         this._name = payload.name;
497         this._url = payload.url;
498         this._securityOrigin = payload.securityOrigin;
499         this._mimeType = payload.mimeType;
500     }
501
502     /**
503      * @type {!Array.<!WebInspector.ResourceTreeFrame>}
504      */
505     this._childFrames = [];
506
507     /**
508      * @type {!Object.<string, !WebInspector.Resource>}
509      */
510     this._resourcesMap = {};
511
512     if (this._parentFrame)
513         this._parentFrame._childFrames.push(this);
514 }
515
516 WebInspector.ResourceTreeFrame.prototype = {
517     /**
518      * @return {string}
519      */
520     get id()
521     {
522         return this._id;
523     },
524
525     /**
526      * @return {string}
527      */
528     get name()
529     {
530         return this._name || "";
531     },
532
533     /**
534      * @return {string}
535      */
536     get url()
537     {
538         return this._url;
539     },
540
541     /**
542      * @return {string}
543      */
544     get securityOrigin()
545     {
546         return this._securityOrigin;
547     },
548
549     /**
550      * @return {string}
551      */
552     get loaderId()
553     {
554         return this._loaderId;
555     },
556
557     /**
558      * @return {?WebInspector.ResourceTreeFrame}
559      */
560     get parentFrame()
561     {
562         return this._parentFrame;
563     },
564
565     /**
566      * @return {!Array.<!WebInspector.ResourceTreeFrame>}
567      */
568     get childFrames()
569     {
570         return this._childFrames;
571     },
572
573     /**
574      * @return {boolean}
575      */
576     isMainFrame: function()
577     {
578         return !this._parentFrame;
579     },
580
581     /**
582      * @param {!PageAgent.Frame} framePayload
583      */
584     _navigate: function(framePayload)
585     {
586         this._loaderId = framePayload.loaderId;
587         this._name = framePayload.name;
588         this._url = framePayload.url;
589         this._securityOrigin = framePayload.securityOrigin;
590         this._mimeType = framePayload.mimeType;
591
592         var mainResource = this._resourcesMap[this._url];
593         this._resourcesMap = {};
594         this._removeChildFrames();
595         if (mainResource && mainResource.loaderId === this._loaderId)
596             this.addResource(mainResource);
597     },
598
599     /**
600      * @return {!WebInspector.Resource}
601      */
602     get mainResource()
603     {
604         return this._resourcesMap[this._url];
605     },
606
607     /**
608      * @param {!WebInspector.ResourceTreeFrame} frame
609      */
610     _removeChildFrame: function(frame)
611     {
612         this._childFrames.remove(frame);
613         frame._remove();
614     },
615
616     _removeChildFrames: function()
617     {
618         var frames = this._childFrames;
619         this._childFrames = [];
620         for (var i = 0; i < frames.length; ++i)
621             frames[i]._remove();
622     },
623
624     _remove: function()
625     {
626         this._removeChildFrames();
627         delete this._model._frames[this.id];
628         this._model.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, this);
629     },
630
631     /**
632      * @param {!WebInspector.Resource} resource
633      */
634     addResource: function(resource)
635     {
636         if (this._resourcesMap[resource.url] === resource) {
637             // Already in the tree, we just got an extra update.
638             return;
639         }
640         this._resourcesMap[resource.url] = resource;
641         this._model.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, resource);
642     },
643
644     /**
645      * @param {!WebInspector.NetworkRequest} request
646      * @return {!WebInspector.Resource}
647      */
648     _addRequest: function(request)
649     {
650         var resource = this._resourcesMap[request.url];
651         if (resource && resource.request === request) {
652             // Already in the tree, we just got an extra update.
653             return resource;
654         }
655         resource = new WebInspector.Resource(request, request.url, request.documentURL, request.frameId, request.loaderId, request.type, request.mimeType);
656         this._resourcesMap[resource.url] = resource;
657         this._model.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, resource);
658         return resource;
659     },
660
661     /**
662      * @return {!Array.<!WebInspector.Resource>}
663      */
664     resources: function()
665     {
666         var result = [];
667         for (var url in this._resourcesMap)
668             result.push(this._resourcesMap[url]);
669         return result;
670     },
671
672     /**
673      * @param {string} url
674      * @return {?WebInspector.Resource}
675      */
676     resourceForURL: function(url)
677     {
678         var result;
679         function filter(resource)
680         {
681             if (resource.url === url) {
682                 result = resource;
683                 return true;
684             }
685         }
686         this._callForFrameResources(filter);
687         return result || null;
688     },
689
690     /**
691      * @param {function(!WebInspector.Resource)} callback
692      * @return {boolean}
693      */
694     _callForFrameResources: function(callback)
695     {
696         for (var url in this._resourcesMap) {
697             if (callback(this._resourcesMap[url]))
698                 return true;
699         }
700
701         for (var i = 0; i < this._childFrames.length; ++i) {
702             if (this._childFrames[i]._callForFrameResources(callback))
703                 return true;
704         }
705         return false;
706     },
707
708     /**
709      * @return {string}
710      */
711     displayName: function()
712     {
713         if (!this._parentFrame)
714             return WebInspector.UIString("<top frame>");
715         var subtitle = new WebInspector.ParsedURL(this._url).displayName;
716         if (subtitle) {
717             if (!this._name)
718                 return subtitle;
719             return this._name + "( " + subtitle + " )";
720         }
721         return WebInspector.UIString("<iframe>");
722     }
723 }
724
725 /**
726  * @constructor
727  * @implements {PageAgent.Dispatcher}
728  */
729 WebInspector.PageDispatcher = function(resourceTreeModel)
730 {
731     this._resourceTreeModel = resourceTreeModel;
732 }
733
734 WebInspector.PageDispatcher.prototype = {
735     domContentEventFired: function(time)
736     {
737         this._resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.DOMContentLoaded, time);
738     },
739
740     loadEventFired: function(time)
741     {
742         this._resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.Load, time);
743     },
744
745     frameAttached: function(frameId, parentFrameId)
746     {
747         this._resourceTreeModel._frameAttached(frameId, parentFrameId);
748     },
749
750     frameNavigated: function(frame)
751     {
752         this._resourceTreeModel._frameNavigated(frame);
753     },
754
755     frameDetached: function(frameId)
756     {
757         this._resourceTreeModel._frameDetached(frameId);
758     },
759
760     frameStartedLoading: function(frameId)
761     {
762     },
763
764     frameStoppedLoading: function(frameId)
765     {
766     },
767
768     frameScheduledNavigation: function(frameId, delay)
769     {
770     },
771
772     frameClearedScheduledNavigation: function(frameId)
773     {
774     },
775
776     frameResized: function()
777     {
778         this._resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameResized, null);
779     },
780
781     javascriptDialogOpening: function(message)
782     {
783     },
784
785     javascriptDialogClosed: function()
786     {
787     },
788
789     scriptsEnabled: function(isEnabled)
790     {
791         WebInspector.settings.javaScriptDisabled.set(!isEnabled);
792     },
793
794     /**
795      * @param {string} data
796      * @param {!PageAgent.ScreencastFrameMetadata=} metadata
797      */
798     screencastFrame: function(data, metadata)
799     {
800         this._resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ScreencastFrame, {data:data, metadata:metadata});
801     },
802
803     /**
804      * @param {boolean} visible
805      */
806     screencastVisibilityChanged: function(visible)
807     {
808         this._resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ScreencastVisibilityChanged, {visible:visible});
809     }
810 }
811
812 /**
813  * @type {!WebInspector.ResourceTreeModel}
814  */
815 WebInspector.resourceTreeModel;