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

Side by Side Diff: chrome/renderer/resources/extensions/input.ime_custom_bindings.js

Issue 12313142: Revert 184837 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 binding for the input ime API. Only injected into the 5 // Custom bindings for the input ime API. Only injected into the
6 // v8 contexts for extensions which have permission for the API. 6 // v8 contexts for extensions which have permission for the API.
7 7
8 var binding = require('binding').Binding.create('input.ime'); 8 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
9 9
10 binding.registerCustomHook(function(api) { 10 chromeHidden.registerCustomHook('input.ime', function() {
11 var input_ime = api.compiledApi; 11 chrome.input.ime.onKeyEvent.dispatchToListener = function(callback, args) {
12
13 input_ime.onKeyEvent.dispatchToListener = function(callback, args) {
14 var engineID = args[0]; 12 var engineID = args[0];
15 var keyData = args[1]; 13 var keyData = args[1];
16 14
17 var result = false; 15 var result = false;
18 try { 16 try {
19 result = chrome.Event.prototype.dispatchToListener(callback, args); 17 result = chrome.Event.prototype.dispatchToListener(callback, args);
20 } catch (e) { 18 } catch (e) {
21 console.error('Error in event handler for onKeyEvent: ' + e.stack); 19 console.error('Error in event handler for onKeyEvent: ' + e.stack);
22 } 20 }
23 if (!input_ime.onKeyEvent.async) 21 if (!chrome.input.ime.onKeyEvent.async)
24 input_ime.keyEventHandled(keyData.requestId, result); 22 chrome.input.ime.keyEventHandled(keyData.requestId, result);
25 }; 23 };
26 24
27 input_ime.onKeyEvent.addListener = function(cb, opt_extraInfo) { 25 chrome.input.ime.onKeyEvent.addListener = function(cb, opt_extraInfo) {
28 input_ime.onKeyEvent.async = false; 26 chrome.input.ime.onKeyEvent.async = false;
29 if (opt_extraInfo instanceof Array) { 27 if (opt_extraInfo instanceof Array) {
30 for (var i = 0; i < opt_extraInfo.length; ++i) { 28 for (var i = 0; i < opt_extraInfo.length; ++i) {
31 if (opt_extraInfo[i] == "async") { 29 if (opt_extraInfo[i] == "async") {
32 input_ime.onKeyEvent.async = true; 30 chrome.input.ime.onKeyEvent.async = true;
33 } 31 }
34 } 32 }
35 } 33 }
36 chrome.Event.prototype.addListener.call(this, cb, null); 34 chrome.Event.prototype.addListener.call(this, cb, null);
37 }; 35 };
38 }); 36 });
39
40 exports.binding = binding.generate();
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/i18n_custom_bindings.js ('k') | chrome/renderer/resources/extensions/json_schema.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698