| 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 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 chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 binding.registerCustomHook(function(bindingsAPI) { | 84 binding.registerCustomHook(function(bindingsAPI) { |
| 85 var apiFunctions = bindingsAPI.apiFunctions; | 85 var apiFunctions = bindingsAPI.apiFunctions; |
| 86 | 86 |
| 87 apiFunctions.setUpdateArgumentsPreValidate('setDefaultSuggestion', | 87 apiFunctions.setUpdateArgumentsPreValidate('setDefaultSuggestion', |
| 88 function(suggestResult) { | 88 function(suggestResult) { |
| 89 if (suggestResult.content != undefined) { // null, etc. | 89 if (suggestResult.content != undefined) { // null, etc. |
| 90 throw new Error( | 90 throw new Error( |
| 91 'setDefaultSuggestion cannot contain the "content" field'); | 91 'setDefaultSuggestion cannot contain the "content" field'); |
| 92 } | 92 } |
| 93 suggestResult.content = ''; | |
| 94 return [suggestResult]; | 93 return [suggestResult]; |
| 95 }); | 94 }); |
| 96 | 95 |
| 97 apiFunctions.setHandleRequest('setDefaultSuggestion', function(details) { | 96 apiFunctions.setHandleRequest('setDefaultSuggestion', function(details) { |
| 98 var parseResult = parseOmniboxDescription(details.description); | 97 var parseResult = parseOmniboxDescription(details.description); |
| 99 sendRequest(this.name, [parseResult], this.definition.parameters); | 98 sendRequest(this.name, [parseResult], this.definition.parameters); |
| 100 }); | 99 }); |
| 101 | 100 |
| 102 apiFunctions.setUpdateArgumentsPostValidate( | 101 apiFunctions.setUpdateArgumentsPostValidate( |
| 103 'sendSuggestions', function(requestId, userSuggestions) { | 102 'sendSuggestions', function(requestId, userSuggestions) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 116 function(args, dispatch) { | 115 function(args, dispatch) { |
| 117 var text = args[0]; | 116 var text = args[0]; |
| 118 var requestId = args[1]; | 117 var requestId = args[1]; |
| 119 var suggestCallback = function(suggestions) { | 118 var suggestCallback = function(suggestions) { |
| 120 chrome.omnibox.sendSuggestions(requestId, suggestions); | 119 chrome.omnibox.sendSuggestions(requestId, suggestions); |
| 121 }; | 120 }; |
| 122 dispatch([text, suggestCallback]); | 121 dispatch([text, suggestCallback]); |
| 123 }); | 122 }); |
| 124 | 123 |
| 125 exports.binding = binding.generate(); | 124 exports.binding = binding.generate(); |
| OLD | NEW |