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 <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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 "jni/ContentViewCore_jni.h" | 53 #include "jni/ContentViewCore_jni.h" |
54 #include "third_party/WebKit/public/web/WebInputEvent.h" | 54 #include "third_party/WebKit/public/web/WebInputEvent.h" |
55 #include "ui/android/view_android.h" | 55 #include "ui/android/view_android.h" |
56 #include "ui/android/window_android.h" | 56 #include "ui/android/window_android.h" |
| 57 #include "ui/base/dragdrop/drop_target_event.h" |
| 58 #include "ui/base/dragdrop/os_exchange_data_provider_android.h" |
57 #include "ui/events/android/motion_event_android.h" | 59 #include "ui/events/android/motion_event_android.h" |
58 #include "ui/gfx/android/java_bitmap.h" | 60 #include "ui/gfx/android/java_bitmap.h" |
59 #include "ui/gfx/geometry/point_conversions.h" | 61 #include "ui/gfx/geometry/point_conversions.h" |
60 #include "ui/gfx/geometry/size_conversions.h" | 62 #include "ui/gfx/geometry/size_conversions.h" |
61 #include "ui/gfx/geometry/size_f.h" | 63 #include "ui/gfx/geometry/size_f.h" |
62 | 64 |
63 using base::android::AttachCurrentThread; | 65 using base::android::AttachCurrentThread; |
64 using base::android::ConvertJavaStringToUTF16; | 66 using base::android::ConvertJavaStringToUTF16; |
65 using base::android::ConvertJavaStringToUTF8; | 67 using base::android::ConvertJavaStringToUTF8; |
66 using base::android::ConvertUTF16ToJavaString; | 68 using base::android::ConvertUTF16ToJavaString; |
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 const JavaParamRef<jobject>& jobj, | 1404 const JavaParamRef<jobject>& jobj, |
1403 jboolean opaque) { | 1405 jboolean opaque) { |
1404 if (GetRenderWidgetHostViewAndroid()) { | 1406 if (GetRenderWidgetHostViewAndroid()) { |
1405 if (opaque) | 1407 if (opaque) |
1406 GetRenderWidgetHostViewAndroid()->SetBackgroundColorToDefault(); | 1408 GetRenderWidgetHostViewAndroid()->SetBackgroundColorToDefault(); |
1407 else | 1409 else |
1408 GetRenderWidgetHostViewAndroid()->SetBackgroundColor(SK_ColorTRANSPARENT); | 1410 GetRenderWidgetHostViewAndroid()->SetBackgroundColor(SK_ColorTRANSPARENT); |
1409 } | 1411 } |
1410 } | 1412 } |
1411 | 1413 |
| 1414 void ContentViewCoreImpl::OnDragEntered( |
| 1415 JNIEnv* env, |
| 1416 const base::android::JavaParamRef<jobject>& jobj, |
| 1417 int x, |
| 1418 int y, |
| 1419 int screen_x, |
| 1420 int screen_y) { |
| 1421 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( |
| 1422 static_cast<WebContentsImpl*>(web_contents())->GetView()); |
| 1423 |
| 1424 ui::OSExchangeData data(new ui::OSExchangeDataProviderAndroid()); |
| 1425 ui::DropTargetEvent event( |
| 1426 data, gfx::Point(x, y), gfx::Point(screen_x, screen_y), |
| 1427 ui::DragDropTypes::DRAG_COPY); // Android drag and drop does only copy. |
| 1428 |
| 1429 wcva->OnDragEntered(event); |
| 1430 } |
| 1431 |
| 1432 void ContentViewCoreImpl::OnDragUpdated( |
| 1433 JNIEnv* env, |
| 1434 const base::android::JavaParamRef<jobject>& jobj, |
| 1435 int x, |
| 1436 int y, |
| 1437 int screen_x, |
| 1438 int screen_y) { |
| 1439 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( |
| 1440 static_cast<WebContentsImpl*>(web_contents())->GetView()); |
| 1441 |
| 1442 ui::OSExchangeData data(new ui::OSExchangeDataProviderAndroid()); |
| 1443 ui::DropTargetEvent event( |
| 1444 data, gfx::Point(x, y), gfx::Point(screen_x, screen_y), |
| 1445 ui::DragDropTypes::DRAG_COPY); // Android drag and drop does only copy. |
| 1446 |
| 1447 wcva->OnDragUpdated(event); |
| 1448 } |
| 1449 |
| 1450 void ContentViewCoreImpl::OnPerformDrop( |
| 1451 JNIEnv* env, |
| 1452 const base::android::JavaParamRef<jobject>& jobj, |
| 1453 int x, |
| 1454 int y, |
| 1455 int screen_x, |
| 1456 int screen_y, |
| 1457 const base::android::JavaParamRef<jstring>& content) { |
| 1458 base::string16 text_to_drop = ConvertJavaStringToUTF16(env, content); |
| 1459 |
| 1460 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( |
| 1461 static_cast<WebContentsImpl*>(web_contents())->GetView()); |
| 1462 |
| 1463 ui::OSExchangeData data(new ui::OSExchangeDataProviderAndroid()); |
| 1464 data.SetString(text_to_drop); |
| 1465 ui::DropTargetEvent event(data, gfx::Point(x, y), |
| 1466 gfx::Point(screen_x, screen_y), |
| 1467 ui::DragDropTypes::DRAG_COPY); |
| 1468 |
| 1469 wcva->OnPerformDrop(event); |
| 1470 } |
| 1471 |
| 1472 void ContentViewCoreImpl::OnDragExited( |
| 1473 JNIEnv* env, |
| 1474 const base::android::JavaParamRef<jobject>& jobj) { |
| 1475 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( |
| 1476 static_cast<WebContentsImpl*>(web_contents())->GetView()); |
| 1477 wcva->OnDragExited(); |
| 1478 } |
| 1479 |
1412 void ContentViewCoreImpl::RequestTextSurroundingSelection( | 1480 void ContentViewCoreImpl::RequestTextSurroundingSelection( |
1413 int max_length, | 1481 int max_length, |
1414 const base::Callback< | 1482 const base::Callback< |
1415 void(const base::string16& content, int start_offset, int end_offset)>& | 1483 void(const base::string16& content, int start_offset, int end_offset)>& |
1416 callback) { | 1484 callback) { |
1417 DCHECK(!callback.is_null()); | 1485 DCHECK(!callback.is_null()); |
1418 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame(); | 1486 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame(); |
1419 if (!focused_frame) | 1487 if (!focused_frame) |
1420 return; | 1488 return; |
1421 if (GetRenderWidgetHostViewAndroid()) { | 1489 if (GetRenderWidgetHostViewAndroid()) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1521 return ScopedJavaLocalRef<jobject>(); | 1589 return ScopedJavaLocalRef<jobject>(); |
1522 | 1590 |
1523 return view->GetJavaObject(); | 1591 return view->GetJavaObject(); |
1524 } | 1592 } |
1525 | 1593 |
1526 bool RegisterContentViewCore(JNIEnv* env) { | 1594 bool RegisterContentViewCore(JNIEnv* env) { |
1527 return RegisterNativesImpl(env); | 1595 return RegisterNativesImpl(env); |
1528 } | 1596 } |
1529 | 1597 |
1530 } // namespace content | 1598 } // namespace content |
OLD | NEW |