Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 target[Bindings.NetworkProject._networkProjectSymbol] = this; | 76 target[Bindings.NetworkProject._networkProjectSymbol] = this; |
| 77 | 77 |
| 78 this._eventListeners = []; | 78 this._eventListeners = []; |
| 79 | 79 |
| 80 if (resourceTreeModel) { | 80 if (resourceTreeModel) { |
| 81 this._eventListeners.push( | 81 this._eventListeners.push( |
| 82 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.Resour ceAdded, this._resourceAdded, this), | 82 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.Resour ceAdded, this._resourceAdded, this), |
| 83 resourceTreeModel.addEventListener( | 83 resourceTreeModel.addEventListener( |
| 84 SDK.ResourceTreeModel.Events.FrameWillNavigate, this._frameWillNav igate, this), | 84 SDK.ResourceTreeModel.Events.FrameWillNavigate, this._frameWillNav igate, this), |
| 85 resourceTreeModel.addEventListener( | 85 resourceTreeModel.addEventListener( |
| 86 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._mainFrameNa vigated, this)); | 86 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._mainFrameNa vigated, this), |
| 87 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.FrameD etached, this._frameDetached, this)); | |
| 87 } | 88 } |
| 88 | 89 |
| 89 var debuggerModel = SDK.DebuggerModel.fromTarget(target); | 90 var debuggerModel = SDK.DebuggerModel.fromTarget(target); |
| 90 if (debuggerModel) { | 91 if (debuggerModel) { |
| 91 this._eventListeners.push( | 92 this._eventListeners.push( |
| 92 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSo urce, this._parsedScriptSource, this), | 93 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSo urce, this._parsedScriptSource, this), |
| 93 debuggerModel.addEventListener( | 94 debuggerModel.addEventListener( |
| 94 SDK.DebuggerModel.Events.FailedToParseScriptSource, this._parsedSc riptSource, this)); | 95 SDK.DebuggerModel.Events.FailedToParseScriptSource, this._parsedSc riptSource, this)); |
| 95 } | 96 } |
| 96 var cssModel = target.model(SDK.CSSModel); | 97 var cssModel = target.model(SDK.CSSModel); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 | 307 |
| 307 // Ignore non-images and non-fonts. | 308 // Ignore non-images and non-fonts. |
| 308 if (resourceType === Common.resourceTypes.Image && resource.mimeType && !res ource.mimeType.startsWith('image')) | 309 if (resourceType === Common.resourceTypes.Image && resource.mimeType && !res ource.mimeType.startsWith('image')) |
| 309 return; | 310 return; |
| 310 if (resourceType === Common.resourceTypes.Font && resource.mimeType && !reso urce.mimeType.includes('font')) | 311 if (resourceType === Common.resourceTypes.Font && resource.mimeType && !reso urce.mimeType.includes('font')) |
| 311 return; | 312 return; |
| 312 if ((resourceType === Common.resourceTypes.Image || resourceType === Common. resourceTypes.Font) && | 313 if ((resourceType === Common.resourceTypes.Image || resourceType === Common. resourceTypes.Font) && |
| 313 resource.contentURL().startsWith('data:')) | 314 resource.contentURL().startsWith('data:')) |
| 314 return; | 315 return; |
| 315 | 316 |
| 317 var frame = SDK.ResourceTreeFrame.fromResource(resource); | |
| 316 // Never load document twice. | 318 // Never load document twice. |
| 317 if (this._workspace.uiSourceCodeForURL(resource.url)) | 319 var projectId = Bindings.NetworkProject.projectId(this.target(), frame, fals e); |
| 320 var project = this._workspaceProjects.get(projectId); | |
| 321 if (project && project.uiSourceCodeForURL(resource.url)) | |
| 318 return; | 322 return; |
| 319 | 323 |
| 320 var uiSourceCode = this._createFile(resource, SDK.ResourceTreeFrame.fromReso urce(resource), false); | 324 var uiSourceCode = this._createFile(resource, frame, false); |
| 321 uiSourceCode[Bindings.NetworkProject._resourceSymbol] = resource; | 325 uiSourceCode[Bindings.NetworkProject._resourceSymbol] = resource; |
| 322 this._addUISourceCodeWithProvider(uiSourceCode, resource, this._resourceMeta data(resource)); | 326 this._addUISourceCodeWithProvider(uiSourceCode, resource, this._resourceMeta data(resource)); |
| 323 } | 327 } |
| 324 | 328 |
| 325 /** | 329 /** |
| 326 * @param {!Common.Event} event | 330 * @param {!SDK.ResourceTreeFrame} frame |
| 327 */ | 331 */ |
| 328 _frameWillNavigate(event) { | 332 _removeFrameResources(frame) { |
| 329 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data); | |
| 330 var project = this._workspaceProject(frame, false); | 333 var project = this._workspaceProject(frame, false); |
| 331 for (var resource of frame.resources()) | 334 for (var resource of frame.resources()) |
| 332 project.removeUISourceCode(resource.url); | 335 project.removeUISourceCode(resource.url); |
| 333 project = this._workspaceProject(frame, true); | 336 project = this._workspaceProject(frame, true); |
| 334 for (var resource of frame.resources()) | 337 for (var resource of frame.resources()) |
| 335 project.removeUISourceCode(resource.url); | 338 project.removeUISourceCode(resource.url); |
| 336 } | 339 } |
| 337 | 340 |
| 338 /** | 341 /** |
| 339 * @param {!Common.Event} event | 342 * @param {!Common.Event} event |
| 340 */ | 343 */ |
| 344 _frameWillNavigate(event) { | |
| 345 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data); | |
| 346 this._removeFrameResources(frame); | |
| 347 } | |
| 348 | |
| 349 /** | |
| 350 * @param {!Common.Event} event | |
| 351 */ | |
| 352 _frameDetached(event) { | |
| 353 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data); | |
| 354 this._removeFrameResources(frame); | |
| 355 } | |
| 356 | |
| 357 /** | |
| 358 * @param {!Common.Event} event | |
| 359 */ | |
| 341 _mainFrameNavigated(event) { | 360 _mainFrameNavigated(event) { |
| 342 this._reset(); | 361 this._reset(); |
|
lushnikov
2017/03/07 19:36:45
the "reset" is still needed since this is where we
| |
| 343 this._populate(); | |
| 344 } | 362 } |
| 345 | 363 |
| 346 _suspendStateChanged() { | 364 _suspendStateChanged() { |
| 347 if (this.target().targetManager().allTargetsSuspended()) | 365 if (this.target().targetManager().allTargetsSuspended()) |
| 348 this._reset(); | 366 this._reset(); |
| 349 else | 367 else |
| 350 this._populate(); | 368 this._populate(); |
| 351 } | 369 } |
| 352 | 370 |
| 353 /** | 371 /** |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 return workspace.uiSourceCode(Bindings.NetworkProject.projectId(header.targe t(), frame, false), url); | 428 return workspace.uiSourceCode(Bindings.NetworkProject.projectId(header.targe t(), frame, false), url); |
| 411 } | 429 } |
| 412 }; | 430 }; |
| 413 | 431 |
| 414 Bindings.NetworkProject._networkProjectSymbol = Symbol('networkProject'); | 432 Bindings.NetworkProject._networkProjectSymbol = Symbol('networkProject'); |
| 415 Bindings.NetworkProject._resourceSymbol = Symbol('resource'); | 433 Bindings.NetworkProject._resourceSymbol = Symbol('resource'); |
| 416 Bindings.NetworkProject._scriptSymbol = Symbol('script'); | 434 Bindings.NetworkProject._scriptSymbol = Symbol('script'); |
| 417 Bindings.NetworkProject._styleSheetSymbol = Symbol('styleSheet'); | 435 Bindings.NetworkProject._styleSheetSymbol = Symbol('styleSheet'); |
| 418 Bindings.NetworkProject._targetSymbol = Symbol('target'); | 436 Bindings.NetworkProject._targetSymbol = Symbol('target'); |
| 419 Bindings.NetworkProject._frameSymbol = Symbol('frame'); | 437 Bindings.NetworkProject._frameSymbol = Symbol('frame'); |
| OLD | NEW |