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

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

Issue 9423049: Make registering custom hooks with schema_generated_bindings.js safer and (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 9 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 (function() {
9 9
10 native function GetChromeHidden(); 10 native function GetChromeHidden();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 })(root); 77 })(root);
78 78
79 return result; 79 return result;
80 } 80 }
81 81
82 GetChromeHidden().registerCustomHook('omnibox', function(bindingsAPI) { 82 GetChromeHidden().registerCustomHook('omnibox', function(bindingsAPI) {
83 var apiFunctions = bindingsAPI.apiFunctions; 83 var apiFunctions = bindingsAPI.apiFunctions;
84 var sendRequest = bindingsAPI.sendRequest; 84 var sendRequest = bindingsAPI.sendRequest;
85 85
86 apiFunctions.setHandleRequest("omnibox.setDefaultSuggestion", 86 apiFunctions.setHandleRequest('setDefaultSuggestion', function(details) {
87 function(details) {
88 var parseResult = parseOmniboxDescription(details.description); 87 var parseResult = parseOmniboxDescription(details.description);
89 sendRequest(this.name, [parseResult], this.definition.parameters); 88 sendRequest(this.name, [parseResult], this.definition.parameters);
90 }); 89 });
91 90
92 apiFunctions.setUpdateArgumentsPostValidate("omnibox.sendSuggestions", 91 apiFunctions.setUpdateArgumentsPostValidate(
93 function(requestId, userSuggestions) { 92 'sendSuggestions', function(requestId, userSuggestions) {
94 var suggestions = []; 93 var suggestions = [];
95 for (var i = 0; i < userSuggestions.length; i++) { 94 for (var i = 0; i < userSuggestions.length; i++) {
96 var parseResult = parseOmniboxDescription( 95 var parseResult = parseOmniboxDescription(
97 userSuggestions[i].description); 96 userSuggestions[i].description);
98 parseResult.content = userSuggestions[i].content; 97 parseResult.content = userSuggestions[i].content;
99 suggestions.push(parseResult); 98 suggestions.push(parseResult);
100 } 99 }
101 return [requestId, suggestions]; 100 return [requestId, suggestions];
102 }); 101 });
103 102
104 chrome.omnibox.onInputChanged.dispatch = 103 chrome.omnibox.onInputChanged.dispatch =
105 function(text, requestId) { 104 function(text, requestId) {
106 var suggestCallback = function(suggestions) { 105 var suggestCallback = function(suggestions) {
107 chrome.omnibox.sendSuggestions(requestId, suggestions); 106 chrome.omnibox.sendSuggestions(requestId, suggestions);
108 }; 107 };
109 chrome.Event.prototype.dispatch.apply(this, [text, suggestCallback]); 108 chrome.Event.prototype.dispatch.apply(this, [text, suggestCallback]);
110 }; 109 };
111 }); 110 });
112 111
113 })(); 112 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698