Chromium Code Reviews| Index: content/browser/android/content_view_core_impl.cc |
| diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc |
| index 0fdc058b01df1913bdd2fd047833cf83185792e2..25643ed0ef4b39a04b57b22f460ce847b073e2a7 100644 |
| --- a/content/browser/android/content_view_core_impl.cc |
| +++ b/content/browser/android/content_view_core_impl.cc |
| @@ -37,6 +37,7 @@ |
| #include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h" |
| #include "content/browser/ssl/ssl_host_state.h" |
| #include "content/browser/web_contents/web_contents_view_android.h" |
| +#include "content/common/frame_messages.h" |
| #include "content/common/input/web_input_event_traits.h" |
| #include "content/common/input_messages.h" |
| #include "content/common/view_messages.h" |
| @@ -1538,6 +1539,18 @@ void ContentViewCoreImpl::SetAccessibilityEnabledInternal(bool enabled) { |
| } |
| } |
| +void ContentViewCoreImpl::OnTextSurroundingSelectionResponse( |
| + const base::string16& content, |
| + int start_offset, |
| + int end_offset) { |
| + if (text_surroundings_callback_.is_null()) |
| + return; |
| + text_surroundings_callback_.Run(content, start_offset, end_offset); |
| + // The callback should be run only once, since it's tied to the request. |
| + // Set to the default constructor so an is_null test can prevent a re-run. |
| + 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.
|
| +} |
| + |
| void ContentViewCoreImpl::SendOrientationChangeEventInternal() { |
| RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| if (rwhv) |
| @@ -1604,6 +1617,23 @@ void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, |
| GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque); |
| } |
| +void ContentViewCoreImpl::RequestTextSurroundingSelection( |
| + int max_length, |
| + const TextSurroundingSelectionCallback& callback) { |
| + DCHECK(!callback.is_null()); |
| + RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame(); |
| + if (!focused_frame) |
| + return; |
| + // Only one outstanding request is allowed at any given time. |
| + DCHECK(text_surroundings_callback_.is_null()); |
| + // 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.
|
| + // and clear it when we change the ContentViewCore or if the renderer crashes. |
| + // See crbug.com/386434 for details. |
| + text_surroundings_callback_ = callback; |
| + focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest( |
| + focused_frame->GetRoutingID(), max_length)); |
| +} |
| + |
| void ContentViewCoreImpl::OnSmartClipDataExtracted( |
| const base::string16& result) { |
| JNIEnv* env = AttachCurrentThread(); |