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

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

Issue 2186753002: [DevTools] Track URL through the target (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 47
48 this._agent = target.pageAgent(); 48 this._agent = target.pageAgent();
49 this._agent.enable(); 49 this._agent.enable();
50 this._securityOriginManager = securityOriginManager; 50 this._securityOriginManager = securityOriginManager;
51 51
52 this._fetchResourceTree(); 52 this._fetchResourceTree();
53 53
54 target.registerPageDispatcher(new WebInspector.PageDispatcher(this)); 54 target.registerPageDispatcher(new WebInspector.PageDispatcher(this));
55 55
56 this._inspectedPageURL = "";
57 this._pendingReloadOptions = null; 56 this._pendingReloadOptions = null;
58 this._reloadSuspensionCount = 0; 57 this._reloadSuspensionCount = 0;
59 58
60 target.runtimeModel.setExecutionContextComparator(this._executionContextComp arator.bind(this)); 59 target.runtimeModel.setExecutionContextComparator(this._executionContextComp arator.bind(this));
61 } 60 }
62 61
63 WebInspector.ResourceTreeModel.EventTypes = { 62 WebInspector.ResourceTreeModel.EventTypes = {
64 FrameAdded: "FrameAdded", 63 FrameAdded: "FrameAdded",
65 FrameNavigated: "FrameNavigated", 64 FrameNavigated: "FrameNavigated",
66 FrameDetached: "FrameDetached", 65 FrameDetached: "FrameDetached",
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 /** @type {!Map<string, !WebInspector.ResourceTreeFrame>} */ 120 /** @type {!Map<string, !WebInspector.ResourceTreeFrame>} */
122 this._frames = new Map(); 121 this._frames = new Map();
123 this._cachedResourcesProcessed = false; 122 this._cachedResourcesProcessed = false;
124 this._agent.getResourceTree(this._processCachedResources.bind(this)); 123 this._agent.getResourceTree(this._processCachedResources.bind(this));
125 }, 124 },
126 125
127 _processCachedResources: function(error, mainFramePayload) 126 _processCachedResources: function(error, mainFramePayload)
128 { 127 {
129 if (!error) { 128 if (!error) {
130 this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTy pes.WillLoadCachedResources); 129 this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTy pes.WillLoadCachedResources);
131 this._inspectedPageURL = mainFramePayload.frame.url;
132 this._addFramesRecursively(null, mainFramePayload); 130 this._addFramesRecursively(null, mainFramePayload);
133 this._dispatchInspectedURLChanged(); 131 this.target().setInspectedURL(mainFramePayload.frame.url);
134 } 132 }
135 this._cachedResourcesProcessed = true; 133 this._cachedResourcesProcessed = true;
136 this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes. CachedResourcesLoaded); 134 this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes. CachedResourcesLoaded);
137 }, 135 },
138 136
139 /** 137 /**
140 * @return {string}
141 */
142 inspectedPageURL: function()
143 {
144 return this._inspectedPageURL;
145 },
146
147 /**
148 * @return {string}
149 */
150 inspectedPageDomain: function()
151 {
152 var parsedURL = this._inspectedPageURL ? this._inspectedPageURL.asParsed URL() : null;
153 return parsedURL ? parsedURL.host : "";
154 },
155
156 /**
157 * @return {boolean} 138 * @return {boolean}
158 */ 139 */
159 cachedResourcesLoaded: function() 140 cachedResourcesLoaded: function()
160 { 141 {
161 return this._cachedResourcesProcessed; 142 return this._cachedResourcesProcessed;
162 }, 143 },
163 144
164 _dispatchInspectedURLChanged: function()
165 {
166 InspectorFrontendHost.inspectedURLChanged(this._inspectedPageURL);
167 this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes. InspectedURLChanged, this._inspectedPageURL);
168 },
169
170 /** 145 /**
171 * @param {!WebInspector.ResourceTreeFrame} frame 146 * @param {!WebInspector.ResourceTreeFrame} frame
172 * @param {boolean=} aboutToNavigate 147 * @param {boolean=} aboutToNavigate
173 */ 148 */
174 _addFrame: function(frame, aboutToNavigate) 149 _addFrame: function(frame, aboutToNavigate)
175 { 150 {
176 this._frames.set(frame.id, frame); 151 this._frames.set(frame.id, frame);
177 if (frame.isMainFrame()) { 152 if (frame.isMainFrame()) {
178 this.mainFrame = frame; 153 this.mainFrame = frame;
179 this._securityOriginManager.setMainSecurityOrigin(frame.url); 154 this._securityOriginManager.setMainSecurityOrigin(frame.url);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 console.assert(frame); 217 console.assert(frame);
243 } 218 }
244 219
245 this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes. FrameWillNavigate, frame); 220 this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes. FrameWillNavigate, frame);
246 221
247 this._securityOriginManager.removeSecurityOrigin(frame.securityOrigin); 222 this._securityOriginManager.removeSecurityOrigin(frame.securityOrigin);
248 frame._navigate(framePayload); 223 frame._navigate(framePayload);
249 var addedOrigin = frame.securityOrigin; 224 var addedOrigin = frame.securityOrigin;
250 225
251 if (frame.isMainFrame()) 226 if (frame.isMainFrame())
252 this._inspectedPageURL = frame.url; 227 this.target().setInspectedURL(frame.url);
dgozman 2016/07/27 17:26:06 Let's do this at the end of the method, so that ev
eostroukhov-old 2016/07/27 17:46:58 Done.
253 228
254 this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes. FrameNavigated, frame); 229 this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes. FrameNavigated, frame);
255 if (frame.isMainFrame()) { 230 if (frame.isMainFrame()) {
256 this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTy pes.MainFrameNavigated, frame); 231 this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTy pes.MainFrameNavigated, frame);
257 if (WebInspector.moduleSetting("preserveConsoleLog").get()) 232 if (WebInspector.moduleSetting("preserveConsoleLog").get())
258 WebInspector.console.log(WebInspector.UIString("Navigated to %s" , frame.url)); 233 WebInspector.console.log(WebInspector.UIString("Navigated to %s" , frame.url));
259 else 234 else
260 this.target().consoleModel.clear(); 235 this.target().consoleModel.clear();
261 } 236 }
262 if (addedOrigin) 237 if (addedOrigin)
263 this._securityOriginManager.addSecurityOrigin(addedOrigin); 238 this._securityOriginManager.addSecurityOrigin(addedOrigin);
264 239
265 // Fill frame with retained resources (the ones loaded using new loader) . 240 // Fill frame with retained resources (the ones loaded using new loader) .
266 var resources = frame.resources(); 241 var resources = frame.resources();
267 for (var i = 0; i < resources.length; ++i) 242 for (var i = 0; i < resources.length; ++i)
268 this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTy pes.ResourceAdded, resources[i]); 243 this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTy pes.ResourceAdded, resources[i]);
269
270 if (frame.isMainFrame())
271 this._dispatchInspectedURLChanged();
272 }, 244 },
273 245
274 /** 246 /**
275 * @param {!PageAgent.FrameId} frameId 247 * @param {!PageAgent.FrameId} frameId
276 */ 248 */
277 _frameDetached: function(frameId) 249 _frameDetached: function(frameId)
278 { 250 {
279 // Do nothing unless cached resource tree is processed - it will overwri te everything. 251 // Do nothing unless cached resource tree is processed - it will overwri te everything.
280 if (!this._cachedResourcesProcessed) 252 if (!this._cachedResourcesProcessed)
281 return; 253 return;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 * @param {?WebInspector.ResourceTreeFrame} parentFrame 343 * @param {?WebInspector.ResourceTreeFrame} parentFrame
372 * @param {!PageAgent.FrameResourceTree} frameTreePayload 344 * @param {!PageAgent.FrameResourceTree} frameTreePayload
373 */ 345 */
374 _addFramesRecursively: function(parentFrame, frameTreePayload) 346 _addFramesRecursively: function(parentFrame, frameTreePayload)
375 { 347 {
376 var framePayload = frameTreePayload.frame; 348 var framePayload = frameTreePayload.frame;
377 var frame = new WebInspector.ResourceTreeFrame(this, parentFrame, frameP ayload.id, framePayload); 349 var frame = new WebInspector.ResourceTreeFrame(this, parentFrame, frameP ayload.id, framePayload);
378 this._addFrame(frame); 350 this._addFrame(frame);
379 351
380 var frameResource = this._createResourceFromFramePayload(framePayload, f ramePayload.url, WebInspector.resourceTypes.Document, framePayload.mimeType); 352 var frameResource = this._createResourceFromFramePayload(framePayload, f ramePayload.url, WebInspector.resourceTypes.Document, framePayload.mimeType);
381 if (frame.isMainFrame())
382 this._inspectedPageURL = frameResource.url;
dgozman 2016/07/27 17:26:06 Where did this go?
eostroukhov-old 2016/07/27 17:46:58 This is ultimately only called from _processCached
383 frame.addResource(frameResource); 353 frame.addResource(frameResource);
384 354
385 for (var i = 0; frameTreePayload.childFrames && i < frameTreePayload.chi ldFrames.length; ++i) 355 for (var i = 0; frameTreePayload.childFrames && i < frameTreePayload.chi ldFrames.length; ++i)
386 this._addFramesRecursively(frame, frameTreePayload.childFrames[i]); 356 this._addFramesRecursively(frame, frameTreePayload.childFrames[i]);
387 357
388 for (var i = 0; i < frameTreePayload.resources.length; ++i) { 358 for (var i = 0; i < frameTreePayload.resources.length; ++i) {
389 var subresource = frameTreePayload.resources[i]; 359 var subresource = frameTreePayload.resources[i];
390 var resource = this._createResourceFromFramePayload(framePayload, su bresource.url, WebInspector.resourceTypes[subresource.type], subresource.mimeTyp e); 360 var resource = this._createResourceFromFramePayload(framePayload, su bresource.url, WebInspector.resourceTypes[subresource.type], subresource.mimeTyp e);
391 frame.addResource(resource); 361 frame.addResource(resource);
392 } 362 }
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 931
962 /** 932 /**
963 * @override 933 * @override
964 */ 934 */
965 navigationRequested: function() 935 navigationRequested: function()
966 { 936 {
967 // Frontend is not interested in interstitials. 937 // Frontend is not interested in interstitials.
968 } 938 }
969 939
970 } 940 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698