Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js

Issue 2851913002: [DevTools] Do not expose agents on Target
Patch Set: storage and tests.js Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 SDK.ResourceTreeModel = class extends SDK.SDKModel { 34 SDK.ResourceTreeModel = class extends SDK.SDKModel {
35 /** 35 /**
36 * @param {!SDK.Target} target 36 * @param {!SDK.Target} target
37 * @param {!Protocol.Dispatcher} dispatcher
37 */ 38 */
38 constructor(target) { 39 constructor(target, dispatcher) {
39 super(target); 40 super(target, dispatcher);
40 41
41 var networkManager = target.model(SDK.NetworkManager); 42 var networkManager = target.model(SDK.NetworkManager);
42 if (networkManager) { 43 if (networkManager) {
43 networkManager.addEventListener(SDK.NetworkManager.Events.RequestFinished, this._onRequestFinished, this); 44 networkManager.addEventListener(SDK.NetworkManager.Events.RequestFinished, this._onRequestFinished, this);
44 networkManager.addEventListener( 45 networkManager.addEventListener(
45 SDK.NetworkManager.Events.RequestUpdateDropped, this._onRequestUpdateD ropped, this); 46 SDK.NetworkManager.Events.RequestUpdateDropped, this._onRequestUpdateD ropped, this);
46 } 47 }
47 48
48 this._agent = target.pageAgent(); 49 this._agent = dispatcher.pageAgent();
49 this._agent.enable(); 50 this._agent.enable();
50 this._securityOriginManager = target.model(SDK.SecurityOriginManager); 51 this._securityOriginManager = target.model(SDK.SecurityOriginManager);
51 52
52 this._fetchResourceTree(); 53 this._fetchResourceTree();
53 54
54 target.registerPageDispatcher(new SDK.PageDispatcher(this)); 55 dispatcher.registerPageDispatcher(new SDK.PageDispatcher(this));
55 56
56 this._pendingReloadOptions = null; 57 this._pendingReloadOptions = null;
57 this._reloadSuspensionCount = 0; 58 this._reloadSuspensionCount = 0;
58 this._isInterstitialShowing = false; 59 this._isInterstitialShowing = false;
60
61 var autoAttachSetting = Common.settings.moduleSetting('autoAttachToCreatedPa ges');
62 autoAttachSetting.addChangeListener(() => this._agent.setAutoAttachToCreated Pages(autoAttachSetting.get()));
63 if (autoAttachSetting.get())
64 this._agent.setAutoAttachToCreatedPages(true);
59 } 65 }
60 66
61 /** 67 /**
62 * @return {!Array.<!SDK.ResourceTreeFrame>} 68 * @return {!Array.<!SDK.ResourceTreeFrame>}
63 */ 69 */
64 static frames() { 70 static frames() {
65 var result = []; 71 var result = [];
66 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel )) 72 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel ))
67 result = result.concat(resourceTreeModel._frames.valuesArray()); 73 result = result.concat(resourceTreeModel._frames.valuesArray());
68 return result; 74 return result;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 var frameId = event.data.frameId; 267 var frameId = event.data.frameId;
262 var frame = this._frames.get(frameId); 268 var frame = this._frames.get(frameId);
263 if (!frame) 269 if (!frame)
264 return; 270 return;
265 271
266 var url = event.data.url; 272 var url = event.data.url;
267 if (frame._resourcesMap[url]) 273 if (frame._resourcesMap[url])
268 return; 274 return;
269 275
270 var resource = new SDK.Resource( 276 var resource = new SDK.Resource(
271 this, null, url, frame.url, frameId, event.data.loaderId, Common.resourc eTypes[event.data.resourceType], 277 this, this._agent, null, url, frame.url, frameId, event.data.loaderId,
272 event.data.mimeType, event.data.lastModified, null); 278 Common.resourceTypes[event.data.resourceType], event.data.mimeType, even t.data.lastModified, null);
273 frame.addResource(resource); 279 frame.addResource(resource);
274 } 280 }
275 281
276 /** 282 /**
277 * @param {!Protocol.Page.FrameId} frameId 283 * @param {!Protocol.Page.FrameId} frameId
278 * @return {!SDK.ResourceTreeFrame} 284 * @return {!SDK.ResourceTreeFrame}
279 */ 285 */
280 frameForId(frameId) { 286 frameForId(frameId) {
281 return this._frames.get(frameId); 287 return this._frames.get(frameId);
282 } 288 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 * @param {string} url 343 * @param {string} url
338 * @param {!Common.ResourceType} type 344 * @param {!Common.ResourceType} type
339 * @param {string} mimeType 345 * @param {string} mimeType
340 * @param {?number} lastModifiedTime 346 * @param {?number} lastModifiedTime
341 * @param {?number} contentSize 347 * @param {?number} contentSize
342 * @return {!SDK.Resource} 348 * @return {!SDK.Resource}
343 */ 349 */
344 _createResourceFromFramePayload(frame, url, type, mimeType, lastModifiedTime, contentSize) { 350 _createResourceFromFramePayload(frame, url, type, mimeType, lastModifiedTime, contentSize) {
345 var lastModified = typeof lastModifiedTime === 'number' ? new Date(lastModif iedTime * 1000) : null; 351 var lastModified = typeof lastModifiedTime === 'number' ? new Date(lastModif iedTime * 1000) : null;
346 return new SDK.Resource( 352 return new SDK.Resource(
347 this, null, url, frame.url, frame.id, frame.loaderId, type, mimeType, la stModified, contentSize); 353 this, this._agent, null, url, frame.url, frame.id, frame.loaderId, type, mimeType, lastModified, contentSize);
348 } 354 }
349 355
350 suspendReload() { 356 suspendReload() {
351 this._reloadSuspensionCount++; 357 this._reloadSuspensionCount++;
352 } 358 }
353 359
354 resumeReload() { 360 resumeReload() {
355 this._reloadSuspensionCount--; 361 this._reloadSuspensionCount--;
356 console.assert(this._reloadSuspensionCount >= 0, 'Unbalanced call to Resourc eTreeModel.resumeReload()'); 362 console.assert(this._reloadSuspensionCount >= 0, 'Unbalanced call to Resourc eTreeModel.resumeReload()');
357 if (!this._reloadSuspensionCount && this._pendingReloadOptions) 363 if (!this._reloadSuspensionCount && this._pendingReloadOptions)
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 var origin = frame.securityOrigin; 477 var origin = frame.securityOrigin;
472 if (!origin) 478 if (!origin)
473 continue; 479 continue;
474 securityOrigins.add(origin); 480 securityOrigins.add(origin);
475 if (frame.isMainFrame()) 481 if (frame.isMainFrame())
476 mainSecurityOrigin = origin; 482 mainSecurityOrigin = origin;
477 } 483 }
478 this._securityOriginManager.updateSecurityOrigins(securityOrigins); 484 this._securityOriginManager.updateSecurityOrigins(securityOrigins);
479 this._securityOriginManager.setMainSecurityOrigin(mainSecurityOrigin || ''); 485 this._securityOriginManager.setMainSecurityOrigin(mainSecurityOrigin || '');
480 } 486 }
487
488 requestAppBanner() {
489 this._agent.requestAppBanner();
490 }
481 }; 491 };
482 492
483 SDK.SDKModel.register(SDK.ResourceTreeModel, SDK.Target.Capability.DOM, true); 493 SDK.SDKModel.register(SDK.ResourceTreeModel, SDK.Target.Capability.DOM, true);
484 494
485 /** @enum {symbol} */ 495 /** @enum {symbol} */
486 SDK.ResourceTreeModel.Events = { 496 SDK.ResourceTreeModel.Events = {
487 FrameAdded: Symbol('FrameAdded'), 497 FrameAdded: Symbol('FrameAdded'),
488 FrameNavigated: Symbol('FrameNavigated'), 498 FrameNavigated: Symbol('FrameNavigated'),
489 FrameDetached: Symbol('FrameDetached'), 499 FrameDetached: Symbol('FrameDetached'),
490 FrameResized: Symbol('FrameResized'), 500 FrameResized: Symbol('FrameResized'),
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 /** 684 /**
675 * @param {!SDK.NetworkRequest} request 685 * @param {!SDK.NetworkRequest} request
676 */ 686 */
677 _addRequest(request) { 687 _addRequest(request) {
678 var resource = this._resourcesMap[request.url()]; 688 var resource = this._resourcesMap[request.url()];
679 if (resource && resource.request === request) { 689 if (resource && resource.request === request) {
680 // Already in the tree, we just got an extra update. 690 // Already in the tree, we just got an extra update.
681 return; 691 return;
682 } 692 }
683 resource = new SDK.Resource( 693 resource = new SDK.Resource(
684 this._model, request, request.url(), request.documentURL, request.frameI d, request.loaderId, 694 this._model, this._model._agent, request, request.url(), request.documen tURL, request.frameId, request.loaderId,
685 request.resourceType(), request.mimeType, null, null); 695 request.resourceType(), request.mimeType, null, null);
686 this._resourcesMap[resource.url] = resource; 696 this._resourcesMap[resource.url] = resource;
687 this._model.dispatchEventToListeners(SDK.ResourceTreeModel.Events.ResourceAd ded, resource); 697 this._model.dispatchEventToListeners(SDK.ResourceTreeModel.Events.ResourceAd ded, resource);
688 } 698 }
689 699
690 /** 700 /**
691 * @return {!Array.<!SDK.Resource>} 701 * @return {!Array.<!SDK.Resource>}
692 */ 702 */
693 resources() { 703 resources() {
694 var result = []; 704 var result = [];
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Event s.InterstitialHidden); 893 this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Event s.InterstitialHidden);
884 } 894 }
885 895
886 /** 896 /**
887 * @override 897 * @override
888 */ 898 */
889 navigationRequested() { 899 navigationRequested() {
890 // Frontend is not interested in when navigations are requested. 900 // Frontend is not interested in when navigations are requested.
891 } 901 }
892 }; 902 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698