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

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

Issue 414423002: Removing ContentViewCore dependencies from few functions which acts as direct wrapper to WebContents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed NavigationTransitionDelegate interface from ContentViewCore. Created 6 years, 4 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 "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
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(JNIEnv* env,
823 jobject obj,
823 jintArray indices) { 824 jintArray indices) {
824 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( 825 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
825 web_contents_->GetRenderViewHost()); 826 web_contents_->GetRenderViewHost());
826 DCHECK(rvhi); 827 DCHECK(rvhi);
827 if (indices == NULL) { 828 if (indices == NULL) {
828 rvhi->DidCancelPopupMenu(); 829 rvhi->DidCancelPopupMenu();
829 return; 830 return;
830 } 831 }
831 832
832 int selected_count = env->GetArrayLength(indices); 833 int selected_count = env->GetArrayLength(indices);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 params.referrer = content::Referrer( 889 params.referrer = content::Referrer(
889 GURL(ConvertJavaStringToUTF8(env, j_referrer_url)), 890 GURL(ConvertJavaStringToUTF8(env, j_referrer_url)),
890 static_cast<blink::WebReferrerPolicy>(referrer_policy)); 891 static_cast<blink::WebReferrerPolicy>(referrer_policy));
891 } 892 }
892 893
893 params.is_renderer_initiated = is_renderer_initiated; 894 params.is_renderer_initiated = is_renderer_initiated;
894 895
895 LoadUrl(params); 896 LoadUrl(params);
896 } 897 }
897 898
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 { 899 WebContents* ContentViewCoreImpl::GetWebContents() const {
908 return web_contents_; 900 return web_contents_;
909 } 901 }
910 902
911 void ContentViewCoreImpl::SetFocus(JNIEnv* env, jobject obj, jboolean focused) { 903 void ContentViewCoreImpl::SetFocus(JNIEnv* env, jobject obj, jboolean focused) {
912 SetFocusInternal(focused); 904 SetFocusInternal(focused);
913 } 905 }
914 906
915 void ContentViewCoreImpl::SetFocusInternal(bool focused) { 907 void ContentViewCoreImpl::SetFocusInternal(bool focused) {
916 if (!GetRenderWidgetHostViewAndroid()) 908 if (!GetRenderWidgetHostViewAndroid())
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 static_cast<int>(x / dpi_scale()), 1484 static_cast<int>(x / dpi_scale()),
1493 static_cast<int>(y / dpi_scale()), 1485 static_cast<int>(y / dpi_scale()),
1494 static_cast<int>((width > 0 && width < dpi_scale()) ? 1486 static_cast<int>((width > 0 && width < dpi_scale()) ?
1495 1 : (int)(width / dpi_scale())), 1487 1 : (int)(width / dpi_scale())),
1496 static_cast<int>((height > 0 && height < dpi_scale()) ? 1488 static_cast<int>((height > 0 && height < dpi_scale()) ?
1497 1 : (int)(height / dpi_scale()))); 1489 1 : (int)(height / dpi_scale())));
1498 GetWebContents()->Send(new ViewMsg_ExtractSmartClipData( 1490 GetWebContents()->Send(new ViewMsg_ExtractSmartClipData(
1499 GetWebContents()->GetRoutingID(), rect)); 1491 GetWebContents()->GetRoutingID(), rect));
1500 } 1492 }
1501 1493
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) { 1494 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) {
1525 return GetRenderProcessIdFromRenderViewHost( 1495 return GetRenderProcessIdFromRenderViewHost(
1526 web_contents_->GetRenderViewHost()); 1496 web_contents_->GetRenderViewHost());
1527 } 1497 }
1528 1498
1529 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, 1499 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj,
1530 jboolean opaque) { 1500 jboolean opaque) {
1531 if (GetRenderWidgetHostViewAndroid()) 1501 if (GetRenderWidgetHostViewAndroid())
1532 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque); 1502 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque);
1533 } 1503 }
1534 1504
1535 void ContentViewCoreImpl::RequestTextSurroundingSelection( 1505 void ContentViewCoreImpl::RequestTextSurroundingSelection(
1536 int max_length, 1506 int max_length,
1537 const base::Callback< 1507 const base::Callback<
1538 void(const base::string16& content, int start_offset, int end_offset)>& 1508 void(const base::string16& content, int start_offset, int end_offset)>&
1539 callback) { 1509 callback) {
1540 DCHECK(!callback.is_null()); 1510 DCHECK(!callback.is_null());
1541 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame(); 1511 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame();
1542 if (!focused_frame) 1512 if (!focused_frame)
1543 return; 1513 return;
1544 if (GetRenderWidgetHostViewAndroid()) { 1514 if (GetRenderWidgetHostViewAndroid()) {
1545 GetRenderWidgetHostViewAndroid()->SetTextSurroundingSelectionCallback( 1515 GetRenderWidgetHostViewAndroid()->SetTextSurroundingSelectionCallback(
1546 callback); 1516 callback);
1547 focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest( 1517 focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest(
1548 focused_frame->GetRoutingID(), max_length)); 1518 focused_frame->GetRoutingID(), max_length));
1549 } 1519 }
1550 } 1520 }
1551 1521
1552 void ContentViewCoreImpl::DidDeferAfterResponseStarted(
1553 const scoped_refptr<net::HttpResponseHeaders>& headers,
1554 const GURL& url) {
1555 JNIEnv* env = AttachCurrentThread();
1556 ScopedJavaLocalRef<jobject> obj(java_ref_.get(env));
1557 if (obj.is_null())
1558 return;
1559
1560 std::vector<GURL> entering_stylesheets;
1561 std::string transition_color;
1562 if (headers) {
1563 TransitionRequestManager::ParseTransitionStylesheetsFromHeaders(
1564 headers, entering_stylesheets, url);
1565
1566 headers->EnumerateHeader(
1567 NULL, "X-Transition-Entering-Color", &transition_color);
1568 }
1569
1570 ScopedJavaLocalRef<jstring> jstring_transition_color(ConvertUTF8ToJavaString(
1571 env, transition_color));
1572
1573 Java_ContentViewCore_didDeferAfterResponseStarted(
1574 env, obj.obj(), jstring_transition_color.obj());
1575
1576 std::vector<GURL>::const_iterator iter = entering_stylesheets.begin();
1577 for (; iter != entering_stylesheets.end(); ++iter) {
1578 ScopedJavaLocalRef<jstring> jstring_url(ConvertUTF8ToJavaString(
1579 env, iter->spec()));
1580 Java_ContentViewCore_addEnteringStylesheetToTransition(
1581 env, obj.obj(), jstring_url.obj());
1582 }
1583 }
1584
1585 bool ContentViewCoreImpl::WillHandleDeferAfterResponseStarted() {
1586 JNIEnv* env = AttachCurrentThread();
1587 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
1588 if (obj.is_null())
1589 return false;
1590
1591 return Java_ContentViewCore_willHandleDeferAfterResponseStarted(env,
1592 obj.obj());
1593 }
1594
1595 void ContentViewCoreImpl::DidStartNavigationTransitionForFrame(int64 frame_id) {
1596 JNIEnv* env = AttachCurrentThread();
1597 ScopedJavaLocalRef<jobject> obj(java_ref_.get(env));
1598 if (obj.is_null())
1599 return;
1600 Java_ContentViewCore_didStartNavigationTransitionForFrame(
1601 env, obj.obj(), frame_id);
1602 }
1603
1604 void ContentViewCoreImpl::OnSmartClipDataExtracted( 1522 void ContentViewCoreImpl::OnSmartClipDataExtracted(
1605 const base::string16& text, 1523 const base::string16& text,
1606 const base::string16& html, 1524 const base::string16& html,
1607 const gfx::Rect& clip_rect) { 1525 const gfx::Rect& clip_rect) {
1608 JNIEnv* env = AttachCurrentThread(); 1526 JNIEnv* env = AttachCurrentThread();
1609 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 1527 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
1610 if (obj.is_null()) 1528 if (obj.is_null())
1611 return; 1529 return;
1612 ScopedJavaLocalRef<jstring> jtext = ConvertUTF16ToJavaString(env, text); 1530 ScopedJavaLocalRef<jstring> jtext = ConvertUTF16ToJavaString(env, text);
1613 ScopedJavaLocalRef<jstring> jhtml = ConvertUTF16ToJavaString(env, html); 1531 ScopedJavaLocalRef<jstring> jhtml = ConvertUTF16ToJavaString(env, html);
(...skipping 23 matching lines...) Expand all
1637 reinterpret_cast<ui::WindowAndroid*>(window_android), 1555 reinterpret_cast<ui::WindowAndroid*>(window_android),
1638 retained_objects_set); 1556 retained_objects_set);
1639 return reinterpret_cast<intptr_t>(view); 1557 return reinterpret_cast<intptr_t>(view);
1640 } 1558 }
1641 1559
1642 bool RegisterContentViewCore(JNIEnv* env) { 1560 bool RegisterContentViewCore(JNIEnv* env) {
1643 return RegisterNativesImpl(env); 1561 return RegisterNativesImpl(env);
1644 } 1562 }
1645 1563
1646 } // namespace content 1564 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698