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

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

Issue 17451011: Make the externally connectable browser test clobber all of the builtins, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 eventBindings = require('event_bindings'); 10 var eventBindings = require('event_bindings');
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 // Process and descend into a subset of recognized tags. 60 // Process and descend into a subset of recognized tags.
61 if (child.nodeType == Node.ELEMENT_NODE && 61 if (child.nodeType == Node.ELEMENT_NODE &&
62 (child.nodeName == 'dim' || child.nodeName == 'match' || 62 (child.nodeName == 'dim' || child.nodeName == 'match' ||
63 child.nodeName == 'url')) { 63 child.nodeName == 'url')) {
64 var style = { 64 var style = {
65 'type': child.nodeName, 65 'type': child.nodeName,
66 'offset': result.description.length 66 'offset': result.description.length
67 }; 67 };
68 result.descriptionStyles.push(style); 68 $Array.push(result.descriptionStyles, style);
69 walk(child); 69 walk(child);
70 style.length = result.description.length - style.offset; 70 style.length = result.description.length - style.offset;
71 continue; 71 continue;
72 } 72 }
73 73
74 // Descend into all other nodes, even if they are unrecognized, for 74 // Descend into all other nodes, even if they are unrecognized, for
75 // forward compat. 75 // forward compat.
76 walk(child); 76 walk(child);
77 } 77 }
78 }; 78 };
(...skipping 19 matching lines...) Expand all
98 sendRequest(this.name, [parseResult], this.definition.parameters); 98 sendRequest(this.name, [parseResult], this.definition.parameters);
99 }); 99 });
100 100
101 apiFunctions.setUpdateArgumentsPostValidate( 101 apiFunctions.setUpdateArgumentsPostValidate(
102 'sendSuggestions', function(requestId, userSuggestions) { 102 'sendSuggestions', function(requestId, userSuggestions) {
103 var suggestions = []; 103 var suggestions = [];
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 $Array.push(suggestions, parseResult);
109 } 109 }
110 return [requestId, suggestions]; 110 return [requestId, suggestions];
111 }); 111 });
112 }); 112 });
113 113
114 eventBindings.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

Powered by Google App Engine
This is Rietveld 408576698