| 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 18 matching lines...) Expand all Loading... |
| 29 #include "content/browser/renderer_host/input/motion_event_android.h" | 29 #include "content/browser/renderer_host/input/motion_event_android.h" |
| 30 #include "content/browser/renderer_host/input/web_input_event_builders_android.h
" | 30 #include "content/browser/renderer_host/input/web_input_event_builders_android.h
" |
| 31 #include "content/browser/renderer_host/input/web_input_event_util.h" | 31 #include "content/browser/renderer_host/input/web_input_event_util.h" |
| 32 #include "content/browser/renderer_host/java/java_bound_object.h" | 32 #include "content/browser/renderer_host/java/java_bound_object.h" |
| 33 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" | 33 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" |
| 34 #include "content/browser/renderer_host/render_view_host_impl.h" | 34 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 35 #include "content/browser/renderer_host/render_widget_host_impl.h" | 35 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 36 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 36 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 37 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host.
h" | 37 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host.
h" |
| 38 #include "content/browser/ssl/ssl_host_state.h" | 38 #include "content/browser/ssl/ssl_host_state.h" |
| 39 #include "content/browser/transition_request_manager.h" |
| 39 #include "content/browser/web_contents/web_contents_view_android.h" | 40 #include "content/browser/web_contents/web_contents_view_android.h" |
| 40 #include "content/common/frame_messages.h" | 41 #include "content/common/frame_messages.h" |
| 41 #include "content/common/input/web_input_event_traits.h" | 42 #include "content/common/input/web_input_event_traits.h" |
| 42 #include "content/common/input_messages.h" | 43 #include "content/common/input_messages.h" |
| 43 #include "content/common/view_messages.h" | 44 #include "content/common/view_messages.h" |
| 44 #include "content/public/browser/browser_accessibility_state.h" | 45 #include "content/public/browser/browser_accessibility_state.h" |
| 45 #include "content/public/browser/browser_context.h" | 46 #include "content/public/browser/browser_context.h" |
| 47 #include "content/public/browser/browser_thread.h" |
| 46 #include "content/public/browser/favicon_status.h" | 48 #include "content/public/browser/favicon_status.h" |
| 47 #include "content/public/browser/render_frame_host.h" | 49 #include "content/public/browser/render_frame_host.h" |
| 48 #include "content/public/browser/web_contents.h" | 50 #include "content/public/browser/web_contents.h" |
| 49 #include "content/public/common/content_client.h" | 51 #include "content/public/common/content_client.h" |
| 50 #include "content/public/common/content_switches.h" | 52 #include "content/public/common/content_switches.h" |
| 51 #include "content/public/common/menu_item.h" | 53 #include "content/public/common/menu_item.h" |
| 52 #include "content/public/common/page_transition_types.h" | 54 #include "content/public/common/page_transition_types.h" |
| 53 #include "content/public/common/user_agent.h" | 55 #include "content/public/common/user_agent.h" |
| 54 #include "jni/ContentViewCore_jni.h" | 56 #include "jni/ContentViewCore_jni.h" |
| 55 #include "third_party/WebKit/public/web/WebBindings.h" | 57 #include "third_party/WebKit/public/web/WebBindings.h" |
| (...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 static_cast<int>(x / dpi_scale()), | 1564 static_cast<int>(x / dpi_scale()), |
| 1563 static_cast<int>(y / dpi_scale()), | 1565 static_cast<int>(y / dpi_scale()), |
| 1564 static_cast<int>((width > 0 && width < dpi_scale()) ? | 1566 static_cast<int>((width > 0 && width < dpi_scale()) ? |
| 1565 1 : (int)(width / dpi_scale())), | 1567 1 : (int)(width / dpi_scale())), |
| 1566 static_cast<int>((height > 0 && height < dpi_scale()) ? | 1568 static_cast<int>((height > 0 && height < dpi_scale()) ? |
| 1567 1 : (int)(height / dpi_scale()))); | 1569 1 : (int)(height / dpi_scale()))); |
| 1568 GetWebContents()->Send(new ViewMsg_ExtractSmartClipData( | 1570 GetWebContents()->Send(new ViewMsg_ExtractSmartClipData( |
| 1569 GetWebContents()->GetRoutingID(), rect)); | 1571 GetWebContents()->GetRoutingID(), rect)); |
| 1570 } | 1572 } |
| 1571 | 1573 |
| 1574 void ContentViewCoreImpl::ResumeResponseDeferredAtStart(JNIEnv* env, |
| 1575 jobject obj) { |
| 1576 static_cast<WebContentsImpl*>(GetWebContents())-> |
| 1577 ResumeResponseDeferredAtStart(); |
| 1578 } |
| 1579 |
| 1580 void ContentViewCoreImpl::SetHasPendingNavigationTransitionForTesting( |
| 1581 JNIEnv* env, |
| 1582 jobject obj) { |
| 1583 RenderFrameHost* frame = static_cast<WebContentsImpl*>(GetWebContents())-> |
| 1584 GetMainFrame(); |
| 1585 BrowserThread::PostTask( |
| 1586 BrowserThread::IO, |
| 1587 FROM_HERE, |
| 1588 base::Bind( |
| 1589 &TransitionRequestManager::SetHasPendingTransitionRequest, |
| 1590 base::Unretained(TransitionRequestManager::GetInstance()), |
| 1591 frame->GetProcess()->GetID(), |
| 1592 frame->GetRoutingID(), |
| 1593 true)); |
| 1594 } |
| 1595 |
| 1572 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { | 1596 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { |
| 1573 return GetRenderProcessIdFromRenderViewHost( | 1597 return GetRenderProcessIdFromRenderViewHost( |
| 1574 web_contents_->GetRenderViewHost()); | 1598 web_contents_->GetRenderViewHost()); |
| 1575 } | 1599 } |
| 1576 | 1600 |
| 1577 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, | 1601 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, |
| 1578 jboolean opaque) { | 1602 jboolean opaque) { |
| 1579 if (GetRenderWidgetHostViewAndroid()) | 1603 if (GetRenderWidgetHostViewAndroid()) |
| 1580 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque); | 1604 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque); |
| 1581 } | 1605 } |
| 1582 | 1606 |
| 1583 void ContentViewCoreImpl::RequestTextSurroundingSelection( | 1607 void ContentViewCoreImpl::RequestTextSurroundingSelection( |
| 1584 int max_length, | 1608 int max_length, |
| 1585 const base::Callback< | 1609 const base::Callback< |
| 1586 void(const base::string16& content, int start_offset, int end_offset)>& | 1610 void(const base::string16& content, int start_offset, int end_offset)>& |
| 1587 callback) { | 1611 callback) { |
| 1588 DCHECK(!callback.is_null()); | 1612 DCHECK(!callback.is_null()); |
| 1589 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame(); | 1613 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame(); |
| 1590 if (!focused_frame) | 1614 if (!focused_frame) |
| 1591 return; | 1615 return; |
| 1592 if (GetRenderWidgetHostViewAndroid()) { | 1616 if (GetRenderWidgetHostViewAndroid()) { |
| 1593 GetRenderWidgetHostViewAndroid()->SetTextSurroundingSelectionCallback( | 1617 GetRenderWidgetHostViewAndroid()->SetTextSurroundingSelectionCallback( |
| 1594 callback); | 1618 callback); |
| 1595 focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest( | 1619 focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest( |
| 1596 focused_frame->GetRoutingID(), max_length)); | 1620 focused_frame->GetRoutingID(), max_length)); |
| 1597 } | 1621 } |
| 1598 } | 1622 } |
| 1599 | 1623 |
| 1624 void ContentViewCoreImpl::DidDeferAfterResponseStarted() { |
| 1625 JNIEnv* env = AttachCurrentThread(); |
| 1626 ScopedJavaLocalRef<jobject> obj(java_ref_.get(env)); |
| 1627 if (obj.is_null()) |
| 1628 return; |
| 1629 Java_ContentViewCore_didDeferAfterResponseStarted(env, obj.obj()); |
| 1630 } |
| 1631 |
| 1632 bool ContentViewCoreImpl::WillHandleDeferAfterResponseStarted() { |
| 1633 JNIEnv* env = AttachCurrentThread(); |
| 1634 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 1635 if (obj.is_null()) |
| 1636 return false; |
| 1637 |
| 1638 return Java_ContentViewCore_willHandleDeferAfterResponseStarted(env, |
| 1639 obj.obj()); |
| 1640 } |
| 1641 |
| 1600 void ContentViewCoreImpl::OnSmartClipDataExtracted( | 1642 void ContentViewCoreImpl::OnSmartClipDataExtracted( |
| 1601 const base::string16& result) { | 1643 const base::string16& result) { |
| 1602 JNIEnv* env = AttachCurrentThread(); | 1644 JNIEnv* env = AttachCurrentThread(); |
| 1603 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1645 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 1604 if (obj.is_null()) | 1646 if (obj.is_null()) |
| 1605 return; | 1647 return; |
| 1606 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result); | 1648 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result); |
| 1607 Java_ContentViewCore_onSmartClipDataExtracted( | 1649 Java_ContentViewCore_onSmartClipDataExtracted( |
| 1608 env, obj.obj(), jresult.obj()); | 1650 env, obj.obj(), jresult.obj()); |
| 1609 } | 1651 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1629 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1671 reinterpret_cast<ui::WindowAndroid*>(window_android), |
| 1630 retained_objects_set); | 1672 retained_objects_set); |
| 1631 return reinterpret_cast<intptr_t>(view); | 1673 return reinterpret_cast<intptr_t>(view); |
| 1632 } | 1674 } |
| 1633 | 1675 |
| 1634 bool RegisterContentViewCore(JNIEnv* env) { | 1676 bool RegisterContentViewCore(JNIEnv* env) { |
| 1635 return RegisterNativesImpl(env); | 1677 return RegisterNativesImpl(env); |
| 1636 } | 1678 } |
| 1637 | 1679 |
| 1638 } // namespace content | 1680 } // namespace content |
| OLD | NEW |