Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / sdk / 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.SDKModel}
34  * @param {!WebInspector.Target} target
35  */
36 WebInspector.ResourceTreeModel = function(target)
37 {
38     WebInspector.SDKModel.call(this, WebInspector.ResourceTreeModel, target);
39
40     target.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.RequestFinished, this._onRequestFinished, this);
41     target.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.RequestUpdateDropped, this._onRequestUpdateDropped, this);
42
43     target.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._consoleMessageAdded, this);
44     target.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this);
45
46     this._agent = target.pageAgent();
47     this._agent.enable();
48
49     this._fetchResourceTree();
50
51     target.registerPageDispatcher(new WebInspector.PageDispatcher(this));
52
53     this._pendingConsoleMessages = {};
54     this._securityOriginFrameCount = {};
55     this._inspectedPageURL = "";
56 }
57
58 WebInspector.ResourceTreeModel.EventTypes = {
59     FrameAdded: "FrameAdded",
60     FrameNavigated: "FrameNavigated",
61     FrameDetached: "FrameDetached",
62     FrameResized: "FrameResized",
63     MainFrameNavigated: "MainFrameNavigated",
64     ResourceAdded: "ResourceAdded",
65     WillLoadCachedResources: "WillLoadCachedResources",
66     CachedResourcesLoaded: "CachedResourcesLoaded",
67     DOMContentLoaded: "DOMContentLoaded",
68     Load: "Load",
69     WillReloadPage: "WillReloadPage",
70     InspectedURLChanged: "InspectedURLChanged",
71     SecurityOriginAdded: "SecurityOriginAdded",
72     SecurityOriginRemoved: "SecurityOriginRemoved",
73     ScreencastFrame: "ScreencastFrame",
74     ScreencastVisibilityChanged: "ScreencastVisibilityChanged",
75     ViewportChanged: "ViewportChanged"
76 }
77
78 WebInspector.ResourceTreeModel.prototype = {
79     _fetchResourceTree: function()
80     {
81         /** @type {!Object.<string, !WebInspector.ResourceTreeFrame>} */
82         this._frames = {};
83         delete this._cachedResourcesProcessed;
84         this._agent.getResourceTree(this._processCachedResources.bind(this));
85     },
86
87     _processCachedResources: function(error, mainFramePayload)
88     {
89         if (error) {
90             //FIXME: remove resourceTreeModel from worker
91             if (!this.target().isWorkerTarget())
92                 console.error(JSON.stringify(error));
93             return;
94         }
95
96         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.WillLoadCachedResources);
97         this._inspectedPageURL = mainFramePayload.frame.url;
98         this._addFramesRecursively(null, mainFramePayload);
99         this._dispatchInspectedURLChanged();
100         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded);
101         this._cachedResourcesProcessed = true;
102     },
103
104     /**
105      * @return {string}
106      */
107     inspectedPageURL: function()
108     {
109         return this._inspectedPageURL;
110     },
111
112     /**
113      * @return {string}
114      */
115     inspectedPageDomain: function()
116     {
117         var parsedURL = this._inspectedPageURL ? this._inspectedPageURL.asParsedURL() : null;
118         return parsedURL ? parsedURL.host : "";
119     },
120
121     /**
122      * @return {boolean}
123      */
124     cachedResourcesLoaded: function()
125     {
126         return this._cachedResourcesProcessed;
127     },
128
129     _dispatchInspectedURLChanged: function()
130     {
131         InspectorFrontendHost.inspectedURLChanged(this._inspectedPageURL);
132         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._inspectedPageURL);
133     },
134
135     /**
136      * @param {!WebInspector.ResourceTreeFrame} frame
137      * @param {boolean=} aboutToNavigate
138      */
139     _addFrame: function(frame, aboutToNavigate)
140     {
141         this._frames[frame.id] = frame;
142         if (frame.isMainFrame())
143             this.mainFrame = frame;
144         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameAdded, frame);
145         if (!aboutToNavigate)
146             this._addSecurityOrigin(frame.securityOrigin);
147     },
148
149     /**
150      * @param {string} securityOrigin
151      */
152     _addSecurityOrigin: function(securityOrigin)
153     {
154         if (!this._securityOriginFrameCount[securityOrigin]) {
155             this._securityOriginFrameCount[securityOrigin] = 1;
156             this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.SecurityOriginAdded, securityOrigin);
157             return;
158         }
159         this._securityOriginFrameCount[securityOrigin] += 1;
160     },
161
162     /**
163      * @param {string|undefined} securityOrigin
164      */
165     _removeSecurityOrigin: function(securityOrigin)
166     {
167         if (typeof securityOrigin === "undefined")
168             return;
169         if (this._securityOriginFrameCount[securityOrigin] === 1) {
170             delete this._securityOriginFrameCount[securityOrigin];
171             this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.SecurityOriginRemoved, securityOrigin);
172             return;
173         }
174         this._securityOriginFrameCount[securityOrigin] -= 1;
175     },
176
177     /**
178      * @return {!Array.<string>}
179      */
180     securityOrigins: function()
181     {
182         return Object.keys(this._securityOriginFrameCount);
183     },
184
185     /**
186      * @param {!WebInspector.ResourceTreeFrame} mainFrame
187      */
188     _handleMainFrameDetached: function(mainFrame)
189     {
190         /**
191          * @param {!WebInspector.ResourceTreeFrame} frame
192          * @this {WebInspector.ResourceTreeModel}
193          */
194         function removeOriginForFrame(frame)
195         {
196             for (var i = 0; i < frame.childFrames.length; ++i)
197                 removeOriginForFrame.call(this, frame.childFrames[i]);
198             if (!frame.isMainFrame())
199                 this._removeSecurityOrigin(frame.securityOrigin);
200         }
201         removeOriginForFrame.call(this, WebInspector.resourceTreeModel.mainFrame);
202     },
203
204     /**
205      * @param {!PageAgent.FrameId} frameId
206      * @param {?PageAgent.FrameId} parentFrameId
207      * @return {?WebInspector.ResourceTreeFrame}
208      */
209     _frameAttached: function(frameId, parentFrameId)
210     {
211         // Do nothing unless cached resource tree is processed - it will overwrite everything.
212         if (!this._cachedResourcesProcessed)
213             return null;
214         if (this._frames[frameId])
215             return null;
216
217         var parentFrame = parentFrameId ? this._frames[parentFrameId] : null;
218         var frame = new WebInspector.ResourceTreeFrame(this, parentFrame, frameId);
219         if (frame.isMainFrame() && this.mainFrame) {
220             this._handleMainFrameDetached(this.mainFrame);
221             // Navigation to the new backend process.
222             this._frameDetached(this.mainFrame.id);
223         }
224         this._addFrame(frame, true);
225         return frame;
226     },
227
228     /**
229      * @param {!PageAgent.Frame} framePayload
230      */
231     _frameNavigated: function(framePayload)
232     {
233         // Do nothing unless cached resource tree is processed - it will overwrite everything.
234         if (!this._cachedResourcesProcessed)
235             return;
236         var frame = this._frames[framePayload.id];
237         if (!frame) {
238             // Simulate missed "frameAttached" for a main frame navigation to the new backend process.
239             console.assert(!framePayload.parentId, "Main frame shouldn't have parent frame id.");
240             frame = this._frameAttached(framePayload.id, framePayload.parentId || "");
241             console.assert(frame);
242         }
243         this._removeSecurityOrigin(frame.securityOrigin);
244         frame._navigate(framePayload);
245         var addedOrigin = frame.securityOrigin;
246
247         if (frame.isMainFrame())
248             this._inspectedPageURL = frame.url;
249
250         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, frame);
251         if (frame.isMainFrame())
252             this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, frame);
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(this.target(), 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(this.target(), 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.SDKModel.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 {!WebInspector.Target}
519      */
520     target: function()
521     {
522         return this._model.target();
523     },
524
525     /**
526      * @return {string}
527      */
528     get id()
529     {
530         return this._id;
531     },
532
533     /**
534      * @return {string}
535      */
536     get name()
537     {
538         return this._name || "";
539     },
540
541     /**
542      * @return {string}
543      */
544     get url()
545     {
546         return this._url;
547     },
548
549     /**
550      * @return {string}
551      */
552     get securityOrigin()
553     {
554         return this._securityOrigin;
555     },
556
557     /**
558      * @return {string}
559      */
560     get loaderId()
561     {
562         return this._loaderId;
563     },
564
565     /**
566      * @return {?WebInspector.ResourceTreeFrame}
567      */
568     get parentFrame()
569     {
570         return this._parentFrame;
571     },
572
573     /**
574      * @return {!Array.<!WebInspector.ResourceTreeFrame>}
575      */
576     get childFrames()
577     {
578         return this._childFrames;
579     },
580
581     /**
582      * @return {boolean}
583      */
584     isMainFrame: function()
585     {
586         return !this._parentFrame;
587     },
588
589     /**
590      * @param {!PageAgent.Frame} framePayload
591      */
592     _navigate: function(framePayload)
593     {
594         this._loaderId = framePayload.loaderId;
595         this._name = framePayload.name;
596         this._url = framePayload.url;
597         this._securityOrigin = framePayload.securityOrigin;
598         this._mimeType = framePayload.mimeType;
599
600         var mainResource = this._resourcesMap[this._url];
601         this._resourcesMap = {};
602         this._removeChildFrames();
603         if (mainResource && mainResource.loaderId === this._loaderId)
604             this.addResource(mainResource);
605     },
606
607     /**
608      * @return {!WebInspector.Resource}
609      */
610     get mainResource()
611     {
612         return this._resourcesMap[this._url];
613     },
614
615     /**
616      * @param {!WebInspector.ResourceTreeFrame} frame
617      */
618     _removeChildFrame: function(frame)
619     {
620         this._childFrames.remove(frame);
621         frame._remove();
622     },
623
624     _removeChildFrames: function()
625     {
626         var frames = this._childFrames;
627         this._childFrames = [];
628         for (var i = 0; i < frames.length; ++i)
629             frames[i]._remove();
630     },
631
632     _remove: function()
633     {
634         this._removeChildFrames();
635         delete this._model._frames[this.id];
636         this._model.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, this);
637     },
638
639     /**
640      * @param {!WebInspector.Resource} resource
641      */
642     addResource: function(resource)
643     {
644         if (this._resourcesMap[resource.url] === resource) {
645             // Already in the tree, we just got an extra update.
646             return;
647         }
648         this._resourcesMap[resource.url] = resource;
649         this._model.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, resource);
650     },
651
652     /**
653      * @param {!WebInspector.NetworkRequest} request
654      * @return {!WebInspector.Resource}
655      */
656     _addRequest: function(request)
657     {
658         var resource = this._resourcesMap[request.url];
659         if (resource && resource.request === request) {
660             // Already in the tree, we just got an extra update.
661             return resource;
662         }
663         resource = new WebInspector.Resource(this.target(), request, request.url, request.documentURL, request.frameId, request.loaderId, request.type, request.mimeType);
664         this._resourcesMap[resource.url] = resource;
665         this._model.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, resource);
666         return resource;
667     },
668
669     /**
670      * @return {!Array.<!WebInspector.Resource>}
671      */
672     resources: function()
673     {
674         var result = [];
675         for (var url in this._resourcesMap)
676             result.push(this._resourcesMap[url]);
677         return result;
678     },
679
680     /**
681      * @param {string} url
682      * @return {?WebInspector.Resource}
683      */
684     resourceForURL: function(url)
685     {
686         var result;
687         function filter(resource)
688         {
689             if (resource.url === url) {
690                 result = resource;
691                 return true;
692             }
693         }
694         this._callForFrameResources(filter);
695         return result || null;
696     },
697
698     /**
699      * @param {function(!WebInspector.Resource)} callback
700      * @return {boolean}
701      */
702     _callForFrameResources: function(callback)
703     {
704         for (var url in this._resourcesMap) {
705             if (callback(this._resourcesMap[url]))
706                 return true;
707         }
708
709         for (var i = 0; i < this._childFrames.length; ++i) {
710             if (this._childFrames[i]._callForFrameResources(callback))
711                 return true;
712         }
713         return false;
714     },
715
716     /**
717      * @return {string}
718      */
719     displayName: function()
720     {
721         if (!this._parentFrame)
722             return WebInspector.UIString("<top frame>");
723         var subtitle = new WebInspector.ParsedURL(this._url).displayName;
724         if (subtitle) {
725             if (!this._name)
726                 return subtitle;
727             return this._name + "( " + subtitle + " )";
728         }
729         return WebInspector.UIString("<iframe>");
730     }
731 }
732
733 /**
734  * @constructor
735  * @implements {PageAgent.Dispatcher}
736  */
737 WebInspector.PageDispatcher = function(resourceTreeModel)
738 {
739     this._resourceTreeModel = resourceTreeModel;
740 }
741
742 WebInspector.PageDispatcher.prototype = {
743     domContentEventFired: function(time)
744     {
745         this._resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.DOMContentLoaded, time);
746     },
747
748     loadEventFired: function(time)
749     {
750         this._resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.Load, time);
751     },
752
753     frameAttached: function(frameId, parentFrameId)
754     {
755         this._resourceTreeModel._frameAttached(frameId, parentFrameId);
756     },
757
758     frameNavigated: function(frame)
759     {
760         this._resourceTreeModel._frameNavigated(frame);
761     },
762
763     frameDetached: function(frameId)
764     {
765         this._resourceTreeModel._frameDetached(frameId);
766     },
767
768     frameStartedLoading: function(frameId)
769     {
770     },
771
772     frameStoppedLoading: function(frameId)
773     {
774     },
775
776     frameScheduledNavigation: function(frameId, delay)
777     {
778     },
779
780     frameClearedScheduledNavigation: function(frameId)
781     {
782     },
783
784     frameResized: function()
785     {
786         this._resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameResized, null);
787     },
788
789     javascriptDialogOpening: function(message)
790     {
791     },
792
793     javascriptDialogClosed: function()
794     {
795     },
796
797     scriptsEnabled: function(isEnabled)
798     {
799         WebInspector.settings.javaScriptDisabled.set(!isEnabled);
800     },
801
802     /**
803      * @param {string} data
804      * @param {!PageAgent.ScreencastFrameMetadata=} metadata
805      */
806     screencastFrame: function(data, metadata)
807     {
808         this._resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ScreencastFrame, {data:data, metadata:metadata});
809     },
810
811     /**
812      * @param {boolean} visible
813      */
814     screencastVisibilityChanged: function(visible)
815     {
816         this._resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ScreencastVisibilityChanged, {visible:visible});
817     },
818
819     /**
820      * @param {!PageAgent.Viewport=} viewport
821      */
822     viewportChanged: function(viewport)
823     {
824         this._resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ViewportChanged, viewport);
825     }
826 }
827
828 /**
829  * @type {!WebInspector.ResourceTreeModel}
830  */
831 WebInspector.resourceTreeModel;