Chromium Code Reviews| 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/cursor_type.h" | |
|
Jinsuk Kim
2017/05/17 04:49:50
It's already included in the header. No need to in
jaebaek
2017/05/18 01:44:29
Done.
| |
| 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/motion_event_android.h" | 19 #include "ui/events/android/motion_event_android.h" |
| 20 #include "ui/gfx/android/java_bitmap.h" | |
| 19 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 20 | 22 |
| 21 namespace ui { | 23 namespace ui { |
| 22 | 24 |
| 23 using base::android::ConvertUTF8ToJavaString; | 25 using base::android::ConvertUTF8ToJavaString; |
| 24 using base::android::JavaRef; | 26 using base::android::JavaRef; |
| 25 using base::android::ScopedJavaLocalRef; | 27 using base::android::ScopedJavaLocalRef; |
| 26 | 28 |
| 27 ViewAndroid::ScopedAnchorView::ScopedAnchorView( | 29 ViewAndroid::ScopedAnchorView::ScopedAnchorView( |
| 28 JNIEnv* env, | 30 JNIEnv* env, |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, | 238 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, |
| 237 const JavaRef<jobject>& jimage) { | 239 const JavaRef<jobject>& jimage) { |
| 238 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 240 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 239 if (delegate.is_null()) | 241 if (delegate.is_null()) |
| 240 return false; | 242 return false; |
| 241 JNIEnv* env = base::android::AttachCurrentThread(); | 243 JNIEnv* env = base::android::AttachCurrentThread(); |
| 242 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, | 244 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, |
| 243 jimage); | 245 jimage); |
| 244 } | 246 } |
| 245 | 247 |
| 248 void ViewAndroid::OnCursorChanged(CursorType type, | |
| 249 const SkBitmap& custom_image, | |
| 250 const gfx::Point& hotspot) { | |
| 251 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | |
| 252 if (delegate.is_null()) | |
| 253 return; | |
| 254 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 255 if (type == CURSOR_TYPE_CUSTOM) { | |
| 256 ScopedJavaLocalRef<jobject> java_bitmap = | |
| 257 gfx::ConvertToJavaBitmap(&custom_image); | |
| 258 Java_ViewAndroidDelegate_onCursorChangedToCustom( | |
| 259 env, delegate, java_bitmap, static_cast<jint>(hotspot.x()), | |
|
Jinsuk Kim
2017/05/17 04:49:50
I think you can do without static_cast.
jaebaek
2017/05/18 01:44:29
Done.
| |
| 260 static_cast<jint>(hotspot.y())); | |
| 261 } else { | |
| 262 Java_ViewAndroidDelegate_onCursorChanged(env, delegate, | |
| 263 static_cast<jint>(type)); | |
| 264 } | |
| 265 } | |
| 266 | |
| 246 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) { | 267 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) { |
| 247 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 268 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 248 if (delegate.is_null()) | 269 if (delegate.is_null()) |
| 249 return; | 270 return; |
| 250 JNIEnv* env = base::android::AttachCurrentThread(); | 271 JNIEnv* env = base::android::AttachCurrentThread(); |
| 251 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color); | 272 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color); |
| 252 } | 273 } |
| 253 | 274 |
| 254 void ViewAndroid::OnTopControlsChanged(float top_controls_offset, | 275 void ViewAndroid::OnTopControlsChanged(float top_controls_offset, |
| 255 float top_content_offset) { | 276 float top_content_offset) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 matched = bound.Contains(e->GetX(0), e->GetY(0)); | 353 matched = bound.Contains(e->GetX(0), e->GetY(0)); |
| 333 } | 354 } |
| 334 if (matched && child->HitTest(send_to_client, *e)) | 355 if (matched && child->HitTest(send_to_client, *e)) |
| 335 return true; | 356 return true; |
| 336 } | 357 } |
| 337 } | 358 } |
| 338 return false; | 359 return false; |
| 339 } | 360 } |
| 340 | 361 |
| 341 } // namespace ui | 362 } // namespace ui |
| OLD | NEW |