Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / common / StaticContentProvider.js
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
3 // found in the LICENSE file.
4
5 /**
6  * @constructor
7  * @implements {WebInspector.ContentProvider}
8  * @param {!WebInspector.ResourceType} contentType
9  * @param {string} content
10  */
11 WebInspector.StaticContentProvider = function(contentType, content)
12 {
13     this._content = content;
14     this._contentType = contentType;
15 }
16
17 WebInspector.StaticContentProvider.prototype = {
18     /**
19      * @return {string}
20      */
21     contentURL: function()
22     {
23         return "";
24     },
25
26     /**
27      * @return {!WebInspector.ResourceType}
28      */
29     contentType: function()
30     {
31         return this._contentType;
32     },
33
34     /**
35      * @param {function(?string)} callback
36      */
37     requestContent: function(callback)
38     {
39         callback(this._content);
40     },
41
42     /**
43      * @param {string} query
44      * @param {boolean} caseSensitive
45      * @param {boolean} isRegex
46      * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callback
47      */
48     searchInContent: function(query, caseSensitive, isRegex, callback)
49     {
50         /**
51          * @this {WebInspector.StaticContentProvider}
52          */
53         function performSearch()
54         {
55             callback(WebInspector.ContentProvider.performSearchInContent(this._content, query, caseSensitive, isRegex));
56         }
57
58         // searchInContent should call back later.
59         self.setTimeout(performSearch.bind(this), 0);
60     }
61 }