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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 * @param {!WebInspector.Target} target | 147 * @param {!WebInspector.Target} target |
| 148 * @param {!WebInspector.Workspace} workspace | 148 * @param {!WebInspector.Workspace} workspace |
| 149 * @param {!WebInspector.NetworkMapping} networkMapping | 149 * @param {!WebInspector.NetworkMapping} networkMapping |
| 150 */ | 150 */ |
| 151 WebInspector.NetworkProject = function(target, workspace, networkMapping) | 151 WebInspector.NetworkProject = function(target, workspace, networkMapping) |
| 152 { | 152 { |
| 153 WebInspector.SDKObject.call(this, target); | 153 WebInspector.SDKObject.call(this, target); |
| 154 this._workspace = workspace; | 154 this._workspace = workspace; |
| 155 this._networkMapping = networkMapping; | 155 this._networkMapping = networkMapping; |
| 156 this._projectDelegates = {}; | 156 this._projectDelegates = {}; |
| 157 this._processedURLs = {}; | |
| 158 target[WebInspector.NetworkProject._networkProjectSymbol] = this; | 157 target[WebInspector.NetworkProject._networkProjectSymbol] = this; |
| 159 | 158 |
| 160 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.ResourceAdded, this._resourceAdded, this); | 159 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.ResourceAdded, this._resourceAdded, this); |
| 161 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.MainFrameNavigated, this._mainFrameNavigated, this); | 160 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.MainFrameNavigated, this._mainFrameNavigated, this); |
| 162 | 161 |
| 163 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | 162 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); |
| 164 if (debuggerModel) { | 163 if (debuggerModel) { |
| 165 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedS criptSource, this._parsedScriptSource, this); | 164 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedS criptSource, this._parsedScriptSource, this); |
| 166 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedT oParseScriptSource, this._parsedScriptSource, this); | 165 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedT oParseScriptSource, this._parsedScriptSource, this); |
| 167 } | 166 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 var projectDelegate = this._projectDelegate(projectURL, isContentScript || false); | 259 var projectDelegate = this._projectDelegate(projectURL, isContentScript || false); |
| 261 var path = projectDelegate.addFile(parentPath, name, url, contentProvide r); | 260 var path = projectDelegate.addFile(parentPath, name, url, contentProvide r); |
| 262 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (this._work space.uiSourceCode(projectDelegate.id(), path)); | 261 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (this._work space.uiSourceCode(projectDelegate.id(), path)); |
| 263 console.assert(uiSourceCode); | 262 console.assert(uiSourceCode); |
| 264 return uiSourceCode; | 263 return uiSourceCode; |
| 265 }, | 264 }, |
| 266 | 265 |
| 267 /** | 266 /** |
| 268 * @param {string} url | 267 * @param {string} url |
| 269 */ | 268 */ |
| 270 removeFileForURL: function(url) | 269 _removeFileForURL: function(url) |
| 271 { | 270 { |
| 272 delete this._processedURLs[url]; | |
| 273 var splitURL = WebInspector.ParsedURL.splitURLIntoPathComponents(url); | 271 var splitURL = WebInspector.ParsedURL.splitURLIntoPathComponents(url); |
| 274 var projectURL = splitURL[0]; | 272 var projectURL = splitURL[0]; |
| 275 var path = splitURL.slice(1).join("/"); | 273 var path = splitURL.slice(1).join("/"); |
| 276 var projectDelegate = this._projectDelegates[WebInspector.NetworkProject .projectId(this.target(), projectURL, false)]; | 274 var projectDelegate = this._projectDelegates[WebInspector.NetworkProject .projectId(this.target(), projectURL, false)]; |
| 275 if (!projectDelegate) | |
|
dgozman
2015/11/10 21:01:25
How come you now need this check?
| |
| 276 return; | |
| 277 projectDelegate.removeFile(path); | 277 projectDelegate.removeFile(path); |
| 278 }, | 278 }, |
| 279 | 279 |
| 280 _populate: function() | 280 _populate: function() |
| 281 { | 281 { |
| 282 /** | 282 /** |
| 283 * @param {!WebInspector.ResourceTreeFrame} frame | 283 * @param {!WebInspector.ResourceTreeFrame} frame |
| 284 * @this {WebInspector.NetworkProject} | 284 * @this {WebInspector.NetworkProject} |
| 285 */ | 285 */ |
| 286 function populateFrame(frame) | 286 function populateFrame(frame) |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 297 if (mainFrame) | 297 if (mainFrame) |
| 298 populateFrame.call(this, mainFrame); | 298 populateFrame.call(this, mainFrame); |
| 299 }, | 299 }, |
| 300 | 300 |
| 301 /** | 301 /** |
| 302 * @param {!WebInspector.Event} event | 302 * @param {!WebInspector.Event} event |
| 303 */ | 303 */ |
| 304 _parsedScriptSource: function(event) | 304 _parsedScriptSource: function(event) |
| 305 { | 305 { |
| 306 var script = /** @type {!WebInspector.Script} */ (event.data); | 306 var script = /** @type {!WebInspector.Script} */ (event.data); |
| 307 if (!script.sourceURL || (script.isInlineScript() && !script.hasSourceUR L)) | 307 if (!script.sourceURL || script.isLiveEdit() || (script.isInlineScript() && !script.hasSourceURL)) |
| 308 return; | 308 return; |
| 309 // Filter out embedder injected content scripts. | 309 // Filter out embedder injected content scripts. |
| 310 if (script.isContentScript() && !script.hasSourceURL) { | 310 if (script.isContentScript() && !script.hasSourceURL) { |
| 311 var parsedURL = new WebInspector.ParsedURL(script.sourceURL); | 311 var parsedURL = new WebInspector.ParsedURL(script.sourceURL); |
| 312 if (!parsedURL.isValid) | 312 if (!parsedURL.isValid) |
| 313 return; | 313 return; |
| 314 } | 314 } |
| 315 this._addFile(script.sourceURL, script, script.isContentScript()); | 315 this._addFile(script.sourceURL, script, script.isContentScript()); |
| 316 }, | 316 }, |
| 317 | 317 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 329 | 329 |
| 330 /** | 330 /** |
| 331 * @param {!WebInspector.Event} event | 331 * @param {!WebInspector.Event} event |
| 332 */ | 332 */ |
| 333 _styleSheetRemoved: function(event) | 333 _styleSheetRemoved: function(event) |
| 334 { | 334 { |
| 335 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat a); | 335 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat a); |
| 336 if (header.isInline && !header.hasSourceURL && header.origin !== "inspec tor") | 336 if (header.isInline && !header.hasSourceURL && header.origin !== "inspec tor") |
| 337 return; | 337 return; |
| 338 | 338 |
| 339 this.removeFileForURL(header.resourceURL()); | 339 this._removeFileForURL(header.resourceURL()); |
| 340 }, | 340 }, |
| 341 | 341 |
| 342 /** | 342 /** |
| 343 * @param {!WebInspector.Event} event | 343 * @param {!WebInspector.Event} event |
| 344 */ | 344 */ |
| 345 _resourceAdded: function(event) | 345 _resourceAdded: function(event) |
| 346 { | 346 { |
| 347 var resource = /** @type {!WebInspector.Resource} */ (event.data); | 347 var resource = /** @type {!WebInspector.Resource} */ (event.data); |
| 348 this._addResource(resource); | 348 this._addResource(resource); |
| 349 }, | 349 }, |
| 350 | 350 |
| 351 /** | 351 /** |
| 352 * @param {!WebInspector.Resource} resource | 352 * @param {!WebInspector.Resource} resource |
| 353 */ | 353 */ |
| 354 _addResource: function(resource) | 354 _addResource: function(resource) |
| 355 { | 355 { |
| 356 if (resource.resourceType() === WebInspector.resourceTypes.Document) | 356 // Only load documents from resources. |
| 357 this._addFile(resource.url, resource); | 357 if (resource.resourceType() !== WebInspector.resourceTypes.Document) |
| 358 return; | |
| 359 | |
| 360 // Never load document twice. | |
| 361 if (this._workspace.uiSourceCodeForOriginURL(resource.url)) | |
| 362 return; | |
| 363 this._addFile(resource.url, resource); | |
| 358 }, | 364 }, |
| 359 | 365 |
| 360 /** | 366 /** |
| 361 * @param {!WebInspector.Event} event | 367 * @param {!WebInspector.Event} event |
| 362 */ | 368 */ |
| 363 _mainFrameNavigated: function(event) | 369 _mainFrameNavigated: function(event) |
| 364 { | 370 { |
| 365 this._reset(); | 371 this._reset(); |
| 366 this._populate(); | 372 this._populate(); |
| 367 }, | 373 }, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 380 * @param {boolean=} isContentScript | 386 * @param {boolean=} isContentScript |
| 381 */ | 387 */ |
| 382 _addFile: function(url, contentProvider, isContentScript) | 388 _addFile: function(url, contentProvider, isContentScript) |
| 383 { | 389 { |
| 384 if (this._networkMapping.hasMappingForURL(url)) | 390 if (this._networkMapping.hasMappingForURL(url)) |
| 385 return; | 391 return; |
| 386 | 392 |
| 387 var type = contentProvider.contentType(); | 393 var type = contentProvider.contentType(); |
| 388 if (type !== WebInspector.resourceTypes.Stylesheet && type !== WebInspec tor.resourceTypes.Document && type !== WebInspector.resourceTypes.Script) | 394 if (type !== WebInspector.resourceTypes.Stylesheet && type !== WebInspec tor.resourceTypes.Document && type !== WebInspector.resourceTypes.Script) |
| 389 return; | 395 return; |
| 390 if (this._processedURLs[url]) | |
| 391 return; | |
| 392 this._processedURLs[url] = true; | |
| 393 var uiSourceCode = this.addFileForURL(url, contentProvider, isContentScr ipt); | 396 var uiSourceCode = this.addFileForURL(url, contentProvider, isContentScr ipt); |
| 394 uiSourceCode[WebInspector.NetworkProject._contentTypeSymbol] = type; | 397 uiSourceCode[WebInspector.NetworkProject._contentTypeSymbol] = type; |
| 395 }, | 398 }, |
| 396 | 399 |
| 397 _dispose: function() | 400 _dispose: function() |
| 398 { | 401 { |
| 399 this._reset(); | 402 this._reset(); |
| 400 var target = this.target(); | 403 var target = this.target(); |
| 401 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo del.EventTypes.ResourceAdded, this._resourceAdded, this); | 404 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo del.EventTypes.ResourceAdded, this._resourceAdded, this); |
| 402 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo del.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this); | 405 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo del.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this); |
| 403 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | 406 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); |
| 404 if (debuggerModel) { | 407 if (debuggerModel) { |
| 405 debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events. ParsedScriptSource, this._parsedScriptSource, this); | 408 debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events. ParsedScriptSource, this._parsedScriptSource, this); |
| 406 debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events. FailedToParseScriptSource, this._parsedScriptSource, this); | 409 debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events. FailedToParseScriptSource, this._parsedScriptSource, this); |
| 407 } | 410 } |
| 408 var cssModel = WebInspector.CSSStyleModel.fromTarget(target); | 411 var cssModel = WebInspector.CSSStyleModel.fromTarget(target); |
| 409 if (cssModel) { | 412 if (cssModel) { |
| 410 cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Style SheetAdded, this._styleSheetAdded, this); | 413 cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Style SheetAdded, this._styleSheetAdded, this); |
| 411 cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Style SheetRemoved, this._styleSheetRemoved, this); | 414 cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Style SheetRemoved, this._styleSheetRemoved, this); |
| 412 } | 415 } |
| 413 delete target[WebInspector.NetworkProject._networkProjectSymbol]; | 416 delete target[WebInspector.NetworkProject._networkProjectSymbol]; |
| 414 }, | 417 }, |
| 415 | 418 |
| 416 _reset: function() | 419 _reset: function() |
| 417 { | 420 { |
| 418 this._processedURLs = {}; | |
| 419 for (var projectId in this._projectDelegates) | 421 for (var projectId in this._projectDelegates) |
| 420 this._projectDelegates[projectId].reset(); | 422 this._projectDelegates[projectId].reset(); |
| 421 this._projectDelegates = {}; | 423 this._projectDelegates = {}; |
| 422 }, | 424 }, |
| 423 | 425 |
| 424 __proto__: WebInspector.SDKObject.prototype | 426 __proto__: WebInspector.SDKObject.prototype |
| 425 } | 427 } |
| OLD | NEW |