OLD | NEW |
1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. | 1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. |
2 // limitations under the License. | 2 // limitations under the License. |
3 // See the License for the specific language governing permissions and | 3 // See the License for the specific language governing permissions and |
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
5 // distributed under the License is distributed on an "AS-IS" BASIS, | 5 // distributed under the License is distributed on an "AS-IS" BASIS, |
6 // Unless required by applicable law or agreed to in writing, software | 6 // Unless required by applicable law or agreed to in writing, software |
7 // | 7 // |
8 // http://www.apache.org/licenses/LICENSE-2.0 | 8 // http://www.apache.org/licenses/LICENSE-2.0 |
9 // | 9 // |
10 // You may obtain a copy of the License at | 10 // You may obtain a copy of the License at |
11 // you may not use this file except in compliance with the License. | 11 // you may not use this file except in compliance with the License. |
12 // Licensed under the Apache License, Version 2.0 (the "License"); | 12 // Licensed under the Apache License, Version 2.0 (the "License"); |
13 // | 13 // |
14 goog.provide('i18n.input.chrome.inputview.Adapter'); | 14 goog.provide('i18n.input.chrome.inputview.Adapter'); |
15 | 15 |
16 goog.require('goog.events.Event'); | 16 goog.require('goog.events.Event'); |
17 goog.require('goog.events.EventHandler'); | 17 goog.require('goog.events.EventHandler'); |
18 goog.require('goog.events.EventTarget'); | 18 goog.require('goog.events.EventTarget'); |
19 goog.require('goog.events.EventType'); | 19 goog.require('goog.events.EventType'); |
20 goog.require('goog.object'); | 20 goog.require('goog.object'); |
21 goog.require('i18n.input.chrome.DataSource'); | 21 goog.require('i18n.input.chrome.DataSource'); |
22 goog.require('i18n.input.chrome.inputview.FeatureName'); | 22 goog.require('i18n.input.chrome.inputview.FeatureName'); |
23 goog.require('i18n.input.chrome.inputview.FeatureTracker'); | 23 goog.require('i18n.input.chrome.inputview.FeatureTracker'); |
24 goog.require('i18n.input.chrome.inputview.GlobalFlags'); | |
25 goog.require('i18n.input.chrome.inputview.ReadyState'); | 24 goog.require('i18n.input.chrome.inputview.ReadyState'); |
26 goog.require('i18n.input.chrome.inputview.StateType'); | 25 goog.require('i18n.input.chrome.inputview.StateType'); |
27 goog.require('i18n.input.chrome.inputview.events.EventType'); | 26 goog.require('i18n.input.chrome.inputview.events.EventType'); |
| 27 goog.require('i18n.input.chrome.inputview.events.MessageEvent'); |
28 goog.require('i18n.input.chrome.inputview.events.SurroundingTextChangedEvent'); | 28 goog.require('i18n.input.chrome.inputview.events.SurroundingTextChangedEvent'); |
29 goog.require('i18n.input.chrome.message'); | 29 goog.require('i18n.input.chrome.message'); |
30 goog.require('i18n.input.chrome.message.ContextType'); | 30 goog.require('i18n.input.chrome.message.ContextType'); |
31 goog.require('i18n.input.chrome.message.Event'); | |
32 goog.require('i18n.input.chrome.message.Name'); | 31 goog.require('i18n.input.chrome.message.Name'); |
33 goog.require('i18n.input.chrome.message.Type'); | 32 goog.require('i18n.input.chrome.message.Type'); |
34 | 33 |
35 goog.scope(function() { | 34 goog.scope(function() { |
36 var CandidatesBackEvent = i18n.input.chrome.DataSource.CandidatesBackEvent; | 35 var CandidatesBackEvent = i18n.input.chrome.DataSource.CandidatesBackEvent; |
37 var ContextType = i18n.input.chrome.message.ContextType; | 36 var ContextType = i18n.input.chrome.message.ContextType; |
38 var FeatureTracker = i18n.input.chrome.inputview.FeatureTracker; | 37 var FeatureTracker = i18n.input.chrome.inputview.FeatureTracker; |
39 var FeatureName = i18n.input.chrome.inputview.FeatureName; | 38 var FeatureName = i18n.input.chrome.inputview.FeatureName; |
| 39 var GesturesBackEvent = i18n.input.chrome.DataSource.GesturesBackEvent; |
40 var Name = i18n.input.chrome.message.Name; | 40 var Name = i18n.input.chrome.message.Name; |
| 41 var State = i18n.input.chrome.inputview.ReadyState.State; |
41 var Type = i18n.input.chrome.message.Type; | 42 var Type = i18n.input.chrome.message.Type; |
| 43 var events = i18n.input.chrome.inputview.events; |
42 | 44 |
43 | 45 |
44 | 46 |
45 /** | 47 /** |
46 * The adapter for interview. | 48 * The adapter for interview. |
47 * | 49 * |
48 * @param {!i18n.input.chrome.inputview.ReadyState} readyState . | 50 * @param {!i18n.input.chrome.inputview.ReadyState} readyState . |
49 * @extends {goog.events.EventTarget} | 51 * @extends {goog.events.EventTarget} |
50 * @constructor | 52 * @constructor |
51 */ | 53 */ |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 135 |
134 /** @type {boolean} */ | 136 /** @type {boolean} */ |
135 Adapter.prototype.isChromeVoxOn = false; | 137 Adapter.prototype.isChromeVoxOn = false; |
136 | 138 |
137 | 139 |
138 /** @type {string} */ | 140 /** @type {string} */ |
139 Adapter.prototype.textBeforeCursor = ''; | 141 Adapter.prototype.textBeforeCursor = ''; |
140 | 142 |
141 | 143 |
142 /** @type {boolean} */ | 144 /** @type {boolean} */ |
143 Adapter.prototype.isQPInputView = true; | 145 Adapter.prototype.isFloating = false; |
144 | 146 |
145 | 147 |
146 /** | 148 /** |
147 * Whether the background controller is on switching. | 149 * Whether the background controller is on switching. |
148 * | 150 * |
149 * @private {boolean} | 151 * @private {boolean} |
150 */ | 152 */ |
151 Adapter.prototype.isBgControllerSwitching_ = false; | 153 Adapter.prototype.isBgControllerSwitching_ = false; |
152 | 154 |
153 | 155 |
154 /** | 156 /** |
155 * Callback for updating settings. | 157 * Callback for updating settings. |
156 * | 158 * |
157 * @param {!Object} message . | 159 * @param {!Object} message . |
158 * @private | 160 * @private |
159 */ | 161 */ |
160 Adapter.prototype.onUpdateSettings_ = function(message) { | 162 Adapter.prototype.onUpdateSettings_ = function(message) { |
161 this.screen = message[Name.SCREEN]; | 163 this.screen = message[Name.SCREEN]; |
162 this.queryCurrentSite(); | 164 this.queryCurrentSite(); |
163 this.contextType = /** @type {string} */ (message[Name.CONTEXT_TYPE]); | 165 this.contextType = /** @type {string} */ (message[Name.CONTEXT_TYPE]); |
164 // Resets the flag, since when inputview receive the update setting response, | 166 // Resets the flag, since when inputview receive the update setting response, |
165 // it means the background switching is done. | 167 // it means the background switching is done. |
166 this.isBgControllerSwitching_ = false; | 168 this.isBgControllerSwitching_ = false; |
167 this.dispatchEvent(new i18n.input.chrome.message.Event(Type.UPDATE_SETTINGS, | 169 this.dispatchEvent( |
168 message)); | 170 new events.MessageEvent(events.EventType.UPDATE_SETTINGS, message)); |
169 }; | 171 }; |
170 | 172 |
171 | 173 |
172 /** | 174 /** |
173 * Sets the modifier states. | 175 * Sets the modifier states. |
174 * | 176 * |
175 * @param {i18n.input.chrome.inputview.StateType} stateType . | 177 * @param {i18n.input.chrome.inputview.StateType} stateType . |
176 * @param {boolean} enable True to enable the state, false otherwise. | 178 * @param {boolean} enable True to enable the state, false otherwise. |
177 */ | 179 */ |
178 Adapter.prototype.setModifierState = function(stateType, enable) { | 180 Adapter.prototype.setModifierState = function(stateType, enable) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 */ | 230 */ |
229 Adapter.prototype.sendKeyDownEvent = function(key, code, opt_keyCode, | 231 Adapter.prototype.sendKeyDownEvent = function(key, code, opt_keyCode, |
230 opt_spatialData) { | 232 opt_spatialData) { |
231 this.sendKeyEvent_([this.generateKeyboardEvent_( | 233 this.sendKeyEvent_([this.generateKeyboardEvent_( |
232 goog.events.EventType.KEYDOWN, key, code, opt_keyCode, | 234 goog.events.EventType.KEYDOWN, key, code, opt_keyCode, |
233 opt_spatialData)]); | 235 opt_spatialData)]); |
234 }; | 236 }; |
235 | 237 |
236 | 238 |
237 /** | 239 /** |
| 240 * Sets whether gesture editing is in progress. |
| 241 * |
| 242 * @param {boolean} inProgress |
| 243 * @param {?boolean=} opt_isSwipe Whether it was triggered by a swipe. |
| 244 */ |
| 245 Adapter.prototype.setGestureEditingInProgress = function(inProgress, |
| 246 opt_isSwipe) { |
| 247 chrome.runtime.sendMessage( |
| 248 goog.object.create( |
| 249 Name.TYPE, Type.SET_GESTURE_EDITING, |
| 250 Name.IN_PROGRESS, inProgress, |
| 251 Name.IS_SWIPE, opt_isSwipe)); |
| 252 }; |
| 253 |
| 254 |
| 255 /** |
| 256 * Sends a gesture typing event to the backend for decoding. |
| 257 * |
| 258 * @param {!Array.<!i18n.input.chrome.inputview.elements.content. |
| 259 * GestureCanvasView.Point>} gestureData The gesture data |
| 260 * (trail) to send. |
| 261 */ |
| 262 Adapter.prototype.sendGestureEvent = function(gestureData) { |
| 263 chrome.runtime.sendMessage( |
| 264 goog.object.create(Name.TYPE, Type.SEND_GESTURE_EVENT, Name.GESTURE_DATA, |
| 265 gestureData)); |
| 266 }; |
| 267 |
| 268 |
| 269 /** |
238 * Simulates to send 'keyup' event. | 270 * Simulates to send 'keyup' event. |
239 * | 271 * |
240 * @param {string} key | 272 * @param {string} key |
241 * @param {string} code | 273 * @param {string} code |
242 * @param {number=} opt_keyCode The key code. | 274 * @param {number=} opt_keyCode The key code. |
243 * @param {!Object=} opt_spatialData . | 275 * @param {!Object=} opt_spatialData . |
244 */ | 276 */ |
245 Adapter.prototype.sendKeyUpEvent = function(key, code, opt_keyCode, | 277 Adapter.prototype.sendKeyUpEvent = function(key, code, opt_keyCode, |
246 opt_spatialData) { | 278 opt_spatialData) { |
247 this.sendKeyEvent_([this.generateKeyboardEvent_( | 279 this.sendKeyEvent_([this.generateKeyboardEvent_( |
248 goog.events.EventType.KEYUP, key, code, opt_keyCode, opt_spatialData)]); | 280 goog.events.EventType.KEYUP, key, code, opt_keyCode, opt_spatialData)]); |
249 }; | 281 }; |
250 | 282 |
251 | 283 |
252 /** | 284 /** |
253 * Use {@code chrome.input.ime.sendKeyEvents} to simulate key events. | 285 * Use {@code chrome.input.ime.sendKeyEvents} to simulate key events. |
254 * | 286 * |
255 * @param {!Array.<!Object.<string, string|boolean>>} keyData . | 287 * @param {!Array.<!Object.<string, string|boolean>>} keyData . |
256 * @private | 288 * @private |
257 */ | 289 */ |
258 Adapter.prototype.sendKeyEvent_ = function(keyData) { | 290 Adapter.prototype.sendKeyEvent_ = function(keyData) { |
259 chrome.runtime.sendMessage( | 291 chrome.runtime.sendMessage( |
260 goog.object.create(Name.TYPE, Type.SEND_KEY_EVENT, Name.KEY_DATA, | 292 goog.object.create(Name.TYPE, Type.SEND_KEY_EVENT, Name.KEY_DATA, |
261 keyData)); | 293 keyData)); |
262 }; | 294 }; |
263 | 295 |
264 | 296 |
265 /** | 297 /** |
| 298 * Sends an updated keyboard layout to the backend gesture typing decoder. |
| 299 * |
| 300 * @param {?Object} keyboardLayout The keyboard layout object to send. |
| 301 */ |
| 302 Adapter.prototype.sendKeyboardLayout = function(keyboardLayout) { |
| 303 chrome.runtime.sendMessage( |
| 304 goog.object.create(Name.TYPE, Type.SEND_KEYBOARD_LAYOUT, |
| 305 Name.KEYBOARD_LAYOUT, keyboardLayout)); |
| 306 }; |
| 307 |
| 308 |
| 309 /** |
266 * Generates a {@code ChromeKeyboardEvent} by given values. | 310 * Generates a {@code ChromeKeyboardEvent} by given values. |
267 * | 311 * |
268 * @param {string} type . | 312 * @param {string} type . |
269 * @param {string} key The key. | 313 * @param {string} key The key. |
270 * @param {string} code The code. | 314 * @param {string} code The code. |
271 * @param {number=} opt_keyCode The key code. | 315 * @param {number=} opt_keyCode The key code. |
272 * @param {!Object=} opt_spatialData . | 316 * @param {!Object=} opt_spatialData . |
273 * @param {!Object.<{ctrl: boolean, shift: boolean}>=} opt_modifiers . | 317 * @param {!Object.<{ctrl: boolean, shift: boolean}>=} opt_modifiers . |
274 * @return {!Object.<string, string|boolean>} | 318 * @return {!Object.<string, string|boolean>} |
275 * @private | 319 * @private |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 * True if it is a password box. | 395 * True if it is a password box. |
352 * | 396 * |
353 * @return {boolean} . | 397 * @return {boolean} . |
354 */ | 398 */ |
355 Adapter.prototype.isPasswordBox = function() { | 399 Adapter.prototype.isPasswordBox = function() { |
356 return this.contextType == 'password'; | 400 return this.contextType == 'password'; |
357 }; | 401 }; |
358 | 402 |
359 | 403 |
360 /** | 404 /** |
361 * True to enable gesture deletion. | 405 * Whether the floating virtual keyboard feature is enabled. |
362 * | 406 * |
363 * @return {boolean} | 407 * @return {boolean} |
364 */ | 408 */ |
365 Adapter.prototype.isGestureDeletionEnabled = function() { | 409 Adapter.prototype.isFloatingVirtualKeyboardEnabled = function() { |
366 // TODO: Omni bar sends wrong anchor/focus when autocompleting | 410 // This feature depends on setMode API. The api is a private API and may not |
367 // URLs. Re-enable when that is fixed. | 411 // be available all the time. |
368 if (this.contextType == ContextType.URL) { | 412 if (!inputview || !inputview.setMode) { |
369 return false; | 413 return false; |
370 } | 414 } |
371 return this.features.isEnabled(FeatureName.GESTURE_DELETION); | 415 return this.features.isEnabled(FeatureName.FLOATING_VIRTUAL_KEYBOARD); |
372 }; | 416 }; |
373 | 417 |
374 | 418 |
375 /** | |
376 * True to enable gesture typing. | |
377 * | |
378 * @return {boolean} | |
379 */ | |
380 Adapter.prototype.isGestureTypingEnabled = function() { | |
381 return this.features.isEnabled(FeatureName.GESTURE_TYPING); | |
382 }; | |
383 | |
384 | |
385 /** | 419 /** |
386 * Callback when blurs in the context. | 420 * Callback when blurs in the context. |
387 * | 421 * |
388 * @private | 422 * @private |
389 */ | 423 */ |
390 Adapter.prototype.onContextBlur_ = function() { | 424 Adapter.prototype.onContextBlur_ = function() { |
391 this.contextType = ''; | 425 this.contextType = ''; |
392 this.dispatchEvent(new goog.events.Event(i18n.input.chrome.inputview.events. | 426 this.dispatchEvent(new goog.events.Event(i18n.input.chrome.inputview.events. |
393 EventType.CONTEXT_BLUR)); | 427 EventType.CONTEXT_BLUR)); |
394 }; | 428 }; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 this.isBgControllerSwitching_ = true; | 494 this.isBgControllerSwitching_ = true; |
461 chrome.runtime.sendMessage(goog.object.create( | 495 chrome.runtime.sendMessage(goog.object.create( |
462 Name.TYPE, Type.CONNECT, | 496 Name.TYPE, Type.CONNECT, |
463 Name.VISIBILITY, this.isVisible)); | 497 Name.VISIBILITY, this.isVisible)); |
464 }).bind(this)); | 498 }).bind(this)); |
465 }; | 499 }; |
466 | 500 |
467 | 501 |
468 /** | 502 /** |
469 * Loads the keyboard settings. | 503 * Loads the keyboard settings. |
470 * | |
471 * @param {string} languageCode The language code. | |
472 */ | 504 */ |
473 Adapter.prototype.initialize = function(languageCode) { | 505 Adapter.prototype.initialize = function() { |
474 if (chrome.accessibilityFeatures && | 506 if (chrome.accessibilityFeatures && |
475 chrome.accessibilityFeatures.spokenFeedback) { | 507 chrome.accessibilityFeatures.spokenFeedback) { |
476 chrome.accessibilityFeatures.spokenFeedback.get({}, (function(details) { | 508 chrome.accessibilityFeatures.spokenFeedback.get({}, (function(details) { |
477 this.isChromeVoxOn = details['value']; | 509 this.isChromeVoxOn = details['value']; |
478 }).bind(this)); | 510 }).bind(this)); |
479 chrome.accessibilityFeatures.spokenFeedback.onChange.addListener((function( | 511 chrome.accessibilityFeatures.spokenFeedback.onChange.addListener((function( |
480 details) { | 512 details) { |
481 if (!this.isChromeVoxOn && details['value']) { | 513 if (!this.isChromeVoxOn && details['value']) { |
482 this.dispatchEvent(new goog.events.Event( | 514 this.dispatchEvent(new goog.events.Event( |
483 i18n.input.chrome.inputview.events.EventType.REFRESH)); | 515 i18n.input.chrome.inputview.events.EventType.REFRESH)); |
484 } | 516 } |
485 this.isChromeVoxOn = details['value']; | 517 this.isChromeVoxOn = details['value']; |
486 }).bind(this)); | 518 }).bind(this)); |
487 } | 519 } |
488 | 520 |
489 this.initBackground_(); | 521 this.initBackground_(); |
490 | 522 |
491 var StateType = i18n.input.chrome.inputview.ReadyState.StateType; | |
492 if (window.inputview) { | 523 if (window.inputview) { |
493 inputview.getKeyboardConfig((function(config) { | 524 inputview.getKeyboardConfig((function(config) { |
494 this.isA11yMode = !!config['a11ymode']; | 525 this.isA11yMode = !!config['a11ymode']; |
495 this.features.initialize(config); | 526 this.features.initialize(config); |
496 this.readyState_.markStateReady(StateType.KEYBOARD_CONFIG_READY); | 527 this.isVoiceInputEnabled = |
| 528 this.features.isEnabled(FeatureName.VOICE_INPUT); |
| 529 this.readyState_.markStateReady(State.KEYBOARD_CONFIG_READY); |
497 this.maybeDispatchSettingsReadyEvent_(); | 530 this.maybeDispatchSettingsReadyEvent_(); |
498 }).bind(this)); | 531 }).bind(this)); |
499 inputview.getInputMethods((function(inputMethods) { | 532 inputview.getInputMethods((function(inputMethods) { |
500 // Only show globe key to switching between IMEs when there are more | 533 // Only show globe key to switching between IMEs when there are more |
501 // than one IME. | 534 // than one IME. |
502 this.showGlobeKey = inputMethods.length > 1; | 535 this.showGlobeKey = inputMethods.length > 1; |
503 this.readyState_.markStateReady(StateType.IME_LIST_READY); | 536 this.readyState_.markStateReady(State.IME_LIST_READY); |
504 this.maybeDispatchSettingsReadyEvent_(); | |
505 }).bind(this)); | |
506 inputview.getInputMethodConfig((function(config) { | |
507 this.isQPInputView = !!config['isNewQPInputViewEnabled'] || | |
508 !!config['isNewMDInputViewEnabled']; | |
509 var voiceEnabled = config['isVoiceInputEnabled']; | |
510 if (goog.isDef(voiceEnabled)) { | |
511 this.isVoiceInputEnabled = !!voiceEnabled; | |
512 } | |
513 i18n.input.chrome.inputview.GlobalFlags.isQPInputView = | |
514 this.isQPInputView; | |
515 this.readyState_.markStateReady(StateType.INPUT_METHOD_CONFIG_READY); | |
516 this.maybeDispatchSettingsReadyEvent_(); | 537 this.maybeDispatchSettingsReadyEvent_(); |
517 }).bind(this)); | 538 }).bind(this)); |
518 } else { | 539 } else { |
519 this.readyState_.markStateReady(StateType.IME_LIST_READY); | 540 this.readyState_.markStateReady(State.IME_LIST_READY); |
520 this.readyState_.markStateReady(StateType.KEYBOARD_CONFIG_READY); | 541 this.readyState_.markStateReady(State.KEYBOARD_CONFIG_READY); |
521 this.readyState_.markStateReady(StateType.INPUT_METHOD_CONFIG_READY); | |
522 } | 542 } |
523 | 543 |
524 this.maybeDispatchSettingsReadyEvent_(); | 544 this.maybeDispatchSettingsReadyEvent_(); |
525 }; | 545 }; |
526 | 546 |
527 | 547 |
528 /** | 548 /** |
529 * Dispatch event SETTINGS_READY if all required bits are flipped. | 549 * Dispatch event SETTINGS_READY if all required bits are flipped. |
530 * | 550 * |
531 * @private | 551 * @private |
532 */ | 552 */ |
533 Adapter.prototype.maybeDispatchSettingsReadyEvent_ = function() { | 553 Adapter.prototype.maybeDispatchSettingsReadyEvent_ = function() { |
534 var StateType = i18n.input.chrome.inputview.ReadyState.StateType; | |
535 var states = [ | 554 var states = [ |
536 StateType.KEYBOARD_CONFIG_READY, | 555 State.KEYBOARD_CONFIG_READY, |
537 StateType.IME_LIST_READY, | 556 State.IME_LIST_READY]; |
538 StateType.INPUT_METHOD_CONFIG_READY]; | |
539 var ready = true; | 557 var ready = true; |
540 for (var i = 0; i < states.length; i++) { | 558 for (var i = 0; i < states.length; i++) { |
541 ready = ready && this.readyState_.isReady(states[i]); | 559 ready = ready && this.readyState_.isReady(states[i]); |
542 } | 560 } |
543 if (ready) { | 561 if (ready) { |
544 window.setTimeout((function() { | 562 window.setTimeout((function() { |
545 this.dispatchEvent(new goog.events.Event( | 563 this.dispatchEvent(new goog.events.Event( |
546 i18n.input.chrome.inputview.events.EventType.SETTINGS_READY)); | 564 i18n.input.chrome.inputview.events.EventType.SETTINGS_READY)); |
547 }).bind(this), 0); | 565 }).bind(this), 0); |
548 } | 566 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 * Callback for visibility change on the input view window. | 613 * Callback for visibility change on the input view window. |
596 * | 614 * |
597 * @private | 615 * @private |
598 */ | 616 */ |
599 Adapter.prototype.onVisibilityChange_ = function() { | 617 Adapter.prototype.onVisibilityChange_ = function() { |
600 this.isVisible = !document.webkitHidden; | 618 this.isVisible = !document.webkitHidden; |
601 this.dispatchEvent(new goog.events.Event(i18n.input.chrome.inputview. | 619 this.dispatchEvent(new goog.events.Event(i18n.input.chrome.inputview. |
602 events.EventType.VISIBILITY_CHANGE)); | 620 events.EventType.VISIBILITY_CHANGE)); |
603 chrome.runtime.sendMessage(goog.object.create( | 621 chrome.runtime.sendMessage(goog.object.create( |
604 Name.TYPE, Type.VISIBILITY_CHANGE, | 622 Name.TYPE, Type.VISIBILITY_CHANGE, |
605 Name.VISIBILITY, !document.webkitHidden, | 623 Name.VISIBILITY, !document.webkitHidden)); |
606 Name.WORKSPACE_HEIGHT, screen.height - window.innerHeight)); | |
607 }; | 624 }; |
608 | 625 |
609 | 626 |
610 /** | 627 /** |
611 * Sends request for completion. | 628 * Sends request for completion. |
612 * | 629 * |
613 * @param {string} query . | 630 * @param {string} query . |
614 * @param {!Object=} opt_spatialData . | 631 * @param {!Object=} opt_spatialData . |
615 */ | 632 */ |
616 Adapter.prototype.sendCompletionRequest = function(query, opt_spatialData) { | 633 Adapter.prototype.sendCompletionRequest = function(query, opt_spatialData) { |
(...skipping 23 matching lines...) Expand all Loading... |
640 * | 657 * |
641 * @param {string} text . | 658 * @param {string} text . |
642 */ | 659 */ |
643 Adapter.prototype.commitText = function(text) { | 660 Adapter.prototype.commitText = function(text) { |
644 chrome.runtime.sendMessage(goog.object.create( | 661 chrome.runtime.sendMessage(goog.object.create( |
645 Name.TYPE, Type.COMMIT_TEXT, Name.TEXT, text)); | 662 Name.TYPE, Type.COMMIT_TEXT, Name.TEXT, text)); |
646 }; | 663 }; |
647 | 664 |
648 | 665 |
649 /** | 666 /** |
| 667 * Commits the gesture result. |
| 668 * |
| 669 * @param {string} text . |
| 670 */ |
| 671 Adapter.prototype.commitGestureResult = function(text) { |
| 672 chrome.runtime.sendMessage(goog.object.create( |
| 673 Name.TYPE, Type.CONFIRM_GESTURE_RESULT, Name.TEXT, text)); |
| 674 }; |
| 675 |
| 676 |
| 677 /** |
650 * Sets the language. | 678 * Sets the language. |
651 * | 679 * |
652 * @param {string} language . | 680 * @param {string} language . |
653 */ | 681 */ |
654 Adapter.prototype.setLanguage = function(language) { | 682 Adapter.prototype.setLanguage = function(language) { |
655 chrome.runtime.sendMessage(goog.object.create( | 683 chrome.runtime.sendMessage(goog.object.create( |
656 Name.TYPE, Type.SET_LANGUAGE, Name.LANGUAGE, language)); | 684 Name.TYPE, Type.SET_LANGUAGE, Name.LANGUAGE, language)); |
657 }; | 685 }; |
658 | 686 |
659 | 687 |
660 /** | 688 /** |
661 * Callbck when completion is back. | 689 * Callbck when completion is back. |
662 * | 690 * |
663 * @param {!Object} message . | 691 * @param {!Object} message . |
664 * @private | 692 * @private |
665 */ | 693 */ |
666 Adapter.prototype.onCandidatesBack_ = function(message) { | 694 Adapter.prototype.onCandidatesBack_ = function(message) { |
667 var source = message['source'] || ''; | 695 var source = message['source'] || ''; |
668 var candidates = message['candidates'] || []; | 696 var candidates = message['candidates'] || []; |
669 this.dispatchEvent(new CandidatesBackEvent(source, candidates)); | 697 this.dispatchEvent(new CandidatesBackEvent(source, candidates)); |
670 }; | 698 }; |
671 | 699 |
672 | 700 |
673 /** | 701 /** |
| 702 * Callbck when completion is back. |
| 703 * |
| 704 * @param {!Object} message . |
| 705 * @private |
| 706 */ |
| 707 Adapter.prototype.onGesturesBack_ = function(message) { |
| 708 var results = message[Name.GESTURE_RESULTS]; |
| 709 this.dispatchEvent(new GesturesBackEvent(results)); |
| 710 }; |
| 711 |
| 712 |
| 713 /** |
674 * Hides the keyboard. | 714 * Hides the keyboard. |
675 */ | 715 */ |
676 Adapter.prototype.hideKeyboard = function() { | 716 Adapter.prototype.hideKeyboard = function() { |
677 chrome.input.ime.hideInputView(); | 717 chrome.input.ime.hideInputView(); |
678 }; | 718 }; |
679 | 719 |
680 | 720 |
681 /** | 721 /** |
682 * Sends DOUBLE_CLICK_ON_SPACE_KEY message. | 722 * Sends DOUBLE_CLICK_ON_SPACE_KEY message. |
683 */ | 723 */ |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 switch (type) { | 764 switch (type) { |
725 case Type.CANDIDATES_BACK: | 765 case Type.CANDIDATES_BACK: |
726 this.onCandidatesBack_(msg); | 766 this.onCandidatesBack_(msg); |
727 break; | 767 break; |
728 case Type.CONTEXT_FOCUS: | 768 case Type.CONTEXT_FOCUS: |
729 this.onContextFocus_(msg); | 769 this.onContextFocus_(msg); |
730 break; | 770 break; |
731 case Type.CONTEXT_BLUR: | 771 case Type.CONTEXT_BLUR: |
732 this.onContextBlur_(); | 772 this.onContextBlur_(); |
733 break; | 773 break; |
| 774 case Type.GESTURES_BACK: |
| 775 this.onGesturesBack_(msg); |
| 776 break; |
734 case Type.SURROUNDING_TEXT_CHANGED: | 777 case Type.SURROUNDING_TEXT_CHANGED: |
735 this.onSurroundingTextChanged_(request[Name.TEXT], | 778 this.onSurroundingTextChanged_(request[Name.TEXT], |
736 request[Name.ANCHOR], | 779 request[Name.ANCHOR], |
737 request[Name.FOCUS]); | 780 request[Name.FOCUS]); |
738 break; | 781 break; |
739 case Type.UPDATE_SETTINGS: | 782 case Type.UPDATE_SETTINGS: |
740 this.onUpdateSettings_(msg); | 783 this.onUpdateSettings_(msg); |
741 break; | 784 break; |
742 case Type.VOICE_STATE_CHANGE: | 785 case Type.VOICE_STATE_CHANGE: |
| 786 this.dispatchEvent( |
| 787 new events.MessageEvent(events.EventType.VOICE_STATE_CHANGE, |
| 788 msg)); |
| 789 break; |
743 case Type.HWT_NETWORK_ERROR: | 790 case Type.HWT_NETWORK_ERROR: |
| 791 this.dispatchEvent( |
| 792 new events.MessageEvent(events.EventType.HWT_NETWORK_ERROR, |
| 793 msg)); |
| 794 break; |
744 case Type.FRONT_TOGGLE_LANGUAGE_STATE: | 795 case Type.FRONT_TOGGLE_LANGUAGE_STATE: |
745 this.dispatchEvent(new i18n.input.chrome.message.Event(type, msg)); | 796 this.dispatchEvent( |
| 797 new events.MessageEvent(events.EventType.FRONT_TOGGLE_LANGUAGE_STATE, |
| 798 msg)); |
746 break; | 799 break; |
747 } | 800 } |
748 }; | 801 }; |
749 | 802 |
750 | 803 |
751 /** | 804 /** |
752 * Sends the voice state to background. | 805 * Sends the voice state to background. |
753 * | 806 * |
754 * @param {boolean} state . | 807 * @param {boolean} state . |
755 */ | 808 */ |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 * Unset the inputtool | 850 * Unset the inputtool |
798 */ | 851 */ |
799 Adapter.prototype.unsetController = function() { | 852 Adapter.prototype.unsetController = function() { |
800 chrome.runtime.sendMessage( | 853 chrome.runtime.sendMessage( |
801 goog.object.create( | 854 goog.object.create( |
802 Name.TYPE, | 855 Name.TYPE, |
803 Type.UNSET_CONTROLLER)); | 856 Type.UNSET_CONTROLLER)); |
804 }; | 857 }; |
805 }); // goog.scope | 858 }); // goog.scope |
806 | 859 |
OLD | NEW |