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 if (!contentProvider) | |
193 console.assert(false, "Resource content request failed. " + this ._resource.url); | |
vsevik
2014/02/13 14:02:48
console.assert(contentProvider, "Resource content
sergeyv
2014/02/13 14:14:14
Done.
| |
194 | |
195 contentProvider.requestContent(callback); | |
196 } | |
197 | |
198 /** | |
199 * @param {?string} content | |
200 * @this {WebInspector.NetworkUISourceCodeProvider.FallbackResource} | |
201 */ | |
202 function requestContentLoaded(content) | |
203 { | |
204 if (content) | |
205 callback(content) | |
206 else | |
207 loadFallbackContent.call(this); | |
208 } | |
209 | |
210 this._resource.requestContent(requestContentLoaded.bind(this)); | |
211 }, | |
212 | |
213 /** | |
214 * @param {string} query | |
215 * @param {boolean} caseSensitive | |
216 * @param {boolean} isRegex | |
217 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal lback | |
218 */ | |
219 searchInContent: function(query, caseSensitive, isRegex, callback) | |
220 { | |
221 /** | |
222 * @param {?string} content | |
223 */ | |
224 function documentContentLoaded(content) | |
225 { | |
226 if (content === null) { | |
227 callback([]); | |
228 return; | |
229 } | |
230 | |
231 var result = WebInspector.ContentProvider.performSearchInContent(con tent, query, caseSensitive, isRegex); | |
232 callback(result); | |
233 } | |
234 | |
235 if (this.contentType() === WebInspector.resourceTypes.Document) { | |
236 this.requestContent(documentContentLoaded); | |
237 return; | |
238 } | |
239 | |
240 this._resource.searchInContent(query, caseSensitive, isRegex, callback); | |
241 } | |
242 } | |
243 | |
244 /** | |
143 * @type {!WebInspector.SimpleWorkspaceProvider} | 245 * @type {!WebInspector.SimpleWorkspaceProvider} |
144 */ | 246 */ |
145 WebInspector.networkWorkspaceProvider; | 247 WebInspector.networkWorkspaceProvider; |
OLD | NEW |