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
3 // found in the LICENSE file.
5 // Custom binding for the input ime API. Only injected into the
6 // v8 contexts for extensions which have permission for the API.
8 var binding = require('binding').Binding.create('input.ime');
10 var Event = require('event_bindings').Event;
12 binding.registerCustomHook(function(api) {
13 var input_ime = api.compiledApi;
15 input_ime.onKeyEvent.dispatchToListener = function(callback, args) {
16 var engineID = args[0];
17 var keyData = args[1];
21 result = $Function.call(Event.prototype.dispatchToListener,
22 this, callback, args);
24 console.error('Error in event handler for onKeyEvent: ' + e.stack);
26 if (!input_ime.onKeyEvent.async) {
27 input_ime.keyEventHandled(keyData.requestId, result);
31 input_ime.onKeyEvent.addListener = function(cb, opt_extraInfo) {
32 input_ime.onKeyEvent.async = false;
33 if (opt_extraInfo instanceof Array) {
34 for (var i = 0; i < opt_extraInfo.length; ++i) {
35 if (opt_extraInfo[i] == "async") {
36 input_ime.onKeyEvent.async = true;
40 $Function.call(Event.prototype.addListener, this, cb);
44 exports.binding = binding.generate();