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

Side by Side Diff: content/shell/android/java/src/org/chromium/content_shell/ShellViewAndroidDelegate.java

Issue 2878403002: Support setting mouse cursor icon in Android N. (Closed)
Patch Set: Support setting mouse cursor icon in Android N Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_shell; 5 package org.chromium.content_shell;
6 6
7 import android.graphics.Bitmap;
8 import android.os.Build;
9 import android.view.PointerIcon;
7 import android.view.ViewGroup; 10 import android.view.ViewGroup;
8 11
12 import org.chromium.base.test.util.CallbackHelper;
13 import org.chromium.blink_public.web.WebCursorInfoType;
9 import org.chromium.ui.base.ViewAndroidDelegate; 14 import org.chromium.ui.base.ViewAndroidDelegate;
10 15
11 /** 16 /**
12 * Implementation of the abstract class {@link ViewAndroidDelegate} for content shell. 17 * Implementation of the abstract class {@link ViewAndroidDelegate} for content shell.
13 * Extended for testing. 18 * Extended for testing.
14 */ 19 */
15 public class ShellViewAndroidDelegate extends ViewAndroidDelegate { 20 public class ShellViewAndroidDelegate extends ViewAndroidDelegate {
21 /**
22 * CallbackHelper for cursor update.
23 */
24 public static class OnCursorUpdateHelper extends CallbackHelper {
25 private int mPointerType;
26 public void notifyCalled(int type) {
27 mPointerType = type;
28 notifyCalled();
29 }
30 public int getPointerType() {
31 assert getCallCount() > 0;
32 return mPointerType;
33 }
34 }
35
16 private final ViewGroup mContainerView; 36 private final ViewGroup mContainerView;
37 private final OnCursorUpdateHelper mOnCursorUpdateHelper;
17 38
18 public ShellViewAndroidDelegate(ViewGroup containerView) { 39 public ShellViewAndroidDelegate(ViewGroup containerView) {
19 mContainerView = containerView; 40 mContainerView = containerView;
41 mOnCursorUpdateHelper = new OnCursorUpdateHelper();
20 } 42 }
21 43
22 @Override 44 @Override
23 public ViewGroup getContainerView() { 45 public ViewGroup getContainerView() {
24 return mContainerView; 46 return mContainerView;
25 } 47 }
48
49 public OnCursorUpdateHelper getOnCursorUpdateHelper() {
50 return mOnCursorUpdateHelper;
51 }
52
53 @Override
54 public void onCursorChangedToCustom(Bitmap customCursorBitmap, int hotspotX, int hotspotY) {
55 super.onCursorChangedToCustom(customCursorBitmap, hotspotX, hotspotY);
56 mOnCursorUpdateHelper.notifyCalled(WebCursorInfoType.TYPE_CUSTOM);
57 }
58
59 @Override
60 public void onCursorChanged(int cursorType) {
61 super.onCursorChanged(cursorType);
62 mOnCursorUpdateHelper.notifyCalled(cursorType);
63 }
64
65 @Override
66 public void updatePointerIcon(PointerIcon icon) {
67 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
68 getContainerView().setPointerIcon(icon);
69 }
70 }
26 } 71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698