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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 */ | 59 */ |
| 60 targetRemoved: function(target) | 60 targetRemoved: function(target) |
| 61 { | 61 { |
| 62 // FIXME: add workspace cleanup here. | 62 // FIXME: add workspace cleanup here. |
| 63 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo del.EventTypes.ResourceAdded, this._resourceAdded, this); | 63 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo del.EventTypes.ResourceAdded, this._resourceAdded, this); |
| 64 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo del.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this); | 64 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeMo del.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this); |
| 65 target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Even ts.ParsedScriptSource, this._parsedScriptSource, this); | 65 target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Even ts.ParsedScriptSource, this._parsedScriptSource, this); |
| 66 target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.St yleSheetAdded, this._styleSheetAdded, this); | 66 target.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.St yleSheetAdded, this._styleSheetAdded, this); |
| 67 }, | 67 }, |
| 68 | 68 |
| 69 _populate: function() | 69 /** |
| 70 * @param {!WebInspector.Target} target | |
| 71 */ | |
| 72 _populate: function(target) | |
| 70 { | 73 { |
| 71 /** | 74 /** |
| 72 * @param {!WebInspector.ResourceTreeFrame} frame | 75 * @param {!WebInspector.ResourceTreeFrame} frame |
| 73 * @this {WebInspector.NetworkUISourceCodeProvider} | 76 * @this {WebInspector.NetworkUISourceCodeProvider} |
| 74 */ | 77 */ |
| 75 function populateFrame(frame) | 78 function populateFrame(frame) |
| 76 { | 79 { |
| 77 for (var i = 0; i < frame.childFrames.length; ++i) | 80 for (var i = 0; i < frame.childFrames.length; ++i) |
| 78 populateFrame.call(this, frame.childFrames[i]); | 81 populateFrame.call(this, frame.childFrames[i]); |
| 79 | 82 |
| 80 var resources = frame.resources(); | 83 var resources = frame.resources(); |
| 81 for (var i = 0; i < resources.length; ++i) | 84 for (var i = 0; i < resources.length; ++i) |
| 82 this._resourceAdded({data:resources[i]}); | 85 this._addFile(resources[i].url, new WebInspector.NetworkUISource CodeProvider.FallbackResource(target, resources[i])); |
| 83 } | 86 } |
| 84 | 87 |
| 85 populateFrame.call(this, WebInspector.resourceTreeModel.mainFrame); | 88 var mainFrame = target.resourceTreeModel.mainFrame; |
| 89 if (mainFrame) | |
| 90 populateFrame.call(this, mainFrame); | |
| 86 }, | 91 }, |
| 87 | 92 |
| 88 /** | 93 /** |
| 89 * @param {!WebInspector.Event} event | 94 * @param {!WebInspector.Event} event |
| 90 */ | 95 */ |
| 91 _parsedScriptSource: function(event) | 96 _parsedScriptSource: function(event) |
| 92 { | 97 { |
| 93 var script = /** @type {!WebInspector.Script} */ (event.data); | 98 var script = /** @type {!WebInspector.Script} */ (event.data); |
| 94 if (!script.sourceURL || script.isInlineScript() || script.isSnippet()) | 99 if (!script.sourceURL || script.isInlineScript() || script.isSnippet()) |
| 95 return; | 100 return; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 108 _styleSheetAdded: function(event) | 113 _styleSheetAdded: function(event) |
| 109 { | 114 { |
| 110 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat a); | 115 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat a); |
| 111 if ((!header.hasSourceURL || header.isInline) && header.origin !== "insp ector") | 116 if ((!header.hasSourceURL || header.isInline) && header.origin !== "insp ector") |
| 112 return; | 117 return; |
| 113 | 118 |
| 114 this._addFile(header.resourceURL(), header, false); | 119 this._addFile(header.resourceURL(), header, false); |
| 115 }, | 120 }, |
| 116 | 121 |
| 117 /** | 122 /** |
| 118 * @param {!WebInspector.Event|!{data: !WebInspector.Resource}} event | 123 * @param {!WebInspector.Event} event |
| 119 */ | 124 */ |
| 120 _resourceAdded: function(event) | 125 _resourceAdded: function(event) |
| 121 { | 126 { |
| 122 var resource = /** @type {!WebInspector.Resource} */ (event.data); | 127 var resource = /** @type {!WebInspector.Resource} */ (event.data); |
| 123 this._addFile(resource.url, new WebInspector.NetworkUISourceCodeProvider .FallbackResource(resource)); | 128 var target = /** @type {!WebInspector.Target} */ (event.target.target()) ; |
| 129 this._addFile(resource.url, new WebInspector.NetworkUISourceCodeProvider .FallbackResource(target, resource)); | |
| 124 }, | 130 }, |
| 125 | 131 |
| 126 /** | 132 /** |
| 127 * @param {!WebInspector.Event} event | 133 * @param {!WebInspector.Event} event |
| 128 */ | 134 */ |
| 129 _mainFrameNavigated: function(event) | 135 _mainFrameNavigated: function(event) |
| 130 { | 136 { |
| 131 this._reset(); | 137 var target = /** @type {!WebInspector.Target} */ (event.target.target()) ; |
|
vsevik
2014/06/26 13:11:33
please cast event.target instead, otherwise it's n
sergeyv
2014/06/26 14:55:59
Done.
| |
| 138 //We assume that mainFrameNavigated could be fired only in one main targ et | |
| 139 this._reset(target); | |
| 132 }, | 140 }, |
| 133 | 141 |
| 134 /** | 142 /** |
| 135 * @param {string} url | 143 * @param {string} url |
| 136 * @param {!WebInspector.ContentProvider} contentProvider | 144 * @param {!WebInspector.ContentProvider} contentProvider |
| 137 * @param {boolean=} isContentScript | 145 * @param {boolean=} isContentScript |
| 138 */ | 146 */ |
| 139 _addFile: function(url, contentProvider, isContentScript) | 147 _addFile: function(url, contentProvider, isContentScript) |
| 140 { | 148 { |
| 141 if (this._workspace.hasMappingForURL(url)) | 149 if (this._workspace.hasMappingForURL(url)) |
| 142 return; | 150 return; |
| 143 | 151 |
| 144 var type = contentProvider.contentType(); | 152 var type = contentProvider.contentType(); |
| 145 if (type !== WebInspector.resourceTypes.Stylesheet && type !== WebInspec tor.resourceTypes.Document && type !== WebInspector.resourceTypes.Script) | 153 if (type !== WebInspector.resourceTypes.Stylesheet && type !== WebInspec tor.resourceTypes.Document && type !== WebInspector.resourceTypes.Script) |
| 146 return; | 154 return; |
| 147 if (this._processedURLs[url]) | 155 if (this._processedURLs[url]) |
| 148 return; | 156 return; |
| 149 this._processedURLs[url] = true; | 157 this._processedURLs[url] = true; |
| 150 this._networkWorkspaceBinding.addFileForURL(url, contentProvider, isCont entScript); | 158 this._networkWorkspaceBinding.addFileForURL(url, contentProvider, isCont entScript); |
| 151 }, | 159 }, |
| 152 | 160 |
| 153 _reset: function() | 161 /** |
| 162 * @param {!WebInspector.Target} target | |
| 163 */ | |
| 164 _reset: function(target) | |
| 154 { | 165 { |
| 155 this._processedURLs = {}; | 166 this._processedURLs = {}; |
| 156 this._networkWorkspaceBinding.reset(); | 167 this._networkWorkspaceBinding.reset(); |
| 157 this._populate(); | 168 this._populate(target); |
| 158 } | 169 } |
| 159 } | 170 } |
| 160 | 171 |
| 161 /** | 172 /** |
| 162 * @constructor | 173 * @constructor |
| 174 * @extends {WebInspector.TargetAware} | |
| 163 * @implements {WebInspector.ContentProvider} | 175 * @implements {WebInspector.ContentProvider} |
| 176 * @param {!WebInspector.Target} target | |
| 164 * @param {!WebInspector.Resource} resource | 177 * @param {!WebInspector.Resource} resource |
| 165 */ | 178 */ |
| 166 WebInspector.NetworkUISourceCodeProvider.FallbackResource = function(resource) | 179 WebInspector.NetworkUISourceCodeProvider.FallbackResource = function(target, res ource) |
|
vsevik
2014/06/26 13:11:33
Let's make Resource TargetAware instead.
sergeyv
2014/06/26 14:56:00
Done.
| |
| 167 { | 180 { |
| 181 WebInspector.TargetAware.call(this, target); | |
| 168 this._resource = resource; | 182 this._resource = resource; |
| 169 } | 183 } |
| 170 | 184 |
| 171 WebInspector.NetworkUISourceCodeProvider.FallbackResource.prototype = { | 185 WebInspector.NetworkUISourceCodeProvider.FallbackResource.prototype = { |
| 172 | 186 |
| 173 /** | 187 /** |
| 174 * @return {string} | 188 * @return {string} |
| 175 */ | 189 */ |
| 176 contentURL: function() | 190 contentURL: function() |
| 177 { | 191 { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 189 /** | 203 /** |
| 190 * @param {function(?string)} callback | 204 * @param {function(?string)} callback |
| 191 */ | 205 */ |
| 192 requestContent: function(callback) | 206 requestContent: function(callback) |
| 193 { | 207 { |
| 194 /** | 208 /** |
| 195 * @this {WebInspector.NetworkUISourceCodeProvider.FallbackResource} | 209 * @this {WebInspector.NetworkUISourceCodeProvider.FallbackResource} |
| 196 */ | 210 */ |
| 197 function loadFallbackContent() | 211 function loadFallbackContent() |
| 198 { | 212 { |
| 199 var scripts = WebInspector.debuggerModel.scriptsForSourceURL(this._r esource.url); | 213 var scripts = this.target().debuggerModel.scriptsForSourceURL(this._ resource.url); |
| 200 if (!scripts.length) { | 214 if (!scripts.length) { |
| 201 callback(null); | 215 callback(null); |
| 202 return; | 216 return; |
| 203 } | 217 } |
| 204 | 218 |
| 205 var contentProvider; | 219 var contentProvider; |
| 206 if (this._resource.type === WebInspector.resourceTypes.Document) | 220 if (this._resource.type === WebInspector.resourceTypes.Document) |
| 207 contentProvider = new WebInspector.ConcatenatedScriptsContentPro vider(scripts); | 221 contentProvider = new WebInspector.ConcatenatedScriptsContentPro vider(scripts); |
| 208 else if (this._resource.type === WebInspector.resourceTypes.Script) | 222 else if (this._resource.type === WebInspector.resourceTypes.Script) |
| 209 contentProvider = scripts[0]; | 223 contentProvider = scripts[0]; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 var result = WebInspector.ContentProvider.performSearchInContent(con tent, query, caseSensitive, isRegex); | 263 var result = WebInspector.ContentProvider.performSearchInContent(con tent, query, caseSensitive, isRegex); |
| 250 callback(result); | 264 callback(result); |
| 251 } | 265 } |
| 252 | 266 |
| 253 if (this.contentType() === WebInspector.resourceTypes.Document) { | 267 if (this.contentType() === WebInspector.resourceTypes.Document) { |
| 254 this.requestContent(documentContentLoaded); | 268 this.requestContent(documentContentLoaded); |
| 255 return; | 269 return; |
| 256 } | 270 } |
| 257 | 271 |
| 258 this._resource.searchInContent(query, caseSensitive, isRegex, callback); | 272 this._resource.searchInContent(query, caseSensitive, isRegex, callback); |
| 259 } | 273 }, |
| 274 | |
| 275 __proto__: WebInspector.TargetAware.prototype | |
| 260 } | 276 } |
| 261 | 277 |
| 262 /** | 278 /** |
| 263 * @type {!WebInspector.NetworkWorkspaceBinding} | 279 * @type {!WebInspector.NetworkWorkspaceBinding} |
| 264 */ | 280 */ |
| 265 WebInspector.networkWorkspaceBinding; | 281 WebInspector.networkWorkspaceBinding; |
| OLD | NEW |