| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 */ | 149 */ |
| 150 WebInspector.NetworkProject = function(target, workspace, networkMapping) | 150 WebInspector.NetworkProject = function(target, workspace, networkMapping) |
| 151 { | 151 { |
| 152 WebInspector.SDKObject.call(this, target); | 152 WebInspector.SDKObject.call(this, target); |
| 153 this._workspace = workspace; | 153 this._workspace = workspace; |
| 154 this._networkMapping = networkMapping; | 154 this._networkMapping = networkMapping; |
| 155 this._projectDelegates = {}; | 155 this._projectDelegates = {}; |
| 156 this._processedURLs = {}; | 156 this._processedURLs = {}; |
| 157 target[WebInspector.NetworkProject._networkProjectSymbol] = this; | 157 target[WebInspector.NetworkProject._networkProjectSymbol] = this; |
| 158 | 158 |
| 159 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.ResourceAdded, this._resourceAdded, this); |
| 159 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.MainFrameNavigated, this._mainFrameNavigated, this); | 160 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.MainFrameNavigated, this._mainFrameNavigated, this); |
| 160 | 161 |
| 161 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | 162 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); |
| 162 if (debuggerModel) { | 163 if (debuggerModel) { |
| 163 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedS
criptSource, this._parsedScriptSource, this); | 164 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedS
criptSource, this._parsedScriptSource, this); |
| 164 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedT
oParseScriptSource, this._parsedScriptSource, this); | 165 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedT
oParseScriptSource, this._parsedScriptSource, this); |
| 165 } | 166 } |
| 166 var cssModel = WebInspector.CSSStyleModel.fromTarget(target); | 167 var cssModel = WebInspector.CSSStyleModel.fromTarget(target); |
| 167 if (cssModel) { | 168 if (cssModel) { |
| 168 cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetAd
ded, this._styleSheetAdded, this); | 169 cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetAd
ded, this._styleSheetAdded, this); |
| 169 cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetRe
moved, this._styleSheetRemoved, this); | 170 cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetRe
moved, this._styleSheetRemoved, this); |
| 170 } | 171 } |
| 171 | |
| 172 if (debuggerModel && !debuggerModel.debuggerEnabled()) | |
| 173 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debugge
rWasEnabled, this._debuggerEnabled, this); | |
| 174 else | |
| 175 this._debuggerEnabled(); | |
| 176 } | 172 } |
| 177 | 173 |
| 178 WebInspector.NetworkProject._networkProjectSymbol = Symbol("networkProject"); | 174 WebInspector.NetworkProject._networkProjectSymbol = Symbol("networkProject"); |
| 179 WebInspector.NetworkProject._contentTypeSymbol = Symbol("networkContentType"); | 175 WebInspector.NetworkProject._contentTypeSymbol = Symbol("networkContentType"); |
| 180 | 176 |
| 181 /** | 177 /** |
| 182 * @param {!WebInspector.Target} target | 178 * @param {!WebInspector.Target} target |
| 183 * @param {string} projectURL | 179 * @param {string} projectURL |
| 184 * @param {boolean} isContentScripts | 180 * @param {boolean} isContentScripts |
| 185 * @return {string} | 181 * @return {string} |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 */ | 267 */ |
| 272 _removeFileForURL: function(url) | 268 _removeFileForURL: function(url) |
| 273 { | 269 { |
| 274 var splitURL = WebInspector.ParsedURL.splitURLIntoPathComponents(url); | 270 var splitURL = WebInspector.ParsedURL.splitURLIntoPathComponents(url); |
| 275 var projectURL = splitURL[0]; | 271 var projectURL = splitURL[0]; |
| 276 var path = splitURL.slice(1).join("/"); | 272 var path = splitURL.slice(1).join("/"); |
| 277 var projectDelegate = this._projectDelegates[WebInspector.NetworkProject
.projectId(this.target(), projectURL, false)]; | 273 var projectDelegate = this._projectDelegates[WebInspector.NetworkProject
.projectId(this.target(), projectURL, false)]; |
| 278 projectDelegate.removeFile(path); | 274 projectDelegate.removeFile(path); |
| 279 }, | 275 }, |
| 280 | 276 |
| 281 _debuggerEnabled: function() | |
| 282 { | |
| 283 var debuggerModel = WebInspector.DebuggerModel.fromTarget(this.target())
; | |
| 284 if (debuggerModel) | |
| 285 debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.
DebuggerWasEnabled, this._debuggerEnabled, this); | |
| 286 this._populate(); | |
| 287 this.target().resourceTreeModel.addEventListener(WebInspector.ResourceTr
eeModel.EventTypes.ResourceAdded, this._resourceAdded, this); | |
| 288 }, | |
| 289 | |
| 290 _populate: function() | 277 _populate: function() |
| 291 { | 278 { |
| 292 /** | 279 /** |
| 293 * @param {!WebInspector.ResourceTreeFrame} frame | 280 * @param {!WebInspector.ResourceTreeFrame} frame |
| 294 * @this {WebInspector.NetworkProject} | 281 * @this {WebInspector.NetworkProject} |
| 295 */ | 282 */ |
| 296 function populateFrame(frame) | 283 function populateFrame(frame) |
| 297 { | 284 { |
| 298 for (var i = 0; i < frame.childFrames.length; ++i) | 285 for (var i = 0; i < frame.childFrames.length; ++i) |
| 299 populateFrame.call(this, frame.childFrames[i]); | 286 populateFrame.call(this, frame.childFrames[i]); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 }, | 386 }, |
| 400 | 387 |
| 401 _dispose: function() | 388 _dispose: function() |
| 402 { | 389 { |
| 403 this._reset(); | 390 this._reset(); |
| 404 var target = this.target(); | 391 var target = this.target(); |
| 405 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo
del.EventTypes.ResourceAdded, this._resourceAdded, this); | 392 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo
del.EventTypes.ResourceAdded, this._resourceAdded, this); |
| 406 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo
del.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this); | 393 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo
del.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this); |
| 407 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | 394 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); |
| 408 if (debuggerModel) { | 395 if (debuggerModel) { |
| 409 debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.
DebuggerWasEnabled, this._debuggerEnabled, this); | |
| 410 debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.
ParsedScriptSource, this._parsedScriptSource, this); | 396 debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.
ParsedScriptSource, this._parsedScriptSource, this); |
| 411 debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.
FailedToParseScriptSource, this._parsedScriptSource, this); | 397 debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.
FailedToParseScriptSource, this._parsedScriptSource, this); |
| 412 } | 398 } |
| 413 var cssModel = WebInspector.CSSStyleModel.fromTarget(target); | 399 var cssModel = WebInspector.CSSStyleModel.fromTarget(target); |
| 414 if (cssModel) { | 400 if (cssModel) { |
| 415 cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Style
SheetAdded, this._styleSheetAdded, this); | 401 cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Style
SheetAdded, this._styleSheetAdded, this); |
| 416 cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Style
SheetRemoved, this._styleSheetRemoved, this); | 402 cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Style
SheetRemoved, this._styleSheetRemoved, this); |
| 417 } | 403 } |
| 418 }, | 404 }, |
| 419 | 405 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 return this._resource.resourceType(); | 444 return this._resource.resourceType(); |
| 459 }, | 445 }, |
| 460 | 446 |
| 461 /** | 447 /** |
| 462 * @override | 448 * @override |
| 463 * @param {function(?string)} callback | 449 * @param {function(?string)} callback |
| 464 */ | 450 */ |
| 465 requestContent: function(callback) | 451 requestContent: function(callback) |
| 466 { | 452 { |
| 467 /** | 453 /** |
| 468 * @param {!WebInspector.Target} target | 454 * @this {WebInspector.NetworkProject.FallbackResource} |
| 469 * @param {string} url | |
| 470 * @return {!Array.<!WebInspector.Script>} | |
| 471 */ | 455 */ |
| 472 function findScripts(target, url) | 456 function loadFallbackContent() |
| 473 { | 457 { |
| 474 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | 458 var debuggerModel = WebInspector.DebuggerModel.fromTarget(this._reso
urce.target()); |
| 475 return debuggerModel ? debuggerModel.scriptsForSourceURL(url) : []; | 459 if (!debuggerModel) { |
| 460 callback(null); |
| 461 return; |
| 462 } |
| 463 var scripts = debuggerModel.scriptsForSourceURL(this._resource.url); |
| 464 if (!scripts.length) { |
| 465 callback(null); |
| 466 return; |
| 467 } |
| 468 |
| 469 var contentProvider; |
| 470 var type = this._resource.resourceType(); |
| 471 if (type === WebInspector.resourceTypes.Document) |
| 472 contentProvider = new WebInspector.ConcatenatedScriptsContentPro
vider(scripts); |
| 473 else if (type === WebInspector.resourceTypes.Script) |
| 474 contentProvider = scripts[0]; |
| 475 |
| 476 console.assert(contentProvider, "Resource content request failed. "
+ this._resource.url); |
| 477 |
| 478 contentProvider.requestContent(callback); |
| 476 } | 479 } |
| 477 | 480 |
| 478 /** | 481 /** |
| 479 * @param {?string} content | 482 * @param {?string} content |
| 480 * @this {WebInspector.NetworkProject.FallbackResource} | 483 * @this {WebInspector.NetworkProject.FallbackResource} |
| 481 */ | 484 */ |
| 482 function loadFallbackContent(content) | 485 function requestContentLoaded(content) |
| 483 { | 486 { |
| 484 if (content) { | 487 if (content) |
| 485 callback(content); | 488 callback(content) |
| 486 return; | |
| 487 } | |
| 488 | |
| 489 if (this._resource.resourceType() !== WebInspector.resourceTypes.Doc
ument) { | |
| 490 callback(null); | |
| 491 return; | |
| 492 } | |
| 493 | |
| 494 var scripts = findScripts(this._resource.target(), this._resource.ur
l); | |
| 495 if (scripts.length) | |
| 496 new WebInspector.ConcatenatedScriptsContentProvider(scripts).req
uestContent(callback); | |
| 497 else | 489 else |
| 498 callback(null); | 490 loadFallbackContent.call(this); |
| 499 } | 491 } |
| 500 | 492 |
| 501 if (this._resource.resourceType() === WebInspector.resourceTypes.Script)
{ | 493 this._resource.requestContent(requestContentLoaded.bind(this)); |
| 502 var scripts = findScripts(this._resource.target(), this._resource.ur
l); | |
| 503 if (scripts.length) { | |
| 504 scripts[0].requestContent(callback); | |
| 505 return; | |
| 506 } | |
| 507 } | |
| 508 | |
| 509 this._resource.requestContent(loadFallbackContent.bind(this)); | |
| 510 }, | 494 }, |
| 511 | 495 |
| 512 /** | 496 /** |
| 513 * @override | 497 * @override |
| 514 * @param {string} query | 498 * @param {string} query |
| 515 * @param {boolean} caseSensitive | 499 * @param {boolean} caseSensitive |
| 516 * @param {boolean} isRegex | 500 * @param {boolean} isRegex |
| 517 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal
lback | 501 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal
lback |
| 518 */ | 502 */ |
| 519 searchInContent: function(query, caseSensitive, isRegex, callback) | 503 searchInContent: function(query, caseSensitive, isRegex, callback) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 533 } | 517 } |
| 534 | 518 |
| 535 if (this.contentType() === WebInspector.resourceTypes.Document) { | 519 if (this.contentType() === WebInspector.resourceTypes.Document) { |
| 536 this.requestContent(documentContentLoaded); | 520 this.requestContent(documentContentLoaded); |
| 537 return; | 521 return; |
| 538 } | 522 } |
| 539 | 523 |
| 540 this._resource.searchInContent(query, caseSensitive, isRegex, callback); | 524 this._resource.searchInContent(query, caseSensitive, isRegex, callback); |
| 541 } | 525 } |
| 542 } | 526 } |
| OLD | NEW |