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.FeatureName'); |
23 goog.require('i18n.input.chrome.inputview.FeatureTracker'); | 23 goog.require('i18n.input.chrome.FeatureTracker'); |
24 goog.require('i18n.input.chrome.inputview.ReadyState'); | 24 goog.require('i18n.input.chrome.inputview.ReadyState'); |
25 goog.require('i18n.input.chrome.inputview.StateType'); | 25 goog.require('i18n.input.chrome.inputview.StateType'); |
26 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'); | 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.Name'); | 31 goog.require('i18n.input.chrome.message.Name'); |
32 goog.require('i18n.input.chrome.message.Type'); | 32 goog.require('i18n.input.chrome.message.Type'); |
33 | 33 |
34 goog.scope(function() { | 34 goog.scope(function() { |
35 var CandidatesBackEvent = i18n.input.chrome.DataSource.CandidatesBackEvent; | 35 var CandidatesBackEvent = i18n.input.chrome.DataSource.CandidatesBackEvent; |
36 var ContextType = i18n.input.chrome.message.ContextType; | 36 var ContextType = i18n.input.chrome.message.ContextType; |
37 var FeatureTracker = i18n.input.chrome.inputview.FeatureTracker; | 37 var FeatureTracker = i18n.input.chrome.FeatureTracker; |
38 var FeatureName = i18n.input.chrome.inputview.FeatureName; | 38 var FeatureName = i18n.input.chrome.FeatureName; |
39 var GesturesBackEvent = i18n.input.chrome.DataSource.GesturesBackEvent; | 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 State = i18n.input.chrome.inputview.ReadyState.State; |
42 var Type = i18n.input.chrome.message.Type; | 42 var Type = i18n.input.chrome.message.Type; |
43 var events = i18n.input.chrome.inputview.events; | 43 var events = i18n.input.chrome.inputview.events; |
44 | 44 |
45 | 45 |
46 | 46 |
47 /** | 47 /** |
48 * The adapter for interview. | 48 * The adapter for interview. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 var Adapter = i18n.input.chrome.inputview.Adapter; | 102 var Adapter = i18n.input.chrome.inputview.Adapter; |
103 | 103 |
104 | 104 |
105 /** | 105 /** |
106 * URL prefixes of common Google sites. | 106 * URL prefixes of common Google sites. |
107 * | 107 * |
108 * @enum {string} | 108 * @enum {string} |
109 */ | 109 */ |
110 Adapter.GoogleSites = { | 110 Adapter.GoogleSites = { |
111 // TODO: Add support for spreadsheets. | 111 // TODO: Add support for spreadsheets. |
112 DOCS: 'https://docs.google.com/document/d' | 112 DOCS: 'https://docs.google.com/document/d', |
| 113 MAIL: 'https://mail.google.com' |
113 }; | 114 }; |
114 | 115 |
115 | 116 |
| 117 /** |
| 118 * The minimal inches of display which enables floating virtual keyboard. |
| 119 * |
| 120 * @private {number} |
| 121 */ |
| 122 Adapter.ENABLE_FLOATING_THRESHOLD_INCHES_ = 15; |
| 123 |
| 124 |
116 /** @type {boolean} */ | 125 /** @type {boolean} */ |
117 Adapter.prototype.isA11yMode = false; | 126 Adapter.prototype.isA11yMode = false; |
118 | 127 |
119 | 128 |
120 /** @type {boolean} */ | 129 /** @type {boolean} */ |
| 130 Adapter.prototype.isHotrod = false; |
| 131 |
| 132 |
| 133 /** @type {boolean} */ |
121 Adapter.prototype.isVoiceInputEnabled = true; | 134 Adapter.prototype.isVoiceInputEnabled = true; |
122 | 135 |
123 | 136 |
124 /** @type {boolean} */ | 137 /** @type {boolean} */ |
125 Adapter.prototype.showGlobeKey = false; | 138 Adapter.prototype.showGlobeKey = false; |
126 | 139 |
127 | 140 |
| 141 /** @type {number} */ |
| 142 Adapter.prototype.displayInInches = 0; |
| 143 |
| 144 |
128 /** @type {string} */ | 145 /** @type {string} */ |
129 Adapter.prototype.contextType = ContextType.DEFAULT; | 146 Adapter.prototype.contextType = ContextType.DEFAULT; |
130 | 147 |
131 | 148 |
132 /** @type {string} */ | 149 /** @type {string} */ |
133 Adapter.prototype.screen = ''; | 150 Adapter.prototype.screen = ''; |
134 | 151 |
135 | 152 |
136 /** @type {boolean} */ | 153 /** @type {boolean} */ |
137 Adapter.prototype.isChromeVoxOn = false; | 154 Adapter.prototype.isChromeVoxOn = false; |
138 | 155 |
139 | 156 |
140 /** @type {string} */ | 157 /** @type {string} */ |
141 Adapter.prototype.textBeforeCursor = ''; | 158 Adapter.prototype.textBeforeCursor = ''; |
142 | 159 |
143 | 160 |
144 /** @type {boolean} */ | |
145 Adapter.prototype.isFloating = false; | |
146 | |
147 | |
148 /** | 161 /** |
149 * Whether the background controller is on switching. | 162 * Whether the background controller is on switching. |
150 * | 163 * |
151 * @private {boolean} | 164 * @private {boolean} |
152 */ | 165 */ |
153 Adapter.prototype.isBgControllerSwitching_ = false; | 166 Adapter.prototype.isBgControllerSwitching_ = false; |
154 | 167 |
155 | 168 |
156 /** | 169 /** |
157 * Callback for updating settings. | 170 * Callback for updating settings. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 goog.object.create( | 261 goog.object.create( |
249 Name.TYPE, Type.SET_GESTURE_EDITING, | 262 Name.TYPE, Type.SET_GESTURE_EDITING, |
250 Name.IN_PROGRESS, inProgress, | 263 Name.IN_PROGRESS, inProgress, |
251 Name.IS_SWIPE, opt_isSwipe)); | 264 Name.IS_SWIPE, opt_isSwipe)); |
252 }; | 265 }; |
253 | 266 |
254 | 267 |
255 /** | 268 /** |
256 * Sends a gesture typing event to the backend for decoding. | 269 * Sends a gesture typing event to the backend for decoding. |
257 * | 270 * |
258 * @param {!Array.<!i18n.input.chrome.inputview.elements.content. | 271 * @param {!Array.<!i18n.input.chrome.inputview.elements.content.Point>} |
259 * GestureCanvasView.Point>} gestureData The gesture data | 272 * gestureData The gesture data (trail) to send. |
260 * (trail) to send. | |
261 */ | 273 */ |
262 Adapter.prototype.sendGestureEvent = function(gestureData) { | 274 Adapter.prototype.sendGestureEvent = function(gestureData) { |
263 chrome.runtime.sendMessage( | 275 chrome.runtime.sendMessage( |
264 goog.object.create(Name.TYPE, Type.SEND_GESTURE_EVENT, Name.GESTURE_DATA, | 276 goog.object.create(Name.TYPE, Type.SEND_GESTURE_EVENT, Name.GESTURE_DATA, |
265 gestureData)); | 277 gestureData)); |
266 }; | 278 }; |
267 | 279 |
268 | 280 |
269 /** | 281 /** |
270 * Simulates to send 'keyup' event. | 282 * Simulates to send 'keyup' event. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 * @private | 331 * @private |
320 */ | 332 */ |
321 Adapter.prototype.generateKeyboardEvent_ = function( | 333 Adapter.prototype.generateKeyboardEvent_ = function( |
322 type, key, code, opt_keyCode, opt_spatialData, opt_modifiers) { | 334 type, key, code, opt_keyCode, opt_spatialData, opt_modifiers) { |
323 var StateType = i18n.input.chrome.inputview.StateType; | 335 var StateType = i18n.input.chrome.inputview.StateType; |
324 var ctrl = !!this.modifierState_[StateType.CTRL]; | 336 var ctrl = !!this.modifierState_[StateType.CTRL]; |
325 var alt = !!this.modifierState_[StateType.ALT]; | 337 var alt = !!this.modifierState_[StateType.ALT]; |
326 var shift = !!this.modifierState_[StateType.SHIFT]; | 338 var shift = !!this.modifierState_[StateType.SHIFT]; |
327 | 339 |
328 if (opt_modifiers) { | 340 if (opt_modifiers) { |
329 if (opt_modifiers.ctrl) | 341 if (opt_modifiers.ctrl != undefined) |
330 ctrl = opt_modifiers.ctrl; | 342 ctrl = opt_modifiers.ctrl; |
331 if (opt_modifiers.shift) | 343 if (opt_modifiers.shift != undefined) |
332 shift = opt_modifiers.shift; | 344 shift = opt_modifiers.shift; |
333 } | 345 } |
334 | 346 |
335 if (ctrl || alt) { | 347 if (ctrl || alt) { |
336 key = ''; | 348 key = ''; |
337 } | 349 } |
338 var result = { | 350 var result = { |
339 'type': type, | 351 'type': type, |
340 'key': key, | 352 'key': key, |
341 'code': code, | 353 'code': code, |
342 'keyCode': opt_keyCode || 0, | 354 'keyCode': opt_keyCode || 0, |
343 'spatialData': opt_spatialData | 355 'spatialData': opt_spatialData |
344 }; | 356 }; |
345 | 357 |
346 result['altKey'] = alt; | 358 result['altKey'] = alt; |
347 result['ctrlKey'] = ctrl; | 359 result['ctrlKey'] = ctrl; |
348 result['shiftKey'] = shift; | 360 result['shiftKey'] = shift; |
349 result['capsLock'] = !!this.modifierState_[StateType.CAPSLOCK]; | 361 result['capsLock'] = !!this.modifierState_[StateType.CAPSLOCK]; |
350 | 362 |
351 return result; | 363 return result; |
352 }; | 364 }; |
353 | 365 |
354 | 366 |
355 /** | 367 /** |
356 * Callback when surrounding text is changed. | 368 * Callback when surrounding text is changed. |
357 * | 369 * |
358 * @param {string} text . | 370 * @param {string} textBeforeCursor . |
359 * @param {number} anchor . | 371 * @param {number} anchor . |
360 * @param {number} focus . | 372 * @param {number} focus . |
| 373 * @param {number} offset . |
361 * @private | 374 * @private |
362 */ | 375 */ |
363 Adapter.prototype.onSurroundingTextChanged_ = function(text, anchor, focus) { | 376 Adapter.prototype.onSurroundingTextChanged_ = function(textBeforeCursor, |
364 this.textBeforeCursor = text; | 377 anchor, focus, offset) { |
| 378 this.textBeforeCursor = textBeforeCursor; |
365 this.dispatchEvent(new i18n.input.chrome.inputview.events. | 379 this.dispatchEvent(new i18n.input.chrome.inputview.events. |
366 SurroundingTextChangedEvent(this.textBeforeCursor, anchor, focus)); | 380 SurroundingTextChangedEvent(textBeforeCursor, anchor, focus, |
| 381 offset)); |
367 }; | 382 }; |
368 | 383 |
369 | 384 |
370 /** | 385 /** |
371 * Gets the context. | 386 * Gets the context. |
372 * | 387 * |
373 * @return {string} . | 388 * @return {string} . |
374 */ | 389 */ |
375 Adapter.prototype.getContext = function() { | 390 Adapter.prototype.getContext = function() { |
376 var matches = this.textBeforeCursor.match(/([a-zA-Z'-Ḁ-ỹÀ-ȳ]+)\s+$/); | 391 var matches = this.textBeforeCursor.match(/([a-zA-Z'-Ḁ-ỹÀ-ȳ]+)\s+$/); |
(...skipping 28 matching lines...) Expand all Loading... |
405 * Whether the floating virtual keyboard feature is enabled. | 420 * Whether the floating virtual keyboard feature is enabled. |
406 * | 421 * |
407 * @return {boolean} | 422 * @return {boolean} |
408 */ | 423 */ |
409 Adapter.prototype.isFloatingVirtualKeyboardEnabled = function() { | 424 Adapter.prototype.isFloatingVirtualKeyboardEnabled = function() { |
410 // This feature depends on setMode API. The api is a private API and may not | 425 // This feature depends on setMode API. The api is a private API and may not |
411 // be available all the time. | 426 // be available all the time. |
412 if (!inputview || !inputview.setMode) { | 427 if (!inputview || !inputview.setMode) { |
413 return false; | 428 return false; |
414 } | 429 } |
| 430 |
| 431 if (!this.readyState_.isReady(State.DISPLAY_SIZE_READY)) |
| 432 console.error('Display size is not ready yet.'); |
| 433 |
| 434 // Disable floating virtual keyboard if the screen is smaller than |
| 435 // ENABLE_FLOATING_THRESHOLD_PX. |
| 436 if (this.displayInInches < Adapter.ENABLE_FLOATING_THRESHOLD_INCHES_) { |
| 437 return false; |
| 438 } |
415 return this.features.isEnabled(FeatureName.FLOATING_VIRTUAL_KEYBOARD); | 439 return this.features.isEnabled(FeatureName.FLOATING_VIRTUAL_KEYBOARD); |
416 }; | 440 }; |
417 | 441 |
418 | 442 |
419 /** | 443 /** |
420 * Callback when blurs in the context. | 444 * Callback when blurs in the context. |
421 * | 445 * |
422 * @private | 446 * @private |
423 */ | 447 */ |
424 Adapter.prototype.onContextBlur_ = function() { | 448 Adapter.prototype.onContextBlur_ = function() { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 * | 486 * |
463 * @return {boolean} . | 487 * @return {boolean} . |
464 */ | 488 */ |
465 Adapter.prototype.isGoogleDocument = function() { | 489 Adapter.prototype.isGoogleDocument = function() { |
466 return this.currentSite_ && | 490 return this.currentSite_ && |
467 this.currentSite_.lastIndexOf(Adapter.GoogleSites.DOCS) === 0; | 491 this.currentSite_.lastIndexOf(Adapter.GoogleSites.DOCS) === 0; |
468 }; | 492 }; |
469 | 493 |
470 | 494 |
471 /** | 495 /** |
| 496 * Returns whether the current context is Google Mail. |
| 497 * |
| 498 * @return {boolean} |
| 499 */ |
| 500 Adapter.prototype.isGoogleMail = function() { |
| 501 return this.currentSite_ && |
| 502 this.currentSite_.lastIndexOf(Adapter.GoogleSites.MAIL) === 0; |
| 503 }; |
| 504 |
| 505 |
| 506 /** |
472 * Callback when focus on a context. | 507 * Callback when focus on a context. |
473 * | 508 * |
474 * @param {!Object<string, *>} message . | 509 * @param {!Object<string, *>} message . |
475 * @private | 510 * @private |
476 */ | 511 */ |
477 Adapter.prototype.onContextFocus_ = function(message) { | 512 Adapter.prototype.onContextFocus_ = function(message) { |
478 // URL might have changed. | 513 // URL might have changed. |
479 this.queryCurrentSite(); | 514 this.queryCurrentSite(); |
480 | 515 |
481 this.contextType = /** @type {string} */ (message[Name.CONTEXT_TYPE]); | 516 this.contextType = /** @type {string} */ (message[Name.CONTEXT_TYPE]); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 } | 551 } |
517 this.isChromeVoxOn = details['value']; | 552 this.isChromeVoxOn = details['value']; |
518 }).bind(this)); | 553 }).bind(this)); |
519 } | 554 } |
520 | 555 |
521 this.initBackground_(); | 556 this.initBackground_(); |
522 | 557 |
523 if (window.inputview) { | 558 if (window.inputview) { |
524 inputview.getKeyboardConfig((function(config) { | 559 inputview.getKeyboardConfig((function(config) { |
525 this.isA11yMode = !!config['a11ymode']; | 560 this.isA11yMode = !!config['a11ymode']; |
| 561 this.isHotrod = !!config['hotrodmode']; |
526 this.features.initialize(config); | 562 this.features.initialize(config); |
527 this.isVoiceInputEnabled = | 563 this.isVoiceInputEnabled = |
528 this.features.isEnabled(FeatureName.VOICE_INPUT); | 564 this.features.isEnabled(FeatureName.VOICE_INPUT); |
529 this.readyState_.markStateReady(State.KEYBOARD_CONFIG_READY); | 565 this.readyState_.markStateReady(State.KEYBOARD_CONFIG_READY); |
530 this.maybeDispatchSettingsReadyEvent_(); | 566 this.maybeDispatchSettingsReadyEvent_(); |
531 }).bind(this)); | 567 }).bind(this)); |
532 inputview.getInputMethods((function(inputMethods) { | 568 inputview.getInputMethods((function(inputMethods) { |
533 // Only show globe key to switching between IMEs when there are more | 569 // Globe key is disabled if either condition is met: |
534 // than one IME. | 570 // - Only one IME presents. |
535 this.showGlobeKey = inputMethods.length > 1; | 571 // - In hotrod mode. |
| 572 this.showGlobeKey = inputMethods.length > 1 && !this.isHotrod; |
536 this.readyState_.markStateReady(State.IME_LIST_READY); | 573 this.readyState_.markStateReady(State.IME_LIST_READY); |
537 this.maybeDispatchSettingsReadyEvent_(); | 574 this.maybeDispatchSettingsReadyEvent_(); |
538 }).bind(this)); | 575 }).bind(this)); |
| 576 inputview.getDisplayInInches((function(inches) { |
| 577 this.displayInInches = inches; |
| 578 this.readyState_.markStateReady(State.DISPLAY_SIZE_READY); |
| 579 this.maybeDispatchSettingsReadyEvent_(); |
| 580 }).bind(this)); |
539 } else { | 581 } else { |
540 this.readyState_.markStateReady(State.IME_LIST_READY); | 582 this.readyState_.markStateReady(State.IME_LIST_READY); |
541 this.readyState_.markStateReady(State.KEYBOARD_CONFIG_READY); | 583 this.readyState_.markStateReady(State.KEYBOARD_CONFIG_READY); |
| 584 this.readyState_.markStateReady(State.DISPLAY_SIZE_READY); |
542 } | 585 } |
543 | 586 |
544 this.maybeDispatchSettingsReadyEvent_(); | 587 this.maybeDispatchSettingsReadyEvent_(); |
545 }; | 588 }; |
546 | 589 |
547 | 590 |
548 /** | 591 /** |
549 * Dispatch event SETTINGS_READY if all required bits are flipped. | 592 * Dispatch event SETTINGS_READY if all required bits are flipped. |
550 * | 593 * |
551 * @private | 594 * @private |
552 */ | 595 */ |
553 Adapter.prototype.maybeDispatchSettingsReadyEvent_ = function() { | 596 Adapter.prototype.maybeDispatchSettingsReadyEvent_ = function() { |
554 var states = [ | 597 var states = [ |
555 State.KEYBOARD_CONFIG_READY, | 598 State.KEYBOARD_CONFIG_READY, |
556 State.IME_LIST_READY]; | 599 State.IME_LIST_READY, |
| 600 State.DISPLAY_SIZE_READY]; |
557 var ready = true; | 601 var ready = true; |
558 for (var i = 0; i < states.length; i++) { | 602 for (var i = 0; i < states.length; i++) { |
559 ready = ready && this.readyState_.isReady(states[i]); | 603 ready = ready && this.readyState_.isReady(states[i]); |
560 } | 604 } |
561 if (ready) { | 605 if (ready) { |
562 window.setTimeout((function() { | 606 window.setTimeout((function() { |
563 this.dispatchEvent(new goog.events.Event( | 607 this.dispatchEvent(new goog.events.Event( |
564 i18n.input.chrome.inputview.events.EventType.SETTINGS_READY)); | 608 i18n.input.chrome.inputview.events.EventType.SETTINGS_READY)); |
565 }).bind(this), 0); | 609 }).bind(this), 0); |
566 } | 610 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 * | 701 * |
658 * @param {string} text . | 702 * @param {string} text . |
659 */ | 703 */ |
660 Adapter.prototype.commitText = function(text) { | 704 Adapter.prototype.commitText = function(text) { |
661 chrome.runtime.sendMessage(goog.object.create( | 705 chrome.runtime.sendMessage(goog.object.create( |
662 Name.TYPE, Type.COMMIT_TEXT, Name.TEXT, text)); | 706 Name.TYPE, Type.COMMIT_TEXT, Name.TEXT, text)); |
663 }; | 707 }; |
664 | 708 |
665 | 709 |
666 /** | 710 /** |
667 * Commits the gesture result. | 711 * Commits the gesture result, possibly with a force space before the result. |
668 * | 712 * |
669 * @param {string} text . | 713 * @param {string} text . |
| 714 * @param {boolean} forceAutoSpace . |
670 */ | 715 */ |
671 Adapter.prototype.commitGestureResult = function(text) { | 716 Adapter.prototype.commitGestureResult = function(text, forceAutoSpace) { |
672 chrome.runtime.sendMessage(goog.object.create( | 717 chrome.runtime.sendMessage(goog.object.create( |
673 Name.TYPE, Type.CONFIRM_GESTURE_RESULT, Name.TEXT, text)); | 718 Name.TYPE, Type.CONFIRM_GESTURE_RESULT, Name.TEXT, text, |
| 719 Name.FORCE_AUTO_SPACE, forceAutoSpace)); |
674 }; | 720 }; |
675 | 721 |
676 | 722 |
677 /** | 723 /** |
678 * Sets the language. | 724 * Sets the language. |
679 * | 725 * |
680 * @param {string} language . | 726 * @param {string} language . |
681 */ | 727 */ |
682 Adapter.prototype.setLanguage = function(language) { | 728 Adapter.prototype.setLanguage = function(language) { |
683 chrome.runtime.sendMessage(goog.object.create( | 729 chrome.runtime.sendMessage(goog.object.create( |
684 Name.TYPE, Type.SET_LANGUAGE, Name.LANGUAGE, language)); | 730 Name.TYPE, Type.SET_LANGUAGE, Name.LANGUAGE, language)); |
685 }; | 731 }; |
686 | 732 |
687 | 733 |
688 /** | 734 /** |
689 * Callbck when completion is back. | 735 * Callbck when completion is back. |
690 * | 736 * |
691 * @param {!Object} message . | 737 * @param {!Object} message . |
692 * @private | 738 * @private |
693 */ | 739 */ |
694 Adapter.prototype.onCandidatesBack_ = function(message) { | 740 Adapter.prototype.onCandidatesBack_ = function(message) { |
695 var source = message['source'] || ''; | 741 var source = message['source'] || ''; |
696 var candidates = message['candidates'] || []; | 742 var candidates = message['candidates'] || []; |
697 this.dispatchEvent(new CandidatesBackEvent(source, candidates)); | 743 this.dispatchEvent(new CandidatesBackEvent(source, candidates)); |
698 }; | 744 }; |
699 | 745 |
700 | 746 |
701 /** | 747 /** |
702 * Callbck when completion is back. | 748 * Callback when completion is back. |
703 * | 749 * |
704 * @param {!Object} message . | 750 * @param {!Object} message . |
705 * @private | 751 * @private |
706 */ | 752 */ |
707 Adapter.prototype.onGesturesBack_ = function(message) { | 753 Adapter.prototype.onGesturesBack_ = function(message) { |
708 var results = message[Name.GESTURE_RESULTS]; | 754 var results = message[Name.GESTURE_RESULTS]; |
709 this.dispatchEvent(new GesturesBackEvent(results)); | 755 this.dispatchEvent(new GesturesBackEvent(results)); |
710 }; | 756 }; |
711 | 757 |
712 | 758 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 case Type.CONTEXT_FOCUS: | 814 case Type.CONTEXT_FOCUS: |
769 this.onContextFocus_(msg); | 815 this.onContextFocus_(msg); |
770 break; | 816 break; |
771 case Type.CONTEXT_BLUR: | 817 case Type.CONTEXT_BLUR: |
772 this.onContextBlur_(); | 818 this.onContextBlur_(); |
773 break; | 819 break; |
774 case Type.GESTURES_BACK: | 820 case Type.GESTURES_BACK: |
775 this.onGesturesBack_(msg); | 821 this.onGesturesBack_(msg); |
776 break; | 822 break; |
777 case Type.SURROUNDING_TEXT_CHANGED: | 823 case Type.SURROUNDING_TEXT_CHANGED: |
778 this.onSurroundingTextChanged_(request[Name.TEXT], | 824 this.onSurroundingTextChanged_(request[Name.TEXT_BEFORE_CURSOR], |
779 request[Name.ANCHOR], | 825 request[Name.ANCHOR], |
780 request[Name.FOCUS]); | 826 request[Name.FOCUS], |
| 827 request[Name.OFFSET]); |
781 break; | 828 break; |
782 case Type.UPDATE_SETTINGS: | 829 case Type.UPDATE_SETTINGS: |
783 this.onUpdateSettings_(msg); | 830 this.onUpdateSettings_(msg); |
784 break; | 831 break; |
785 case Type.VOICE_STATE_CHANGE: | 832 case Type.VOICE_STATE_CHANGE: |
786 this.dispatchEvent( | 833 this.dispatchEvent( |
787 new events.MessageEvent(events.EventType.VOICE_STATE_CHANGE, | 834 new events.MessageEvent(events.EventType.VOICE_STATE_CHANGE, |
788 msg)); | 835 msg)); |
789 break; | 836 break; |
790 case Type.HWT_NETWORK_ERROR: | 837 case Type.HWT_NETWORK_ERROR: |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 /** | 896 /** |
850 * Unset the inputtool | 897 * Unset the inputtool |
851 */ | 898 */ |
852 Adapter.prototype.unsetController = function() { | 899 Adapter.prototype.unsetController = function() { |
853 chrome.runtime.sendMessage( | 900 chrome.runtime.sendMessage( |
854 goog.object.create( | 901 goog.object.create( |
855 Name.TYPE, | 902 Name.TYPE, |
856 Type.UNSET_CONTROLLER)); | 903 Type.UNSET_CONTROLLER)); |
857 }; | 904 }; |
858 }); // goog.scope | 905 }); // goog.scope |
859 | |
OLD | NEW |