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

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 181833003: [Android] Out with the Android GR, in with the new unified C++ GR (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix type count Created 6 years, 9 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 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/web_input_event_builders_android.h " 28 #include "content/browser/renderer_host/input/web_input_event_builders_android.h "
28 #include "content/browser/renderer_host/java/java_bound_object.h" 29 #include "content/browser/renderer_host/java/java_bound_object.h"
29 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h" 30 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h"
30 #include "content/browser/renderer_host/render_view_host_impl.h" 31 #include "content/browser/renderer_host/render_view_host_impl.h"
31 #include "content/browser/renderer_host/render_widget_host_impl.h" 32 #include "content/browser/renderer_host/render_widget_host_impl.h"
32 #include "content/browser/renderer_host/render_widget_host_view_android.h" 33 #include "content/browser/renderer_host/render_widget_host_view_android.h"
33 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h" 34 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h"
34 #include "content/browser/ssl/ssl_host_state.h" 35 #include "content/browser/ssl/ssl_host_state.h"
35 #include "content/browser/web_contents/web_contents_view_android.h" 36 #include "content/browser/web_contents/web_contents_view_android.h"
36 #include "content/common/input/web_input_event_traits.h" 37 #include "content/common/input/web_input_event_traits.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 JNIEnv* env, 106 JNIEnv* env,
106 const gfx::Rect& rect) { 107 const gfx::Rect& rect) {
107 return ScopedJavaLocalRef<jobject>( 108 return ScopedJavaLocalRef<jobject>(
108 Java_ContentViewCore_createRect(env, 109 Java_ContentViewCore_createRect(env,
109 static_cast<int>(rect.x()), 110 static_cast<int>(rect.x()),
110 static_cast<int>(rect.y()), 111 static_cast<int>(rect.y()),
111 static_cast<int>(rect.right()), 112 static_cast<int>(rect.right()),
112 static_cast<int>(rect.bottom()))); 113 static_cast<int>(rect.bottom())));
113 } 114 }
114 115
115 bool PossiblyTriggeredByTouchTimeout(const WebGestureEvent& event) { 116 int ToGestureEventType(WebInputEvent::Type type) {
116 switch (event.type) {
117 case WebInputEvent::GestureShowPress:
118 case WebInputEvent::GestureLongPress:
119 return true;
120 // On Android, a GestureTap may be sent after a certain timeout window
121 // if there is no GestureDoubleTap follow-up.
122 case WebInputEvent::GestureTap:
123 return true;
124 // On Android, a GestureTapCancel may be triggered by the loss of window
125 // focus (e.g., following a GestureLongPress).
126 case WebInputEvent::GestureTapCancel:
127 return true;
128 default:
129 break;
130 }
131 return false;
132 }
133
134 int ToContentViewGestureHandlerType(WebInputEvent::Type type) {
135 switch (type) { 117 switch (type) {
136 case WebInputEvent::GestureScrollBegin: 118 case WebInputEvent::GestureScrollBegin:
137 return SCROLL_START; 119 return SCROLL_START;
138 case WebInputEvent::GestureScrollEnd: 120 case WebInputEvent::GestureScrollEnd:
139 return SCROLL_END; 121 return SCROLL_END;
140 case WebInputEvent::GestureScrollUpdate: 122 case WebInputEvent::GestureScrollUpdate:
141 return SCROLL_BY; 123 return SCROLL_BY;
142 case WebInputEvent::GestureFlingStart: 124 case WebInputEvent::GestureFlingStart:
143 return FLING_START; 125 return FLING_START;
144 case WebInputEvent::GestureFlingCancel: 126 case WebInputEvent::GestureFlingCancel:
(...skipping 22 matching lines...) Expand all
167 return PINCH_BY; 149 return PINCH_BY;
168 case WebInputEvent::GestureTwoFingerTap: 150 case WebInputEvent::GestureTwoFingerTap:
169 case WebInputEvent::GestureScrollUpdateWithoutPropagation: 151 case WebInputEvent::GestureScrollUpdateWithoutPropagation:
170 default: 152 default:
171 NOTREACHED() << "Invalid source gesture type: " 153 NOTREACHED() << "Invalid source gesture type: "
172 << WebInputEventTraits::GetName(type); 154 << WebInputEventTraits::GetName(type);
173 return -1; 155 return -1;
174 }; 156 };
175 } 157 }
176 158
159 float GetPrimaryDisplayDeviceScaleFactor() {
160 const gfx::Display& display =
161 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
162 return display.device_scale_factor();
163 }
164
177 } // namespace 165 } // namespace
178 166
179 // Enables a callback when the underlying WebContents is destroyed, to enable 167 // Enables a callback when the underlying WebContents is destroyed, to enable
180 // nulling the back-pointer. 168 // nulling the back-pointer.
181 class ContentViewCoreImpl::ContentViewUserData 169 class ContentViewCoreImpl::ContentViewUserData
182 : public base::SupportsUserData::Data { 170 : public base::SupportsUserData::Data {
183 public: 171 public:
184 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core) 172 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core)
185 : content_view_core_(content_view_core) { 173 : content_view_core_(content_view_core) {
186 } 174 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 214
227 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, 215 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env,
228 jobject obj, 216 jobject obj,
229 WebContents* web_contents, 217 WebContents* web_contents,
230 ui::ViewAndroid* view_android, 218 ui::ViewAndroid* view_android,
231 ui::WindowAndroid* window_android) 219 ui::WindowAndroid* window_android)
232 : WebContentsObserver(web_contents), 220 : WebContentsObserver(web_contents),
233 java_ref_(env, obj), 221 java_ref_(env, obj),
234 web_contents_(static_cast<WebContentsImpl*>(web_contents)), 222 web_contents_(static_cast<WebContentsImpl*>(web_contents)),
235 root_layer_(cc::Layer::Create()), 223 root_layer_(cc::Layer::Create()),
224 dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()),
236 vsync_interval_(base::TimeDelta::FromMicroseconds( 225 vsync_interval_(base::TimeDelta::FromMicroseconds(
237 kDefaultVSyncIntervalMicros)), 226 kDefaultVSyncIntervalMicros)),
238 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds( 227 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds(
239 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)), 228 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)),
240 view_android_(view_android), 229 view_android_(view_android),
241 window_android_(window_android), 230 window_android_(window_android),
231 gesture_provider_(this, 1.f / dpi_scale_),
242 device_orientation_(0), 232 device_orientation_(0),
243 geolocation_needs_pause_(false), 233 geolocation_needs_pause_(false) {
244 touch_disposition_gesture_filter_(this),
245 handling_touch_event_(false) {
246 CHECK(web_contents) << 234 CHECK(web_contents) <<
247 "A ContentViewCoreImpl should be created with a valid WebContents."; 235 "A ContentViewCoreImpl should be created with a valid WebContents.";
248 236
249 const gfx::Display& display =
250 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
251 dpi_scale_ = display.device_scale_factor();
252
253 // Currently, the only use case we have for overriding a user agent involves 237 // Currently, the only use case we have for overriding a user agent involves
254 // spoofing a desktop Linux user agent for "Request desktop site". 238 // spoofing a desktop Linux user agent for "Request desktop site".
255 // Automatically set it for all WebContents so that it is available when a 239 // Automatically set it for all WebContents so that it is available when a
256 // NavigationEntry requires the user agent to be overridden. 240 // NavigationEntry requires the user agent to be overridden.
257 const char kLinuxInfoStr[] = "X11; Linux x86_64"; 241 const char kLinuxInfoStr[] = "X11; Linux x86_64";
258 std::string product = content::GetContentClient()->GetProduct(); 242 std::string product = content::GetContentClient()->GetProduct();
259 std::string spoofed_ua = 243 std::string spoofed_ua =
260 webkit_glue::BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); 244 webkit_glue::BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product);
261 web_contents->SetUserAgentOverride(spoofed_ua); 245 web_contents->SetUserAgentOverride(spoofed_ua);
262 246
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 break; 351 break;
368 } 352 }
369 } 353 }
370 } 354 }
371 355
372 void ContentViewCoreImpl::RenderViewReady() { 356 void ContentViewCoreImpl::RenderViewReady() {
373 if (device_orientation_ != 0) 357 if (device_orientation_ != 0)
374 SendOrientationChangeEventInternal(); 358 SendOrientationChangeEventInternal();
375 } 359 }
376 360
377 void ContentViewCoreImpl::ForwardGestureEvent( 361 void ContentViewCoreImpl::OnGestureEvent(const blink::WebGestureEvent& event) {
378 const blink::WebGestureEvent& event) { 362 SendGestureEvent(event);
379 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
380 if (rwhv)
381 rwhv->SendGestureEvent(event);
382 } 363 }
383 364
384 RenderWidgetHostViewAndroid* 365 RenderWidgetHostViewAndroid*
385 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() { 366 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() {
386 RenderWidgetHostView* rwhv = NULL; 367 RenderWidgetHostView* rwhv = NULL;
387 if (web_contents_) { 368 if (web_contents_) {
388 rwhv = web_contents_->GetRenderWidgetHostView(); 369 rwhv = web_contents_->GetRenderWidgetHostView();
389 if (web_contents_->ShowingInterstitialPage()) { 370 if (web_contents_->ShowingInterstitialPage()) {
390 rwhv = static_cast<InterstitialPageImpl*>( 371 rwhv = static_cast<InterstitialPageImpl*>(
391 web_contents_->GetInterstitialPage())-> 372 web_contents_->GetInterstitialPage())->
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled); 546 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled);
566 } 547 }
567 ScopedJavaLocalRef<jobjectArray> items_array( 548 ScopedJavaLocalRef<jobjectArray> items_array(
568 base::android::ToJavaArrayOfStrings(env, labels)); 549 base::android::ToJavaArrayOfStrings(env, labels));
569 Java_ContentViewCore_showSelectPopup(env, j_obj.obj(), 550 Java_ContentViewCore_showSelectPopup(env, j_obj.obj(),
570 items_array.obj(), enabled_array.obj(), 551 items_array.obj(), enabled_array.obj(),
571 multiple, selected_array.obj()); 552 multiple, selected_array.obj());
572 } 553 }
573 554
574 void ContentViewCoreImpl::ConfirmTouchEvent(InputEventAckState ack_result) { 555 void ContentViewCoreImpl::ConfirmTouchEvent(InputEventAckState ack_result) {
575 touch_disposition_gesture_filter_.OnTouchEventAck(ack_result); 556 gesture_provider_.OnTouchEventAck(ack_result);
576 } 557 }
577 558
578 void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event, 559 void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event,
579 InputEventAckState ack_result) { 560 InputEventAckState ack_result) {
580 JNIEnv* env = AttachCurrentThread(); 561 JNIEnv* env = AttachCurrentThread();
581 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 562 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
582 if (j_obj.is_null()) 563 if (j_obj.is_null())
583 return; 564 return;
584 565
585 switch (event.type) { 566 switch (event.type) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 event.type != WebInputEvent::GestureLongPress) 618 event.type != WebInputEvent::GestureLongPress)
638 return false; 619 return false;
639 620
640 JNIEnv* env = AttachCurrentThread(); 621 JNIEnv* env = AttachCurrentThread();
641 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 622 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
642 if (j_obj.is_null()) 623 if (j_obj.is_null())
643 return false; 624 return false;
644 625
645 const blink::WebGestureEvent& gesture = 626 const blink::WebGestureEvent& gesture =
646 static_cast<const blink::WebGestureEvent&>(event); 627 static_cast<const blink::WebGestureEvent&>(event);
647 int gesture_type = ToContentViewGestureHandlerType(event.type); 628 int gesture_type = ToGestureEventType(event.type);
648 return Java_ContentViewCore_filterTapOrPressEvent(env, 629 return Java_ContentViewCore_filterTapOrPressEvent(env,
649 j_obj.obj(), 630 j_obj.obj(),
650 gesture_type, 631 gesture_type,
651 gesture.x * GetDpiScale(), 632 gesture.x * GetDpiScale(),
652 gesture.y * GetDpiScale()); 633 gesture.y * GetDpiScale());
634
635 // TODO(jdduke): Also report double-tap UMA, crbug/347568.
653 } 636 }
654 637
655 bool ContentViewCoreImpl::HasFocus() { 638 bool ContentViewCoreImpl::HasFocus() {
656 JNIEnv* env = AttachCurrentThread(); 639 JNIEnv* env = AttachCurrentThread();
657 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 640 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
658 if (obj.is_null()) 641 if (obj.is_null())
659 return false; 642 return false;
660 return Java_ContentViewCore_hasFocus(env, obj.obj()); 643 return Java_ContentViewCore_hasFocus(env, obj.obj());
661 } 644 }
662 645
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 987
1005 void ContentViewCoreImpl::SendOrientationChangeEvent(JNIEnv* env, 988 void ContentViewCoreImpl::SendOrientationChangeEvent(JNIEnv* env,
1006 jobject obj, 989 jobject obj,
1007 jint orientation) { 990 jint orientation) {
1008 if (device_orientation_ != orientation) { 991 if (device_orientation_ != orientation) {
1009 device_orientation_ = orientation; 992 device_orientation_ = orientation;
1010 SendOrientationChangeEventInternal(); 993 SendOrientationChangeEventInternal();
1011 } 994 }
1012 } 995 }
1013 996
1014 void ContentViewCoreImpl::OnTouchEventHandlingBegin(JNIEnv* env, 997 jboolean ContentViewCoreImpl::OnTouchEvent(JNIEnv* env,
1015 jobject obj, 998 jobject obj,
1016 jobject motion_event) { 999 jobject motion_event) {
1017 DCHECK(!handling_touch_event_);
1018 handling_touch_event_ = true;
1019
1020 pending_touch_event_ =
1021 WebTouchEventBuilder::Build(motion_event, GetDpiScale());
1022
1023 pending_gesture_packet_ =
1024 GestureEventPacket::FromTouch(pending_touch_event_);
1025 }
1026
1027 void ContentViewCoreImpl::OnTouchEventHandlingEnd(JNIEnv* env, jobject obj) {
1028 if (!handling_touch_event_)
1029 return;
1030
1031 GestureEventPacket gesture_packet;
1032 std::swap(gesture_packet, pending_gesture_packet_);
1033
1034 handling_touch_event_ = false;
1035
1036 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); 1000 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
1037 if (!rwhv) 1001 if (!rwhv)
1038 return; 1002 return false;
1039 1003
1040 // Note: Order is important here, as the touch may be ack'ed synchronously 1004 MotionEventAndroid event(env, motion_event, false);
1041 TouchDispositionGestureFilter::PacketResult result = 1005
1042 touch_disposition_gesture_filter_.OnGestureEventPacket(gesture_packet); 1006 if (!gesture_provider_.OnTouchEvent(event))
1043 if (result != TouchDispositionGestureFilter::SUCCESS) { 1007 return false;
1044 NOTREACHED() << "Invalid touch gesture sequence detected."; 1008
1045 return; 1009 rwhv->SendTouchEvent(WebTouchEventBuilder::Build(event, GetDpiScale()));
1046 } 1010 return true;
1047 rwhv->SendTouchEvent(pending_touch_event_);
1048 } 1011 }
1049 1012
1050 float ContentViewCoreImpl::GetTouchPaddingDip() { 1013 float ContentViewCoreImpl::GetTouchPaddingDip() {
1051 return 48.0f / GetDpiScale(); 1014 return 48.0f / GetDpiScale();
1052 } 1015 }
1053 1016
1054 float ContentViewCoreImpl::GetDpiScale() const { 1017 float ContentViewCoreImpl::GetDpiScale() const {
1055 return dpi_scale_; 1018 return dpi_scale_;
1056 } 1019 }
1057 1020
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 } 1062 }
1100 1063
1101 WebGestureEvent ContentViewCoreImpl::MakeGestureEvent( 1064 WebGestureEvent ContentViewCoreImpl::MakeGestureEvent(
1102 WebInputEvent::Type type, int64 time_ms, float x, float y) const { 1065 WebInputEvent::Type type, int64 time_ms, float x, float y) const {
1103 return WebGestureEventBuilder::Build( 1066 return WebGestureEventBuilder::Build(
1104 type, time_ms / 1000.0, x / GetDpiScale(), y / GetDpiScale()); 1067 type, time_ms / 1000.0, x / GetDpiScale(), y / GetDpiScale());
1105 } 1068 }
1106 1069
1107 void ContentViewCoreImpl::SendGestureEvent( 1070 void ContentViewCoreImpl::SendGestureEvent(
1108 const blink::WebGestureEvent& event) { 1071 const blink::WebGestureEvent& event) {
1109 // Gestures received while |handling_touch_event_| will accumulate until 1072 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
1110 // touch handling finishes, at which point the gestures will be pushed to the 1073 if (rwhv)
1111 // |touch_disposition_gesture_filter_|. 1074 rwhv->SendGestureEvent(event);
1112 if (handling_touch_event_) {
1113 pending_gesture_packet_.Push(event);
1114 return;
1115 }
1116
1117 // TODO(jdduke): In general, timeout-based gestures *should* have the same
1118 // timestamp as the initial TouchStart of the current sequence. We should
1119 // verify that this is true, and use that as another timeout check.
1120 if (PossiblyTriggeredByTouchTimeout(event)) {
1121 TouchDispositionGestureFilter::PacketResult result =
1122 touch_disposition_gesture_filter_.OnGestureEventPacket(
1123 GestureEventPacket::FromTouchTimeout(event));
1124 DCHECK_EQ(TouchDispositionGestureFilter::SUCCESS, result);
1125 return;
1126 }
1127
1128 // If |event| was not (directly or indirectly) touch-derived, treat it as
1129 // a synthetic gesture event.
1130 SendSyntheticGestureEvent(event);
1131 }
1132
1133 void ContentViewCoreImpl::SendSyntheticGestureEvent(
1134 const blink::WebGestureEvent& event) {
1135 // Synthetic gestures (e.g., those not generated directly by touches
1136 // for which we expect an ack), should be forwarded directly.
1137 ForwardGestureEvent(event);
1138 } 1075 }
1139 1076
1140 void ContentViewCoreImpl::ScrollBegin(JNIEnv* env, 1077 void ContentViewCoreImpl::ScrollBegin(JNIEnv* env,
1141 jobject obj, 1078 jobject obj,
1142 jlong time_ms, 1079 jlong time_ms,
1143 jfloat x, 1080 jfloat x,
1144 jfloat y, 1081 jfloat y,
1145 jfloat hintx, 1082 jfloat hintx,
1146 jfloat hinty) { 1083 jfloat hinty) {
1147 WebGestureEvent event = MakeGestureEvent( 1084 WebGestureEvent event = MakeGestureEvent(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 1124
1188 void ContentViewCoreImpl::SingleTap(JNIEnv* env, jobject obj, jlong time_ms, 1125 void ContentViewCoreImpl::SingleTap(JNIEnv* env, jobject obj, jlong time_ms,
1189 jfloat x, jfloat y, 1126 jfloat x, jfloat y,
1190 jboolean disambiguation_popup_tap) { 1127 jboolean disambiguation_popup_tap) {
1191 WebGestureEvent event = MakeGestureEvent( 1128 WebGestureEvent event = MakeGestureEvent(
1192 WebInputEvent::GestureTap, time_ms, x, y); 1129 WebInputEvent::GestureTap, time_ms, x, y);
1193 1130
1194 event.data.tap.tapCount = 1; 1131 event.data.tap.tapCount = 1;
1195 1132
1196 // Disambiguation popup gestures are treated as synthetic because their 1133 // Disambiguation popup gestures are treated as synthetic because their
1197 // generating touches were never forwarded to the renderer. 1134 // generating touches were never forwarded to the renderer.
Ted C 2014/02/28 19:52:33 This comment seems no longer valid. Does this sti
jdduke (slow) 2014/02/28 20:22:04 You're absolutely right, these will always be synt
1198 if (disambiguation_popup_tap) { 1135 if (disambiguation_popup_tap) {
1199 SendSyntheticGestureEvent(event); 1136 SendGestureEvent(event);
1200 return; 1137 return;
1201 } 1138 }
1202 1139
1203 const float touch_padding_dip = GetTouchPaddingDip(); 1140 const float touch_padding_dip = GetTouchPaddingDip();
1204 event.data.tap.width = touch_padding_dip; 1141 event.data.tap.width = touch_padding_dip;
1205 event.data.tap.height = touch_padding_dip; 1142 event.data.tap.height = touch_padding_dip;
1206 SendGestureEvent(event); 1143 SendGestureEvent(event);
1207 } 1144 }
1208 1145
1209 void ContentViewCoreImpl::SingleTapUnconfirmed(JNIEnv* env, jobject obj,
1210 jlong time_ms,
1211 jfloat x, jfloat y) {
1212 WebGestureEvent event = MakeGestureEvent(
1213 WebInputEvent::GestureTapUnconfirmed, time_ms, x, y);
1214
1215 event.data.tap.tapCount = 1;
1216
1217 const float touch_padding_dip = GetTouchPaddingDip();
1218 event.data.tap.width = touch_padding_dip;
1219 event.data.tap.height = touch_padding_dip;
1220
1221 SendGestureEvent(event);
1222 }
1223
1224 void ContentViewCoreImpl::ShowPress(JNIEnv* env, jobject obj,
1225 jlong time_ms,
1226 jfloat x, jfloat y) {
1227 WebGestureEvent event = MakeGestureEvent(
1228 WebInputEvent::GestureShowPress, time_ms, x, y);
1229 SendGestureEvent(event);
1230 }
1231
1232 void ContentViewCoreImpl::TapCancel(JNIEnv* env,
1233 jobject obj,
1234 jlong time_ms,
1235 jfloat x,
1236 jfloat y) {
1237 WebGestureEvent event = MakeGestureEvent(
1238 WebInputEvent::GestureTapCancel, time_ms, x, y);
1239 SendGestureEvent(event);
1240 }
1241
1242 void ContentViewCoreImpl::TapDown(JNIEnv* env, jobject obj,
1243 jlong time_ms,
1244 jfloat x, jfloat y) {
1245 WebGestureEvent event = MakeGestureEvent(
1246 WebInputEvent::GestureTapDown, time_ms, x, y);
1247 SendGestureEvent(event);
1248 }
1249
1250 void ContentViewCoreImpl::DoubleTap(JNIEnv* env, jobject obj, jlong time_ms, 1146 void ContentViewCoreImpl::DoubleTap(JNIEnv* env, jobject obj, jlong time_ms,
1251 jfloat x, jfloat y) { 1147 jfloat x, jfloat y) {
1252 WebGestureEvent event = MakeGestureEvent( 1148 WebGestureEvent event = MakeGestureEvent(
1253 WebInputEvent::GestureDoubleTap, time_ms, x, y); 1149 WebInputEvent::GestureDoubleTap, time_ms, x, y);
1254 SendGestureEvent(event); 1150 SendGestureEvent(event);
1255 } 1151 }
1256 1152
1257 void ContentViewCoreImpl::LongPress(JNIEnv* env, jobject obj, jlong time_ms, 1153 void ContentViewCoreImpl::LongPress(JNIEnv* env, jobject obj, jlong time_ms,
1258 jfloat x, jfloat y, 1154 jfloat x, jfloat y,
1259 jboolean disambiguation_popup_tap) { 1155 jboolean disambiguation_popup_tap) {
1260 WebGestureEvent event = MakeGestureEvent( 1156 WebGestureEvent event = MakeGestureEvent(
1261 WebInputEvent::GestureLongPress, time_ms, x, y); 1157 WebInputEvent::GestureLongPress, time_ms, x, y);
1262 1158
1263 // Disambiguation popup gestures are treated as synthetic because their 1159 // Disambiguation popup gestures are treated as synthetic because their
1264 // generating touches were never forwarded to the renderer. 1160 // generating touches were never forwarded to the renderer.
1265 if (disambiguation_popup_tap) { 1161 if (disambiguation_popup_tap) {
Ted C 2014/02/28 19:52:33 same general comment as above.
jdduke (slow) 2014/02/28 20:22:04 Done.
1266 SendSyntheticGestureEvent(event); 1162 SendGestureEvent(event);
1267 return; 1163 return;
1268 } 1164 }
1269 1165
1270 const float touch_padding_dip = GetTouchPaddingDip();
1271 event.data.longPress.width = touch_padding_dip;
1272 event.data.longPress.height = touch_padding_dip;
1273 SendGestureEvent(event);
1274 }
1275
1276 void ContentViewCoreImpl::LongTap(JNIEnv* env, jobject obj, jlong time_ms,
1277 jfloat x, jfloat y,
1278 jboolean disambiguation_popup_tap) {
1279 WebGestureEvent event = MakeGestureEvent(
1280 WebInputEvent::GestureLongTap, time_ms, x, y);
1281
1282 // Disambiguation popup gestures are treated as synthetic because their
1283 // generating touches were never forwarded to the renderer.
1284 if (disambiguation_popup_tap) {
1285 SendSyntheticGestureEvent(event);
1286 return;
1287 }
1288
1289 const float touch_padding_dip = GetTouchPaddingDip(); 1166 const float touch_padding_dip = GetTouchPaddingDip();
1290 event.data.longPress.width = touch_padding_dip; 1167 event.data.longPress.width = touch_padding_dip;
1291 event.data.longPress.height = touch_padding_dip; 1168 event.data.longPress.height = touch_padding_dip;
1292 SendGestureEvent(event); 1169 SendGestureEvent(event);
1293 } 1170 }
1294 1171
1295 void ContentViewCoreImpl::PinchBegin(JNIEnv* env, jobject obj, jlong time_ms, 1172 void ContentViewCoreImpl::PinchBegin(JNIEnv* env, jobject obj, jlong time_ms,
1296 jfloat x, jfloat y) { 1173 jfloat x, jfloat y) {
1297 WebGestureEvent event = MakeGestureEvent( 1174 WebGestureEvent event = MakeGestureEvent(
1298 WebInputEvent::GesturePinchBegin, time_ms, x, y); 1175 WebInputEvent::GesturePinchBegin, time_ms, x, y);
(...skipping 27 matching lines...) Expand all
1326 } 1203 }
1327 1204
1328 void ContentViewCoreImpl::MoveCaret(JNIEnv* env, jobject obj, 1205 void ContentViewCoreImpl::MoveCaret(JNIEnv* env, jobject obj,
1329 jfloat x, jfloat y) { 1206 jfloat x, jfloat y) {
1330 if (GetRenderWidgetHostViewAndroid()) { 1207 if (GetRenderWidgetHostViewAndroid()) {
1331 GetRenderWidgetHostViewAndroid()->MoveCaret( 1208 GetRenderWidgetHostViewAndroid()->MoveCaret(
1332 gfx::Point(x / GetDpiScale(), y / GetDpiScale())); 1209 gfx::Point(x / GetDpiScale(), y / GetDpiScale()));
1333 } 1210 }
1334 } 1211 }
1335 1212
1213 void ContentViewCoreImpl::ResetGestureDetectors(JNIEnv* env, jobject obj) {
1214 gesture_provider_.ResetGestureDetectors();
1215 }
1216
1217 void ContentViewCoreImpl::IgnoreRemainingTouchEvents(JNIEnv* env, jobject obj) {
1218 gesture_provider_.CancelActiveTouchSequence();
1219 }
1220
1221 void ContentViewCoreImpl::OnWindowFocusLost(JNIEnv* env, jobject obj) {
1222 gesture_provider_.CancelActiveTouchSequence();
1223 }
1224
1225 void ContentViewCoreImpl::SetDoubleTapSupportForPageEnabled(JNIEnv* env,
1226 jobject obj,
1227 jboolean enabled) {
1228 gesture_provider_.SetDoubleTapSupportForPageEnabled(enabled);
1229 }
1230
1231 void ContentViewCoreImpl::SetDoubleTapSupportEnabled(JNIEnv* env,
1232 jobject obj,
1233 jboolean enabled) {
1234 gesture_provider_.SetDoubleTapSupportForPlatformEnabled(enabled);
1235 }
1236
1237 void ContentViewCoreImpl::SetMultiTouchZoomSupportEnabled(JNIEnv* env,
1238 jobject obj,
1239 jboolean enabled) {
1240 gesture_provider_.SetMultiTouchSupportEnabled(enabled);
1241 }
1242
1336 void ContentViewCoreImpl::LoadIfNecessary(JNIEnv* env, jobject obj) { 1243 void ContentViewCoreImpl::LoadIfNecessary(JNIEnv* env, jobject obj) {
1337 web_contents_->GetController().LoadIfNecessary(); 1244 web_contents_->GetController().LoadIfNecessary();
1338 } 1245 }
1339 1246
1340 void ContentViewCoreImpl::RequestRestoreLoad(JNIEnv* env, jobject obj) { 1247 void ContentViewCoreImpl::RequestRestoreLoad(JNIEnv* env, jobject obj) {
1341 web_contents_->GetController().SetNeedsReload(); 1248 web_contents_->GetController().SetNeedsReload();
1342 } 1249 }
1343 1250
1344 void ContentViewCoreImpl::StopLoading(JNIEnv* env, jobject obj) { 1251 void ContentViewCoreImpl::StopLoading(JNIEnv* env, jobject obj) {
1345 web_contents_->Stop(); 1252 web_contents_->Stop();
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 // If it was actually enabled globally, enable it for this RenderWidget now. 1644 // If it was actually enabled globally, enable it for this RenderWidget now.
1738 if (accessibility_state->IsAccessibleBrowser() && host_impl) 1645 if (accessibility_state->IsAccessibleBrowser() && host_impl)
1739 host_impl->AddAccessibilityMode(AccessibilityModeComplete); 1646 host_impl->AddAccessibilityMode(AccessibilityModeComplete);
1740 } else { 1647 } else {
1741 accessibility_state->ResetAccessibilityMode(); 1648 accessibility_state->ResetAccessibilityMode();
1742 if (host_impl) 1649 if (host_impl)
1743 host_impl->ResetAccessibilityMode(); 1650 host_impl->ResetAccessibilityMode();
1744 } 1651 }
1745 } 1652 }
1746 1653
1747 void ContentViewCoreImpl::SendSingleTapUma(JNIEnv* env,
1748 jobject obj,
1749 jint type,
1750 jint count) {
1751 UMA_HISTOGRAM_ENUMERATION("Event.SingleTapType", type, count);
1752 }
1753
1754 void ContentViewCoreImpl::SendActionAfterDoubleTapUma(JNIEnv* env,
1755 jobject obj,
1756 jint type,
1757 jboolean has_delay,
1758 jint count) {
1759 // This UMA stat tracks a user's action after a double tap within
1760 // k seconds (where k == 5 currently). This UMA will tell us if
1761 // removing the tap gesture delay will lead to significantly more
1762 // accidental navigations after a double tap.
1763 if (has_delay) {
1764 UMA_HISTOGRAM_ENUMERATION("Event.ActionAfterDoubleTapWithDelay", type,
1765 count);
1766 } else {
1767 UMA_HISTOGRAM_ENUMERATION("Event.ActionAfterDoubleTapNoDelay", type,
1768 count);
1769 }
1770 }
1771
1772 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { 1654 void ContentViewCoreImpl::SendOrientationChangeEventInternal() {
1773 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); 1655 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
1774 if (rwhv) 1656 if (rwhv)
1775 rwhv->UpdateScreenInfo(rwhv->GetNativeView()); 1657 rwhv->UpdateScreenInfo(rwhv->GetNativeView());
1776 1658
1777 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( 1659 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
1778 web_contents_->GetRenderViewHost()); 1660 web_contents_->GetRenderViewHost());
1779 rvhi->SendOrientationChangeEvent(device_orientation_); 1661 rvhi->SendOrientationChangeEvent(device_orientation_);
1780 1662
1781 // TODO(mlamouri): temporary plumbing for Screen Orientation, this will change 1663 // TODO(mlamouri): temporary plumbing for Screen Orientation, this will change
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 reinterpret_cast<ui::ViewAndroid*>(view_android), 1740 reinterpret_cast<ui::ViewAndroid*>(view_android),
1859 reinterpret_cast<ui::WindowAndroid*>(window_android)); 1741 reinterpret_cast<ui::WindowAndroid*>(window_android));
1860 return reinterpret_cast<intptr_t>(view); 1742 return reinterpret_cast<intptr_t>(view);
1861 } 1743 }
1862 1744
1863 bool RegisterContentViewCore(JNIEnv* env) { 1745 bool RegisterContentViewCore(JNIEnv* env) {
1864 return RegisterNativesImpl(env); 1746 return RegisterNativesImpl(env);
1865 } 1747 }
1866 1748
1867 } // namespace content 1749 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698