| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 { | 256 { |
| 257 if (typeof content !== "string") { | 257 if (typeof content !== "string") { |
| 258 callback([]); | 258 callback([]); |
| 259 return; | 259 return; |
| 260 } | 260 } |
| 261 | 261 |
| 262 callback(WebInspector.ContentProvider.performSearchInContent(content
, query, caseSensitive, isRegex)); | 262 callback(WebInspector.ContentProvider.performSearchInContent(content
, query, caseSensitive, isRegex)); |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | |
| 267 /** | |
| 268 * @constructor | |
| 269 * @implements {WebInspector.ContentProvider} | |
| 270 * @param {!WebInspector.ResourceType} contentType | |
| 271 * @param {string} content | |
| 272 */ | |
| 273 WebInspector.StaticContentProvider = function(contentType, content) | |
| 274 { | |
| 275 this._content = content; | |
| 276 this._contentType = contentType; | |
| 277 } | |
| 278 | |
| 279 WebInspector.StaticContentProvider.prototype = { | |
| 280 /** | |
| 281 * @return {string} | |
| 282 */ | |
| 283 contentURL: function() | |
| 284 { | |
| 285 return ""; | |
| 286 }, | |
| 287 | |
| 288 /** | |
| 289 * @return {!WebInspector.ResourceType} | |
| 290 */ | |
| 291 contentType: function() | |
| 292 { | |
| 293 return this._contentType; | |
| 294 }, | |
| 295 | |
| 296 /** | |
| 297 * @param {function(?string)} callback | |
| 298 */ | |
| 299 requestContent: function(callback) | |
| 300 { | |
| 301 callback(this._content); | |
| 302 }, | |
| 303 | |
| 304 /** | |
| 305 * @param {string} query | |
| 306 * @param {boolean} caseSensitive | |
| 307 * @param {boolean} isRegex | |
| 308 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal
lback | |
| 309 */ | |
| 310 searchInContent: function(query, caseSensitive, isRegex, callback) | |
| 311 { | |
| 312 /** | |
| 313 * @this {WebInspector.StaticContentProvider} | |
| 314 */ | |
| 315 function performSearch() | |
| 316 { | |
| 317 callback(WebInspector.ContentProvider.performSearchInContent(this._c
ontent, query, caseSensitive, isRegex)); | |
| 318 } | |
| 319 | |
| 320 // searchInContent should call back later. | |
| 321 window.setTimeout(performSearch.bind(this), 0); | |
| 322 } | |
| 323 } | |
| OLD | NEW |