| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 * @constructor | 110 * @constructor |
| 111 * @param {!WebInspector.TargetManager} targetManager | 111 * @param {!WebInspector.TargetManager} targetManager |
| 112 * @param {!WebInspector.Workspace} workspace | 112 * @param {!WebInspector.Workspace} workspace |
| 113 * @param {!WebInspector.NetworkMapping} networkMapping | 113 * @param {!WebInspector.NetworkMapping} networkMapping |
| 114 * @implements {WebInspector.TargetManager.Observer} | 114 * @implements {WebInspector.TargetManager.Observer} |
| 115 */ | 115 */ |
| 116 WebInspector.NetworkProjectManager = function(targetManager, workspace, networkM
apping) | 116 WebInspector.NetworkProjectManager = function(targetManager, workspace, networkM
apping) |
| 117 { | 117 { |
| 118 this._workspace = workspace; | 118 this._workspace = workspace; |
| 119 this._networkMapping = networkMapping; | 119 this._networkMapping = networkMapping; |
| 120 this._projectSymbol = Symbol("networkProject"); | |
| 121 targetManager.observeTargets(this); | 120 targetManager.observeTargets(this); |
| 122 } | 121 } |
| 123 | 122 |
| 124 WebInspector.NetworkProjectManager.prototype = { | 123 WebInspector.NetworkProjectManager.prototype = { |
| 125 /** | 124 /** |
| 126 * @override | 125 * @override |
| 127 * @param {!WebInspector.Target} target | 126 * @param {!WebInspector.Target} target |
| 128 */ | 127 */ |
| 129 targetAdded: function(target) | 128 targetAdded: function(target) |
| 130 { | 129 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedT
oParseScriptSource, this._parsedScriptSource, this); | 165 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedT
oParseScriptSource, this._parsedScriptSource, this); |
| 167 } | 166 } |
| 168 var cssModel = WebInspector.CSSStyleModel.fromTarget(target); | 167 var cssModel = WebInspector.CSSStyleModel.fromTarget(target); |
| 169 if (cssModel) { | 168 if (cssModel) { |
| 170 cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetAd
ded, this._styleSheetAdded, this); | 169 cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetAd
ded, this._styleSheetAdded, this); |
| 171 cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetRe
moved, this._styleSheetRemoved, this); | 170 cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetRe
moved, this._styleSheetRemoved, this); |
| 172 } | 171 } |
| 173 } | 172 } |
| 174 | 173 |
| 175 WebInspector.NetworkProject._networkProjectSymbol = Symbol("networkProject"); | 174 WebInspector.NetworkProject._networkProjectSymbol = Symbol("networkProject"); |
| 176 WebInspector.NetworkProject._targetSymbol = Symbol("target"); | |
| 177 WebInspector.NetworkProject._contentTypeSymbol = Symbol("networkContentType"); | 175 WebInspector.NetworkProject._contentTypeSymbol = Symbol("networkContentType"); |
| 178 | 176 |
| 179 /** | 177 /** |
| 180 * @param {!WebInspector.Target} target | 178 * @param {!WebInspector.Target} target |
| 181 * @param {string} projectURL | 179 * @param {string} projectURL |
| 182 * @param {boolean} isContentScripts | 180 * @param {boolean} isContentScripts |
| 183 * @return {string} | 181 * @return {string} |
| 184 */ | 182 */ |
| 185 WebInspector.NetworkProject.projectId = function(target, projectURL, isContentSc
ripts) | 183 WebInspector.NetworkProject.projectId = function(target, projectURL, isContentSc
ripts) |
| 186 { | 184 { |
| 187 return target.id() + ":" + (isContentScripts ? "contentscripts:" : "") + pro
jectURL; | 185 return target.id() + ":" + (isContentScripts ? "contentscripts:" : "") + pro
jectURL; |
| 188 } | 186 } |
| 189 | 187 |
| 190 /** | 188 /** |
| 189 * @param {!WebInspector.Project} project |
| 190 * @return {?WebInspector.Target} |
| 191 */ |
| 192 WebInspector.NetworkProject._targetForProject = function(project) |
| 193 { |
| 194 var targetId = parseInt(project.id(), 10); |
| 195 return WebInspector.targetManager.targetById(targetId); |
| 196 } |
| 197 |
| 198 /** |
| 191 * @param {!WebInspector.Target} target | 199 * @param {!WebInspector.Target} target |
| 192 * @return {!WebInspector.NetworkProject} | 200 * @return {!WebInspector.NetworkProject} |
| 193 */ | 201 */ |
| 194 WebInspector.NetworkProject.forTarget = function(target) | 202 WebInspector.NetworkProject.forTarget = function(target) |
| 195 { | 203 { |
| 196 return target[WebInspector.NetworkProject._networkProjectSymbol]; | 204 return target[WebInspector.NetworkProject._networkProjectSymbol]; |
| 197 } | 205 } |
| 198 | 206 |
| 199 /** | 207 /** |
| 200 * @param {!WebInspector.UISourceCode} uiSourceCode | 208 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 201 * @return {?WebInspector.Target} target | 209 * @return {?WebInspector.Target} target |
| 202 */ | 210 */ |
| 203 WebInspector.NetworkProject.targetForUISourceCode = function(uiSourceCode) | 211 WebInspector.NetworkProject.targetForUISourceCode = function(uiSourceCode) |
| 204 { | 212 { |
| 205 return uiSourceCode[WebInspector.NetworkProject._targetSymbol]; | 213 if (uiSourceCode.project().type() !== WebInspector.projectTypes.ContentScrip
ts && uiSourceCode.project().type() !== WebInspector.projectTypes.Network) |
| 214 return null; |
| 215 |
| 216 return WebInspector.NetworkProject._targetForProject(uiSourceCode.project())
; |
| 206 } | 217 } |
| 207 | 218 |
| 208 /** | 219 /** |
| 209 * @param {!WebInspector.UISourceCode} uiSourceCode | 220 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 210 * @return {(!WebInspector.ResourceType|undefined)} | 221 * @return {(!WebInspector.ResourceType|undefined)} |
| 211 */ | 222 */ |
| 212 WebInspector.NetworkProject.uiSourceCodeContentType = function(uiSourceCode) | 223 WebInspector.NetworkProject.uiSourceCodeContentType = function(uiSourceCode) |
| 213 { | 224 { |
| 214 return uiSourceCode[WebInspector.NetworkProject._contentTypeSymbol]; | 225 return uiSourceCode[WebInspector.NetworkProject._contentTypeSymbol]; |
| 215 } | 226 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 240 */ | 251 */ |
| 241 addFileForURL: function(url, contentProvider, isContentScript) | 252 addFileForURL: function(url, contentProvider, isContentScript) |
| 242 { | 253 { |
| 243 var splitURL = WebInspector.ParsedURL.splitURLIntoPathComponents(url); | 254 var splitURL = WebInspector.ParsedURL.splitURLIntoPathComponents(url); |
| 244 var projectURL = splitURL[0]; | 255 var projectURL = splitURL[0]; |
| 245 var parentPath = splitURL.slice(1, -1).join("/"); | 256 var parentPath = splitURL.slice(1, -1).join("/"); |
| 246 var name = splitURL.peekLast() || ""; | 257 var name = splitURL.peekLast() || ""; |
| 247 var projectDelegate = this._projectDelegate(projectURL, isContentScript
|| false); | 258 var projectDelegate = this._projectDelegate(projectURL, isContentScript
|| false); |
| 248 var path = projectDelegate.addFile(parentPath, name, url, contentProvide
r); | 259 var path = projectDelegate.addFile(parentPath, name, url, contentProvide
r); |
| 249 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (this._work
space.uiSourceCode(projectDelegate.id(), path)); | 260 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (this._work
space.uiSourceCode(projectDelegate.id(), path)); |
| 250 uiSourceCode[WebInspector.NetworkProject._targetSymbol] = this.target(); | |
| 251 console.assert(uiSourceCode); | 261 console.assert(uiSourceCode); |
| 252 return uiSourceCode; | 262 return uiSourceCode; |
| 253 }, | 263 }, |
| 254 | 264 |
| 255 /** | 265 /** |
| 256 * @param {string} url | 266 * @param {string} url |
| 257 */ | 267 */ |
| 258 _removeFileForURL: function(url) | 268 _removeFileForURL: function(url) |
| 259 { | 269 { |
| 260 var splitURL = WebInspector.ParsedURL.splitURLIntoPathComponents(url); | 270 var splitURL = WebInspector.ParsedURL.splitURLIntoPathComponents(url); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 } | 517 } |
| 508 | 518 |
| 509 if (this.contentType() === WebInspector.resourceTypes.Document) { | 519 if (this.contentType() === WebInspector.resourceTypes.Document) { |
| 510 this.requestContent(documentContentLoaded); | 520 this.requestContent(documentContentLoaded); |
| 511 return; | 521 return; |
| 512 } | 522 } |
| 513 | 523 |
| 514 this._resource.searchInContent(query, caseSensitive, isRegex, callback); | 524 this._resource.searchInContent(query, caseSensitive, isRegex, callback); |
| 515 } | 525 } |
| 516 } | 526 } |
| OLD | NEW |