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

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

Issue 15841013: Make miscellaneous_bindings and event_bindings Required as needed. Previously (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 binding for the omnibox API. Only injected into the v8 contexts 5 // Custom binding 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 var binding = require('binding').Binding.create('omnibox'); 8 var binding = require('binding').Binding.create('omnibox');
9 9
10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 10 var eventBindings = require('event_bindings');
11 var sendRequest = require('sendRequest').sendRequest; 11 var sendRequest = require('sendRequest').sendRequest;
12 12
13 // Remove invalid characters from |text| so that it is suitable to use 13 // Remove invalid characters from |text| so that it is suitable to use
14 // for |AutocompleteMatch::contents|. 14 // for |AutocompleteMatch::contents|.
15 function sanitizeString(text, shouldTrim) { 15 function sanitizeString(text, shouldTrim) {
16 // NOTE: This logic mirrors |AutocompleteMatch::SanitizeString()|. 16 // NOTE: This logic mirrors |AutocompleteMatch::SanitizeString()|.
17 // 0x2028 = line separator; 0x2029 = paragraph separator. 17 // 0x2028 = line separator; 0x2029 = paragraph separator.
18 var kRemoveChars = /(\r|\n|\t|\u2028|\u2029)/gm; 18 var kRemoveChars = /(\r|\n|\t|\u2028|\u2029)/gm;
19 if (shouldTrim) 19 if (shouldTrim)
20 text = text.trimLeft(); 20 text = text.trimLeft();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 for (var i = 0; i < userSuggestions.length; i++) { 104 for (var i = 0; i < userSuggestions.length; i++) {
105 var parseResult = parseOmniboxDescription( 105 var parseResult = parseOmniboxDescription(
106 userSuggestions[i].description); 106 userSuggestions[i].description);
107 parseResult.content = userSuggestions[i].content; 107 parseResult.content = userSuggestions[i].content;
108 suggestions.push(parseResult); 108 suggestions.push(parseResult);
109 } 109 }
110 return [requestId, suggestions]; 110 return [requestId, suggestions];
111 }); 111 });
112 }); 112 });
113 113
114 chromeHidden.Event.registerArgumentMassager('omnibox.onInputChanged', 114 eventBindings.registerArgumentMassager('omnibox.onInputChanged',
115 function(args, dispatch) { 115 function(args, dispatch) {
116 var text = args[0]; 116 var text = args[0];
117 var requestId = args[1]; 117 var requestId = args[1];
118 var suggestCallback = function(suggestions) { 118 var suggestCallback = function(suggestions) {
119 chrome.omnibox.sendSuggestions(requestId, suggestions); 119 chrome.omnibox.sendSuggestions(requestId, suggestions);
120 }; 120 };
121 dispatch([text, suggestCallback]); 121 dispatch([text, suggestCallback]);
122 }); 122 });
123 123
124 exports.binding = binding.generate(); 124 exports.binding = binding.generate();
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/miscellaneous_bindings.js ('k') | chrome/renderer/resources/extensions/on_unload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698