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 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { | 1396 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { |
1397 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 1397 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
1398 if (rwhv) | 1398 if (rwhv) |
1399 rwhv->UpdateScreenInfo(GetViewAndroid()); | 1399 rwhv->UpdateScreenInfo(GetViewAndroid()); |
1400 | 1400 |
1401 static_cast<WebContentsImpl*>(web_contents()) | 1401 static_cast<WebContentsImpl*>(web_contents()) |
1402 ->GetScreenOrientationProvider() | 1402 ->GetScreenOrientationProvider() |
1403 ->OnOrientationChange(); | 1403 ->OnOrientationChange(); |
1404 } | 1404 } |
1405 | 1405 |
1406 void ContentViewCoreImpl::ExtractSmartClipData(JNIEnv* env, | |
1407 const JavaParamRef<jobject>& obj, | |
1408 jint x, | |
1409 jint y, | |
1410 jint width, | |
1411 jint height) { | |
1412 gfx::Rect rect( | |
1413 static_cast<int>(x / dpi_scale()), | |
1414 static_cast<int>(y / dpi_scale()), | |
1415 static_cast<int>((width > 0 && width < dpi_scale()) ? | |
1416 1 : (int)(width / dpi_scale())), | |
1417 static_cast<int>((height > 0 && height < dpi_scale()) ? | |
1418 1 : (int)(height / dpi_scale()))); | |
1419 GetWebContents()->Send(new ViewMsg_ExtractSmartClipData( | |
1420 GetWebContents()->GetRenderViewHost()->GetRoutingID(), rect)); | |
1421 } | |
1422 | |
1423 jint ContentViewCoreImpl::GetCurrentRenderProcessId( | 1406 jint ContentViewCoreImpl::GetCurrentRenderProcessId( |
1424 JNIEnv* env, | 1407 JNIEnv* env, |
1425 const JavaParamRef<jobject>& obj) { | 1408 const JavaParamRef<jobject>& obj) { |
1426 return GetRenderProcessIdFromRenderViewHost( | 1409 return GetRenderProcessIdFromRenderViewHost( |
1427 web_contents_->GetRenderViewHost()); | 1410 web_contents_->GetRenderViewHost()); |
1428 } | 1411 } |
1429 | 1412 |
1430 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, | 1413 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, |
1431 const JavaParamRef<jobject>& jobj, | 1414 const JavaParamRef<jobject>& jobj, |
1432 jboolean opaque) { | 1415 jboolean opaque) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 | 1501 |
1519 void ContentViewCoreImpl::HidePopupsAndPreserveSelection() { | 1502 void ContentViewCoreImpl::HidePopupsAndPreserveSelection() { |
1520 JNIEnv* env = AttachCurrentThread(); | 1503 JNIEnv* env = AttachCurrentThread(); |
1521 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1504 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1522 if (obj.is_null()) | 1505 if (obj.is_null()) |
1523 return; | 1506 return; |
1524 | 1507 |
1525 Java_ContentViewCore_hidePopupsAndPreserveSelection(env, obj); | 1508 Java_ContentViewCore_hidePopupsAndPreserveSelection(env, obj); |
1526 } | 1509 } |
1527 | 1510 |
1528 void ContentViewCoreImpl::OnSmartClipDataExtracted( | |
1529 const base::string16& text, | |
1530 const base::string16& html, | |
1531 const gfx::Rect& clip_rect) { | |
1532 JNIEnv* env = AttachCurrentThread(); | |
1533 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
1534 if (obj.is_null()) | |
1535 return; | |
1536 ScopedJavaLocalRef<jstring> jtext = ConvertUTF16ToJavaString(env, text); | |
1537 ScopedJavaLocalRef<jstring> jhtml = ConvertUTF16ToJavaString(env, html); | |
1538 ScopedJavaLocalRef<jobject> clip_rect_object(CreateJavaRect(env, clip_rect)); | |
1539 Java_ContentViewCore_onSmartClipDataExtracted(env, obj, jtext, jhtml, | |
1540 clip_rect_object); | |
1541 } | |
1542 | |
1543 void ContentViewCoreImpl::WebContentsDestroyed() { | 1511 void ContentViewCoreImpl::WebContentsDestroyed() { |
1544 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( | 1512 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( |
1545 static_cast<WebContentsImpl*>(web_contents())->GetView()); | 1513 static_cast<WebContentsImpl*>(web_contents())->GetView()); |
1546 DCHECK(wcva); | 1514 DCHECK(wcva); |
1547 wcva->SetContentViewCore(NULL); | 1515 wcva->SetContentViewCore(NULL); |
1548 } | 1516 } |
1549 | 1517 |
1550 // This is called for each ContentView. | 1518 // This is called for each ContentView. |
1551 jlong Init(JNIEnv* env, | 1519 jlong Init(JNIEnv* env, |
1552 const JavaParamRef<jobject>& obj, | 1520 const JavaParamRef<jobject>& obj, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 return ScopedJavaLocalRef<jobject>(); | 1554 return ScopedJavaLocalRef<jobject>(); |
1587 | 1555 |
1588 return view->GetJavaObject(); | 1556 return view->GetJavaObject(); |
1589 } | 1557 } |
1590 | 1558 |
1591 bool RegisterContentViewCore(JNIEnv* env) { | 1559 bool RegisterContentViewCore(JNIEnv* env) { |
1592 return RegisterNativesImpl(env); | 1560 return RegisterNativesImpl(env); |
1593 } | 1561 } |
1594 | 1562 |
1595 } // namespace content | 1563 } // namespace content |
OLD | NEW |