Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 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/web_contents/web_contents_view_android.h" | 39 #include "content/browser/web_contents/web_contents_view_android.h" |
| 40 #include "content/common/frame_messages.h" | |
| 40 #include "content/common/input/web_input_event_traits.h" | 41 #include "content/common/input/web_input_event_traits.h" |
| 41 #include "content/common/input_messages.h" | 42 #include "content/common/input_messages.h" |
| 42 #include "content/common/view_messages.h" | 43 #include "content/common/view_messages.h" |
| 43 #include "content/public/browser/browser_accessibility_state.h" | 44 #include "content/public/browser/browser_accessibility_state.h" |
| 44 #include "content/public/browser/browser_context.h" | 45 #include "content/public/browser/browser_context.h" |
| 45 #include "content/public/browser/favicon_status.h" | 46 #include "content/public/browser/favicon_status.h" |
| 46 #include "content/public/browser/render_frame_host.h" | 47 #include "content/public/browser/render_frame_host.h" |
| 47 #include "content/public/browser/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
| 48 #include "content/public/common/content_client.h" | 49 #include "content/public/common/content_client.h" |
| 49 #include "content/public/common/content_switches.h" | 50 #include "content/public/common/content_switches.h" |
| (...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1531 // If it was actually enabled globally, enable it for this RenderWidget now. | 1532 // If it was actually enabled globally, enable it for this RenderWidget now. |
| 1532 if (accessibility_state->IsAccessibleBrowser() && host_impl) | 1533 if (accessibility_state->IsAccessibleBrowser() && host_impl) |
| 1533 host_impl->AddAccessibilityMode(AccessibilityModeComplete); | 1534 host_impl->AddAccessibilityMode(AccessibilityModeComplete); |
| 1534 } else { | 1535 } else { |
| 1535 accessibility_state->ResetAccessibilityMode(); | 1536 accessibility_state->ResetAccessibilityMode(); |
| 1536 if (host_impl) | 1537 if (host_impl) |
| 1537 host_impl->ResetAccessibilityMode(); | 1538 host_impl->ResetAccessibilityMode(); |
| 1538 } | 1539 } |
| 1539 } | 1540 } |
| 1540 | 1541 |
| 1542 void ContentViewCoreImpl::OnTextSurroundingSelectionResponse( | |
| 1543 const base::string16& content, | |
| 1544 int start_offset, | |
| 1545 int end_offset) { | |
| 1546 if (text_surroundings_callback_.is_null()) | |
| 1547 return; | |
| 1548 text_surroundings_callback_.Run(content, start_offset, end_offset); | |
| 1549 // The callback should be run only once, since it's tied to the request. | |
| 1550 // Set to the default constructor so an is_null test can prevent a re-run. | |
| 1551 text_surroundings_callback_ = TextSurroundingSelectionCallback(); | |
|
Ted C
2014/06/19 21:05:12
could this also be .Reset() instead of constructin
donnd
2014/06/19 21:27:24
Done.
| |
| 1552 } | |
| 1553 | |
| 1541 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { | 1554 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { |
| 1542 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 1555 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| 1543 if (rwhv) | 1556 if (rwhv) |
| 1544 rwhv->UpdateScreenInfo(GetViewAndroid()); | 1557 rwhv->UpdateScreenInfo(GetViewAndroid()); |
| 1545 | 1558 |
| 1546 // TODO(mlamouri): temporary plumbing for Screen Orientation, this will change | 1559 // TODO(mlamouri): temporary plumbing for Screen Orientation, this will change |
| 1547 // in the future. The OnResize IPC message sent from UpdateScreenInfo() will | 1560 // in the future. The OnResize IPC message sent from UpdateScreenInfo() will |
| 1548 // propagate the information. | 1561 // propagate the information. |
| 1549 blink::WebScreenOrientationType orientation = | 1562 blink::WebScreenOrientationType orientation = |
| 1550 blink::WebScreenOrientationPortraitPrimary; | 1563 blink::WebScreenOrientationPortraitPrimary; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1597 return GetRenderProcessIdFromRenderViewHost( | 1610 return GetRenderProcessIdFromRenderViewHost( |
| 1598 web_contents_->GetRenderViewHost()); | 1611 web_contents_->GetRenderViewHost()); |
| 1599 } | 1612 } |
| 1600 | 1613 |
| 1601 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, | 1614 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, |
| 1602 jboolean opaque) { | 1615 jboolean opaque) { |
| 1603 if (GetRenderWidgetHostViewAndroid()) | 1616 if (GetRenderWidgetHostViewAndroid()) |
| 1604 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque); | 1617 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque); |
| 1605 } | 1618 } |
| 1606 | 1619 |
| 1620 void ContentViewCoreImpl::RequestTextSurroundingSelection( | |
| 1621 int max_length, | |
| 1622 const TextSurroundingSelectionCallback& callback) { | |
| 1623 DCHECK(!callback.is_null()); | |
| 1624 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame(); | |
| 1625 if (!focused_frame) | |
| 1626 return; | |
| 1627 // Only one outstanding request is allowed at any given time. | |
| 1628 DCHECK(text_surroundings_callback_.is_null()); | |
| 1629 // TODO(donnd): consider storing the callback in RenderWidgetHostViewAndroid, | |
|
Donn Denman
2014/06/19 14:24:29
Ted, we're particularly interested in your opinion
Ted C
2014/06/19 21:05:12
Per the offline discussion, I think it is safer to
donnd
2014/06/19 21:27:24
Done.
| |
| 1630 // and clear it when we change the ContentViewCore or if the renderer crashes. | |
| 1631 // See crbug.com/386434 for details. | |
| 1632 text_surroundings_callback_ = callback; | |
| 1633 focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest( | |
| 1634 focused_frame->GetRoutingID(), max_length)); | |
| 1635 } | |
| 1636 | |
| 1607 void ContentViewCoreImpl::OnSmartClipDataExtracted( | 1637 void ContentViewCoreImpl::OnSmartClipDataExtracted( |
| 1608 const base::string16& result) { | 1638 const base::string16& result) { |
| 1609 JNIEnv* env = AttachCurrentThread(); | 1639 JNIEnv* env = AttachCurrentThread(); |
| 1610 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1640 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 1611 if (obj.is_null()) | 1641 if (obj.is_null()) |
| 1612 return; | 1642 return; |
| 1613 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result); | 1643 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result); |
| 1614 Java_ContentViewCore_onSmartClipDataExtracted( | 1644 Java_ContentViewCore_onSmartClipDataExtracted( |
| 1615 env, obj.obj(), jresult.obj()); | 1645 env, obj.obj(), jresult.obj()); |
| 1616 } | 1646 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1636 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1666 reinterpret_cast<ui::WindowAndroid*>(window_android), |
| 1637 retained_objects_set); | 1667 retained_objects_set); |
| 1638 return reinterpret_cast<intptr_t>(view); | 1668 return reinterpret_cast<intptr_t>(view); |
| 1639 } | 1669 } |
| 1640 | 1670 |
| 1641 bool RegisterContentViewCore(JNIEnv* env) { | 1671 bool RegisterContentViewCore(JNIEnv* env) { |
| 1642 return RegisterNativesImpl(env); | 1672 return RegisterNativesImpl(env); |
| 1643 } | 1673 } |
| 1644 | 1674 |
| 1645 } // namespace content | 1675 } // namespace content |
| OLD | NEW |