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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java

Issue 2839993002: [Android] Adding Smart GO/NEXT feature in Chrome (Closed)
Patch Set: Fixed the build break by replacing WebViewImpl object with WebViewBase Created 3 years, 7 months 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 package org.chromium.content.browser.input; 5 package org.chromium.content.browser.input;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.content.res.Configuration; 8 import android.content.res.Configuration;
9 import android.graphics.Rect; 9 import android.graphics.Rect;
10 import android.os.Build; 10 import android.os.Build;
(...skipping 13 matching lines...) Expand all
24 import android.view.inputmethod.EditorInfo; 24 import android.view.inputmethod.EditorInfo;
25 import android.view.inputmethod.ExtractedText; 25 import android.view.inputmethod.ExtractedText;
26 import android.view.inputmethod.InputConnection; 26 import android.view.inputmethod.InputConnection;
27 import android.view.inputmethod.InputMethodManager; 27 import android.view.inputmethod.InputMethodManager;
28 28
29 import org.chromium.base.Log; 29 import org.chromium.base.Log;
30 import org.chromium.base.TraceEvent; 30 import org.chromium.base.TraceEvent;
31 import org.chromium.base.VisibleForTesting; 31 import org.chromium.base.VisibleForTesting;
32 import org.chromium.base.annotations.CalledByNative; 32 import org.chromium.base.annotations.CalledByNative;
33 import org.chromium.base.annotations.JNINamespace; 33 import org.chromium.base.annotations.JNINamespace;
34 import org.chromium.blink_public.web.WebFocusType;
34 import org.chromium.blink_public.web.WebInputEventModifier; 35 import org.chromium.blink_public.web.WebInputEventModifier;
35 import org.chromium.blink_public.web.WebInputEventType; 36 import org.chromium.blink_public.web.WebInputEventType;
36 import org.chromium.blink_public.web.WebTextInputMode; 37 import org.chromium.blink_public.web.WebTextInputMode;
37 import org.chromium.content.browser.ViewUtils; 38 import org.chromium.content.browser.ViewUtils;
38 import org.chromium.content.browser.picker.InputDialogContainer; 39 import org.chromium.content.browser.picker.InputDialogContainer;
39 import org.chromium.content_public.browser.ImeEventObserver; 40 import org.chromium.content_public.browser.ImeEventObserver;
40 import org.chromium.content_public.browser.WebContents; 41 import org.chromium.content_public.browser.WebContents;
41 import org.chromium.ui.base.ime.TextInputType; 42 import org.chromium.ui.base.ime.TextInputType;
42 43
43 import java.lang.ref.WeakReference; 44 import java.lang.ref.WeakReference;
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 case android.R.id.paste: 622 case android.R.id.paste:
622 mWebContents.paste(); 623 mWebContents.paste();
623 return true; 624 return true;
624 default: 625 default:
625 return false; 626 return false;
626 } 627 }
627 } 628 }
628 629
629 boolean performEditorAction(int actionCode) { 630 boolean performEditorAction(int actionCode) {
630 if (!isValid()) return false; 631 if (!isValid()) return false;
631 if (actionCode == EditorInfo.IME_ACTION_NEXT) { 632 switch (actionCode) {
632 sendSyntheticKeyPress(KeyEvent.KEYCODE_TAB, 633 case EditorInfo.IME_ACTION_NEXT:
633 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE 634 advanceFocusInForm(WebFocusType.FORWARD);
634 | KeyEvent.FLAG_EDITOR_ACTION); 635 break;
635 } else { 636 case EditorInfo.IME_ACTION_PREVIOUS:
636 sendSyntheticKeyPress(KeyEvent.KEYCODE_ENTER, 637 advanceFocusInForm(WebFocusType.BACKWARD);
637 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE 638 break;
638 | KeyEvent.FLAG_EDITOR_ACTION); 639 default:
640 sendSyntheticKeyPress(KeyEvent.KEYCODE_ENTER,
641 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_M ODE
642 | KeyEvent.FLAG_EDITOR_ACTION);
643 break;
639 } 644 }
640 return true; 645 return true;
641 } 646 }
642 647
648 /**
649 * Advances the focus to next input field in the current form.
650 *
651 * @param focusType indicates whether to advance forward or backward directi on.
652 */
653 private void advanceFocusInForm(int focusType) {
654 if (mNativeImeAdapterAndroid == 0) return;
655 nativeAdvanceFocusInForm(mNativeImeAdapterAndroid, focusType);
656 }
657
643 void notifyUserAction() { 658 void notifyUserAction() {
644 mInputMethodManagerWrapper.notifyUserAction(); 659 mInputMethodManagerWrapper.notifyUserAction();
645 } 660 }
646 661
647 @VisibleForTesting 662 @VisibleForTesting
648 protected void sendSyntheticKeyPress(int keyCode, int flags) { 663 protected void sendSyntheticKeyPress(int keyCode, int flags) {
649 long eventTime = SystemClock.uptimeMillis(); 664 long eventTime = SystemClock.uptimeMillis();
650 sendKeyEvent(new KeyEvent(eventTime, eventTime, 665 sendKeyEvent(new KeyEvent(eventTime, eventTime,
651 KeyEvent.ACTION_DOWN, keyCode, 0, 0, 666 KeyEvent.ACTION_DOWN, keyCode, 0, 0,
652 KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 667 KeyCharacterMap.VIRTUAL_KEYBOARD, 0,
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 private native void nativeSetEditableSelectionOffsets(long nativeImeAdapterA ndroid, 923 private native void nativeSetEditableSelectionOffsets(long nativeImeAdapterA ndroid,
909 int start, int end); 924 int start, int end);
910 private native void nativeSetComposingRegion(long nativeImeAdapterAndroid, i nt start, int end); 925 private native void nativeSetComposingRegion(long nativeImeAdapterAndroid, i nt start, int end);
911 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid , 926 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid ,
912 int before, int after); 927 int before, int after);
913 private native void nativeDeleteSurroundingTextInCodePoints( 928 private native void nativeDeleteSurroundingTextInCodePoints(
914 long nativeImeAdapterAndroid, int before, int after); 929 long nativeImeAdapterAndroid, int before, int after);
915 private native boolean nativeRequestTextInputStateUpdate(long nativeImeAdapt erAndroid); 930 private native boolean nativeRequestTextInputStateUpdate(long nativeImeAdapt erAndroid);
916 private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid, 931 private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid,
917 boolean immediateRequest, boolean monitorRequest); 932 boolean immediateRequest, boolean monitorRequest);
933 private native void nativeAdvanceFocusInForm(long nativeImeAdapterAndroid, i nt focusType);
918 } 934 }
OLDNEW
« no previous file with comments | « content/common/frame_messages.h ('k') | content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698