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

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

Issue 2551023003: Added UMA counters for Android tool-types. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 using base::android::AttachCurrentThread; 70 using base::android::AttachCurrentThread;
71 using base::android::ConvertJavaStringToUTF16; 71 using base::android::ConvertJavaStringToUTF16;
72 using base::android::ConvertJavaStringToUTF8; 72 using base::android::ConvertJavaStringToUTF8;
73 using base::android::ConvertUTF16ToJavaString; 73 using base::android::ConvertUTF16ToJavaString;
74 using base::android::ConvertUTF8ToJavaString; 74 using base::android::ConvertUTF8ToJavaString;
75 using base::android::JavaParamRef; 75 using base::android::JavaParamRef;
76 using base::android::JavaRef; 76 using base::android::JavaRef;
77 using base::android::ScopedJavaLocalRef; 77 using base::android::ScopedJavaLocalRef;
78 using blink::WebGestureEvent; 78 using blink::WebGestureEvent;
79 using blink::WebInputEvent; 79 using blink::WebInputEvent;
80 using ui::MotionEventAndroid;
80 81
81 namespace content { 82 namespace content {
82 83
83 namespace { 84 namespace {
84 85
85 // Describes the type and enabled state of a select popup item. 86 // Describes the type and enabled state of a select popup item.
86 // 87 //
87 // A Java counterpart will be generated for this enum. 88 // A Java counterpart will be generated for this enum.
88 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input 89 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input
89 enum PopupItemType { 90 enum PopupItemType {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 case WebInputEvent::GesturePinchUpdate: 155 case WebInputEvent::GesturePinchUpdate:
155 return GESTURE_EVENT_TYPE_PINCH_BY; 156 return GESTURE_EVENT_TYPE_PINCH_BY;
156 case WebInputEvent::GestureTwoFingerTap: 157 case WebInputEvent::GestureTwoFingerTap:
157 default: 158 default:
158 NOTREACHED() << "Invalid source gesture type: " 159 NOTREACHED() << "Invalid source gesture type: "
159 << WebInputEvent::GetName(type); 160 << WebInputEvent::GetName(type);
160 return -1; 161 return -1;
161 } 162 }
162 } 163 }
163 164
165 void RecordToolTypeForActionDown(MotionEventAndroid& event) {
166 MotionEventAndroid::Action action = event.GetAction();
167 if (action == MotionEventAndroid::ACTION_DOWN ||
168 action == MotionEventAndroid::ACTION_POINTER_DOWN ||
169 action == MotionEventAndroid::ACTION_BUTTON_PRESS) {
170 UMA_HISTOGRAM_ENUMERATION("Event.AndroidActionDown.ToolType",
171 event.GetToolType(0),
172 MotionEventAndroid::TOOL_TYPE_LAST + 1);
173 }
174 }
175
164 } // namespace 176 } // namespace
165 177
166 // Enables a callback when the underlying WebContents is destroyed, to enable 178 // Enables a callback when the underlying WebContents is destroyed, to enable
167 // nulling the back-pointer. 179 // nulling the back-pointer.
168 class ContentViewCoreImpl::ContentViewUserData 180 class ContentViewCoreImpl::ContentViewUserData
169 : public base::SupportsUserData::Data { 181 : public base::SupportsUserData::Data {
170 public: 182 public:
171 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core) 183 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core)
172 : content_view_core_(content_view_core) { 184 : content_view_core_(content_view_core) {
173 } 185 }
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 jint android_tool_type_0, 932 jint android_tool_type_0,
921 jint android_tool_type_1, 933 jint android_tool_type_1,
922 jint android_button_state, 934 jint android_button_state,
923 jint android_meta_state, 935 jint android_meta_state,
924 jboolean is_touch_handle_event) { 936 jboolean is_touch_handle_event) {
925 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); 937 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
926 // Avoid synthesizing a touch event if it cannot be forwarded. 938 // Avoid synthesizing a touch event if it cannot be forwarded.
927 if (!rwhv) 939 if (!rwhv)
928 return false; 940 return false;
929 941
930 ui::MotionEventAndroid::Pointer pointer0(pointer_id_0, 942 MotionEventAndroid::Pointer pointer0(pointer_id_0,
931 pos_x_0, 943 pos_x_0,
932 pos_y_0, 944 pos_y_0,
933 touch_major_0, 945 touch_major_0,
934 touch_minor_0, 946 touch_minor_0,
935 orientation_0, 947 orientation_0,
936 tilt_0, 948 tilt_0,
937 android_tool_type_0); 949 android_tool_type_0);
938 ui::MotionEventAndroid::Pointer pointer1(pointer_id_1, 950 MotionEventAndroid::Pointer pointer1(pointer_id_1,
939 pos_x_1, 951 pos_x_1,
940 pos_y_1, 952 pos_y_1,
941 touch_major_1, 953 touch_major_1,
942 touch_minor_1, 954 touch_minor_1,
943 orientation_1, 955 orientation_1,
944 tilt_1, 956 tilt_1,
945 android_tool_type_1); 957 android_tool_type_1);
946 ui::MotionEventAndroid event(1.f / dpi_scale(), 958 MotionEventAndroid event(1.f / dpi_scale(),
947 env, 959 env,
948 motion_event, 960 motion_event,
949 time_ms, 961 time_ms,
950 android_action, 962 android_action,
951 pointer_count, 963 pointer_count,
952 history_size, 964 history_size,
953 action_index, 965 action_index,
954 android_button_state, 966 android_button_state,
955 android_meta_state, 967 android_meta_state,
956 raw_pos_x - pos_x_0, 968 raw_pos_x - pos_x_0,
957 raw_pos_y - pos_y_0, 969 raw_pos_y - pos_y_0,
958 &pointer0, 970 &pointer0,
959 &pointer1); 971 &pointer1);
960 972
973 RecordToolTypeForActionDown(event);
974
961 return is_touch_handle_event ? rwhv->OnTouchHandleEvent(event) 975 return is_touch_handle_event ? rwhv->OnTouchHandleEvent(event)
962 : rwhv->OnTouchEvent(event); 976 : rwhv->OnTouchEvent(event);
963 } 977 }
964 978
965 jboolean ContentViewCoreImpl::SendMouseEvent( 979 jboolean ContentViewCoreImpl::SendMouseEvent(
966 JNIEnv* env, 980 JNIEnv* env,
967 const JavaParamRef<jobject>& obj, 981 const JavaParamRef<jobject>& obj,
968 jlong time_ms, 982 jlong time_ms,
969 jint android_action, 983 jint android_action,
970 jfloat x, 984 jfloat x,
971 jfloat y, 985 jfloat y,
972 jint pointer_id, 986 jint pointer_id,
973 jfloat pressure, 987 jfloat pressure,
974 jfloat orientation, 988 jfloat orientation,
975 jfloat tilt, 989 jfloat tilt,
976 jint android_changed_button, 990 jint android_changed_button,
977 jint android_button_state, 991 jint android_button_state,
978 jint android_meta_state, 992 jint android_meta_state,
979 jint android_tool_type) { 993 jint android_tool_type) {
980 994
981 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); 995 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
982 if (!rwhv) 996 if (!rwhv)
983 return false; 997 return false;
984 998
985 // Construct a motion_event object minimally, only to convert the raw 999 // Construct a motion_event object minimally, only to convert the raw
986 // parameters to ui::MotionEvent values. Since we used only the cached values 1000 // parameters to ui::MotionEvent values. Since we used only the cached values
987 // at index=0, it is okay to even pass a null event to the constructor. 1001 // at index=0, it is okay to even pass a null event to the constructor.
988 ui::MotionEventAndroid::Pointer pointer0( 1002 MotionEventAndroid::Pointer pointer0(
989 pointer_id, x, y, 0.0f /* touch_major */, 0.0f /* touch_minor */, 1003 pointer_id, x, y, 0.0f /* touch_major */, 0.0f /* touch_minor */,
990 orientation, tilt, android_tool_type); 1004 orientation, tilt, android_tool_type);
991 1005
992 ui::MotionEventAndroid motion_event(1.f / dpi_scale(), 1006 MotionEventAndroid motion_event(1.f / dpi_scale(),
993 env, 1007 env,
994 nullptr /* event */, 1008 nullptr /* event */,
995 time_ms, 1009 time_ms,
996 android_action, 1010 android_action,
997 1 /* pointer_count */, 1011 1 /* pointer_count */,
998 0 /* history_size */, 1012 0 /* history_size */,
999 0 /* action_index */, 1013 0 /* action_index */,
1000 android_button_state, 1014 android_button_state,
1001 android_meta_state, 1015 android_meta_state,
1002 0 /* raw_offset_x_pixels */, 1016 0 /* raw_offset_x_pixels */,
1003 0 /* raw_offset_y_pixels */, 1017 0 /* raw_offset_y_pixels */,
1004 &pointer0, 1018 &pointer0,
1005 nullptr); 1019 nullptr);
1006 1020
1021 RecordToolTypeForActionDown(motion_event);
1022
1007 // Note: This relies on identical button enum values in MotionEvent and 1023 // Note: This relies on identical button enum values in MotionEvent and
1008 // MotionEventAndroid. 1024 // MotionEventAndroid.
1009 rwhv->SendMouseEvent(motion_event, android_changed_button); 1025 rwhv->SendMouseEvent(motion_event, android_changed_button);
1010 1026
1011 return true; 1027 return true;
1012 } 1028 }
1013 1029
1014 jboolean ContentViewCoreImpl::SendMouseWheelEvent( 1030 jboolean ContentViewCoreImpl::SendMouseWheelEvent(
1015 JNIEnv* env, 1031 JNIEnv* env,
1016 const JavaParamRef<jobject>& obj, 1032 const JavaParamRef<jobject>& obj,
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 return ScopedJavaLocalRef<jobject>(); 1623 return ScopedJavaLocalRef<jobject>();
1608 1624
1609 return view->GetJavaObject(); 1625 return view->GetJavaObject();
1610 } 1626 }
1611 1627
1612 bool RegisterContentViewCore(JNIEnv* env) { 1628 bool RegisterContentViewCore(JNIEnv* env) {
1613 return RegisterNativesImpl(env); 1629 return RegisterNativesImpl(env);
1614 } 1630 }
1615 1631
1616 } // namespace content 1632 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698