| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 var connection; | 4 var connection; |
| 5 var mojo_api; | 5 var mojo_api; |
| 6 var input_focused_event; | 6 var input_focused_event; |
| 7 | 7 |
| 8 if (!chrome.virtualKeyboardPrivate) { | 8 if (!chrome.virtualKeyboardPrivate) { |
| 9 define('main', [ | 9 define('main', [ |
| 10 'mojo/public/js/bindings/connection', | 10 'mojo/public/js/bindings/connection', |
| 11 'ui/keyboard/webui/keyboard.mojom', | 11 'ui/keyboard/webui/keyboard.mojom', |
| 12 'content/public/renderer/service_provider', | 12 'content/public/renderer/service_provider', |
| 13 ], function(connector, keyboard, serviceProvider) { | 13 ], function(connector, keyboard, serviceProvider) { |
| 14 'use strict'; | 14 'use strict'; |
| 15 function KeyboardImpl(kbd) { | 15 function KeyboardImpl(kbd) { |
| 16 console.log('Creating KeyboardImpl'); | 16 console.log('Creating KeyboardImpl'); |
| 17 this.keyboard_ = kbd; | 17 this.keyboard_ = kbd; |
| 18 mojo_api = this; | 18 mojo_api = this; |
| 19 } | 19 } |
| 20 | 20 |
| 21 KeyboardImpl.prototype = Object.create(keyboard.KeyboardAPIStub.prototype); | 21 KeyboardImpl.prototype = Object.create( |
| 22 keyboard.KeyboardAPI.stubClass.prototype); |
| 22 | 23 |
| 23 KeyboardImpl.prototype.onTextInputTypeChanged = function(input_type) { | 24 KeyboardImpl.prototype.onTextInputTypeChanged = function(input_type) { |
| 24 console.log('Text input changed: ' + input_type); | 25 console.log('Text input changed: ' + input_type); |
| 25 input_focused_event.forEach(function(listener) { | 26 input_focused_event.forEach(function(listener) { |
| 26 listener({type: input_type}); | 27 listener({type: input_type}); |
| 27 }); | 28 }); |
| 28 }; | 29 }; |
| 29 | 30 |
| 30 return function() { | 31 return function() { |
| 31 connection = new connector.Connection( | 32 connection = new connector.Connection( |
| 32 serviceProvider.connectToService( | 33 serviceProvider.connectToService( |
| 33 keyboard.KeyboardUIHandlerMojoProxy.NAME_), | 34 keyboard.KeyboardUIHandlerMojo.name), |
| 34 KeyboardImpl, | 35 KeyboardImpl, |
| 35 keyboard.KeyboardUIHandlerMojoProxy); | 36 keyboard.KeyboardUIHandlerMojo.proxyClass); |
| 36 }; | 37 }; |
| 37 }); | 38 }); |
| 38 | 39 |
| 39 chrome.virtualKeyboardPrivate = {}; | 40 chrome.virtualKeyboardPrivate = {}; |
| 40 chrome.virtualKeyboardPrivate.sendKeyEvent = function(event) { | 41 chrome.virtualKeyboardPrivate.sendKeyEvent = function(event) { |
| 41 if (!mojo_api) | 42 if (!mojo_api) |
| 42 return; | 43 return; |
| 43 console.log('sending key event: ' + event.type); | 44 console.log('sending key event: ' + event.type); |
| 44 mojo_api.keyboard_.sendKeyEvent(event.type, | 45 mojo_api.keyboard_.sendKeyEvent(event.type, |
| 45 event.charValue, | 46 event.charValue, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 BrowserEvent.prototype.forEach = function(callback) { | 69 BrowserEvent.prototype.forEach = function(callback) { |
| 69 for (var i = 0; i < this.listeners_.length; ++i) | 70 for (var i = 0; i < this.listeners_.length; ++i) |
| 70 callback(this.listeners_[i]); | 71 callback(this.listeners_[i]); |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 input_focused_event = new BrowserEvent; | 74 input_focused_event = new BrowserEvent; |
| 74 chrome.virtualKeyboardPrivate.onTextInputBoxFocused = input_focused_event; | 75 chrome.virtualKeyboardPrivate.onTextInputBoxFocused = input_focused_event; |
| 75 } | 76 } |
| OLD | NEW |