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 "cc/layers/layer.h" | 12 #include "cc/layers/layer.h" |
13 #include "jni/ViewAndroidDelegate_jni.h" | 13 #include "jni/ViewAndroidDelegate_jni.h" |
14 #include "ui/android/event_forwarder.h" | 14 #include "ui/android/event_forwarder.h" |
15 #include "ui/android/view_client.h" | 15 #include "ui/android/view_client.h" |
16 #include "ui/android/window_android.h" | 16 #include "ui/android/window_android.h" |
17 #include "ui/base/layout.h" | 17 #include "ui/base/layout.h" |
18 #include "ui/events/android/motion_event_android.h" | 18 #include "ui/events/android/motion_event_android.h" |
| 19 #include "ui/gfx/android/java_bitmap.h" |
19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
20 | 21 |
21 namespace ui { | 22 namespace ui { |
22 | 23 |
23 using base::android::ConvertUTF8ToJavaString; | 24 using base::android::ConvertUTF8ToJavaString; |
24 using base::android::JavaRef; | 25 using base::android::JavaRef; |
25 using base::android::ScopedJavaLocalRef; | 26 using base::android::ScopedJavaLocalRef; |
26 | 27 |
27 ViewAndroid::ScopedAnchorView::ScopedAnchorView( | 28 ViewAndroid::ScopedAnchorView::ScopedAnchorView( |
28 JNIEnv* env, | 29 JNIEnv* env, |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, | 242 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, |
242 const JavaRef<jobject>& jimage) { | 243 const JavaRef<jobject>& jimage) { |
243 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 244 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
244 if (delegate.is_null()) | 245 if (delegate.is_null()) |
245 return false; | 246 return false; |
246 JNIEnv* env = base::android::AttachCurrentThread(); | 247 JNIEnv* env = base::android::AttachCurrentThread(); |
247 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, | 248 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, |
248 jimage); | 249 jimage); |
249 } | 250 } |
250 | 251 |
| 252 void ViewAndroid::OnCursorChanged(bool to_custom_cursor, |
| 253 int type, |
| 254 const SkBitmap& custom_image, |
| 255 const gfx::Point& hotspot) { |
| 256 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 257 if (delegate.is_null()) |
| 258 return; |
| 259 JNIEnv* env = base::android::AttachCurrentThread(); |
| 260 if (to_custom_cursor) { |
| 261 ScopedJavaLocalRef<jobject> java_bitmap = |
| 262 gfx::ConvertToJavaBitmap(&custom_image); |
| 263 Java_ViewAndroidDelegate_onCursorChangedToCustom(env, delegate, java_bitmap, |
| 264 hotspot.x(), hotspot.y()); |
| 265 } else { |
| 266 Java_ViewAndroidDelegate_onCursorChanged(env, delegate, type); |
| 267 } |
| 268 } |
| 269 |
251 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) { | 270 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) { |
252 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 271 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
253 if (delegate.is_null()) | 272 if (delegate.is_null()) |
254 return; | 273 return; |
255 JNIEnv* env = base::android::AttachCurrentThread(); | 274 JNIEnv* env = base::android::AttachCurrentThread(); |
256 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color); | 275 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color); |
257 } | 276 } |
258 | 277 |
259 void ViewAndroid::OnTopControlsChanged(float top_controls_offset, | 278 void ViewAndroid::OnTopControlsChanged(float top_controls_offset, |
260 float top_content_offset) { | 279 float top_content_offset) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 matched = bound.Contains(e->GetX(0), e->GetY(0)); | 370 matched = bound.Contains(e->GetX(0), e->GetY(0)); |
352 } | 371 } |
353 if (matched && child->HitTest(send_to_client, *e)) | 372 if (matched && child->HitTest(send_to_client, *e)) |
354 return true; | 373 return true; |
355 } | 374 } |
356 } | 375 } |
357 return false; | 376 return false; |
358 } | 377 } |
359 | 378 |
360 } // namespace ui | 379 } // namespace ui |
OLD | NEW |