1 // Copyright 2014 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.
6 var input_focused_event;
8 if (!chrome.virtualKeyboardPrivate) {
10 'mojo/public/js/bindings/connection',
11 'ui/keyboard/webui/keyboard.mojom',
12 'content/public/renderer/service_provider',
13 ], function(connector, keyboard, serviceProvider) {
15 function KeyboardImpl(kbd) {
16 console.log('Creating KeyboardImpl');
21 KeyboardImpl.prototype = Object.create(keyboard.KeyboardAPIStub.prototype);
23 KeyboardImpl.prototype.onTextInputTypeChanged = function(input_type) {
24 console.log('Text input changed: ' + input_type);
25 input_focused_event.forEach(function(listener) {
26 listener({type: input_type});
31 connection = new connector.Connection(
32 serviceProvider.connectToService(
33 keyboard.KeyboardUIHandlerMojoProxy.NAME_),
35 keyboard.KeyboardUIHandlerMojoProxy);
39 chrome.virtualKeyboardPrivate = {};
40 chrome.virtualKeyboardPrivate.sendKeyEvent = function(event) {
43 console.log('sending key event: ' + event.type);
44 mojo_api.keyboard_.sendKeyEvent(event.type,
50 chrome.virtualKeyboardPrivate.hideKeyboard = function() {
53 mojo_api.keyboard_.hideKeyboard();
55 chrome.virtualKeyboardPrivate.moveCursor = function() {};
56 chrome.virtualKeyboardPrivate.lockKeyboard = function() {};
57 chrome.virtualKeyboardPrivate.keyboardLoaded = function() {};
58 chrome.virtualKeyboardPrivate.getKeyboardConfig = function() {};
60 function BrowserEvent() {
64 BrowserEvent.prototype.addListener = function(callback) {
65 this.listeners_.push(callback);
68 BrowserEvent.prototype.forEach = function(callback) {
69 for (var i = 0; i < this.listeners_.length; ++i)
70 callback(this.listeners_[i]);
73 input_focused_event = new BrowserEvent;
74 chrome.virtualKeyboardPrivate.onTextInputBoxFocused = input_focused_event;