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

Unified Diff: content/browser/android/content_view_core_impl.cc

Issue 322203002: Add an interface to gather text surrounding the selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@surroundings-patch-5
Patch Set: Comments. Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
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..625121e78ec1c556e1fa68810c5bb697a08107af 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"
@@ -222,7 +223,8 @@ ContentViewCoreImpl::ContentViewCoreImpl(
view_android_(view_android),
window_android_(window_android),
device_orientation_(0),
- accessibility_enabled_(false) {
+ accessibility_enabled_(false),
+ text_surroundings_delegate_(NULL) {
CHECK(web_contents) <<
"A ContentViewCoreImpl should be created with a valid WebContents.";
@@ -246,7 +248,6 @@ ContentViewCoreImpl::ContentViewCoreImpl(
java_bridge_dispatcher_host_manager_.reset(
new JavaBridgeDispatcherHostManager(web_contents,
java_bridge_retained_object_set));
-
jdduke (slow) 2014/06/17 22:43:26 Hmm, did you remove this line break? If so, maybe
donnd 2014/06/18 00:09:58 Looks like I did -- replaced.
InitWebContents();
}
@@ -1538,6 +1539,21 @@ void ContentViewCoreImpl::SetAccessibilityEnabledInternal(bool enabled) {
}
}
+void ContentViewCoreImpl::SetTextSurroundingsDelegate(
+ TextSurroundingsDelegate* delegate) {
+ text_surroundings_delegate_ = delegate;
+}
+
+void ContentViewCoreImpl::OnTextSurroundingSelectionResponse(
+ const base::string16& content,
+ int start_offset,
+ int end_offset) {
+ if (text_surroundings_delegate_ != NULL) {
jdduke (slow) 2014/06/17 22:43:26 Nit, no need for "!= NULL", you can just do: if (
donnd 2014/06/18 00:09:58 Done.
+ text_surroundings_delegate_->OnTextSurroundingSelectionResponse(
+ content, start_offset, end_offset);
+ }
+}
+
void ContentViewCoreImpl::SendOrientationChangeEventInternal() {
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
if (rwhv)
@@ -1604,6 +1620,13 @@ void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj,
GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque);
}
+void ContentViewCoreImpl::RequestTextSurroundingSelection(
+ int max_length) const {
+ RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame();
jdduke (slow) 2014/06/17 22:43:26 What guarantees do we have that focused_frame will
jdduke (slow) 2014/06/17 22:43:26 Should we enforce that |text_surroundings_delegate
donnd 2014/06/18 00:09:58 Good idea to check it. I'm cribbing off of Mounir
donnd 2014/06/18 00:09:58 Done.
+ focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest(
+ focused_frame->GetRoutingID(), max_length));
+}
+
void ContentViewCoreImpl::OnSmartClipDataExtracted(
const base::string16& result) {
JNIEnv* env = AttachCurrentThread();

Powered by Google App Engine
This is Rietveld 408576698