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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._mainFrameNa vigated, this)); | 86 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._mainFrameNa vigated, this)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 var debuggerModel = SDK.DebuggerModel.fromTarget(target); | 89 var debuggerModel = SDK.DebuggerModel.fromTarget(target); |
| 90 if (debuggerModel) { | 90 if (debuggerModel) { |
| 91 this._eventListeners.push( | 91 this._eventListeners.push( |
| 92 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSo urce, this._parsedScriptSource, this), | 92 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSo urce, this._parsedScriptSource, this), |
| 93 debuggerModel.addEventListener( | 93 debuggerModel.addEventListener( |
| 94 SDK.DebuggerModel.Events.FailedToParseScriptSource, this._parsedSc riptSource, this)); | 94 SDK.DebuggerModel.Events.FailedToParseScriptSource, this._parsedSc riptSource, this)); |
| 95 } | 95 } |
| 96 var cssModel = SDK.CSSModel.fromTarget(target); | |
| 97 if (cssModel) { | |
| 98 this._eventListeners.push( | |
| 99 cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetAdded, this._s tyleSheetAdded, this), | |
| 100 cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetRemoved, this. _styleSheetRemoved, this)); | |
| 101 } | |
| 102 this._eventListeners.push(target.targetManager().addEventListener( | 96 this._eventListeners.push(target.targetManager().addEventListener( |
| 103 SDK.TargetManager.Events.SuspendStateChanged, this._suspendStateChanged, this)); | 97 SDK.TargetManager.Events.SuspendStateChanged, this._suspendStateChanged, this)); |
| 104 } | 98 } |
| 105 | 99 |
| 106 /** | 100 /** |
| 107 * @param {!SDK.Target} target | 101 * @param {!SDK.Target} target |
| 108 * @param {?SDK.ResourceTreeFrame} frame | 102 * @param {?SDK.ResourceTreeFrame} frame |
| 109 * @param {boolean} isContentScripts | 103 * @param {boolean} isContentScripts |
| 110 * @return {string} | 104 * @return {string} |
| 111 */ | 105 */ |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 * @return {!Workspace.UISourceCode} | 183 * @return {!Workspace.UISourceCode} |
| 190 */ | 184 */ |
| 191 addFile(contentProvider, frame, isContentScript, contentSize) { | 185 addFile(contentProvider, frame, isContentScript, contentSize) { |
| 192 var uiSourceCode = this._createFile(contentProvider, frame, isContentScript || false); | 186 var uiSourceCode = this._createFile(contentProvider, frame, isContentScript || false); |
| 193 var metadata = typeof contentSize === 'number' ? new Workspace.UISourceCodeM etadata(null, contentSize) : null; | 187 var metadata = typeof contentSize === 'number' ? new Workspace.UISourceCodeM etadata(null, contentSize) : null; |
| 194 this._addUISourceCodeWithProvider(uiSourceCode, contentProvider, metadata); | 188 this._addUISourceCodeWithProvider(uiSourceCode, contentProvider, metadata); |
| 195 return uiSourceCode; | 189 return uiSourceCode; |
| 196 } | 190 } |
| 197 | 191 |
| 198 /** | 192 /** |
| 193 * @param {string} url | |
| 199 * @param {?SDK.ResourceTreeFrame} frame | 194 * @param {?SDK.ResourceTreeFrame} frame |
| 200 * @param {string} url | 195 * @param {boolean} isContentScript |
| 196 * @return {?Workspace.UISourceCode} | |
| 201 */ | 197 */ |
| 202 _removeFileForURL(frame, url) { | 198 getFile(url, frame, isContentScript) { |
|
dgozman
2017/01/27 23:49:12
uiSourceCode(frame, url, isContentScript)
| |
| 203 var project = this._workspaceProjects.get(Bindings.NetworkProject.projectId( this.target(), frame, false)); | 199 var project = this._workspaceProject(frame, isContentScript); |
| 204 if (!project) | 200 return project.uiSourceCodeForURL(url); |
| 205 return; | 201 } |
| 206 project.removeFile(url); | 202 |
| 203 /** | |
| 204 * @param {!Workspace.UISourceCode} uiSourceCode | |
| 205 */ | |
| 206 removeFile(uiSourceCode) { | |
|
dgozman
2017/01/27 23:49:12
removeUISourceCode
lushnikov
2017/01/30 14:19:15
I was a bit hesitant to add just another one "remo
| |
| 207 var project = uiSourceCode.project(); | |
| 208 console.assert( | |
| 209 project[Bindings.NetworkProject._targetSymbol] === this.target(), 'Canno t remove foreign UISourceCode'); | |
| 210 /** @type {!Bindings.ContentProviderBasedProject} */ (project).removeFile(ui SourceCode.url()); | |
| 207 } | 211 } |
| 208 | 212 |
| 209 _populate() { | 213 _populate() { |
| 210 /** | 214 /** |
| 211 * @param {!SDK.ResourceTreeFrame} frame | 215 * @param {!SDK.ResourceTreeFrame} frame |
| 212 * @this {Bindings.NetworkProject} | 216 * @this {Bindings.NetworkProject} |
| 213 */ | 217 */ |
| 214 function populateFrame(frame) { | 218 function populateFrame(frame) { |
| 215 for (var i = 0; i < frame.childFrames.length; ++i) | 219 for (var i = 0; i < frame.childFrames.length; ++i) |
| 216 populateFrame.call(this, frame.childFrames[i]); | 220 populateFrame.call(this, frame.childFrames[i]); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 if (!parsedURL.isValid) | 253 if (!parsedURL.isValid) |
| 250 return; | 254 return; |
| 251 } | 255 } |
| 252 var uiSourceCode = this._createFile(script, SDK.ResourceTreeFrame.fromScript (script), script.isContentScript()); | 256 var uiSourceCode = this._createFile(script, SDK.ResourceTreeFrame.fromScript (script), script.isContentScript()); |
| 253 uiSourceCode[Bindings.NetworkProject._scriptSymbol] = script; | 257 uiSourceCode[Bindings.NetworkProject._scriptSymbol] = script; |
| 254 var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url()); | 258 var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url()); |
| 255 this._addUISourceCodeWithProvider(uiSourceCode, script, this._resourceMetada ta(resource)); | 259 this._addUISourceCodeWithProvider(uiSourceCode, script, this._resourceMetada ta(resource)); |
| 256 } | 260 } |
| 257 | 261 |
| 258 /** | 262 /** |
| 259 * @param {!Common.Event} event | 263 * @param {!SDK.CSSStyleSheetHeader} header |
| 264 * @return {!Workspace.UISourceCode} | |
| 260 */ | 265 */ |
| 261 _styleSheetAdded(event) { | 266 createFileForStyleSheetHeader(header) { |
|
dgozman
2017/01/27 23:49:12
Let's get rid of this one as well. We should expos
| |
| 262 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data); | |
| 263 if (header.isInline && !header.hasSourceURL && header.origin !== 'inspector' ) | |
| 264 return; | |
| 265 if (!header.resourceURL()) | |
| 266 return; | |
| 267 | |
| 268 var originalContentProvider = header.originalContentProvider(); | 267 var originalContentProvider = header.originalContentProvider(); |
| 269 var uiSourceCode = this._createFile(originalContentProvider, SDK.ResourceTre eFrame.fromStyleSheet(header), false); | 268 var uiSourceCode = this._createFile(originalContentProvider, SDK.ResourceTre eFrame.fromStyleSheet(header), false); |
| 270 uiSourceCode[Bindings.NetworkProject._styleSheetSymbol] = header; | 269 uiSourceCode[Bindings.NetworkProject._styleSheetSymbol] = header; |
| 271 var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url()); | 270 var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url()); |
| 272 this._addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, thi s._resourceMetadata(resource)); | 271 this._addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, thi s._resourceMetadata(resource)); |
| 272 return uiSourceCode; | |
| 273 } | 273 } |
| 274 | 274 |
| 275 /** | 275 /** |
| 276 * @param {!Common.Event} event | |
| 277 */ | |
| 278 _styleSheetRemoved(event) { | |
| 279 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data); | |
| 280 if (header.isInline && !header.hasSourceURL && header.origin !== 'inspector' ) | |
| 281 return; | |
| 282 | |
| 283 this._removeFileForURL(SDK.ResourceTreeFrame.fromStyleSheet(header), header. resourceURL()); | |
| 284 } | |
| 285 | |
| 286 /** | |
| 287 * @param {!Common.Event} event | 276 * @param {!Common.Event} event |
| 288 */ | 277 */ |
| 289 _resourceAdded(event) { | 278 _resourceAdded(event) { |
| 290 var resource = /** @type {!SDK.Resource} */ (event.data); | 279 var resource = /** @type {!SDK.Resource} */ (event.data); |
| 291 this._addResource(resource); | 280 this._addResource(resource); |
| 292 } | 281 } |
| 293 | 282 |
| 294 /** | 283 /** |
| 295 * @param {!SDK.Resource} resource | 284 * @param {!SDK.Resource} resource |
| 296 */ | 285 */ |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 return workspace.uiSourceCode(Bindings.NetworkProject.projectId(header.targe t(), frame, false), url); | 397 return workspace.uiSourceCode(Bindings.NetworkProject.projectId(header.targe t(), frame, false), url); |
| 409 } | 398 } |
| 410 }; | 399 }; |
| 411 | 400 |
| 412 Bindings.NetworkProject._networkProjectSymbol = Symbol('networkProject'); | 401 Bindings.NetworkProject._networkProjectSymbol = Symbol('networkProject'); |
| 413 Bindings.NetworkProject._resourceSymbol = Symbol('resource'); | 402 Bindings.NetworkProject._resourceSymbol = Symbol('resource'); |
| 414 Bindings.NetworkProject._scriptSymbol = Symbol('script'); | 403 Bindings.NetworkProject._scriptSymbol = Symbol('script'); |
| 415 Bindings.NetworkProject._styleSheetSymbol = Symbol('styleSheet'); | 404 Bindings.NetworkProject._styleSheetSymbol = Symbol('styleSheet'); |
| 416 Bindings.NetworkProject._targetSymbol = Symbol('target'); | 405 Bindings.NetworkProject._targetSymbol = Symbol('target'); |
| 417 Bindings.NetworkProject._frameSymbol = Symbol('frame'); | 406 Bindings.NetworkProject._frameSymbol = Symbol('frame'); |
| OLD | NEW |