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

Side by Side 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, 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "ui/android/view_android.h" 5 #include "ui/android/view_android.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
11 #include "base/containers/adapters.h" 11 #include "base/containers/adapters.h"
12 #include "cc/layers/layer.h" 12 #include "cc/layers/layer.h"
13 #include "jni/ViewAndroidDelegate_jni.h" 13 #include "jni/ViewAndroidDelegate_jni.h"
14 #include "third_party/WebKit/public/platform/WebCursorInfo.h"
14 #include "ui/android/event_forwarder.h" 15 #include "ui/android/event_forwarder.h"
15 #include "ui/android/view_client.h" 16 #include "ui/android/view_client.h"
16 #include "ui/android/window_android.h" 17 #include "ui/android/window_android.h"
17 #include "ui/base/layout.h" 18 #include "ui/base/layout.h"
18 #include "ui/events/android/drag_event_android.h" 19 #include "ui/events/android/drag_event_android.h"
19 #include "ui/events/android/motion_event_android.h" 20 #include "ui/events/android/motion_event_android.h"
21 #include "ui/gfx/android/java_bitmap.h"
20 #include "url/gurl.h" 22 #include "url/gurl.h"
21 23
22 namespace ui { 24 namespace ui {
23 25
24 using base::android::ConvertUTF8ToJavaString; 26 using base::android::ConvertUTF8ToJavaString;
25 using base::android::JavaRef; 27 using base::android::JavaRef;
26 using base::android::ScopedJavaLocalRef; 28 using base::android::ScopedJavaLocalRef;
29 using blink::WebCursorInfo;
27 30
28 ViewAndroid::ScopedAnchorView::ScopedAnchorView( 31 ViewAndroid::ScopedAnchorView::ScopedAnchorView(
29 JNIEnv* env, 32 JNIEnv* env,
30 const JavaRef<jobject>& jview, 33 const JavaRef<jobject>& jview,
31 const JavaRef<jobject>& jdelegate) 34 const JavaRef<jobject>& jdelegate)
32 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) { 35 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) {
33 // If there's a view, then we need a delegate to remove it. 36 // If there's a view, then we need a delegate to remove it.
34 DCHECK(!jdelegate.is_null() || jview.is_null()); 37 DCHECK(!jdelegate.is_null() || jview.is_null());
35 } 38 }
36 39
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, 249 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext,
247 const JavaRef<jobject>& jimage) { 250 const JavaRef<jobject>& jimage) {
248 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); 251 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
249 if (delegate.is_null()) 252 if (delegate.is_null())
250 return false; 253 return false;
251 JNIEnv* env = base::android::AttachCurrentThread(); 254 JNIEnv* env = base::android::AttachCurrentThread();
252 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, 255 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext,
253 jimage); 256 jimage);
254 } 257 }
255 258
259 void ViewAndroid::OnCursorChanged(int type,
260 const SkBitmap& custom_image,
261 const gfx::Point& hotspot) {
262 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
263 if (delegate.is_null())
264 return;
265 JNIEnv* env = base::android::AttachCurrentThread();
266 if (type == WebCursorInfo::kTypeCustom) {
267 ScopedJavaLocalRef<jobject> java_bitmap =
268 gfx::ConvertToJavaBitmap(&custom_image);
269 Java_ViewAndroidDelegate_onCursorChangedToCustom(env, delegate, java_bitmap,
270 hotspot.x(), hotspot.y());
271 } else {
272 Java_ViewAndroidDelegate_onCursorChanged(env, delegate, type);
273 }
274 }
275
256 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) { 276 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) {
257 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); 277 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
258 if (delegate.is_null()) 278 if (delegate.is_null())
259 return; 279 return;
260 JNIEnv* env = base::android::AttachCurrentThread(); 280 JNIEnv* env = base::android::AttachCurrentThread();
261 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color); 281 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color);
262 } 282 }
263 283
264 void ViewAndroid::OnTopControlsChanged(float top_controls_offset, 284 void ViewAndroid::OnTopControlsChanged(float top_controls_offset,
265 float top_content_offset) { 285 float top_content_offset) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 matched = bound.Contains(int_point); 400 matched = bound.Contains(int_point);
381 } 401 }
382 if (matched && child->HitTest(send_to_client, event, offset_point)) 402 if (matched && child->HitTest(send_to_client, event, offset_point))
383 return true; 403 return true;
384 } 404 }
385 } 405 }
386 return false; 406 return false;
387 } 407 }
388 408
389 } // namespace ui 409 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698