OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @implements {WebInspector.ContentProvider} | 7 * @implements {WebInspector.ContentProvider} |
8 * @param {!WebInspector.ResourceType} contentType | 8 * @param {!WebInspector.ResourceType} contentType |
9 * @param {string} content | 9 * @param {string} content |
| 10 * @param {string=} contentURL |
10 */ | 11 */ |
11 WebInspector.StaticContentProvider = function(contentType, content) | 12 WebInspector.StaticContentProvider = function(contentType, content, contentURL) |
12 { | 13 { |
13 this._content = content; | 14 this._content = content; |
14 this._contentType = contentType; | 15 this._contentType = contentType; |
| 16 this._contentURL = contentURL || ""; |
15 } | 17 } |
16 | 18 |
17 /** | 19 /** |
18 * @param {string} content | 20 * @param {string} content |
19 * @param {string} query | 21 * @param {string} query |
20 * @param {boolean} caseSensitive | 22 * @param {boolean} caseSensitive |
21 * @param {boolean} isRegex | 23 * @param {boolean} isRegex |
22 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callbac
k | 24 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callbac
k |
23 */ | 25 */ |
24 WebInspector.StaticContentProvider.searchInContent = function(content, query, ca
seSensitive, isRegex, callback) | 26 WebInspector.StaticContentProvider.searchInContent = function(content, query, ca
seSensitive, isRegex, callback) |
25 { | 27 { |
26 function performSearch() | 28 function performSearch() |
27 { | 29 { |
28 callback(WebInspector.ContentProvider.performSearchInContent(content, qu
ery, caseSensitive, isRegex)); | 30 callback(WebInspector.ContentProvider.performSearchInContent(content, qu
ery, caseSensitive, isRegex)); |
29 } | 31 } |
30 | 32 |
31 // searchInContent should call back later. | 33 // searchInContent should call back later. |
32 setTimeout(performSearch.bind(null), 0); | 34 setTimeout(performSearch.bind(null), 0); |
33 } | 35 } |
34 | 36 |
35 WebInspector.StaticContentProvider.prototype = { | 37 WebInspector.StaticContentProvider.prototype = { |
36 /** | 38 /** |
37 * @return {string} | 39 * @return {string} |
38 */ | 40 */ |
39 contentURL: function() | 41 contentURL: function() |
40 { | 42 { |
41 return ""; | 43 return this._contentURL; |
42 }, | 44 }, |
43 | 45 |
44 /** | 46 /** |
45 * @return {!WebInspector.ResourceType} | 47 * @return {!WebInspector.ResourceType} |
46 */ | 48 */ |
47 contentType: function() | 49 contentType: function() |
48 { | 50 { |
49 return this._contentType; | 51 return this._contentType; |
50 }, | 52 }, |
51 | 53 |
52 /** | 54 /** |
53 * @param {function(?string)} callback | 55 * @param {function(?string)} callback |
54 */ | 56 */ |
55 requestContent: function(callback) | 57 requestContent: function(callback) |
56 { | 58 { |
57 callback(this._content); | 59 callback(this._content); |
58 }, | 60 }, |
59 | 61 |
60 /** | 62 /** |
61 * @param {string} query | 63 * @param {string} query |
62 * @param {boolean} caseSensitive | 64 * @param {boolean} caseSensitive |
63 * @param {boolean} isRegex | 65 * @param {boolean} isRegex |
64 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal
lback | 66 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal
lback |
65 */ | 67 */ |
66 searchInContent: function(query, caseSensitive, isRegex, callback) | 68 searchInContent: function(query, caseSensitive, isRegex, callback) |
67 { | 69 { |
68 WebInspector.StaticContentProvider.searchInContent(this._content, query,
caseSensitive, isRegex, callback); | 70 WebInspector.StaticContentProvider.searchInContent(this._content, query,
caseSensitive, isRegex, callback); |
69 } | 71 } |
70 } | 72 } |
OLD | NEW |