Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/common/ContentProvider.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 /** 30 /**
31 * @interface 31 * @interface
32 */ 32 */
33 WebInspector.ContentProvider = function() {}; 33 Common.ContentProvider = function() {};
34 34
35 WebInspector.ContentProvider.prototype = { 35 Common.ContentProvider.prototype = {
36 /** 36 /**
37 * @return {string} 37 * @return {string}
38 */ 38 */
39 contentURL: function() {}, 39 contentURL: function() {},
40 40
41 /** 41 /**
42 * @return {!WebInspector.ResourceType} 42 * @return {!Common.ResourceType}
43 */ 43 */
44 contentType: function() {}, 44 contentType: function() {},
45 45
46 /** 46 /**
47 * @return {!Promise<?string>} 47 * @return {!Promise<?string>}
48 */ 48 */
49 requestContent: function() {}, 49 requestContent: function() {},
50 50
51 /** 51 /**
52 * @param {string} query 52 * @param {string} query
53 * @param {boolean} caseSensitive 53 * @param {boolean} caseSensitive
54 * @param {boolean} isRegex 54 * @param {boolean} isRegex
55 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callb ack 55 * @param {function(!Array.<!Common.ContentProvider.SearchMatch>)} callback
56 */ 56 */
57 searchInContent: function(query, caseSensitive, isRegex, callback) {} 57 searchInContent: function(query, caseSensitive, isRegex, callback) {}
58 }; 58 };
59 59
60 /** 60 /**
61 * @unrestricted 61 * @unrestricted
62 */ 62 */
63 WebInspector.ContentProvider.SearchMatch = class { 63 Common.ContentProvider.SearchMatch = class {
64 /** 64 /**
65 * @param {number} lineNumber 65 * @param {number} lineNumber
66 * @param {string} lineContent 66 * @param {string} lineContent
67 */ 67 */
68 constructor(lineNumber, lineContent) { 68 constructor(lineNumber, lineContent) {
69 this.lineNumber = lineNumber; 69 this.lineNumber = lineNumber;
70 this.lineContent = lineContent; 70 this.lineContent = lineContent;
71 } 71 }
72 }; 72 };
73 73
74 /** 74 /**
75 * @param {string} content 75 * @param {string} content
76 * @param {string} query 76 * @param {string} query
77 * @param {boolean} caseSensitive 77 * @param {boolean} caseSensitive
78 * @param {boolean} isRegex 78 * @param {boolean} isRegex
79 * @return {!Array.<!WebInspector.ContentProvider.SearchMatch>} 79 * @return {!Array.<!Common.ContentProvider.SearchMatch>}
80 */ 80 */
81 WebInspector.ContentProvider.performSearchInContent = function(content, query, c aseSensitive, isRegex) { 81 Common.ContentProvider.performSearchInContent = function(content, query, caseSen sitive, isRegex) {
82 var regex = createSearchRegex(query, caseSensitive, isRegex); 82 var regex = createSearchRegex(query, caseSensitive, isRegex);
83 83
84 var text = new WebInspector.Text(content); 84 var text = new Common.Text(content);
85 var result = []; 85 var result = [];
86 for (var i = 0; i < text.lineCount(); ++i) { 86 for (var i = 0; i < text.lineCount(); ++i) {
87 var lineContent = text.lineAt(i); 87 var lineContent = text.lineAt(i);
88 regex.lastIndex = 0; 88 regex.lastIndex = 0;
89 if (regex.exec(lineContent)) 89 if (regex.exec(lineContent))
90 result.push(new WebInspector.ContentProvider.SearchMatch(i, lineContent)); 90 result.push(new Common.ContentProvider.SearchMatch(i, lineContent));
91 } 91 }
92 return result; 92 return result;
93 }; 93 };
94 94
95 /** 95 /**
96 * @param {?string} content 96 * @param {?string} content
97 * @param {string} mimeType 97 * @param {string} mimeType
98 * @param {boolean} contentEncoded 98 * @param {boolean} contentEncoded
99 * @param {?string=} charset 99 * @param {?string=} charset
100 * @return {?string} 100 * @return {?string}
101 */ 101 */
102 WebInspector.ContentProvider.contentAsDataURL = function(content, mimeType, cont entEncoded, charset) { 102 Common.ContentProvider.contentAsDataURL = function(content, mimeType, contentEnc oded, charset) {
103 const maxDataUrlSize = 1024 * 1024; 103 const maxDataUrlSize = 1024 * 1024;
104 if (content === null || content.length > maxDataUrlSize) 104 if (content === null || content.length > maxDataUrlSize)
105 return null; 105 return null;
106 106
107 return 'data:' + mimeType + (charset ? ';charset=' + charset : '') + (contentE ncoded ? ';base64' : '') + ',' + 107 return 'data:' + mimeType + (charset ? ';charset=' + charset : '') + (contentE ncoded ? ';base64' : '') + ',' +
108 content; 108 content;
109 }; 109 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698