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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 this._addFile(header.resourceURL(), header, false); | 94 this._addFile(header.resourceURL(), header, false); |
95 }, | 95 }, |
96 | 96 |
97 /** | 97 /** |
98 * @param {!WebInspector.Event|!{data: !WebInspector.Resource}} event | 98 * @param {!WebInspector.Event|!{data: !WebInspector.Resource}} event |
99 */ | 99 */ |
100 _resourceAdded: function(event) | 100 _resourceAdded: function(event) |
101 { | 101 { |
102 var resource = /** @type {!WebInspector.Resource} */ (event.data); | 102 var resource = /** @type {!WebInspector.Resource} */ (event.data); |
103 this._addFile(resource.url, resource); | 103 this._addFile(resource.url, new WebInspector.NetworkUISourceCodeProvider
.FallbackResource(resource)); |
104 }, | 104 }, |
105 | 105 |
106 /** | 106 /** |
107 * @param {!WebInspector.Event} event | 107 * @param {!WebInspector.Event} event |
108 */ | 108 */ |
109 _mainFrameNavigated: function(event) | 109 _mainFrameNavigated: function(event) |
110 { | 110 { |
111 this._reset(); | 111 this._reset(); |
112 }, | 112 }, |
113 | 113 |
(...skipping 19 matching lines...) Expand all Loading... |
133 | 133 |
134 _reset: function() | 134 _reset: function() |
135 { | 135 { |
136 this._processedURLs = {}; | 136 this._processedURLs = {}; |
137 this._networkWorkspaceProvider.reset(); | 137 this._networkWorkspaceProvider.reset(); |
138 this._populate(); | 138 this._populate(); |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 /** | 142 /** |
| 143 * @constructor |
| 144 * @implements {WebInspector.ContentProvider} |
| 145 * @param {!WebInspector.Resource} resource |
| 146 */ |
| 147 WebInspector.NetworkUISourceCodeProvider.FallbackResource = function(resource) |
| 148 { |
| 149 this._resource = resource; |
| 150 } |
| 151 |
| 152 WebInspector.NetworkUISourceCodeProvider.FallbackResource.prototype = { |
| 153 |
| 154 /** |
| 155 * @return {string} |
| 156 */ |
| 157 contentURL: function() |
| 158 { |
| 159 return this._resource.contentURL(); |
| 160 }, |
| 161 |
| 162 /** |
| 163 * @return {!WebInspector.ResourceType} |
| 164 */ |
| 165 contentType: function() |
| 166 { |
| 167 return this._resource.contentType(); |
| 168 }, |
| 169 |
| 170 /** |
| 171 * @param {function(?string)} callback |
| 172 */ |
| 173 requestContent: function(callback) |
| 174 { |
| 175 /** |
| 176 * @this {WebInspector.NetworkUISourceCodeProvider.FallbackResource} |
| 177 */ |
| 178 function loadFallbackContent() |
| 179 { |
| 180 var scripts = WebInspector.debuggerModel.scriptsForSourceURL(this._r
esource.url); |
| 181 if (!scripts.length) { |
| 182 callback(null); |
| 183 return; |
| 184 } |
| 185 |
| 186 var contentProvider; |
| 187 if (this._resource.type === WebInspector.resourceTypes.Document) |
| 188 contentProvider = new WebInspector.ConcatenatedScriptsContentPro
vider(scripts); |
| 189 else if (this._resource.type === WebInspector.resourceTypes.Script) |
| 190 contentProvider = scripts[0]; |
| 191 |
| 192 console.assert(contentProvider, "Resource content request failed. "
+ this._resource.url); |
| 193 |
| 194 contentProvider.requestContent(callback); |
| 195 } |
| 196 |
| 197 /** |
| 198 * @param {?string} content |
| 199 * @this {WebInspector.NetworkUISourceCodeProvider.FallbackResource} |
| 200 */ |
| 201 function requestContentLoaded(content) |
| 202 { |
| 203 if (content) |
| 204 callback(content) |
| 205 else |
| 206 loadFallbackContent.call(this); |
| 207 } |
| 208 |
| 209 this._resource.requestContent(requestContentLoaded.bind(this)); |
| 210 }, |
| 211 |
| 212 /** |
| 213 * @param {string} query |
| 214 * @param {boolean} caseSensitive |
| 215 * @param {boolean} isRegex |
| 216 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal
lback |
| 217 */ |
| 218 searchInContent: function(query, caseSensitive, isRegex, callback) |
| 219 { |
| 220 /** |
| 221 * @param {?string} content |
| 222 */ |
| 223 function documentContentLoaded(content) |
| 224 { |
| 225 if (content === null) { |
| 226 callback([]); |
| 227 return; |
| 228 } |
| 229 |
| 230 var result = WebInspector.ContentProvider.performSearchInContent(con
tent, query, caseSensitive, isRegex); |
| 231 callback(result); |
| 232 } |
| 233 |
| 234 if (this.contentType() === WebInspector.resourceTypes.Document) { |
| 235 this.requestContent(documentContentLoaded); |
| 236 return; |
| 237 } |
| 238 |
| 239 this._resource.searchInContent(query, caseSensitive, isRegex, callback); |
| 240 } |
| 241 } |
| 242 |
| 243 /** |
143 * @type {!WebInspector.SimpleWorkspaceProvider} | 244 * @type {!WebInspector.SimpleWorkspaceProvider} |
144 */ | 245 */ |
145 WebInspector.networkWorkspaceProvider; | 246 WebInspector.networkWorkspaceProvider; |
OLD | NEW |