Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: third_party/google_input_tools/src/chrome/os/inputview/adapter.js

Issue 701603002: Update to google-input-tools version 1.0.5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 193
194 /** 194 /**
195 * Use {@code chrome.input.ime.sendKeyEvents} to simulate key events. 195 * Use {@code chrome.input.ime.sendKeyEvents} to simulate key events.
196 * 196 *
197 * @param {!Array.<!Object.<string, string|boolean>>} keyData . 197 * @param {!Array.<!Object.<string, string|boolean>>} keyData .
198 * @private 198 * @private
199 */ 199 */
200 Adapter.prototype.sendKeyEvent_ = function(keyData) { 200 Adapter.prototype.sendKeyEvent_ = function(keyData) {
201 chrome.runtime.sendMessage( 201 chrome.runtime.sendMessage(
202 goog.object.create(Name.MSG_TYPE, Type.SEND_KEY_EVENT, Name.KEY_DATA, 202 goog.object.create(Name.TYPE, Type.SEND_KEY_EVENT, Name.KEY_DATA,
203 keyData)); 203 keyData));
204 }; 204 };
205 205
206 206
207 /** 207 /**
208 * Generates a {@code ChromeKeyboardEvent} by given values. 208 * Generates a {@code ChromeKeyboardEvent} by given values.
209 * 209 *
210 * @param {string} type . 210 * @param {string} type .
211 * @param {string} key The key. 211 * @param {string} key The key.
212 * @param {string} code The code. 212 * @param {string} code The code.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 }; 276 };
277 277
278 278
279 /** 279 /**
280 * Sends request for handwriting. 280 * Sends request for handwriting.
281 * 281 *
282 * @param {!Object} payload . 282 * @param {!Object} payload .
283 */ 283 */
284 Adapter.prototype.sendHwtRequest = function(payload) { 284 Adapter.prototype.sendHwtRequest = function(payload) {
285 chrome.runtime.sendMessage(goog.object.create( 285 chrome.runtime.sendMessage(goog.object.create(
286 Name.MSG_TYPE, Type.HWT_REQUEST, Name.MSG, payload 286 Name.TYPE, Type.HWT_REQUEST, Name.MSG, payload
287 )); 287 ));
288 }; 288 };
289 289
290 290
291 /** 291 /**
292 * True if it is a password box. 292 * True if it is a password box.
293 * 293 *
294 * @return {boolean} . 294 * @return {boolean} .
295 */ 295 */
296 Adapter.prototype.isPasswordBox = function() { 296 Adapter.prototype.isPasswordBox = function() {
(...skipping 28 matching lines...) Expand all
325 325
326 /** 326 /**
327 * Intializes the communication to background page. 327 * Intializes the communication to background page.
328 * 328 *
329 * @param {string} languageCode The language code. 329 * @param {string} languageCode The language code.
330 * @private 330 * @private
331 */ 331 */
332 Adapter.prototype.initBackground_ = function(languageCode) { 332 Adapter.prototype.initBackground_ = function(languageCode) {
333 chrome.runtime.getBackgroundPage((function() { 333 chrome.runtime.getBackgroundPage((function() {
334 chrome.runtime.sendMessage( 334 chrome.runtime.sendMessage(
335 goog.object.create(Name.MSG_TYPE, Type.CONNECT)); 335 goog.object.create(Name.TYPE, Type.CONNECT));
336 chrome.runtime.sendMessage(goog.object.create(Name.MSG_TYPE, 336 chrome.runtime.sendMessage(goog.object.create(Name.TYPE,
337 Type.VISIBILITY_CHANGE, Name.VISIBILITY, !document.webkitHidden)); 337 Type.VISIBILITY_CHANGE, Name.VISIBILITY, !document.webkitHidden));
338 if (languageCode) { 338 if (languageCode) {
339 this.setLanguage(languageCode); 339 this.setLanguage(languageCode);
340 } 340 }
341 }).bind(this)); 341 }).bind(this));
342 }; 342 };
343 343
344 344
345 /** 345 /**
346 * Loads the keyboard settings. 346 * Loads the keyboard settings.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 449
450 /** 450 /**
451 * Callback for visibility change on the input view window. 451 * Callback for visibility change on the input view window.
452 * 452 *
453 * @private 453 * @private
454 */ 454 */
455 Adapter.prototype.onVisibilityChange_ = function() { 455 Adapter.prototype.onVisibilityChange_ = function() {
456 this.isVisible = !document.webkitHidden; 456 this.isVisible = !document.webkitHidden;
457 this.dispatchEvent(new goog.events.Event(i18n.input.chrome.inputview. 457 this.dispatchEvent(new goog.events.Event(i18n.input.chrome.inputview.
458 events.EventType.VISIBILITY_CHANGE)); 458 events.EventType.VISIBILITY_CHANGE));
459 chrome.runtime.sendMessage(goog.object.create(Name.MSG_TYPE, 459 chrome.runtime.sendMessage(goog.object.create(Name.TYPE,
460 Type.VISIBILITY_CHANGE, Name.VISIBILITY, !document.webkitHidden)); 460 Type.VISIBILITY_CHANGE, Name.VISIBILITY, !document.webkitHidden));
461 }; 461 };
462 462
463 463
464 /** 464 /**
465 * Sends request for completion. 465 * Sends request for completion.
466 * 466 *
467 * @param {string} query . 467 * @param {string} query .
468 * @param {!Object=} opt_spatialData . 468 * @param {!Object=} opt_spatialData .
469 */ 469 */
470 Adapter.prototype.sendCompletionRequest = function(query, opt_spatialData) { 470 Adapter.prototype.sendCompletionRequest = function(query, opt_spatialData) {
471 var spatialData = {}; 471 var spatialData = {};
472 if (opt_spatialData) { 472 if (opt_spatialData) {
473 spatialData[Name.SOURCES] = opt_spatialData.sources; 473 spatialData[Name.SOURCES] = opt_spatialData.sources;
474 spatialData[Name.POSSIBILITIES] = opt_spatialData.possibilities; 474 spatialData[Name.POSSIBILITIES] = opt_spatialData.possibilities;
475 } 475 }
476 chrome.runtime.sendMessage(goog.object.create(Name.MSG_TYPE, 476 chrome.runtime.sendMessage(goog.object.create(Name.TYPE,
477 Type.COMPLETION, Name.TEXT, query, Name.SPATIAL_DATA, spatialData)); 477 Type.COMPLETION, Name.TEXT, query, Name.SPATIAL_DATA, spatialData));
478 }; 478 };
479 479
480 480
481 /** 481 /**
482 * Selects the candidate. 482 * Selects the candidate.
483 * 483 *
484 * @param {!Object} candidate . 484 * @param {!Object} candidate .
485 */ 485 */
486 Adapter.prototype.selectCandidate = function(candidate) { 486 Adapter.prototype.selectCandidate = function(candidate) {
487 chrome.runtime.sendMessage(goog.object.create( 487 chrome.runtime.sendMessage(goog.object.create(
488 Name.MSG_TYPE, Type.SELECT_CANDIDATE, Name.CANDIDATE, candidate)); 488 Name.TYPE, Type.SELECT_CANDIDATE, Name.CANDIDATE, candidate));
489 }; 489 };
490 490
491 491
492 /** 492 /**
493 * Commits the text. 493 * Commits the text.
494 * 494 *
495 * @param {string} text . 495 * @param {string} text .
496 */ 496 */
497 Adapter.prototype.commitText = function(text) { 497 Adapter.prototype.commitText = function(text) {
498 chrome.runtime.sendMessage(goog.object.create( 498 chrome.runtime.sendMessage(goog.object.create(
499 Name.MSG_TYPE, Type.COMMIT_TEXT, Name.TEXT, text)); 499 Name.TYPE, Type.COMMIT_TEXT, Name.TEXT, text));
500 }; 500 };
501 501
502 502
503 /** 503 /**
504 * Sets the language. 504 * Sets the language.
505 * 505 *
506 * @param {string} language . 506 * @param {string} language .
507 */ 507 */
508 Adapter.prototype.setLanguage = function(language) { 508 Adapter.prototype.setLanguage = function(language) {
509 chrome.runtime.sendMessage(goog.object.create( 509 chrome.runtime.sendMessage(goog.object.create(
510 Name.MSG_TYPE, Type.SET_LANGUAGE, Name.LANGUAGE, language)); 510 Name.TYPE, Type.SET_LANGUAGE, Name.LANGUAGE, language));
511 }; 511 };
512 512
513 513
514 /** 514 /**
515 * Callbck when completion is back. 515 * Callbck when completion is back.
516 * 516 *
517 * @param {!Object} message . 517 * @param {!Object} message .
518 * @private 518 * @private
519 */ 519 */
520 Adapter.prototype.onCandidatesBack_ = function(message) { 520 Adapter.prototype.onCandidatesBack_ = function(message) {
(...skipping 12 matching lines...) Expand all
533 533
534 534
535 /** 535 /**
536 * Sends Input Tool code to background. 536 * Sends Input Tool code to background.
537 * 537 *
538 * @param {string} inputToolCode . 538 * @param {string} inputToolCode .
539 */ 539 */
540 Adapter.prototype.setInputToolCode = function(inputToolCode) { 540 Adapter.prototype.setInputToolCode = function(inputToolCode) {
541 chrome.runtime.sendMessage( 541 chrome.runtime.sendMessage(
542 goog.object.create( 542 goog.object.create(
543 Name.MSG_TYPE, 543 Name.TYPE,
544 Type.HWT_SET_INPUTTOOL, 544 Type.HWT_SET_INPUTTOOL,
545 Name.MSG, 545 Name.MSG,
546 inputToolCode)); 546 inputToolCode));
547 }; 547 };
548 548
549 549
550 /** 550 /**
551 * Sends DOUBLE_CLICK_ON_SPACE_KEY message. 551 * Sends DOUBLE_CLICK_ON_SPACE_KEY message.
552 */ 552 */
553 Adapter.prototype.doubleClickOnSpaceKey = function() { 553 Adapter.prototype.doubleClickOnSpaceKey = function() {
554 chrome.runtime.sendMessage( 554 chrome.runtime.sendMessage(
555 goog.object.create( 555 goog.object.create(
556 Name.MSG_TYPE, 556 Name.TYPE,
557 Type.DOUBLE_CLICK_ON_SPACE_KEY)); 557 Type.DOUBLE_CLICK_ON_SPACE_KEY));
558 }; 558 };
559 559
560 560
561 /** 561 /**
562 * Sends message to the background when switch to emoji. 562 * Sends message to the background when switch to emoji.
563 * 563 *
564 */ 564 */
565 Adapter.prototype.setEmojiInputToolCode = function() { 565 Adapter.prototype.setEmojiInputToolCode = function() {
566 chrome.runtime.sendMessage( 566 chrome.runtime.sendMessage(
567 goog.object.create( 567 goog.object.create(
568 Name.MSG_TYPE, 568 Name.TYPE,
569 Type.EMOJI_SET_INPUTTOOL)); 569 Type.EMOJI_SET_INPUTTOOL));
570 }; 570 };
571 571
572 572
573 /** 573 /**
574 * Sends message to the background when do internal inputtool switch. 574 * Sends message to the background when do internal inputtool switch.
575 * 575 *
576 * @param {boolean} inputToolValue The value of the language flag. 576 * @param {boolean} inputToolValue The value of the language flag.
577 */ 577 */
578 Adapter.prototype.toggleLanguageState = function(inputToolValue) { 578 Adapter.prototype.toggleLanguageState = function(inputToolValue) {
579 chrome.runtime.sendMessage( 579 chrome.runtime.sendMessage(
580 goog.object.create( 580 goog.object.create(
581 Name.MSG_TYPE, 581 Name.TYPE,
582 Type.TOGGLE_LANGUAGE_STATE, 582 Type.TOGGLE_LANGUAGE_STATE,
583 Name.MSG, 583 Name.MSG,
584 inputToolValue)); 584 inputToolValue));
585 }; 585 };
586 586
587 587
588 /** 588 /**
589 * Sends unset Input Tool code to background. 589 * Sends unset Input Tool code to background.
590 */ 590 */
591 Adapter.prototype.unsetInputToolCode = function() { 591 Adapter.prototype.unsetInputToolCode = function() {
592 chrome.runtime.sendMessage( 592 chrome.runtime.sendMessage(
593 goog.object.create( 593 goog.object.create(
594 Name.MSG_TYPE, 594 Name.TYPE,
595 Type.HWT_UNSET_INPUTTOOL)); 595 Type.HWT_UNSET_INPUTTOOL));
596 }; 596 };
597 597
598 598
599 /** 599 /**
600 * Sends message to the background when switch to other mode from emoji. 600 * Sends message to the background when switch to other mode from emoji.
601 * 601 *
602 */ 602 */
603 Adapter.prototype.unsetEmojiInputToolCode = function() { 603 Adapter.prototype.unsetEmojiInputToolCode = function() {
604 chrome.runtime.sendMessage( 604 chrome.runtime.sendMessage(
605 goog.object.create( 605 goog.object.create(
606 Name.MSG_TYPE, 606 Name.TYPE,
607 Type.EMOJI_UNSET_INPUTTOOL)); 607 Type.EMOJI_UNSET_INPUTTOOL));
608 }; 608 };
609 609
610 610
611 /** 611 /**
612 * Processes incoming message from option page or inputview window. 612 * Processes incoming message from option page or inputview window.
613 * 613 *
614 * @param {*} request Message from option page or inputview window. 614 * @param {*} request Message from option page or inputview window.
615 * @param {*} sender Information about the script 615 * @param {*} sender Information about the script
616 * context that sent the message. 616 * context that sent the message.
617 * @param {function(*): void} sendResponse Function to call to send a response. 617 * @param {function(*): void} sendResponse Function to call to send a response.
618 * @return {boolean|undefined} {@code true} to keep the message channel open in 618 * @return {boolean|undefined} {@code true} to keep the message channel open in
619 * order to send a response asynchronously. 619 * order to send a response asynchronously.
620 * @private 620 * @private
621 */ 621 */
622 Adapter.prototype.onMessage_ = function(request, sender, sendResponse) { 622 Adapter.prototype.onMessage_ = function(request, sender, sendResponse) {
623 var type = request[Name.MSG_TYPE]; 623 var type = request[Name.TYPE];
624 var msg = request[Name.MSG]; 624 var msg = request[Name.MSG];
625 switch (type) { 625 switch (type) {
626 case Type.CANDIDATES_BACK: 626 case Type.CANDIDATES_BACK:
627 this.onCandidatesBack_(msg); 627 this.onCandidatesBack_(msg);
628 break; 628 break;
629 case Type.CONTEXT_FOCUS: 629 case Type.CONTEXT_FOCUS:
630 this.onContextFocus_(request[Name.CONTEXT_TYPE]); 630 this.onContextFocus_(request[Name.CONTEXT_TYPE]);
631 break; 631 break;
632 case Type.CONTEXT_BLUR: 632 case Type.CONTEXT_BLUR:
633 this.onContextBlur_(); 633 this.onContextBlur_();
(...skipping 10 matching lines...) Expand all
644 break; 644 break;
645 } 645 }
646 }; 646 };
647 647
648 648
649 /** 649 /**
650 * Sends the privacy confirmed message to background and broadcasts it. 650 * Sends the privacy confirmed message to background and broadcasts it.
651 */ 651 */
652 Adapter.prototype.sendHwtPrivacyConfirmMessage = function() { 652 Adapter.prototype.sendHwtPrivacyConfirmMessage = function() {
653 chrome.runtime.sendMessage( 653 chrome.runtime.sendMessage(
654 goog.object.create(Name.MSG_TYPE, Type.HWT_PRIVACY_GOT_IT)); 654 goog.object.create(Name.TYPE, Type.HWT_PRIVACY_GOT_IT));
655 this.dispatchEvent( 655 this.dispatchEvent(
656 new goog.events.Event(Type.HWT_PRIVACY_GOT_IT)); 656 new goog.events.Event(Type.HWT_PRIVACY_GOT_IT));
657 }; 657 };
658 658
659 659
660 /** @override */ 660 /** @override */
661 Adapter.prototype.disposeInternal = function() { 661 Adapter.prototype.disposeInternal = function() {
662 goog.dispose(this.handler_); 662 goog.dispose(this.handler_);
663 663
664 goog.base(this, 'disposeInternal'); 664 goog.base(this, 'disposeInternal');
665 }; 665 };
666 }); // goog.scope 666 }); // goog.scope
667 667
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698