| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 return project; | 216 return project; |
| 217 | 217 |
| 218 project = new WebInspector.ContentProviderBasedProject(this._workspace,
projectId, projectType, ""); | 218 project = new WebInspector.ContentProviderBasedProject(this._workspace,
projectId, projectType, ""); |
| 219 project[WebInspector.NetworkProject._targetSymbol] = this.target(); | 219 project[WebInspector.NetworkProject._targetSymbol] = this.target(); |
| 220 project[WebInspector.NetworkProject._frameSymbol] = frame; | 220 project[WebInspector.NetworkProject._frameSymbol] = frame; |
| 221 this._workspaceProjects.set(projectId, project); | 221 this._workspaceProjects.set(projectId, project); |
| 222 return project; | 222 return project; |
| 223 }, | 223 }, |
| 224 | 224 |
| 225 /** | 225 /** |
| 226 * @param {string} url | 226 * @param {!WebInspector.ContentProvider} contentProvider |
| 227 * @param {?WebInspector.ResourceTreeFrame} frame | 227 * @param {?WebInspector.ResourceTreeFrame} frame |
| 228 * @param {!WebInspector.ContentProvider} contentProvider | |
| 229 * @param {boolean=} isContentScript | 228 * @param {boolean=} isContentScript |
| 230 * @return {?WebInspector.UISourceCode} | 229 * @return {?WebInspector.UISourceCode} |
| 231 */ | 230 */ |
| 232 addFileForURL: function(url, contentProvider, frame, isContentScript) | 231 addFile: function(contentProvider, frame, isContentScript) |
| 233 { | 232 { |
| 234 return this._createFile(url, contentProvider, frame, isContentScript ||
false, true); | 233 var uiSourceCode = this._createFile(contentProvider, frame, isContentScr
ipt || false); |
| 234 if (uiSourceCode) |
| 235 this._addUISourceCodeWithProvider(uiSourceCode, contentProvider); |
| 236 return uiSourceCode; |
| 235 }, | 237 }, |
| 236 | 238 |
| 237 /** | 239 /** |
| 238 * @param {?WebInspector.ResourceTreeFrame} frame | 240 * @param {?WebInspector.ResourceTreeFrame} frame |
| 239 * @param {string} url | 241 * @param {string} url |
| 240 */ | 242 */ |
| 241 _removeFileForURL: function(frame, url) | 243 _removeFileForURL: function(frame, url) |
| 242 { | 244 { |
| 243 var project = this._workspaceProjects.get(WebInspector.NetworkProject.pr
ojectId(this.target(), frame, false)); | 245 var project = this._workspaceProjects.get(WebInspector.NetworkProject.pr
ojectId(this.target(), frame, false)); |
| 244 if (!project) | 246 if (!project) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 { | 285 { |
| 284 var script = /** @type {!WebInspector.Script} */ (event.data); | 286 var script = /** @type {!WebInspector.Script} */ (event.data); |
| 285 if (!script.sourceURL || script.isLiveEdit() || (script.isInlineScript()
&& !script.hasSourceURL)) | 287 if (!script.sourceURL || script.isLiveEdit() || (script.isInlineScript()
&& !script.hasSourceURL)) |
| 286 return; | 288 return; |
| 287 // Filter out embedder injected content scripts. | 289 // Filter out embedder injected content scripts. |
| 288 if (script.isContentScript() && !script.hasSourceURL) { | 290 if (script.isContentScript() && !script.hasSourceURL) { |
| 289 var parsedURL = new WebInspector.ParsedURL(script.sourceURL); | 291 var parsedURL = new WebInspector.ParsedURL(script.sourceURL); |
| 290 if (!parsedURL.isValid) | 292 if (!parsedURL.isValid) |
| 291 return; | 293 return; |
| 292 } | 294 } |
| 293 var uiSourceCode = this._createFile(script.sourceURL, script, WebInspect
or.ResourceTreeFrame.fromScript(script), script.isContentScript(), false); | 295 var uiSourceCode = this._createFile(script, WebInspector.ResourceTreeFra
me.fromScript(script), script.isContentScript()); |
| 294 if (uiSourceCode) { | 296 if (uiSourceCode) { |
| 295 uiSourceCode[WebInspector.NetworkProject._scriptSymbol] = script; | 297 uiSourceCode[WebInspector.NetworkProject._scriptSymbol] = script; |
| 296 this._addUISourceCodeWithProvider(uiSourceCode, script); | 298 this._addUISourceCodeWithProvider(uiSourceCode, script); |
| 297 } | 299 } |
| 298 }, | 300 }, |
| 299 | 301 |
| 300 /** | 302 /** |
| 301 * @param {!WebInspector.Event} event | 303 * @param {!WebInspector.Event} event |
| 302 */ | 304 */ |
| 303 _styleSheetAdded: function(event) | 305 _styleSheetAdded: function(event) |
| 304 { | 306 { |
| 305 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat
a); | 307 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat
a); |
| 306 if (header.isInline && !header.hasSourceURL && header.origin !== "inspec
tor") | 308 if (header.isInline && !header.hasSourceURL && header.origin !== "inspec
tor") |
| 307 return; | 309 return; |
| 308 | 310 |
| 309 var uiSourceCode = this._createFile(header.resourceURL(), header, WebIns
pector.ResourceTreeFrame.fromStyleSheet(header), false, false); | 311 var uiSourceCode = this._createFile(header, WebInspector.ResourceTreeFra
me.fromStyleSheet(header), false); |
| 310 if (uiSourceCode) { | 312 if (uiSourceCode) { |
| 311 uiSourceCode[WebInspector.NetworkProject._styleSheetSymbol] = header
; | 313 uiSourceCode[WebInspector.NetworkProject._styleSheetSymbol] = header
; |
| 312 this._addUISourceCodeWithProvider(uiSourceCode, header); | 314 this._addUISourceCodeWithProvider(uiSourceCode, header); |
| 313 } | 315 } |
| 314 }, | 316 }, |
| 315 | 317 |
| 316 /** | 318 /** |
| 317 * @param {!WebInspector.Event} event | 319 * @param {!WebInspector.Event} event |
| 318 */ | 320 */ |
| 319 _styleSheetRemoved: function(event) | 321 _styleSheetRemoved: function(event) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 return; | 355 return; |
| 354 if (resourceType === WebInspector.resourceTypes.Font && resource.mimeTyp
e && !resource.mimeType.includes("font")) | 356 if (resourceType === WebInspector.resourceTypes.Font && resource.mimeTyp
e && !resource.mimeType.includes("font")) |
| 355 return; | 357 return; |
| 356 if ((resourceType === WebInspector.resourceTypes.Image || resourceType =
== WebInspector.resourceTypes.Font) && resource.contentURL().startsWith("data:")
) | 358 if ((resourceType === WebInspector.resourceTypes.Image || resourceType =
== WebInspector.resourceTypes.Font) && resource.contentURL().startsWith("data:")
) |
| 357 return; | 359 return; |
| 358 | 360 |
| 359 // Never load document twice. | 361 // Never load document twice. |
| 360 if (this._workspace.uiSourceCodeForURL(resource.url)) | 362 if (this._workspace.uiSourceCodeForURL(resource.url)) |
| 361 return; | 363 return; |
| 362 | 364 |
| 363 var uiSourceCode = this._createFile(resource.url, resource, WebInspector
.ResourceTreeFrame.fromResource(resource), false, false); | 365 var uiSourceCode = this._createFile(resource, WebInspector.ResourceTreeF
rame.fromResource(resource), false); |
| 364 if (uiSourceCode) { | 366 if (uiSourceCode) { |
| 365 uiSourceCode[WebInspector.NetworkProject._resourceSymbol] = resource
; | 367 uiSourceCode[WebInspector.NetworkProject._resourceSymbol] = resource
; |
| 366 this._addUISourceCodeWithProvider(uiSourceCode, resource); | 368 this._addUISourceCodeWithProvider(uiSourceCode, resource); |
| 367 } | 369 } |
| 368 }, | 370 }, |
| 369 | 371 |
| 370 /** | 372 /** |
| 371 * @param {!WebInspector.Event} event | 373 * @param {!WebInspector.Event} event |
| 372 */ | 374 */ |
| 373 _frameWillNavigate: function(event) | 375 _frameWillNavigate: function(event) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 392 | 394 |
| 393 _suspendStateChanged: function() | 395 _suspendStateChanged: function() |
| 394 { | 396 { |
| 395 if (this.target().targetManager().allTargetsSuspended()) | 397 if (this.target().targetManager().allTargetsSuspended()) |
| 396 this._reset(); | 398 this._reset(); |
| 397 else | 399 else |
| 398 this._populate(); | 400 this._populate(); |
| 399 }, | 401 }, |
| 400 | 402 |
| 401 /** | 403 /** |
| 402 * @param {string} url | |
| 403 * @param {!WebInspector.ContentProvider} contentProvider | 404 * @param {!WebInspector.ContentProvider} contentProvider |
| 404 * @param {?WebInspector.ResourceTreeFrame} frame | 405 * @param {?WebInspector.ResourceTreeFrame} frame |
| 405 * @param {boolean} isContentScript | 406 * @param {boolean} isContentScript |
| 406 * @param {boolean} addIntoProject | |
| 407 * @return {?WebInspector.UISourceCode} | 407 * @return {?WebInspector.UISourceCode} |
| 408 */ | 408 */ |
| 409 _createFile: function(url, contentProvider, frame, isContentScript, addIntoP
roject) | 409 _createFile: function(contentProvider, frame, isContentScript) |
| 410 { | 410 { |
| 411 var url = contentProvider.contentURL(); |
| 411 if (this._networkMapping.hasMappingForNetworkURL(url)) | 412 if (this._networkMapping.hasMappingForNetworkURL(url)) |
| 412 return null; | 413 return null; |
| 413 | 414 |
| 414 var project = this._workspaceProject(frame, isContentScript); | 415 var project = this._workspaceProject(frame, isContentScript); |
| 415 var uiSourceCode = project.createUISourceCode(url, contentProvider.conte
ntType()); | 416 var uiSourceCode = project.createUISourceCode(url, contentProvider.conte
ntType()); |
| 416 uiSourceCode[WebInspector.NetworkProject._targetSymbol] = this.target(); | 417 uiSourceCode[WebInspector.NetworkProject._targetSymbol] = this.target(); |
| 417 if (addIntoProject) | |
| 418 project.addUISourceCodeWithProvider(uiSourceCode, contentProvider); | |
| 419 return uiSourceCode; | 418 return uiSourceCode; |
| 420 }, | 419 }, |
| 421 | 420 |
| 422 _dispose: function() | 421 _dispose: function() |
| 423 { | 422 { |
| 424 this._reset(); | 423 this._reset(); |
| 425 var target = this.target(); | 424 var target = this.target(); |
| 426 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo
del.EventTypes.ResourceAdded, this._resourceAdded, this); | 425 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo
del.EventTypes.ResourceAdded, this._resourceAdded, this); |
| 427 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo
del.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this); | 426 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo
del.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this); |
| 428 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | 427 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 440 | 439 |
| 441 _reset: function() | 440 _reset: function() |
| 442 { | 441 { |
| 443 for (var project of this._workspaceProjects.values()) | 442 for (var project of this._workspaceProjects.values()) |
| 444 project.reset(); | 443 project.reset(); |
| 445 this._workspaceProjects.clear(); | 444 this._workspaceProjects.clear(); |
| 446 }, | 445 }, |
| 447 | 446 |
| 448 __proto__: WebInspector.SDKObject.prototype | 447 __proto__: WebInspector.SDKObject.prototype |
| 449 } | 448 } |
| OLD | NEW |