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

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: tot-merge Created 6 years, 4 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
« no previous file with comments | « ui/keyboard/resources/index.html ('k') | ui/keyboard/webui/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..eddf8667ec6fa6bae1593d6e09fca2e6d9f1e53f
--- /dev/null
+++ b/ui/keyboard/resources/keyboard_mojo.js
@@ -0,0 +1,75 @@
+// 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',
+ 'content/public/renderer/service_provider',
+ ], function(connector, keyboard, serviceProvider) {
+ '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() {
+ connection = new connector.Connection(
+ serviceProvider.connectToService(
+ keyboard.KeyboardUIHandlerMojoProxy.NAME_),
+ 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;
+}
« no previous file with comments | « ui/keyboard/resources/index.html ('k') | ui/keyboard/webui/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698