| 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 // | 4 // |
| 5 var CLOSURE_NO_DEPS=true; | 5 var CLOSURE_NO_DEPS=true; |
| 6 | 6 |
| 7 var controller; | 7 var controller; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Armed callback to be triggered when a keyset changes. | 10 * Armed callback to be triggered when a keyset changes. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // The first resize call forces resizing of the keyboard window. | 100 // The first resize call forces resizing of the keyboard window. |
| 101 // The second resize call forces a clean layout for chrome://keyboard. | 101 // The second resize call forces a clean layout for chrome://keyboard. |
| 102 controller.resize(false); | 102 controller.resize(false); |
| 103 controller.resize(true); | 103 controller.resize(true); |
| 104 var settings = controller.model_.settings; | 104 var settings = controller.model_.settings; |
| 105 settings.supportCompact = true; | 105 settings.supportCompact = true; |
| 106 if (keysetChangeListener_ && | 106 if (keysetChangeListener_ && |
| 107 keysetChangeListener_.target == arguments[0]) { | 107 keysetChangeListener_.target == arguments[0]) { |
| 108 var callback = keysetChangeListener_.callback; | 108 var callback = keysetChangeListener_.callback; |
| 109 keysetChangeListener_ = undefined; | 109 keysetChangeListener_ = undefined; |
| 110 callback(); | 110 // TODO (rsadam): Get rid of this hack. Currently this is needed to |
| 111 // ensure the keyset was fully loaded before carrying on with the test. |
| 112 setTimeout(callback, 0); |
| 111 } | 113 } |
| 112 } | 114 } |
| 113 return success; | 115 return success; |
| 114 }; | 116 }; |
| 115 } | 117 } |
| 116 | 118 |
| 117 /** | 119 /** |
| 118 * Arms a one time callback to invoke when the VK switches to the target keyset. | 120 * Arms a one time callback to invoke when the VK switches to the target keyset. |
| 119 * Only one keyset change callback may be armed at any time. Used to synchronize | 121 * Only one keyset change callback may be armed at any time. Used to synchronize |
| 120 * tests and to track initial load time for the virtual keyboard. | 122 * tests and to track initial load time for the virtual keyboard. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 * @private | 217 * @private |
| 216 */ | 218 */ |
| 217 function getCurrentInputMethod_(callback) { | 219 function getCurrentInputMethod_(callback) { |
| 218 if (chrome.inputMethodPrivate) | 220 if (chrome.inputMethodPrivate) |
| 219 chrome.inputMethodPrivate.getCurrentInputMethod(callback); | 221 chrome.inputMethodPrivate.getCurrentInputMethod(callback); |
| 220 else | 222 else |
| 221 callback(''); | 223 callback(''); |
| 222 } | 224 } |
| 223 | 225 |
| 224 /** | 226 /** |
| 227 * Retrieve the current input method configuration. |
| 228 * @param {function} callback The callback function for processing the |
| 229 * name of the active input mehtod. |
| 230 * @private |
| 231 */ |
| 232 function getInputMethodConfig_(callback) { |
| 233 if (chrome.inputMethodPrivate) |
| 234 chrome.inputMethodPrivate.getInputMethodConfig(callback); |
| 235 else |
| 236 callback(''); |
| 237 } |
| 238 |
| 239 /** |
| 225 * Changes the active input method. | 240 * Changes the active input method. |
| 226 * @param {string} inputMethodId The id of the input method to activate. | 241 * @param {string} inputMethodId The id of the input method to activate. |
| 227 * @private | 242 * @private |
| 228 */ | 243 */ |
| 229 function switchToInputMethod_(inputMethodId) { | 244 function switchToInputMethod_(inputMethodId) { |
| 230 if (chrome.inputMethodPrivate) | 245 if (chrome.inputMethodPrivate) |
| 231 chrome.inputMethodPrivate.setCurrentInputMethod(inputMethodId) | 246 chrome.inputMethodPrivate.setCurrentInputMethod(inputMethodId) |
| 232 } | 247 } |
| 233 | 248 |
| 234 /** | 249 /** |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 return keyChar.charCodeAt(0); | 311 return keyChar.charCodeAt(0); |
| 297 } | 312 } |
| 298 return 0; | 313 return 0; |
| 299 } | 314 } |
| 300 | 315 |
| 301 window.inputview = { | 316 window.inputview = { |
| 302 commitText: commitText_, | 317 commitText: commitText_, |
| 303 getKeyboardConfig: getKeyboardConfig_, | 318 getKeyboardConfig: getKeyboardConfig_, |
| 304 getInputMethods: getInputMethods_, | 319 getInputMethods: getInputMethods_, |
| 305 getCurrentInputMethod: getCurrentInputMethod_, | 320 getCurrentInputMethod: getCurrentInputMethod_, |
| 321 getInputMethodConfig: getInputMethodConfig_, |
| 306 switchToInputMethod: switchToInputMethod_, | 322 switchToInputMethod: switchToInputMethod_, |
| 307 openSettings: openSettings_ | 323 openSettings: openSettings_ |
| 308 }; | 324 }; |
| 309 | 325 |
| 310 registerFunction('chrome.input.ime.hideInputView', function() { | 326 registerFunction('chrome.input.ime.hideInputView', function() { |
| 311 chrome.virtualKeyboardPrivate.hideKeyboard(); | 327 chrome.virtualKeyboardPrivate.hideKeyboard(); |
| 312 chrome.virtualKeyboardPrivate.lockKeyboard(false); | 328 chrome.virtualKeyboardPrivate.lockKeyboard(false); |
| 313 }); | 329 }); |
| 314 | 330 |
| 315 var defaultSendMessage = registerFunction('chrome.runtime.sendMessage'); | 331 var defaultSendMessage = registerFunction('chrome.runtime.sendMessage'); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 var Controller = i18n.input.chrome.inputview.Controller; | 411 var Controller = i18n.input.chrome.inputview.Controller; |
| 396 Controller.DISABLE_HWT = !(opt_config && opt_config.enableHwtForTesting); | 412 Controller.DISABLE_HWT = !(opt_config && opt_config.enableHwtForTesting); |
| 397 onSwitchToKeyset(keyset, function() { | 413 onSwitchToKeyset(keyset, function() { |
| 398 chrome.virtualKeyboardPrivate.keyboardLoaded(); | 414 chrome.virtualKeyboardPrivate.keyboardLoaded(); |
| 399 }); | 415 }); |
| 400 if (controller) | 416 if (controller) |
| 401 controller.initialize(keyset, languageCode, passwordLayout, name); | 417 controller.initialize(keyset, languageCode, passwordLayout, name); |
| 402 else | 418 else |
| 403 controller = new Controller(keyset, languageCode, passwordLayout, name); | 419 controller = new Controller(keyset, languageCode, passwordLayout, name); |
| 404 }; | 420 }; |
| OLD | NEW |