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

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

Issue 2896993002: Route OnDragEvent through ViewAndroid tree (Closed)
Patch Set: +ui/base Created 3 years, 7 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 <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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "content/public/browser/render_frame_host.h" 45 #include "content/public/browser/render_frame_host.h"
46 #include "content/public/browser/render_view_host.h" 46 #include "content/public/browser/render_view_host.h"
47 #include "content/public/browser/ssl_host_state_delegate.h" 47 #include "content/public/browser/ssl_host_state_delegate.h"
48 #include "content/public/browser/web_contents.h" 48 #include "content/public/browser/web_contents.h"
49 #include "content/public/common/content_client.h" 49 #include "content/public/common/content_client.h"
50 #include "content/public/common/content_switches.h" 50 #include "content/public/common/content_switches.h"
51 #include "content/public/common/menu_item.h" 51 #include "content/public/common/menu_item.h"
52 #include "content/public/common/user_agent.h" 52 #include "content/public/common/user_agent.h"
53 #include "device/geolocation/geolocation_service_context.h" 53 #include "device/geolocation/geolocation_service_context.h"
54 #include "jni/ContentViewCore_jni.h" 54 #include "jni/ContentViewCore_jni.h"
55 #include "jni/DragEvent_jni.h"
56 #include "third_party/WebKit/public/platform/WebInputEvent.h" 55 #include "third_party/WebKit/public/platform/WebInputEvent.h"
57 #include "third_party/WebKit/public/web/WebContextMenuData.h" 56 #include "third_party/WebKit/public/web/WebContextMenuData.h"
58 #include "ui/android/view_android.h" 57 #include "ui/android/view_android.h"
59 #include "ui/android/window_android.h" 58 #include "ui/android/window_android.h"
60 #include "ui/base/clipboard/clipboard.h"
61 #include "ui/base/ui_base_switches_util.h"
62 #include "ui/events/android/motion_event_android.h"
63 #include "ui/events/blink/blink_event_util.h" 59 #include "ui/events/blink/blink_event_util.h"
64 #include "ui/events/blink/web_input_event_traits.h" 60 #include "ui/events/blink/web_input_event_traits.h"
65 #include "ui/events/event_utils.h" 61 #include "ui/events/event_utils.h"
66 #include "ui/events/gesture_detection/motion_event.h" 62 #include "ui/events/gesture_detection/motion_event.h"
67 #include "ui/gfx/android/java_bitmap.h" 63 #include "ui/gfx/android/java_bitmap.h"
68 #include "ui/gfx/geometry/point_conversions.h" 64 #include "ui/gfx/geometry/point_conversions.h"
69 #include "ui/gfx/geometry/size_conversions.h" 65 #include "ui/gfx/geometry/size_conversions.h"
70 #include "ui/gfx/geometry/size_f.h" 66 #include "ui/gfx/geometry/size_f.h"
71 67
72 using base::android::AttachCurrentThread; 68 using base::android::AttachCurrentThread;
73 using base::android::ConvertJavaStringToUTF16; 69 using base::android::ConvertJavaStringToUTF16;
74 using base::android::ConvertJavaStringToUTF8; 70 using base::android::ConvertJavaStringToUTF8;
75 using base::android::ConvertUTF16ToJavaString; 71 using base::android::ConvertUTF16ToJavaString;
76 using base::android::ConvertUTF8ToJavaString; 72 using base::android::ConvertUTF8ToJavaString;
77 using base::android::JavaParamRef; 73 using base::android::JavaParamRef;
78 using base::android::JavaRef; 74 using base::android::JavaRef;
79 using base::android::ScopedJavaLocalRef; 75 using base::android::ScopedJavaLocalRef;
80 using blink::WebContextMenuData; 76 using blink::WebContextMenuData;
81 using blink::WebGestureEvent; 77 using blink::WebGestureEvent;
82 using blink::WebInputEvent; 78 using blink::WebInputEvent;
83 using ui::MotionEventAndroid;
84 79
85 namespace content { 80 namespace content {
86 81
87 namespace { 82 namespace {
88 83
89 // Describes the type and enabled state of a select popup item. 84 // Describes the type and enabled state of a select popup item.
90 // 85 //
91 // A Java counterpart will be generated for this enum. 86 // A Java counterpart will be generated for this enum.
92 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input 87 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input
93 enum PopupItemType { 88 enum PopupItemType {
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 const JavaParamRef<jobject>& jobj, 1133 const JavaParamRef<jobject>& jobj,
1139 jboolean opaque) { 1134 jboolean opaque) {
1140 if (GetRenderWidgetHostViewAndroid()) { 1135 if (GetRenderWidgetHostViewAndroid()) {
1141 if (opaque) 1136 if (opaque)
1142 GetRenderWidgetHostViewAndroid()->SetBackgroundColorToDefault(); 1137 GetRenderWidgetHostViewAndroid()->SetBackgroundColorToDefault();
1143 else 1138 else
1144 GetRenderWidgetHostViewAndroid()->SetBackgroundColor(SK_ColorTRANSPARENT); 1139 GetRenderWidgetHostViewAndroid()->SetBackgroundColor(SK_ColorTRANSPARENT);
1145 } 1140 }
1146 } 1141 }
1147 1142
1148 bool ContentViewCoreImpl::IsTouchDragDropEnabled(
1149 JNIEnv* env,
1150 const base::android::JavaParamRef<jobject>& jobj) {
1151 return switches::IsTouchDragDropEnabled();
1152 }
1153
1154 void ContentViewCoreImpl::OnDragEvent(
1155 JNIEnv* env,
1156 const base::android::JavaParamRef<jobject>& jobj,
1157 jint action,
1158 jint x,
1159 jint y,
1160 jint screen_x,
1161 jint screen_y,
1162 const base::android::JavaParamRef<jobjectArray>& j_mimeTypes,
1163 const base::android::JavaParamRef<jstring>& j_content) {
1164 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>(
1165 static_cast<WebContentsImpl*>(web_contents())->GetView());
1166
1167 const gfx::Point location(x, y);
1168 const gfx::Point screen_location(screen_x, screen_y);
1169
1170 std::vector<base::string16> mime_types;
1171 base::android::AppendJavaStringArrayToStringVector(env, j_mimeTypes,
1172 &mime_types);
1173 switch (action) {
1174 case JNI_DragEvent::ACTION_DRAG_ENTERED: {
1175 std::vector<DropData::Metadata> metadata;
1176 for (const base::string16& mime_type : mime_types) {
1177 metadata.push_back(DropData::Metadata::CreateForMimeType(
1178 DropData::Kind::STRING, mime_type));
1179 }
1180 wcva->OnDragEntered(metadata, location, screen_location);
1181 break;
1182 }
1183 case JNI_DragEvent::ACTION_DRAG_LOCATION: {
1184 wcva->OnDragUpdated(location, screen_location);
1185 break;
1186 }
1187 case JNI_DragEvent::ACTION_DROP: {
1188 base::string16 text_to_drop = ConvertJavaStringToUTF16(env, j_content);
1189 DropData drop_data;
1190 drop_data.did_originate_from_renderer = false;
1191 for (const base::string16& mime_type : mime_types) {
1192 if (base::EqualsASCII(mime_type, ui::Clipboard::kMimeTypeURIList)) {
1193 drop_data.url = GURL(text_to_drop);
1194 } else if (base::EqualsASCII(mime_type, ui::Clipboard::kMimeTypeText)) {
1195 drop_data.text = base::NullableString16(text_to_drop, false);
1196 } else {
1197 drop_data.html = base::NullableString16(text_to_drop, false);
1198 }
1199 }
1200
1201 wcva->OnPerformDrop(&drop_data, location, screen_location);
1202 break;
1203 }
1204 case JNI_DragEvent::ACTION_DRAG_EXITED:
1205 wcva->OnDragExited();
1206 break;
1207 case JNI_DragEvent::ACTION_DRAG_ENDED:
1208 wcva->OnDragEnded();
1209 break;
1210 case JNI_DragEvent::ACTION_DRAG_STARTED:
1211 // Nothing meaningful to do.
1212 break;
1213 }
1214 }
1215
1216 void ContentViewCoreImpl::OnShowUnhandledTapUIIfNeeded(int x_dip, int y_dip) { 1143 void ContentViewCoreImpl::OnShowUnhandledTapUIIfNeeded(int x_dip, int y_dip) {
1217 JNIEnv* env = AttachCurrentThread(); 1144 JNIEnv* env = AttachCurrentThread();
1218 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 1145 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
1219 if (obj.is_null()) 1146 if (obj.is_null())
1220 return; 1147 return;
1221 Java_ContentViewCore_onShowUnhandledTapUIIfNeeded( 1148 Java_ContentViewCore_onShowUnhandledTapUIIfNeeded(
1222 env, obj, static_cast<jint>(x_dip * dpi_scale()), 1149 env, obj, static_cast<jint>(x_dip * dpi_scale()),
1223 static_cast<jint>(y_dip * dpi_scale())); 1150 static_cast<jint>(y_dip * dpi_scale()));
1224 } 1151 }
1225 1152
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 return ScopedJavaLocalRef<jobject>(); 1216 return ScopedJavaLocalRef<jobject>();
1290 1217
1291 return view->GetJavaObject(); 1218 return view->GetJavaObject();
1292 } 1219 }
1293 1220
1294 bool RegisterContentViewCore(JNIEnv* env) { 1221 bool RegisterContentViewCore(JNIEnv* env) {
1295 return RegisterNativesImpl(env); 1222 return RegisterNativesImpl(env);
1296 } 1223 }
1297 1224
1298 } // namespace content 1225 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/web_contents/web_contents_view_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698