Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "content/browser/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "cc/layers/layer.h" | 17 #include "cc/layers/layer.h" |
| 18 #include "cc/output/begin_frame_args.h" | 18 #include "cc/output/begin_frame_args.h" |
| 19 #include "content/browser/android/gesture_event_type.h" | 19 #include "content/browser/android/gesture_event_type.h" |
| 20 #include "content/browser/android/interstitial_page_delegate_android.h" | 20 #include "content/browser/android/interstitial_page_delegate_android.h" |
| 21 #include "content/browser/android/load_url_params.h" | 21 #include "content/browser/android/load_url_params.h" |
| 22 #include "content/browser/frame_host/interstitial_page_impl.h" | 22 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 23 #include "content/browser/frame_host/navigation_controller_impl.h" | 23 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 24 #include "content/browser/frame_host/navigation_entry_impl.h" | 24 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 25 #include "content/browser/media/android/browser_media_player_manager.h" | 25 #include "content/browser/media/android/browser_media_player_manager.h" |
| 26 #include "content/browser/renderer_host/compositor_impl_android.h" | 26 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 27 #include "content/browser/renderer_host/input/motion_event_android.h" | 27 #include "content/browser/renderer_host/input/motion_event_android.h" |
| 28 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " | 28 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " |
| 29 #include "content/browser/renderer_host/input/web_input_event_util.h" | |
| 29 #include "content/browser/renderer_host/java/java_bound_object.h" | 30 #include "content/browser/renderer_host/java/java_bound_object.h" |
| 30 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h" | 31 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h" |
| 31 #include "content/browser/renderer_host/render_view_host_impl.h" | 32 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 32 #include "content/browser/renderer_host/render_widget_host_impl.h" | 33 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 33 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 34 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 34 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h" | 35 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h" |
| 35 #include "content/browser/ssl/ssl_host_state.h" | 36 #include "content/browser/ssl/ssl_host_state.h" |
| 36 #include "content/browser/web_contents/web_contents_view_android.h" | 37 #include "content/browser/web_contents/web_contents_view_android.h" |
| 37 #include "content/common/input/web_input_event_traits.h" | 38 #include "content/common/input/web_input_event_traits.h" |
| 38 #include "content/common/input_messages.h" | 39 #include "content/common/input_messages.h" |
| (...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 987 | 988 |
| 988 void ContentViewCoreImpl::SendOrientationChangeEvent(JNIEnv* env, | 989 void ContentViewCoreImpl::SendOrientationChangeEvent(JNIEnv* env, |
| 989 jobject obj, | 990 jobject obj, |
| 990 jint orientation) { | 991 jint orientation) { |
| 991 if (device_orientation_ != orientation) { | 992 if (device_orientation_ != orientation) { |
| 992 device_orientation_ = orientation; | 993 device_orientation_ = orientation; |
| 993 SendOrientationChangeEventInternal(); | 994 SendOrientationChangeEventInternal(); |
| 994 } | 995 } |
| 995 } | 996 } |
| 996 | 997 |
| 998 void ContentViewCoreImpl::CancelActiveTouchSequenceIfNecessary() { | |
| 999 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | |
| 1000 if (!rwhv) | |
|
tdresser
2014/03/04 16:19:34
Is this check just for testing? Add a comment indi
jdduke (slow)
2014/03/04 19:07:03
Done.
| |
| 1001 return; | |
| 1002 | |
| 1003 const ui::MotionEvent* current_down_event = | |
|
tdresser
2014/03/04 16:19:34
Maybe add a comment indicating why you can't just
jdduke (slow)
2014/03/04 19:07:03
I went ahead and removed that method, as it really
| |
| 1004 gesture_provider_.GetCurrentDownEvent(); | |
| 1005 if (!current_down_event) | |
| 1006 return; | |
| 1007 | |
| 1008 scoped_ptr<ui::MotionEvent> cancel_event = current_down_event->Cancel(); | |
| 1009 DCHECK(cancel_event); | |
| 1010 if (!gesture_provider_.OnTouchEvent(*cancel_event)) | |
| 1011 return; | |
| 1012 | |
| 1013 rwhv->SendTouchEvent( | |
| 1014 CreateWebTouchEventFromMotionEvent(*cancel_event, 1.f / GetDpiScale())); | |
| 1015 } | |
| 1016 | |
| 997 jboolean ContentViewCoreImpl::OnTouchEvent(JNIEnv* env, | 1017 jboolean ContentViewCoreImpl::OnTouchEvent(JNIEnv* env, |
| 998 jobject obj, | 1018 jobject obj, |
| 999 jobject motion_event) { | 1019 jobject motion_event) { |
| 1000 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 1020 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| 1001 if (!rwhv) | 1021 if (!rwhv) |
| 1002 return false; | 1022 return false; |
| 1003 | 1023 |
| 1004 MotionEventAndroid event(env, motion_event, false); | 1024 MotionEventAndroid event(env, motion_event, false); |
| 1005 | 1025 |
| 1006 if (!gesture_provider_.OnTouchEvent(event)) | 1026 if (!gesture_provider_.OnTouchEvent(event)) |
| 1007 return false; | 1027 return false; |
| 1008 | 1028 |
| 1009 rwhv->SendTouchEvent(WebTouchEventBuilder::Build(event, GetDpiScale())); | 1029 rwhv->SendTouchEvent(WebTouchEventBuilder::Build(event, 1.f / GetDpiScale())); |
| 1010 return true; | 1030 return true; |
| 1011 } | 1031 } |
| 1012 | 1032 |
| 1013 float ContentViewCoreImpl::GetDpiScale() const { | 1033 float ContentViewCoreImpl::GetDpiScale() const { |
| 1014 return dpi_scale_; | 1034 return dpi_scale_; |
| 1015 } | 1035 } |
| 1016 | 1036 |
| 1017 jboolean ContentViewCoreImpl::SendMouseMoveEvent(JNIEnv* env, | 1037 jboolean ContentViewCoreImpl::SendMouseMoveEvent(JNIEnv* env, |
| 1018 jobject obj, | 1038 jobject obj, |
| 1019 jlong time_ms, | 1039 jlong time_ms, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1180 GetRenderWidgetHostViewAndroid()->MoveCaret( | 1200 GetRenderWidgetHostViewAndroid()->MoveCaret( |
| 1181 gfx::Point(x / GetDpiScale(), y / GetDpiScale())); | 1201 gfx::Point(x / GetDpiScale(), y / GetDpiScale())); |
| 1182 } | 1202 } |
| 1183 } | 1203 } |
| 1184 | 1204 |
| 1185 void ContentViewCoreImpl::ResetGestureDetectors(JNIEnv* env, jobject obj) { | 1205 void ContentViewCoreImpl::ResetGestureDetectors(JNIEnv* env, jobject obj) { |
| 1186 gesture_provider_.ResetGestureDetectors(); | 1206 gesture_provider_.ResetGestureDetectors(); |
| 1187 } | 1207 } |
| 1188 | 1208 |
| 1189 void ContentViewCoreImpl::IgnoreRemainingTouchEvents(JNIEnv* env, jobject obj) { | 1209 void ContentViewCoreImpl::IgnoreRemainingTouchEvents(JNIEnv* env, jobject obj) { |
| 1190 gesture_provider_.CancelActiveTouchSequence(); | 1210 CancelActiveTouchSequenceIfNecessary(); |
| 1191 } | 1211 } |
| 1192 | 1212 |
| 1193 void ContentViewCoreImpl::OnWindowFocusLost(JNIEnv* env, jobject obj) { | 1213 void ContentViewCoreImpl::OnWindowFocusLost(JNIEnv* env, jobject obj) { |
| 1194 gesture_provider_.CancelActiveTouchSequence(); | 1214 CancelActiveTouchSequenceIfNecessary(); |
| 1195 } | 1215 } |
| 1196 | 1216 |
| 1197 void ContentViewCoreImpl::SetDoubleTapSupportForPageEnabled(JNIEnv* env, | 1217 void ContentViewCoreImpl::SetDoubleTapSupportForPageEnabled(JNIEnv* env, |
| 1198 jobject obj, | 1218 jobject obj, |
| 1199 jboolean enabled) { | 1219 jboolean enabled) { |
| 1200 gesture_provider_.SetDoubleTapSupportForPageEnabled(enabled); | 1220 gesture_provider_.SetDoubleTapSupportForPageEnabled(enabled); |
| 1201 } | 1221 } |
| 1202 | 1222 |
| 1203 void ContentViewCoreImpl::SetDoubleTapSupportEnabled(JNIEnv* env, | 1223 void ContentViewCoreImpl::SetDoubleTapSupportEnabled(JNIEnv* env, |
| 1204 jobject obj, | 1224 jobject obj, |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1712 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1732 reinterpret_cast<ui::ViewAndroid*>(view_android), |
| 1713 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1733 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
| 1714 return reinterpret_cast<intptr_t>(view); | 1734 return reinterpret_cast<intptr_t>(view); |
| 1715 } | 1735 } |
| 1716 | 1736 |
| 1717 bool RegisterContentViewCore(JNIEnv* env) { | 1737 bool RegisterContentViewCore(JNIEnv* env) { |
| 1718 return RegisterNativesImpl(env); | 1738 return RegisterNativesImpl(env); |
| 1719 } | 1739 } |
| 1720 | 1740 |
| 1721 } // namespace content | 1741 } // namespace content |
| OLD | NEW |