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

Unified Diff: ui/android/view_android.cc

Issue 2878403002: Support setting mouse cursor icon in Android N. (Closed)
Patch Set: Support setting mouse cursor icon in Android N 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 side-by-side diff with in-line comments
Download patch
Index: ui/android/view_android.cc
diff --git a/ui/android/view_android.cc b/ui/android/view_android.cc
index 489a1b930c6ed2995f824e310d458b041b3a5302..9bd53338e46c5ab9d04b58112d76a10f8c014171 100644
--- a/ui/android/view_android.cc
+++ b/ui/android/view_android.cc
@@ -11,11 +11,14 @@
#include "base/containers/adapters.h"
#include "cc/layers/layer.h"
#include "jni/ViewAndroidDelegate_jni.h"
+#include "third_party/WebKit/public/platform/WebCursorInfo.h"
#include "ui/android/event_forwarder.h"
#include "ui/android/view_client.h"
#include "ui/android/window_android.h"
+#include "ui/base/cursor/cursors_android.h"
#include "ui/base/layout.h"
#include "ui/events/android/motion_event_android.h"
+#include "ui/gfx/android/java_bitmap.h"
#include "url/gurl.h"
namespace ui {
@@ -23,6 +26,7 @@ namespace ui {
using base::android::ConvertUTF8ToJavaString;
using base::android::JavaRef;
using base::android::ScopedJavaLocalRef;
+using blink::WebCursorInfo;
ViewAndroid::ScopedAnchorView::ScopedAnchorView(
JNIEnv* env,
@@ -252,6 +256,29 @@ bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext,
jimage);
}
+void ViewAndroid::OnCursorChanged(int type,
+ const SkBitmap& custom_image,
+ const gfx::Point& hotspot) {
+ ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
+ if (delegate.is_null())
+ return;
+ JNIEnv* env = base::android::AttachCurrentThread();
+ SkBitmap drawn_cursor_image;
+ if (type == WebCursorInfo::kTypeCustom) {
+ ScopedJavaLocalRef<jobject> java_bitmap =
+ gfx::ConvertToJavaBitmap(&custom_image);
+ Java_ViewAndroidDelegate_onCursorChangedToCustom(env, delegate, java_bitmap,
+ hotspot.x(), hotspot.y());
+ } else if (GetCursorBitmap(type, &drawn_cursor_image)) {
+ ScopedJavaLocalRef<jobject> java_bitmap =
+ gfx::ConvertToJavaBitmap(&drawn_cursor_image);
+ Java_ViewAndroidDelegate_onCursorChangedToCustom(env, delegate, java_bitmap,
+ hotspot.x(), hotspot.y());
+ } else {
+ Java_ViewAndroidDelegate_onCursorChanged(env, delegate, type);
+ }
+}
+
void ViewAndroid::OnBackgroundColorChanged(unsigned int color) {
ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
if (delegate.is_null())

Powered by Google App Engine
This is Rietveld 408576698