| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 * @param {!WebInspector.ResourceTreeFrame} frame | 280 * @param {!WebInspector.ResourceTreeFrame} frame |
| 281 * @this {WebInspector.NetworkProject} | 281 * @this {WebInspector.NetworkProject} |
| 282 */ | 282 */ |
| 283 function populateFrame(frame) | 283 function populateFrame(frame) |
| 284 { | 284 { |
| 285 for (var i = 0; i < frame.childFrames.length; ++i) | 285 for (var i = 0; i < frame.childFrames.length; ++i) |
| 286 populateFrame.call(this, frame.childFrames[i]); | 286 populateFrame.call(this, frame.childFrames[i]); |
| 287 | 287 |
| 288 var resources = frame.resources(); | 288 var resources = frame.resources(); |
| 289 for (var i = 0; i < resources.length; ++i) | 289 for (var i = 0; i < resources.length; ++i) |
| 290 this._addFile(resources[i].url, new WebInspector.NetworkProject.
FallbackResource(resources[i])); | 290 this._addResource(resources[i]); |
| 291 } | 291 } |
| 292 | 292 |
| 293 var mainFrame = this.target().resourceTreeModel.mainFrame; | 293 var mainFrame = this.target().resourceTreeModel.mainFrame; |
| 294 if (mainFrame) | 294 if (mainFrame) |
| 295 populateFrame.call(this, mainFrame); | 295 populateFrame.call(this, mainFrame); |
| 296 }, | 296 }, |
| 297 | 297 |
| 298 /** | 298 /** |
| 299 * @param {!WebInspector.Event} event | 299 * @param {!WebInspector.Event} event |
| 300 */ | 300 */ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 335 |
| 336 this._removeFile(header.resourceURL()); | 336 this._removeFile(header.resourceURL()); |
| 337 }, | 337 }, |
| 338 | 338 |
| 339 /** | 339 /** |
| 340 * @param {!WebInspector.Event} event | 340 * @param {!WebInspector.Event} event |
| 341 */ | 341 */ |
| 342 _resourceAdded: function(event) | 342 _resourceAdded: function(event) |
| 343 { | 343 { |
| 344 var resource = /** @type {!WebInspector.Resource} */ (event.data); | 344 var resource = /** @type {!WebInspector.Resource} */ (event.data); |
| 345 this._addFile(resource.url, new WebInspector.NetworkProject.FallbackReso
urce(resource)); | 345 this._addResource(resource); |
| 346 }, | 346 }, |
| 347 | 347 |
| 348 /** | 348 /** |
| 349 * @param {!WebInspector.Resource} resource |
| 350 */ |
| 351 _addResource: function(resource) |
| 352 { |
| 353 if (resource.resourceType() === WebInspector.resourceTypes.Document) |
| 354 this._addFile(resource.url, resource); |
| 355 }, |
| 356 |
| 357 /** |
| 349 * @param {!WebInspector.Event} event | 358 * @param {!WebInspector.Event} event |
| 350 */ | 359 */ |
| 351 _mainFrameNavigated: function(event) | 360 _mainFrameNavigated: function(event) |
| 352 { | 361 { |
| 353 this._reset(); | 362 this._reset(); |
| 354 this._populate(); | 363 this._populate(); |
| 355 }, | 364 }, |
| 356 | 365 |
| 357 /** | 366 /** |
| 358 * @param {string} url | 367 * @param {string} url |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 _reset: function() | 415 _reset: function() |
| 407 { | 416 { |
| 408 this._processedURLs = {}; | 417 this._processedURLs = {}; |
| 409 for (var projectId in this._projectDelegates) | 418 for (var projectId in this._projectDelegates) |
| 410 this._projectDelegates[projectId].reset(); | 419 this._projectDelegates[projectId].reset(); |
| 411 this._projectDelegates = {}; | 420 this._projectDelegates = {}; |
| 412 }, | 421 }, |
| 413 | 422 |
| 414 __proto__: WebInspector.SDKObject.prototype | 423 __proto__: WebInspector.SDKObject.prototype |
| 415 } | 424 } |
| 416 | |
| 417 /** | |
| 418 * @constructor | |
| 419 * @implements {WebInspector.ContentProvider} | |
| 420 * @param {!WebInspector.Resource} resource | |
| 421 */ | |
| 422 WebInspector.NetworkProject.FallbackResource = function(resource) | |
| 423 { | |
| 424 this._resource = resource; | |
| 425 } | |
| 426 | |
| 427 WebInspector.NetworkProject.FallbackResource.prototype = { | |
| 428 | |
| 429 /** | |
| 430 * @override | |
| 431 * @return {string} | |
| 432 */ | |
| 433 contentURL: function() | |
| 434 { | |
| 435 return this._resource.contentURL(); | |
| 436 }, | |
| 437 | |
| 438 /** | |
| 439 * @override | |
| 440 * @return {!WebInspector.ResourceType} | |
| 441 */ | |
| 442 contentType: function() | |
| 443 { | |
| 444 return this._resource.resourceType(); | |
| 445 }, | |
| 446 | |
| 447 /** | |
| 448 * @override | |
| 449 * @param {function(?string)} callback | |
| 450 */ | |
| 451 requestContent: function(callback) | |
| 452 { | |
| 453 /** | |
| 454 * @this {WebInspector.NetworkProject.FallbackResource} | |
| 455 */ | |
| 456 function loadFallbackContent() | |
| 457 { | |
| 458 var debuggerModel = WebInspector.DebuggerModel.fromTarget(this._reso
urce.target()); | |
| 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); | |
| 479 } | |
| 480 | |
| 481 /** | |
| 482 * @param {?string} content | |
| 483 * @this {WebInspector.NetworkProject.FallbackResource} | |
| 484 */ | |
| 485 function requestContentLoaded(content) | |
| 486 { | |
| 487 if (content) | |
| 488 callback(content) | |
| 489 else | |
| 490 loadFallbackContent.call(this); | |
| 491 } | |
| 492 | |
| 493 this._resource.requestContent(requestContentLoaded.bind(this)); | |
| 494 }, | |
| 495 | |
| 496 /** | |
| 497 * @override | |
| 498 * @param {string} query | |
| 499 * @param {boolean} caseSensitive | |
| 500 * @param {boolean} isRegex | |
| 501 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal
lback | |
| 502 */ | |
| 503 searchInContent: function(query, caseSensitive, isRegex, callback) | |
| 504 { | |
| 505 /** | |
| 506 * @param {?string} content | |
| 507 */ | |
| 508 function documentContentLoaded(content) | |
| 509 { | |
| 510 if (content === null) { | |
| 511 callback([]); | |
| 512 return; | |
| 513 } | |
| 514 | |
| 515 var result = WebInspector.ContentProvider.performSearchInContent(con
tent, query, caseSensitive, isRegex); | |
| 516 callback(result); | |
| 517 } | |
| 518 | |
| 519 if (this.contentType() === WebInspector.resourceTypes.Document) { | |
| 520 this.requestContent(documentContentLoaded); | |
| 521 return; | |
| 522 } | |
| 523 | |
| 524 this._resource.searchInContent(query, caseSensitive, isRegex, callback); | |
| 525 } | |
| 526 } | |
| OLD | NEW |