OLD | NEW |
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 Loading... |
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 })(); |
OLD | NEW |