OLD | NEW |
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 "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "cc/layers/layer.h" | 13 #include "cc/layers/layer.h" |
14 #include "jni/ViewAndroidDelegate_jni.h" | 14 #include "jni/ViewAndroidDelegate_jni.h" |
| 15 #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
15 #include "ui/android/event_forwarder.h" | 16 #include "ui/android/event_forwarder.h" |
16 #include "ui/android/view_client.h" | 17 #include "ui/android/view_client.h" |
17 #include "ui/android/window_android.h" | 18 #include "ui/android/window_android.h" |
18 #include "ui/base/layout.h" | 19 #include "ui/base/layout.h" |
19 #include "ui/events/android/drag_event_android.h" | 20 #include "ui/events/android/drag_event_android.h" |
20 #include "ui/events/android/motion_event_android.h" | 21 #include "ui/events/android/motion_event_android.h" |
| 22 #include "ui/gfx/android/java_bitmap.h" |
21 #include "url/gurl.h" | 23 #include "url/gurl.h" |
22 | 24 |
23 namespace ui { | 25 namespace ui { |
24 | 26 |
25 using base::android::ConvertUTF8ToJavaString; | 27 using base::android::ConvertUTF8ToJavaString; |
26 using base::android::JavaRef; | 28 using base::android::JavaRef; |
27 using base::android::ScopedJavaLocalRef; | 29 using base::android::ScopedJavaLocalRef; |
| 30 using blink::WebCursorInfo; |
28 | 31 |
29 ViewAndroid::ScopedAnchorView::ScopedAnchorView( | 32 ViewAndroid::ScopedAnchorView::ScopedAnchorView( |
30 JNIEnv* env, | 33 JNIEnv* env, |
31 const JavaRef<jobject>& jview, | 34 const JavaRef<jobject>& jview, |
32 const JavaRef<jobject>& jdelegate) | 35 const JavaRef<jobject>& jdelegate) |
33 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) { | 36 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) { |
34 // If there's a view, then we need a delegate to remove it. | 37 // If there's a view, then we need a delegate to remove it. |
35 DCHECK(!jdelegate.is_null() || jview.is_null()); | 38 DCHECK(!jdelegate.is_null() || jview.is_null()); |
36 } | 39 } |
37 | 40 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, | 268 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, |
266 const JavaRef<jobject>& jimage) { | 269 const JavaRef<jobject>& jimage) { |
267 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 270 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
268 if (delegate.is_null()) | 271 if (delegate.is_null()) |
269 return false; | 272 return false; |
270 JNIEnv* env = base::android::AttachCurrentThread(); | 273 JNIEnv* env = base::android::AttachCurrentThread(); |
271 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, | 274 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, |
272 jimage); | 275 jimage); |
273 } | 276 } |
274 | 277 |
| 278 void ViewAndroid::OnCursorChanged(int type, |
| 279 const SkBitmap& custom_image, |
| 280 const gfx::Point& hotspot) { |
| 281 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 282 if (delegate.is_null()) |
| 283 return; |
| 284 JNIEnv* env = base::android::AttachCurrentThread(); |
| 285 if (type == WebCursorInfo::kTypeCustom) { |
| 286 ScopedJavaLocalRef<jobject> java_bitmap = |
| 287 gfx::ConvertToJavaBitmap(&custom_image); |
| 288 Java_ViewAndroidDelegate_onCursorChangedToCustom(env, delegate, java_bitmap, |
| 289 hotspot.x(), hotspot.y()); |
| 290 } else { |
| 291 Java_ViewAndroidDelegate_onCursorChanged(env, delegate, type); |
| 292 } |
| 293 } |
| 294 |
275 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) { | 295 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) { |
276 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 296 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
277 if (delegate.is_null()) | 297 if (delegate.is_null()) |
278 return; | 298 return; |
279 JNIEnv* env = base::android::AttachCurrentThread(); | 299 JNIEnv* env = base::android::AttachCurrentThread(); |
280 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color); | 300 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color); |
281 } | 301 } |
282 | 302 |
283 void ViewAndroid::OnTopControlsChanged(float top_controls_offset, | 303 void ViewAndroid::OnTopControlsChanged(float top_controls_offset, |
284 float top_content_offset) { | 304 float top_content_offset) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 matched = bound.Contains(int_point); | 419 matched = bound.Contains(int_point); |
400 } | 420 } |
401 if (matched && child->HitTest(send_to_client, event, offset_point)) | 421 if (matched && child->HitTest(send_to_client, event, offset_point)) |
402 return true; | 422 return true; |
403 } | 423 } |
404 } | 424 } |
405 return false; | 425 return false; |
406 } | 426 } |
407 | 427 |
408 } // namespace ui | 428 } // namespace ui |
OLD | NEW |