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

Unified Diff: ui/keyboard/resources/keyboard_mojo.js

Issue 328303008: athena: Use mojo to provide the bindings for the virtual keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: ui/keyboard/resources/keyboard_mojo.js
diff --git a/ui/keyboard/resources/keyboard_mojo.js b/ui/keyboard/resources/keyboard_mojo.js
new file mode 100644
index 0000000000000000000000000000000000000000..937995a0f5ea5bf674ceecd3d6981bb0fbabc035
--- /dev/null
+++ b/ui/keyboard/resources/keyboard_mojo.js
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+var connection;
+var mojo_api;
+var input_focused_event;
+
+if (!chrome.virtualKeyboardPrivate) {
+ define('main', [
+ 'mojo/public/js/bindings/connection',
+ 'ui/keyboard/webui/keyboard.mojom',
Sam McNally 2014/06/26 11:04:40 You'll need to depend on 'content/public/renderer/
sadrul 2014/08/01 22:41:47 Done.
+ ], function(connector, keyboard) {
+ 'use strict';
+ function KeyboardImpl(kbd) {
+ console.log('Creating KeyboardImpl');
+ this.keyboard_ = kbd;
+ mojo_api = this;
+ }
+
+ KeyboardImpl.prototype = Object.create(keyboard.KeyboardAPIStub.prototype);
+
+ KeyboardImpl.prototype.onTextInputTypeChanged = function(input_type) {
+ console.log('Text input changed: ' + input_type);
+ input_focused_event.forEach(function(listener) {
+ listener({type: input_type});
+ });
+ };
+
+ return function(handle) {
Sam McNally 2014/06/26 11:04:40 The caller will no longer pass in the handle. You'
sadrul 2014/08/01 22:41:47 Done.
+ connection = connector.Connection(handle, KeyboardImpl,
+ keyboard.KeyboardUIHandlerMojoProxy);
+ };
+ });
+
+ chrome.virtualKeyboardPrivate = {};
+ chrome.virtualKeyboardPrivate.sendKeyEvent = function(event) {
+ if (!mojo_api)
+ return;
+ console.log('sending key event: ' + event.type);
+ mojo_api.keyboard_.sendKeyEvent(event.type,
+ event.charValue,
+ event.keyCode,
+ event.keyName,
+ event.modifiers);
+ };
+ chrome.virtualKeyboardPrivate.hideKeyboard = function() {
+ if (!mojo_api)
+ return;
+ mojo_api.keyboard_.hideKeyboard();
+ };
+ chrome.virtualKeyboardPrivate.moveCursor = function() {};
+ chrome.virtualKeyboardPrivate.lockKeyboard = function() {};
+ chrome.virtualKeyboardPrivate.keyboardLoaded = function() {};
+ chrome.virtualKeyboardPrivate.getKeyboardConfig = function() {};
+
+ function BrowserEvent() {
+ this.listeners_ = [];
+ };
+
+ BrowserEvent.prototype.addListener = function(callback) {
+ this.listeners_.push(callback);
+ };
+
+ BrowserEvent.prototype.forEach = function(callback) {
+ for (var i = 0; i < this.listeners_.length; ++i)
+ callback(this.listeners_[i]);
+ };
+
+ input_focused_event = new BrowserEvent;
+ chrome.virtualKeyboardPrivate.onTextInputBoxFocused = input_focused_event;
+}

Powered by Google App Engine
This is Rietveld 408576698