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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 /** | 30 /** |
31 * @implements {SDK.TargetManager.Observer} | 31 * @implements {SDK.TargetManager.Observer} |
32 * @unrestricted | 32 * @unrestricted |
33 */ | 33 */ |
34 Bindings.NetworkProjectManager = class { | 34 Bindings.NetworkProjectManager = class extends Common.Object { |
35 /** | 35 /** |
36 * @param {!SDK.TargetManager} targetManager | 36 * @param {!SDK.TargetManager} targetManager |
37 * @param {!Workspace.Workspace} workspace | 37 * @param {!Workspace.Workspace} workspace |
38 */ | 38 */ |
39 constructor(targetManager, workspace) { | 39 constructor(targetManager, workspace) { |
| 40 super(); |
40 this._workspace = workspace; | 41 this._workspace = workspace; |
41 targetManager.observeTargets(this); | 42 targetManager.observeTargets(this); |
42 } | 43 } |
43 | 44 |
44 /** | 45 /** |
45 * @override | 46 * @override |
46 * @param {!SDK.Target} target | 47 * @param {!SDK.Target} target |
47 */ | 48 */ |
48 targetAdded(target) { | 49 targetAdded(target) { |
49 new Bindings.NetworkProject(target, this._workspace, SDK.ResourceTreeModel.f
romTarget(target)); | 50 new Bindings.NetworkProject(target, this._workspace, SDK.ResourceTreeModel.f
romTarget(target)); |
50 } | 51 } |
51 | 52 |
52 /** | 53 /** |
53 * @override | 54 * @override |
54 * @param {!SDK.Target} target | 55 * @param {!SDK.Target} target |
55 */ | 56 */ |
56 targetRemoved(target) { | 57 targetRemoved(target) { |
57 Bindings.NetworkProject.forTarget(target)._dispose(); | 58 Bindings.NetworkProject.forTarget(target)._dispose(); |
58 } | 59 } |
59 }; | 60 }; |
60 | 61 |
| 62 /** @implements {Common.Emittable} */ |
| 63 Bindings.NetworkProjectManager.FrameAttributionChangedEvent = class { |
| 64 /** |
| 65 * @param {!Workspace.UISourceCode} uiSourceCode |
| 66 */ |
| 67 constructor(uiSourceCode) { |
| 68 this.uiSourceCode = uiSourceCode; |
| 69 } |
| 70 }; |
| 71 |
| 72 |
61 /** | 73 /** |
62 * @unrestricted | 74 * @unrestricted |
63 */ | 75 */ |
64 Bindings.NetworkProject = class extends SDK.SDKObject { | 76 Bindings.NetworkProject = class extends SDK.SDKObject { |
65 /** | 77 /** |
66 * @param {!SDK.Target} target | 78 * @param {!SDK.Target} target |
67 * @param {!Workspace.Workspace} workspace | 79 * @param {!Workspace.Workspace} workspace |
68 * @param {?SDK.ResourceTreeModel} resourceTreeModel | 80 * @param {?SDK.ResourceTreeModel} resourceTreeModel |
69 */ | 81 */ |
70 constructor(target, workspace, resourceTreeModel) { | 82 constructor(target, workspace, resourceTreeModel) { |
(...skipping 15 matching lines...) Expand all Loading... |
86 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._mainFrameNa
vigated, this)); | 98 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._mainFrameNa
vigated, this)); |
87 } | 99 } |
88 | 100 |
89 var debuggerModel = SDK.DebuggerModel.fromTarget(target); | 101 var debuggerModel = SDK.DebuggerModel.fromTarget(target); |
90 if (debuggerModel) { | 102 if (debuggerModel) { |
91 this._eventListeners.push( | 103 this._eventListeners.push( |
92 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSo
urce, this._parsedScriptSource, this), | 104 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSo
urce, this._parsedScriptSource, this), |
93 debuggerModel.addEventListener( | 105 debuggerModel.addEventListener( |
94 SDK.DebuggerModel.Events.FailedToParseScriptSource, this._parsedSc
riptSource, this)); | 106 SDK.DebuggerModel.Events.FailedToParseScriptSource, this._parsedSc
riptSource, this)); |
95 } | 107 } |
96 var cssModel = target.model(SDK.CSSModel); | |
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( | 108 this._eventListeners.push(target.targetManager().addEventListener( |
103 SDK.TargetManager.Events.SuspendStateChanged, this._suspendStateChanged,
this)); | 109 SDK.TargetManager.Events.SuspendStateChanged, this._suspendStateChanged,
this)); |
104 } | 110 } |
105 | 111 |
106 /** | 112 /** |
107 * @param {!SDK.Target} target | 113 * @param {!SDK.Target} target |
108 * @param {?SDK.ResourceTreeFrame} frame | 114 * @param {?SDK.ResourceTreeFrame} frame |
109 * @param {boolean} isContentScripts | 115 * @param {boolean} isContentScripts |
110 * @return {string} | 116 * @return {string} |
111 */ | 117 */ |
(...skipping 11 matching lines...) Expand all Loading... |
123 | 129 |
124 /** | 130 /** |
125 * @param {!Workspace.Project} project | 131 * @param {!Workspace.Project} project |
126 * @return {?SDK.Target} target | 132 * @return {?SDK.Target} target |
127 */ | 133 */ |
128 static targetForProject(project) { | 134 static targetForProject(project) { |
129 return project[Bindings.NetworkProject._targetSymbol] || null; | 135 return project[Bindings.NetworkProject._targetSymbol] || null; |
130 } | 136 } |
131 | 137 |
132 /** | 138 /** |
133 * @param {!Workspace.Project} project | 139 * @param {!Workspace.UISourceCode} uiSourceCode |
134 * @return {?SDK.ResourceTreeFrame} | 140 * @return {!Array<!SDK.ResourceTreeFrame>} |
135 */ | 141 */ |
136 static frameForProject(project) { | 142 static framesForUISourceCode(uiSourceCode) { |
137 return project[Bindings.NetworkProject._frameSymbol] || null; | 143 return uiSourceCode[Bindings.NetworkProject._frameSymbol] || []; |
138 } | 144 } |
139 | 145 |
140 /** | 146 /** |
141 * @param {!Workspace.UISourceCode} uiSourceCode | 147 * @param {!Workspace.UISourceCode} uiSourceCode |
142 * @return {?SDK.Target} target | 148 * @return {?SDK.Target} target |
143 */ | 149 */ |
144 static targetForUISourceCode(uiSourceCode) { | 150 static targetForUISourceCode(uiSourceCode) { |
145 return uiSourceCode[Bindings.NetworkProject._targetSymbol] || null; | 151 return uiSourceCode.project()[Bindings.NetworkProject._targetSymbol] || null
; |
146 } | 152 } |
147 | 153 |
148 /** | 154 /** |
149 * @param {!Workspace.UISourceCode} uiSourceCode | 155 * @param {!Workspace.UISourceCode} uiSourceCode |
150 * @return {string} | 156 * @return {string} |
151 */ | 157 */ |
152 static uiSourceCodeMimeType(uiSourceCode) { | 158 static uiSourceCodeMimeType(uiSourceCode) { |
153 if (uiSourceCode[Bindings.NetworkProject._scriptSymbol] || uiSourceCode[Bind
ings.NetworkProject._styleSheetSymbol]) | 159 if (uiSourceCode[Bindings.NetworkProject._useExplicitMimeType]) |
154 return uiSourceCode.contentType().canonicalMimeType(); | 160 return uiSourceCode.contentType().canonicalMimeType(); |
155 | 161 |
156 var resource = uiSourceCode[Bindings.NetworkProject._resourceSymbol]; | 162 var resource = uiSourceCode[Bindings.NetworkProject._resourceSymbol]; |
157 if (resource) | 163 if (resource) |
158 return resource.mimeType; | 164 return resource.mimeType; |
159 var mimeType = Common.ResourceType.mimeFromURL(uiSourceCode.url()); | 165 var mimeType = Common.ResourceType.mimeFromURL(uiSourceCode.url()); |
160 return mimeType || uiSourceCode.contentType().canonicalMimeType(); | 166 return mimeType || uiSourceCode.contentType().canonicalMimeType(); |
161 } | 167 } |
162 | 168 |
163 /** | 169 /** |
164 * @param {?SDK.ResourceTreeFrame} frame | 170 * @param {?SDK.ResourceTreeFrame} frame |
165 * @param {boolean} isContentScripts | 171 * @param {boolean} isContentScripts |
166 * @return {!Bindings.ContentProviderBasedProject} | 172 * @return {!Bindings.ContentProviderBasedProject} |
167 */ | 173 */ |
168 _workspaceProject(frame, isContentScripts) { | 174 _workspaceProject(frame, isContentScripts) { |
169 var projectId = Bindings.NetworkProject.projectId(this.target(), frame, isCo
ntentScripts); | 175 var projectId = Bindings.NetworkProject.projectId(this.target(), frame, isCo
ntentScripts); |
170 var projectType = isContentScripts ? Workspace.projectTypes.ContentScripts :
Workspace.projectTypes.Network; | 176 var projectType = isContentScripts ? Workspace.projectTypes.ContentScripts :
Workspace.projectTypes.Network; |
171 | 177 |
172 var project = this._workspaceProjects.get(projectId); | 178 var project = this._workspaceProjects.get(projectId); |
173 if (project) | 179 if (project) |
174 return project; | 180 return project; |
175 | 181 |
176 project = new Bindings.ContentProviderBasedProject( | 182 project = new Bindings.ContentProviderBasedProject( |
177 this._workspace, projectId, projectType, '', false /* isServiceProject *
/); | 183 this._workspace, projectId, projectType, '', false /* isServiceProject *
/); |
178 project[Bindings.NetworkProject._targetSymbol] = this.target(); | 184 project[Bindings.NetworkProject._targetSymbol] = this.target(); |
179 project[Bindings.NetworkProject._frameSymbol] = frame; | |
180 this._workspaceProjects.set(projectId, project); | 185 this._workspaceProjects.set(projectId, project); |
181 return project; | 186 return project; |
182 } | 187 } |
183 | 188 |
184 /** | 189 /** |
| 190 * @param {!Workspace.Project} project |
| 191 * @param {!SDK.Target} target |
| 192 */ |
| 193 static connectProjectToTarget(project, target) { |
| 194 project[Bindings.NetworkProject._targetSymbol] = target; |
| 195 } |
| 196 |
| 197 /** |
| 198 * @param {!Workspace.UISourceCode} uiSourceCode |
| 199 * @param {!SDK.ResourceTreeFrame} frame |
| 200 */ |
| 201 static connectFrameToUISourceCode(uiSourceCode, frame) { |
| 202 var frames = uiSourceCode[Bindings.NetworkProject._frameSymbol]; |
| 203 if (!frames) { |
| 204 frames = []; |
| 205 uiSourceCode[Bindings.NetworkProject._frameSymbol] = frames; |
| 206 } |
| 207 frames.push(frame); |
| 208 Bindings.networkProjectManager.emit(new Bindings.NetworkProjectManager.Frame
AttributionChangedEvent(uiSourceCode)); |
| 209 } |
| 210 |
| 211 /** |
| 212 * @param {!Workspace.UISourceCode} uiSourceCode |
| 213 * @param {!SDK.ResourceTreeFrame} frame |
| 214 */ |
| 215 static disconnectFrameFromUISourceCode(uiSourceCode, frame) { |
| 216 var frames = uiSourceCode[Bindings.NetworkProject._frameSymbol]; |
| 217 var frameIndex = frames.indexOf(frame); |
| 218 if (frameIndex === -1) |
| 219 return; |
| 220 frames.splice(frameIndex, 1); |
| 221 if (!frames.length) |
| 222 uiSourceCode[Bindings.NetworkProject._frameSymbol] = null; |
| 223 Bindings.networkProjectManager.emit(new Bindings.NetworkProjectManager.Frame
AttributionChangedEvent(uiSourceCode)); |
| 224 } |
| 225 |
| 226 /** |
| 227 * @param {!Workspace.UISourceCode} uiSourceCode |
| 228 */ |
| 229 static useExplicitMimeType(uiSourceCode) { |
| 230 uiSourceCode[Bindings.NetworkProject._useExplicitMimeType] = true; |
| 231 } |
| 232 |
| 233 /** |
185 * @param {!Common.ContentProvider} contentProvider | 234 * @param {!Common.ContentProvider} contentProvider |
186 * @param {?SDK.ResourceTreeFrame} frame | 235 * @param {?SDK.ResourceTreeFrame} frame |
187 * @param {boolean} isContentScript | 236 * @param {boolean} isContentScript |
188 * @param {?number} contentSize | 237 * @param {?number} contentSize |
189 * @return {!Workspace.UISourceCode} | 238 * @return {!Workspace.UISourceCode} |
190 */ | 239 */ |
191 addFile(contentProvider, frame, isContentScript, contentSize) { | 240 addFile(contentProvider, frame, isContentScript, contentSize) { |
192 var uiSourceCode = this._createFile(contentProvider, frame, isContentScript
|| false); | 241 var uiSourceCode = this._createFile(contentProvider, frame, isContentScript
|| false); |
193 var metadata = typeof contentSize === 'number' ? new Workspace.UISourceCodeM
etadata(null, contentSize) : null; | 242 var metadata = typeof contentSize === 'number' ? new Workspace.UISourceCodeM
etadata(null, contentSize) : null; |
194 this._addUISourceCodeWithProvider(uiSourceCode, contentProvider, metadata); | 243 this._addUISourceCodeWithProvider(uiSourceCode, contentProvider, metadata); |
195 return uiSourceCode; | 244 return uiSourceCode; |
196 } | 245 } |
197 | 246 |
198 /** | |
199 * @param {?SDK.ResourceTreeFrame} frame | |
200 * @param {string} url | |
201 */ | |
202 _removeFileForURL(frame, url) { | |
203 var project = this._workspaceProjects.get(Bindings.NetworkProject.projectId(
this.target(), frame, false)); | |
204 if (!project) | |
205 return; | |
206 project.removeFile(url); | |
207 } | |
208 | |
209 _populate() { | 247 _populate() { |
210 /** | 248 /** |
211 * @param {!SDK.ResourceTreeFrame} frame | 249 * @param {!SDK.ResourceTreeFrame} frame |
212 * @this {Bindings.NetworkProject} | 250 * @this {Bindings.NetworkProject} |
213 */ | 251 */ |
214 function populateFrame(frame) { | 252 function populateFrame(frame) { |
215 for (var i = 0; i < frame.childFrames.length; ++i) | 253 for (var i = 0; i < frame.childFrames.length; ++i) |
216 populateFrame.call(this, frame.childFrames[i]); | 254 populateFrame.call(this, frame.childFrames[i]); |
217 | 255 |
218 var resources = frame.resources(); | 256 var resources = frame.resources(); |
(...skipping 24 matching lines...) Expand all Loading... |
243 var script = /** @type {!SDK.Script} */ (event.data); | 281 var script = /** @type {!SDK.Script} */ (event.data); |
244 if (!script.sourceURL || script.isLiveEdit() || (script.isInlineScript() &&
!script.hasSourceURL)) | 282 if (!script.sourceURL || script.isLiveEdit() || (script.isInlineScript() &&
!script.hasSourceURL)) |
245 return; | 283 return; |
246 // Filter out embedder injected content scripts. | 284 // Filter out embedder injected content scripts. |
247 if (script.isContentScript() && !script.hasSourceURL) { | 285 if (script.isContentScript() && !script.hasSourceURL) { |
248 var parsedURL = new Common.ParsedURL(script.sourceURL); | 286 var parsedURL = new Common.ParsedURL(script.sourceURL); |
249 if (!parsedURL.isValid) | 287 if (!parsedURL.isValid) |
250 return; | 288 return; |
251 } | 289 } |
252 var uiSourceCode = this._createFile(script, SDK.ResourceTreeFrame.fromScript
(script), script.isContentScript()); | 290 var uiSourceCode = this._createFile(script, SDK.ResourceTreeFrame.fromScript
(script), script.isContentScript()); |
253 uiSourceCode[Bindings.NetworkProject._scriptSymbol] = script; | 291 uiSourceCode[Bindings.NetworkProject._useExplicitMimeType] = true; |
254 var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url()); | 292 var frame = SDK.ResourceTreeFrame.fromScript(script); |
255 this._addUISourceCodeWithProvider(uiSourceCode, script, this._resourceMetada
ta(resource)); | 293 var metadata = frame ? Bindings.resourceMetadata(frame.resourceForURL(uiSour
ceCode.url())) : null; |
| 294 this._addUISourceCodeWithProvider(uiSourceCode, script, metadata); |
256 } | 295 } |
257 | 296 |
258 /** | 297 /** |
259 * @param {!Common.Event} event | |
260 */ | |
261 _styleSheetAdded(event) { | |
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(); | |
269 var uiSourceCode = this._createFile(originalContentProvider, SDK.ResourceTre
eFrame.fromStyleSheet(header), false); | |
270 uiSourceCode[Bindings.NetworkProject._styleSheetSymbol] = header; | |
271 var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url()); | |
272 this._addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, thi
s._resourceMetadata(resource)); | |
273 } | |
274 | |
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 | 298 * @param {!Common.Event} event |
288 */ | 299 */ |
289 _resourceAdded(event) { | 300 _resourceAdded(event) { |
290 var resource = /** @type {!SDK.Resource} */ (event.data); | 301 var resource = /** @type {!SDK.Resource} */ (event.data); |
291 this._addResource(resource); | 302 this._addResource(resource); |
292 } | 303 } |
293 | 304 |
294 /** | 305 /** |
295 * @param {!SDK.Resource} resource | 306 * @param {!SDK.Resource} resource |
296 */ | 307 */ |
(...skipping 13 matching lines...) Expand all Loading... |
310 if ((resourceType === Common.resourceTypes.Image || resourceType === Common.
resourceTypes.Font) && | 321 if ((resourceType === Common.resourceTypes.Image || resourceType === Common.
resourceTypes.Font) && |
311 resource.contentURL().startsWith('data:')) | 322 resource.contentURL().startsWith('data:')) |
312 return; | 323 return; |
313 | 324 |
314 // Never load document twice. | 325 // Never load document twice. |
315 if (this._workspace.uiSourceCodeForURL(resource.url)) | 326 if (this._workspace.uiSourceCodeForURL(resource.url)) |
316 return; | 327 return; |
317 | 328 |
318 var uiSourceCode = this._createFile(resource, SDK.ResourceTreeFrame.fromReso
urce(resource), false); | 329 var uiSourceCode = this._createFile(resource, SDK.ResourceTreeFrame.fromReso
urce(resource), false); |
319 uiSourceCode[Bindings.NetworkProject._resourceSymbol] = resource; | 330 uiSourceCode[Bindings.NetworkProject._resourceSymbol] = resource; |
320 this._addUISourceCodeWithProvider(uiSourceCode, resource, this._resourceMeta
data(resource)); | 331 this._addUISourceCodeWithProvider(uiSourceCode, resource, Bindings.resourceM
etadata(resource)); |
321 } | 332 } |
322 | 333 |
323 /** | 334 /** |
324 * @param {!Common.Event} event | 335 * @param {!Common.Event} event |
325 */ | 336 */ |
326 _frameWillNavigate(event) { | 337 _frameWillNavigate(event) { |
327 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data); | 338 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data); |
328 var project = this._workspaceProject(frame, false); | 339 var project = this._workspaceProject(frame, false); |
329 for (var resource of frame.resources()) | 340 for (var resource of frame.resources()) |
330 project.removeUISourceCode(resource.url); | 341 project.removeUISourceCode(resource.url); |
(...skipping 20 matching lines...) Expand all Loading... |
351 /** | 362 /** |
352 * @param {!Common.ContentProvider} contentProvider | 363 * @param {!Common.ContentProvider} contentProvider |
353 * @param {?SDK.ResourceTreeFrame} frame | 364 * @param {?SDK.ResourceTreeFrame} frame |
354 * @param {boolean} isContentScript | 365 * @param {boolean} isContentScript |
355 * @return {!Workspace.UISourceCode} | 366 * @return {!Workspace.UISourceCode} |
356 */ | 367 */ |
357 _createFile(contentProvider, frame, isContentScript) { | 368 _createFile(contentProvider, frame, isContentScript) { |
358 var url = contentProvider.contentURL(); | 369 var url = contentProvider.contentURL(); |
359 var project = this._workspaceProject(frame, isContentScript); | 370 var project = this._workspaceProject(frame, isContentScript); |
360 var uiSourceCode = project.createUISourceCode(url, contentProvider.contentTy
pe()); | 371 var uiSourceCode = project.createUISourceCode(url, contentProvider.contentTy
pe()); |
361 uiSourceCode[Bindings.NetworkProject._targetSymbol] = this.target(); | 372 uiSourceCode[Bindings.NetworkProject._frameSymbol] = [frame]; |
362 return uiSourceCode; | 373 return uiSourceCode; |
363 } | 374 } |
364 | 375 |
365 /** | |
366 * @param {?SDK.Resource} resource | |
367 * @return {?Workspace.UISourceCodeMetadata} | |
368 */ | |
369 _resourceMetadata(resource) { | |
370 if (!resource || (typeof resource.contentSize() !== 'number' && !resource.la
stModified())) | |
371 return null; | |
372 return new Workspace.UISourceCodeMetadata(resource.lastModified(), resource.
contentSize()); | |
373 } | |
374 | |
375 _dispose() { | 376 _dispose() { |
376 this._reset(); | 377 this._reset(); |
377 Common.EventTarget.removeEventListeners(this._eventListeners); | 378 Common.EventTarget.removeEventListeners(this._eventListeners); |
378 delete this.target()[Bindings.NetworkProject._networkProjectSymbol]; | 379 delete this.target()[Bindings.NetworkProject._networkProjectSymbol]; |
379 } | 380 } |
380 | 381 |
381 _reset() { | 382 _reset() { |
382 for (var project of this._workspaceProjects.values()) | 383 for (var project of this._workspaceProjects.values()) |
383 project.removeProject(); | 384 project.removeProject(); |
384 this._workspaceProjects.clear(); | 385 this._workspaceProjects.clear(); |
(...skipping 19 matching lines...) Expand all Loading... |
404 * @return {?Workspace.UISourceCode} | 405 * @return {?Workspace.UISourceCode} |
405 */ | 406 */ |
406 static uiSourceCodeForStyleURL(workspace, url, header) { | 407 static uiSourceCodeForStyleURL(workspace, url, header) { |
407 var frame = SDK.ResourceTreeFrame.fromStyleSheet(header); | 408 var frame = SDK.ResourceTreeFrame.fromStyleSheet(header); |
408 return workspace.uiSourceCode(Bindings.NetworkProject.projectId(header.targe
t(), frame, false), url); | 409 return workspace.uiSourceCode(Bindings.NetworkProject.projectId(header.targe
t(), frame, false), url); |
409 } | 410 } |
410 }; | 411 }; |
411 | 412 |
412 Bindings.NetworkProject._networkProjectSymbol = Symbol('networkProject'); | 413 Bindings.NetworkProject._networkProjectSymbol = Symbol('networkProject'); |
413 Bindings.NetworkProject._resourceSymbol = Symbol('resource'); | 414 Bindings.NetworkProject._resourceSymbol = Symbol('resource'); |
414 Bindings.NetworkProject._scriptSymbol = Symbol('script'); | 415 Bindings.NetworkProject._useExplicitMimeType = Symbol('useExplicitMimeType'); |
415 Bindings.NetworkProject._styleSheetSymbol = Symbol('styleSheet'); | |
416 Bindings.NetworkProject._targetSymbol = Symbol('target'); | 416 Bindings.NetworkProject._targetSymbol = Symbol('target'); |
417 Bindings.NetworkProject._frameSymbol = Symbol('frame'); | 417 Bindings.NetworkProject._frameSymbol = Symbol('frame'); |
OLD | NEW |