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

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: Using is_null to check if the callback is null. 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..672389aa1490d17ea288ee0c127d91192601e27a 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,17 @@ 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);
+ // Re-initialize to the is_null value.
jdduke (slow) 2014/06/18 20:32:53 In the comments what if we instead say "The callba
donnd 2014/06/18 21:55:27 Done.
+ text_surroundings_callback_ = TextSurroundingSelectionCallback();
+}
+
void ContentViewCoreImpl::SendOrientationChangeEventInternal() {
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
if (rwhv)
@@ -1604,6 +1616,18 @@ void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj,
GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque);
}
+void ContentViewCoreImpl::RequestTextSurroundingSelection(
+ int max_length, const TextSurroundingSelectionCallback& callback) {
+ RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame();
+ if (!focused_frame)
+ return;
+ if (!text_surroundings_callback_.is_null())
jdduke (slow) 2014/06/18 20:32:53 I'm not sure if we should be DCHECK'ing, here, but
donnd 2014/06/18 21:55:27 Glad you caught this possibility! I changed the r
+ return;
+ 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();

Powered by Google App Engine
This is Rietveld 408576698