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 "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" |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
812 } | 812 } |
813 | 813 |
814 scoped_refptr<cc::Layer> ContentViewCoreImpl::GetLayer() const { | 814 scoped_refptr<cc::Layer> ContentViewCoreImpl::GetLayer() const { |
815 return root_layer_.get(); | 815 return root_layer_.get(); |
816 } | 816 } |
817 | 817 |
818 // ---------------------------------------------------------------------------- | 818 // ---------------------------------------------------------------------------- |
819 // Methods called from Java via JNI | 819 // Methods called from Java via JNI |
820 // ---------------------------------------------------------------------------- | 820 // ---------------------------------------------------------------------------- |
821 | 821 |
822 void ContentViewCoreImpl::SelectPopupMenuItems(JNIEnv* env, jobject obj, | 822 void ContentViewCoreImpl::SelectPopupMenuItems( |
823 jintArray indices) { | 823 JNIEnv* env, |
824 jobject obj, | |
825 jintArray indices) { | |
824 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | 826 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
825 web_contents_->GetRenderViewHost()); | 827 web_contents_->GetRenderViewHost()); |
826 DCHECK(rvhi); | 828 DCHECK(rvhi); |
827 if (indices == NULL) { | 829 if (indices == NULL) { |
828 rvhi->DidCancelPopupMenu(); | 830 rvhi->DidCancelPopupMenu(); |
829 return; | 831 return; |
830 } | 832 } |
831 | 833 |
832 int selected_count = env->GetArrayLength(indices); | 834 int selected_count = env->GetArrayLength(indices); |
833 std::vector<int> selected_indices; | 835 std::vector<int> selected_indices; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 params.referrer = content::Referrer( | 890 params.referrer = content::Referrer( |
889 GURL(ConvertJavaStringToUTF8(env, j_referrer_url)), | 891 GURL(ConvertJavaStringToUTF8(env, j_referrer_url)), |
890 static_cast<blink::WebReferrerPolicy>(referrer_policy)); | 892 static_cast<blink::WebReferrerPolicy>(referrer_policy)); |
891 } | 893 } |
892 | 894 |
893 params.is_renderer_initiated = is_renderer_initiated; | 895 params.is_renderer_initiated = is_renderer_initiated; |
894 | 896 |
895 LoadUrl(params); | 897 LoadUrl(params); |
896 } | 898 } |
897 | 899 |
898 ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL( | |
899 JNIEnv* env, jobject) const { | |
900 return ConvertUTF8ToJavaString(env, GetWebContents()->GetURL().spec()); | |
901 } | |
902 | |
903 jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) { | |
904 return GetWebContents()->GetBrowserContext()->IsOffTheRecord(); | |
905 } | |
906 | |
907 WebContents* ContentViewCoreImpl::GetWebContents() const { | 900 WebContents* ContentViewCoreImpl::GetWebContents() const { |
908 return web_contents_; | 901 return web_contents_; |
909 } | 902 } |
910 | 903 |
911 void ContentViewCoreImpl::SetFocus(JNIEnv* env, jobject obj, jboolean focused) { | 904 void ContentViewCoreImpl::SetFocus(JNIEnv* env, jobject obj, jboolean focused) { |
912 SetFocusInternal(focused); | 905 SetFocusInternal(focused); |
913 } | 906 } |
914 | 907 |
915 void ContentViewCoreImpl::SetFocusInternal(bool focused) { | 908 void ContentViewCoreImpl::SetFocusInternal(bool focused) { |
916 if (!GetRenderWidgetHostViewAndroid()) | 909 if (!GetRenderWidgetHostViewAndroid()) |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1492 static_cast<int>(x / dpi_scale()), | 1485 static_cast<int>(x / dpi_scale()), |
1493 static_cast<int>(y / dpi_scale()), | 1486 static_cast<int>(y / dpi_scale()), |
1494 static_cast<int>((width > 0 && width < dpi_scale()) ? | 1487 static_cast<int>((width > 0 && width < dpi_scale()) ? |
1495 1 : (int)(width / dpi_scale())), | 1488 1 : (int)(width / dpi_scale())), |
1496 static_cast<int>((height > 0 && height < dpi_scale()) ? | 1489 static_cast<int>((height > 0 && height < dpi_scale()) ? |
1497 1 : (int)(height / dpi_scale()))); | 1490 1 : (int)(height / dpi_scale()))); |
1498 GetWebContents()->Send(new ViewMsg_ExtractSmartClipData( | 1491 GetWebContents()->Send(new ViewMsg_ExtractSmartClipData( |
1499 GetWebContents()->GetRoutingID(), rect)); | 1492 GetWebContents()->GetRoutingID(), rect)); |
1500 } | 1493 } |
1501 | 1494 |
1502 void ContentViewCoreImpl::ResumeResponseDeferredAtStart(JNIEnv* env, | |
1503 jobject obj) { | |
1504 static_cast<WebContentsImpl*>(GetWebContents())-> | |
1505 ResumeResponseDeferredAtStart(); | |
1506 } | |
1507 | |
1508 void ContentViewCoreImpl::SetHasPendingNavigationTransitionForTesting( | |
1509 JNIEnv* env, | |
1510 jobject obj) { | |
1511 RenderFrameHost* frame = static_cast<WebContentsImpl*>(GetWebContents())-> | |
1512 GetMainFrame(); | |
1513 BrowserThread::PostTask( | |
1514 BrowserThread::IO, | |
1515 FROM_HERE, | |
1516 base::Bind( | |
1517 &TransitionRequestManager::SetHasPendingTransitionRequest, | |
1518 base::Unretained(TransitionRequestManager::GetInstance()), | |
1519 frame->GetProcess()->GetID(), | |
1520 frame->GetRoutingID(), | |
1521 true)); | |
1522 } | |
1523 | |
1524 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { | 1495 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { |
1525 return GetRenderProcessIdFromRenderViewHost( | 1496 return GetRenderProcessIdFromRenderViewHost( |
1526 web_contents_->GetRenderViewHost()); | 1497 web_contents_->GetRenderViewHost()); |
1527 } | 1498 } |
1528 | 1499 |
1529 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, | 1500 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, |
1530 jboolean opaque) { | 1501 jboolean opaque) { |
1531 if (GetRenderWidgetHostViewAndroid()) | 1502 if (GetRenderWidgetHostViewAndroid()) |
1532 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque); | 1503 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque); |
1533 } | 1504 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1575 | 1546 |
1576 std::vector<GURL>::const_iterator iter = entering_stylesheets.begin(); | 1547 std::vector<GURL>::const_iterator iter = entering_stylesheets.begin(); |
1577 for (; iter != entering_stylesheets.end(); ++iter) { | 1548 for (; iter != entering_stylesheets.end(); ++iter) { |
1578 ScopedJavaLocalRef<jstring> jstring_url(ConvertUTF8ToJavaString( | 1549 ScopedJavaLocalRef<jstring> jstring_url(ConvertUTF8ToJavaString( |
1579 env, iter->spec())); | 1550 env, iter->spec())); |
1580 Java_ContentViewCore_addEnteringStylesheetToTransition( | 1551 Java_ContentViewCore_addEnteringStylesheetToTransition( |
1581 env, obj.obj(), jstring_url.obj()); | 1552 env, obj.obj(), jstring_url.obj()); |
1582 } | 1553 } |
1583 } | 1554 } |
1584 | 1555 |
1585 bool ContentViewCoreImpl::WillHandleDeferAfterResponseStarted() { | 1556 bool ContentViewCoreImpl::WillHandleDeferAfterResponseStarted() { |
Yaron
2014/08/04 17:08:30
I think we should probably move these two function
AKVT
2014/08/05 13:58:43
Thank you for reference patch link. I have modifie
| |
1586 JNIEnv* env = AttachCurrentThread(); | 1557 JNIEnv* env = AttachCurrentThread(); |
1587 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1558 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1588 if (obj.is_null()) | 1559 if (obj.is_null()) |
1589 return false; | 1560 return false; |
1590 | 1561 |
1591 return Java_ContentViewCore_willHandleDeferAfterResponseStarted(env, | 1562 return Java_ContentViewCore_willHandleDeferAfterResponseStarted(env, |
1592 obj.obj()); | 1563 obj.obj()); |
1593 } | 1564 } |
1594 | 1565 |
1595 void ContentViewCoreImpl::DidStartNavigationTransitionForFrame(int64 frame_id) { | 1566 void ContentViewCoreImpl::DidStartNavigationTransitionForFrame(int64 frame_id) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1637 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1608 reinterpret_cast<ui::WindowAndroid*>(window_android), |
1638 retained_objects_set); | 1609 retained_objects_set); |
1639 return reinterpret_cast<intptr_t>(view); | 1610 return reinterpret_cast<intptr_t>(view); |
1640 } | 1611 } |
1641 | 1612 |
1642 bool RegisterContentViewCore(JNIEnv* env) { | 1613 bool RegisterContentViewCore(JNIEnv* env) { |
1643 return RegisterNativesImpl(env); | 1614 return RegisterNativesImpl(env); |
1644 } | 1615 } |
1645 | 1616 |
1646 } // namespace content | 1617 } // namespace content |
OLD | NEW |