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

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

Issue 11299270: Add a parameter that specifies whether onKeyEvent is asynchronous (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove extra function Created 8 years 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
« no previous file with comments | « chrome/common/extensions/api/input_ime.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 8 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
9 9
10 chromeHidden.registerCustomHook('input.ime', function() { 10 chromeHidden.registerCustomHook('input.ime', function() {
11 chrome.input.ime.onKeyEvent.dispatchToListener = function(callback, args) { 11 chrome.input.ime.onKeyEvent.dispatchToListener = function(callback, args) {
12 var engineID = args[0]; 12 var engineID = args[0];
13 var keyData = args[1]; 13 var keyData = args[1];
14 14
15 var result = false; 15 var result = false;
16 try { 16 try {
17 result = chrome.Event.prototype.dispatchToListener(callback, args); 17 result = chrome.Event.prototype.dispatchToListener(callback, args);
18 } catch (e) { 18 } catch (e) {
19 console.error('Error in event handler for onKeyEvent: ' + e.stack); 19 console.error('Error in event handler for onKeyEvent: ' + e.stack);
20 } 20 }
21 chrome.input.ime.eventHandled(keyData.requestId, result); 21 if (!chrome.input.ime.onKeyEvent.async)
22 chrome.input.ime.keyEventHandled(keyData.requestId, result);
23 };
24
25 chrome.input.ime.onKeyEvent.addListener = function(cb, opt_extraInfo) {
26 if (!this.eventOptions_.supportsListeners)
Matt Perry 2012/11/30 20:31:59 Rather than cut+pasting, you can call the original
Zachary Kuznia 2012/12/03 05:54:45 Done.
27 throw new Error("This event does not support listeners.");
28 if (this.eventOptions_.maxListeners &&
29 this.getListenerCount() >= this.eventOptions_.maxListeners)
30 throw new Error("Too many listeners for " + this.eventName_);
31 chrome.input.ime.onKeyEvent.async = false;
32 if (opt_extraInfo instanceof Array) {
33 for (var i = 0; i < opt_extraInfo.length; ++i) {
34 if (opt_extraInfo[i] == "async") {
35 chrome.input.ime.onKeyEvent.async = true;
36 }
37 }
38 }
39 var listener = {callback: cb, filters: null};
40 this.attach_(listener);
41 this.listeners_.push(listener);
22 }; 42 };
23 }); 43 });
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/input_ime.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698