| OLD | NEW |
| 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; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 9 import android.app.assist.AssistStructure.ViewNode; | 9 import android.app.assist.AssistStructure.ViewNode; |
| 10 import android.content.ClipData; | 10 import android.content.ClipData; |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 public void setImeAdapterForTest(ImeAdapter imeAdapter) { | 476 public void setImeAdapterForTest(ImeAdapter imeAdapter) { |
| 477 mImeAdapter = imeAdapter; | 477 mImeAdapter = imeAdapter; |
| 478 } | 478 } |
| 479 | 479 |
| 480 @VisibleForTesting | 480 @VisibleForTesting |
| 481 public ImeAdapter getImeAdapterForTest() { | 481 public ImeAdapter getImeAdapterForTest() { |
| 482 return mImeAdapter; | 482 return mImeAdapter; |
| 483 } | 483 } |
| 484 | 484 |
| 485 private ImeAdapter createImeAdapter() { | 485 private ImeAdapter createImeAdapter() { |
| 486 return new ImeAdapter( | 486 return new ImeAdapter(mWebContents, new InputMethodManagerWrapper(mConte
xt), |
| 487 new InputMethodManagerWrapper(mContext), new ImeAdapter.ImeAdapt
erDelegate() { | 487 new ImeAdapter.ImeAdapterDelegate() { |
| 488 @Override | 488 @Override |
| 489 public void onImeEvent() { | 489 public void onImeEvent() { |
| 490 mPopupZoomer.hide(true); | 490 mPopupZoomer.hide(true); |
| 491 getContentViewClient().onImeEvent(); | 491 getContentViewClient().onImeEvent(); |
| 492 if (isFocusedNodeEditable()) mWebContents.dismissTextHan
dles(); | 492 if (isFocusedNodeEditable()) mWebContents.dismissTextHan
dles(); |
| 493 } | 493 } |
| 494 | 494 |
| 495 @Override | 495 @Override |
| 496 public void onKeyboardBoundsUnchanged() { | 496 public void onKeyboardBoundsUnchanged() { |
| 497 assert mWebContents != null; | 497 assert mWebContents != null; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 mRenderCoordinates.setDeviceScaleFactor(dipScale, windowAndroid.getConte
xt()); | 562 mRenderCoordinates.setDeviceScaleFactor(dipScale, windowAndroid.getConte
xt()); |
| 563 | 563 |
| 564 mNativeContentViewCore = nativeInit(webContents, mViewAndroidDelegate, w
indowNativePointer, | 564 mNativeContentViewCore = nativeInit(webContents, mViewAndroidDelegate, w
indowNativePointer, |
| 565 dipScale, mRetainedJavaScriptObjects); | 565 dipScale, mRetainedJavaScriptObjects); |
| 566 mWebContents = nativeGetWebContentsAndroid(mNativeContentViewCore); | 566 mWebContents = nativeGetWebContentsAndroid(mNativeContentViewCore); |
| 567 | 567 |
| 568 setContainerViewInternals(internalDispatcher); | 568 setContainerViewInternals(internalDispatcher); |
| 569 | 569 |
| 570 initPopupZoomer(mContext); | 570 initPopupZoomer(mContext); |
| 571 mImeAdapter = createImeAdapter(); | 571 mImeAdapter = createImeAdapter(); |
| 572 attachImeAdapter(); | |
| 573 | 572 |
| 574 mSelectionPopupController = new SelectionPopupController(mContext, windo
wAndroid, | 573 mSelectionPopupController = new SelectionPopupController(mContext, windo
wAndroid, |
| 575 webContents, viewDelegate.getContainerView(), mRenderCoordinates
, mImeAdapter); | 574 webContents, viewDelegate.getContainerView(), mRenderCoordinates
); |
| 576 mSelectionPopupController.setCallback(ActionModeCallbackHelper.EMPTY_CAL
LBACK); | 575 mSelectionPopupController.setCallback(ActionModeCallbackHelper.EMPTY_CAL
LBACK); |
| 577 mSelectionPopupController.setContainerView(getContainerView()); | 576 mSelectionPopupController.setContainerView(getContainerView()); |
| 578 | 577 |
| 579 mWebContentsObserver = new ContentViewWebContentsObserver(this); | 578 mWebContentsObserver = new ContentViewWebContentsObserver(this); |
| 580 | 579 |
| 581 mShouldRequestUnbufferedDispatch = Build.VERSION.SDK_INT >= Build.VERSIO
N_CODES.LOLLIPOP | 580 mShouldRequestUnbufferedDispatch = Build.VERSION.SDK_INT >= Build.VERSIO
N_CODES.LOLLIPOP |
| 582 && ContentFeatureList.isEnabled(ContentFeatureList.REQUEST_UNBUF
FERED_DISPATCH); | 581 && ContentFeatureList.isEnabled(ContentFeatureList.REQUEST_UNBUF
FERED_DISPATCH); |
| 583 } | 582 } |
| 584 | 583 |
| 585 /** | 584 /** |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1764 } | 1763 } |
| 1765 | 1764 |
| 1766 mImeAdapter.onUpdateFrameInfo(mRenderCoordinates, hasInsertionMarker, | 1765 mImeAdapter.onUpdateFrameInfo(mRenderCoordinates, hasInsertionMarker, |
| 1767 isInsertionMarkerVisible, insertionMarkerHorizontal, insertionMa
rkerTop, | 1766 isInsertionMarkerVisible, insertionMarkerHorizontal, insertionMa
rkerTop, |
| 1768 insertionMarkerBottom); | 1767 insertionMarkerBottom); |
| 1769 | 1768 |
| 1770 TraceEvent.end("ContentViewCore:updateFrameInfo"); | 1769 TraceEvent.end("ContentViewCore:updateFrameInfo"); |
| 1771 } | 1770 } |
| 1772 | 1771 |
| 1773 @CalledByNative | 1772 @CalledByNative |
| 1774 private void updateImeAdapter(long nativeImeAdapterAndroid, int textInputTyp
e, | 1773 private void updateImeAdapter(int textInputType, int textInputFlags, int tex
tInputMode, |
| 1775 int textInputFlags, int textInputMode, String text, int selectionSta
rt, | 1774 String text, int selectionStart, int selectionEnd, int compositionSt
art, |
| 1776 int selectionEnd, int compositionStart, int compositionEnd, boolean
showImeIfNeeded, | 1775 int compositionEnd, boolean showImeIfNeeded, boolean replyToRequest)
{ |
| 1777 boolean replyToRequest) { | |
| 1778 try { | 1776 try { |
| 1779 TraceEvent.begin("ContentViewCore.updateImeAdapter"); | 1777 TraceEvent.begin("ContentViewCore.updateImeAdapter"); |
| 1780 boolean focusedNodeEditable = (textInputType != TextInputType.NONE); | 1778 boolean focusedNodeEditable = (textInputType != TextInputType.NONE); |
| 1781 boolean focusedNodeIsPassword = (textInputType == TextInputType.PASS
WORD); | 1779 boolean focusedNodeIsPassword = (textInputType == TextInputType.PASS
WORD); |
| 1782 | 1780 |
| 1783 mImeAdapter.attach(nativeImeAdapterAndroid); | |
| 1784 mImeAdapter.updateState(textInputType, textInputFlags, textInputMode
, showImeIfNeeded, | 1781 mImeAdapter.updateState(textInputType, textInputFlags, textInputMode
, showImeIfNeeded, |
| 1785 text, selectionStart, selectionEnd, compositionStart, compos
itionEnd, | 1782 text, selectionStart, selectionEnd, compositionStart, compos
itionEnd, |
| 1786 replyToRequest); | 1783 replyToRequest); |
| 1787 | 1784 |
| 1788 boolean editableToggled = (focusedNodeEditable != isFocusedNodeEdita
ble()); | 1785 boolean editableToggled = (focusedNodeEditable != isFocusedNodeEdita
ble()); |
| 1789 mSelectionPopupController.updateSelectionState(focusedNodeEditable, | 1786 mSelectionPopupController.updateSelectionState(focusedNodeEditable, |
| 1790 focusedNodeIsPassword); | 1787 focusedNodeIsPassword); |
| 1791 if (editableToggled) { | 1788 if (editableToggled) { |
| 1792 if (mJoystickScrollProvider != null) { | 1789 if (mJoystickScrollProvider != null) { |
| 1793 mJoystickScrollProvider.setEnabled(!focusedNodeEditable); | 1790 mJoystickScrollProvider.setEnabled(!focusedNodeEditable); |
| 1794 } | 1791 } |
| 1795 getContentViewClient().onFocusedNodeEditabilityChanged(focusedNo
deEditable); | 1792 getContentViewClient().onFocusedNodeEditabilityChanged(focusedNo
deEditable); |
| 1796 } | 1793 } |
| 1797 } finally { | 1794 } finally { |
| 1798 TraceEvent.end("ContentViewCore.updateImeAdapter"); | 1795 TraceEvent.end("ContentViewCore.updateImeAdapter"); |
| 1799 } | 1796 } |
| 1800 } | 1797 } |
| 1801 | 1798 |
| 1802 @CalledByNative | |
| 1803 private void forceUpdateImeAdapter(long nativeImeAdapterAndroid) { | |
| 1804 mImeAdapter.attach(nativeImeAdapterAndroid); | |
| 1805 } | |
| 1806 | |
| 1807 /** | 1799 /** |
| 1808 * Called (from native) when the <select> popup needs to be shown. | 1800 * Called (from native) when the <select> popup needs to be shown. |
| 1809 * @param anchorView View anchored for popup. | 1801 * @param anchorView View anchored for popup. |
| 1810 * @param nativeSelectPopupSourceFrame The native RenderFrameHost that owns
the popup. | 1802 * @param nativeSelectPopupSourceFrame The native RenderFrameHost that owns
the popup. |
| 1811 * @param items Items to show. | 1803 * @param items Items to show. |
| 1812 * @param enabled POPUP_ITEM_TYPEs for items. | 1804 * @param enabled POPUP_ITEM_TYPEs for items. |
| 1813 * @param multiple Whether the popup menu should support multi-select
. | 1805 * @param multiple Whether the popup menu should support multi-select
. |
| 1814 * @param selectedIndices Indices of selected items. | 1806 * @param selectedIndices Indices of selected items. |
| 1815 */ | 1807 */ |
| 1816 @SuppressWarnings("unused") | 1808 @SuppressWarnings("unused") |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1907 } | 1899 } |
| 1908 | 1900 |
| 1909 private boolean canPaste() { | 1901 private boolean canPaste() { |
| 1910 return ((ClipboardManager) mContext.getSystemService( | 1902 return ((ClipboardManager) mContext.getSystemService( |
| 1911 Context.CLIPBOARD_SERVICE)).hasPrimaryClip(); | 1903 Context.CLIPBOARD_SERVICE)).hasPrimaryClip(); |
| 1912 } | 1904 } |
| 1913 | 1905 |
| 1914 @SuppressWarnings("unused") | 1906 @SuppressWarnings("unused") |
| 1915 @CalledByNative | 1907 @CalledByNative |
| 1916 private void onRenderProcessChange() { | 1908 private void onRenderProcessChange() { |
| 1917 attachImeAdapter(); | |
| 1918 // Immediately sync closed caption settings to the new render process. | 1909 // Immediately sync closed caption settings to the new render process. |
| 1919 mSystemCaptioningBridge.syncToListener(this); | 1910 mSystemCaptioningBridge.syncToListener(this); |
| 1920 } | 1911 } |
| 1921 | 1912 |
| 1922 /** | 1913 /** |
| 1923 * Attaches the native ImeAdapter object to the java ImeAdapter to allow com
munication via JNI. | |
| 1924 */ | |
| 1925 public void attachImeAdapter() { | |
| 1926 if (mImeAdapter != null && mNativeContentViewCore != 0) { | |
| 1927 mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentViewCore)
); | |
| 1928 } | |
| 1929 } | |
| 1930 | |
| 1931 /** | |
| 1932 * @see View#hasFocus() | 1914 * @see View#hasFocus() |
| 1933 */ | 1915 */ |
| 1934 @CalledByNative | 1916 @CalledByNative |
| 1935 private boolean hasFocus() { | 1917 private boolean hasFocus() { |
| 1936 // If the container view is not focusable, we consider it always focused
from | 1918 // If the container view is not focusable, we consider it always focused
from |
| 1937 // Chromium's point of view. | 1919 // Chromium's point of view. |
| 1938 if (!mContainerView.isFocusable()) return true; | 1920 if (!mContainerView.isFocusable()) return true; |
| 1939 return mContainerView.hasFocus(); | 1921 return mContainerView.hasFocus(); |
| 1940 } | 1922 } |
| 1941 | 1923 |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2642 | 2624 |
| 2643 private native void nativeSetDoubleTapSupportEnabled( | 2625 private native void nativeSetDoubleTapSupportEnabled( |
| 2644 long nativeContentViewCoreImpl, boolean enabled); | 2626 long nativeContentViewCoreImpl, boolean enabled); |
| 2645 | 2627 |
| 2646 private native void nativeSetMultiTouchZoomSupportEnabled( | 2628 private native void nativeSetMultiTouchZoomSupportEnabled( |
| 2647 long nativeContentViewCoreImpl, boolean enabled); | 2629 long nativeContentViewCoreImpl, boolean enabled); |
| 2648 | 2630 |
| 2649 private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImp
l, | 2631 private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImp
l, |
| 2650 long nativeSelectPopupSourceFrame, int[] indices); | 2632 long nativeSelectPopupSourceFrame, int[] indices); |
| 2651 | 2633 |
| 2652 | |
| 2653 private native long nativeGetNativeImeAdapter(long nativeContentViewCoreImpl
); | |
| 2654 | |
| 2655 private native int nativeGetCurrentRenderProcessId(long nativeContentViewCor
eImpl); | 2634 private native int nativeGetCurrentRenderProcessId(long nativeContentViewCor
eImpl); |
| 2656 | 2635 |
| 2657 private native void nativeSetAllowJavascriptInterfacesInspection( | 2636 private native void nativeSetAllowJavascriptInterfacesInspection( |
| 2658 long nativeContentViewCoreImpl, boolean allow); | 2637 long nativeContentViewCoreImpl, boolean allow); |
| 2659 | 2638 |
| 2660 private native void nativeAddJavascriptInterface(long nativeContentViewCoreI
mpl, Object object, | 2639 private native void nativeAddJavascriptInterface(long nativeContentViewCoreI
mpl, Object object, |
| 2661 String name, Class requiredAnnotation); | 2640 String name, Class requiredAnnotation); |
| 2662 | 2641 |
| 2663 private native void nativeRemoveJavascriptInterface(long nativeContentViewCo
reImpl, | 2642 private native void nativeRemoveJavascriptInterface(long nativeContentViewCo
reImpl, |
| 2664 String name); | 2643 String name); |
| 2665 | 2644 |
| 2666 private native void nativeWasResized(long nativeContentViewCoreImpl); | 2645 private native void nativeWasResized(long nativeContentViewCoreImpl); |
| 2667 | 2646 |
| 2668 private native void nativeSetAccessibilityEnabled( | 2647 private native void nativeSetAccessibilityEnabled( |
| 2669 long nativeContentViewCoreImpl, boolean enabled); | 2648 long nativeContentViewCoreImpl, boolean enabled); |
| 2670 | 2649 |
| 2671 private native void nativeSetTextTrackSettings(long nativeContentViewCoreImp
l, | 2650 private native void nativeSetTextTrackSettings(long nativeContentViewCoreImp
l, |
| 2672 boolean textTracksEnabled, String textTrackBackgroundColor, String t
extTrackFontFamily, | 2651 boolean textTracksEnabled, String textTrackBackgroundColor, String t
extTrackFontFamily, |
| 2673 String textTrackFontStyle, String textTrackFontVariant, String textT
rackTextColor, | 2652 String textTrackFontStyle, String textTrackFontVariant, String textT
rackTextColor, |
| 2674 String textTrackTextShadow, String textTrackTextSize); | 2653 String textTrackTextShadow, String textTrackTextSize); |
| 2675 | 2654 |
| 2676 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl
, boolean opaque); | 2655 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl
, boolean opaque); |
| 2677 private native boolean nativeIsTouchDragDropEnabled(long nativeContentViewCo
reImpl); | 2656 private native boolean nativeIsTouchDragDropEnabled(long nativeContentViewCo
reImpl); |
| 2678 private native void nativeOnDragEvent(long nativeContentViewCoreImpl, int ac
tion, int x, int y, | 2657 private native void nativeOnDragEvent(long nativeContentViewCoreImpl, int ac
tion, int x, int y, |
| 2679 int screenX, int screenY, String[] mimeTypes, String content); | 2658 int screenX, int screenY, String[] mimeTypes, String content); |
| 2680 } | 2659 } |
| OLD | NEW |