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

Side by Side Diff: chrome/renderer/resources/extensions/omnibox_custom_bindings.js

Issue 9386001: Implement a module system for the extension bindings JS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Custom bindings for the omnibox API. Only injected into the v8 contexts 5 // Custom bindings for the omnibox API. Only injected into the v8 contexts
6 // for extensions which have permission for the omnibox API. 6 // for extensions which have permission for the omnibox API.
7 7
8 (function() { 8 var GetChromeHidden = natives.GetChromeHidden;
9
10 native function GetChromeHidden();
11 9
12 // Remove invalid characters from |text| so that it is suitable to use 10 // Remove invalid characters from |text| so that it is suitable to use
13 // for |AutocompleteMatch::contents|. 11 // for |AutocompleteMatch::contents|.
14 function sanitizeString(text, shouldTrim) { 12 function sanitizeString(text, shouldTrim) {
15 // NOTE: This logic mirrors |AutocompleteMatch::SanitizeString()|. 13 // NOTE: This logic mirrors |AutocompleteMatch::SanitizeString()|.
16 // 0x2028 = line separator; 0x2029 = paragraph separator. 14 // 0x2028 = line separator; 0x2029 = paragraph separator.
17 var kRemoveChars = /(\r|\n|\t|\u2028|\u2029)/gm; 15 var kRemoveChars = /(\r|\n|\t|\u2028|\u2029)/gm;
18 if (shouldTrim) 16 if (shouldTrim)
19 text = text.trimLeft(); 17 text = text.trimLeft();
20 return text.replace(kRemoveChars, ''); 18 return text.replace(kRemoveChars, '');
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 }); 100 });
103 101
104 chrome.omnibox.onInputChanged.dispatch = 102 chrome.omnibox.onInputChanged.dispatch =
105 function(text, requestId) { 103 function(text, requestId) {
106 var suggestCallback = function(suggestions) { 104 var suggestCallback = function(suggestions) {
107 chrome.omnibox.sendSuggestions(requestId, suggestions); 105 chrome.omnibox.sendSuggestions(requestId, suggestions);
108 }; 106 };
109 chrome.Event.prototype.dispatch.apply(this, [text, suggestCallback]); 107 chrome.Event.prototype.dispatch.apply(this, [text, suggestCallback]);
110 }; 108 };
111 }); 109 });
112
113 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698