Chromium Code Reviews| Index: ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java |
| diff --git a/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java b/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java |
| index d99f612d6b2770436574b97a96f73aef32a66a33..d2b0a513d99d7155caf41d1c44bff2b070144668 100644 |
| --- a/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java |
| +++ b/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java |
| @@ -8,6 +8,7 @@ import android.annotation.TargetApi; |
| import android.content.ClipData; |
| import android.graphics.Bitmap; |
| import android.os.Build; |
| +import android.view.PointerIcon; |
| import android.view.View; |
| import android.view.ViewGroup; |
| import android.widget.FrameLayout.LayoutParams; |
| @@ -16,6 +17,7 @@ import android.widget.ImageView; |
| import org.chromium.base.ApiCompatibilityUtils; |
| import org.chromium.base.annotations.CalledByNative; |
| import org.chromium.base.annotations.JNINamespace; |
| +import org.chromium.blink_public.web.WebCursorInfoType; |
| /** |
| * Class to acquire, position, and remove anchor views from the implementing View. |
| @@ -99,6 +101,115 @@ public abstract class ViewAndroidDelegate { |
| new View.DragShadowBuilder(imageView), null, View.DRAG_FLAG_GLOBAL); |
| } |
| + @CalledByNative |
| + private void onCursorChangedToCustom(Bitmap customCursorBitmap, int hotspotX, int hotspotY) { |
| + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| + getContainerView().getRootView().setPointerIcon( |
| + PointerIcon.create(customCursorBitmap, hotspotX, hotspotY)); |
| + } |
| + } |
| + |
| + @CalledByNative |
| + public void onCursorChanged(int cursorType) { |
| + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return; |
| + |
| + int pointerIconType; |
| + switch (cursorType) { |
| + case WebCursorInfoType.TYPE_NONE: |
| + pointerIconType = PointerIcon.TYPE_NULL; |
| + break; |
| + case WebCursorInfoType.TYPE_POINTER: |
| + pointerIconType = PointerIcon.TYPE_ARROW; |
| + break; |
| + case WebCursorInfoType.TYPE_CONTEXT_MENU: |
| + pointerIconType = PointerIcon.TYPE_CONTEXT_MENU; |
| + break; |
| + case WebCursorInfoType.TYPE_HAND: |
| + pointerIconType = PointerIcon.TYPE_HAND; |
| + break; |
| + case WebCursorInfoType.TYPE_HELP: |
| + pointerIconType = PointerIcon.TYPE_HELP; |
| + break; |
| + case WebCursorInfoType.TYPE_WAIT: |
| + pointerIconType = PointerIcon.TYPE_WAIT; |
| + break; |
| + case WebCursorInfoType.TYPE_CELL: |
| + pointerIconType = PointerIcon.TYPE_CELL; |
| + break; |
| + case WebCursorInfoType.TYPE_CROSS: |
| + pointerIconType = PointerIcon.TYPE_CROSSHAIR; |
| + break; |
| + case WebCursorInfoType.TYPE_I_BEAM: |
| + pointerIconType = PointerIcon.TYPE_TEXT; |
| + break; |
| + case WebCursorInfoType.TYPE_VERTICAL_TEXT: |
| + pointerIconType = PointerIcon.TYPE_VERTICAL_TEXT; |
| + break; |
| + case WebCursorInfoType.TYPE_ALIAS: |
| + pointerIconType = PointerIcon.TYPE_ALIAS; |
| + break; |
| + case WebCursorInfoType.TYPE_COPY: |
| + pointerIconType = PointerIcon.TYPE_COPY; |
| + break; |
| + case WebCursorInfoType.TYPE_NO_DROP: |
| + pointerIconType = PointerIcon.TYPE_NO_DROP; |
| + break; |
| + case WebCursorInfoType.TYPE_EAST_WEST_RESIZE: |
| + case WebCursorInfoType.TYPE_COLUMN_RESIZE: |
| + pointerIconType = PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW; |
| + break; |
| + case WebCursorInfoType.TYPE_NORTH_SOUTH_RESIZE: |
| + case WebCursorInfoType.TYPE_ROW_RESIZE: |
| + pointerIconType = PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW; |
| + break; |
| + case WebCursorInfoType.TYPE_NORTH_EAST_SOUTH_WEST_RESIZE: |
| + pointerIconType = PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW; |
| + break; |
| + case WebCursorInfoType.TYPE_NORTH_WEST_SOUTH_EAST_RESIZE: |
| + pointerIconType = PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW; |
| + break; |
| + case WebCursorInfoType.TYPE_ZOOM_IN: |
| + pointerIconType = PointerIcon.TYPE_ZOOM_IN; |
| + break; |
| + case WebCursorInfoType.TYPE_ZOOM_OUT: |
| + pointerIconType = PointerIcon.TYPE_ZOOM_OUT; |
| + break; |
| + case WebCursorInfoType.TYPE_GRAB: |
| + pointerIconType = PointerIcon.TYPE_GRAB; |
| + break; |
| + case WebCursorInfoType.TYPE_GRABBING: |
| + pointerIconType = PointerIcon.TYPE_GRABBING; |
| + break; |
| + case WebCursorInfoType.TYPE_EAST_RESIZE: |
|
Jinsuk Kim
2017/05/18 02:19:51
default: will be enough. No need to have other cas
aelias_OOO_until_Jul13
2017/05/18 18:57:34
I would prefer the reverse, please remove "default
jaebaek
2017/05/22 12:08:34
This is for letting others know all enums specifie
|
| + case WebCursorInfoType.TYPE_NORTH_RESIZE: |
| + case WebCursorInfoType.TYPE_NORTH_EAST_RESIZE: |
| + case WebCursorInfoType.TYPE_NORTH_WEST_RESIZE: |
| + case WebCursorInfoType.TYPE_SOUTH_RESIZE: |
| + case WebCursorInfoType.TYPE_SOUTH_EAST_RESIZE: |
| + case WebCursorInfoType.TYPE_SOUTH_WEST_RESIZE: |
| + case WebCursorInfoType.TYPE_WEST_RESIZE: |
| + case WebCursorInfoType.TYPE_MIDDLE_PANNING: |
| + case WebCursorInfoType.TYPE_EAST_PANNING: |
| + case WebCursorInfoType.TYPE_NORTH_PANNING: |
| + case WebCursorInfoType.TYPE_NORTH_EAST_PANNING: |
| + case WebCursorInfoType.TYPE_NORTH_WEST_PANNING: |
| + case WebCursorInfoType.TYPE_SOUTH_PANNING: |
| + case WebCursorInfoType.TYPE_SOUTH_EAST_PANNING: |
| + case WebCursorInfoType.TYPE_SOUTH_WEST_PANNING: |
| + case WebCursorInfoType.TYPE_WEST_PANNING: |
| + case WebCursorInfoType.TYPE_MOVE: |
| + case WebCursorInfoType.TYPE_PROGRESS: |
| + case WebCursorInfoType.TYPE_NOT_ALLOWED: |
| + case WebCursorInfoType.TYPE_CUSTOM: |
| + default: |
| + pointerIconType = PointerIcon.TYPE_ARROW; |
| + break; |
| + } |
| + ViewGroup containerView = getContainerView(); |
| + containerView.getRootView().setPointerIcon( |
| + PointerIcon.getSystemIcon(containerView.getContext(), pointerIconType)); |
| + } |
| + |
| /** |
| * Called whenever the background color of the page changes as notified by Blink. |
| * @param color The new ARGB color of the page background. |