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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 292113008: Plumbing for browser process to access text surrounding selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@adb_install_humans
Patch Set: 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
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index c45c25f982cea947f8070202fea2c3e4654b6fb4..fcc1f16977f1ccfd104790bc6b896f1dc7396c21 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -103,6 +103,7 @@
#include "third_party/WebKit/public/web/WebSearchableFormData.h"
#include "third_party/WebKit/public/web/WebSecurityOrigin.h"
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
+#include "third_party/WebKit/public/web/WebSurroundingText.h"
#include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "webkit/child/weburlresponse_extradata_impl.h"
@@ -728,10 +729,12 @@ bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
OnSetCompositionFromExistingText)
IPC_MESSAGE_HANDLER(FrameMsg_ExtendSelectionAndDelete,
OnExtendSelectionAndDelete)
+ IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload)
+ IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest,
+ OnTextSurroundingSelectionRequest)
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard)
#endif
- IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload)
IPC_END_MESSAGE_MAP()
return handled;
@@ -1211,11 +1214,30 @@ void RenderFrameImpl::OnExtendSelectionAndDelete(int before, int after) {
frame_->extendSelectionAndDelete(before, after);
}
-
void RenderFrameImpl::OnReload(bool ignore_cache) {
frame_->reload(ignore_cache);
}
+void RenderFrameImpl::OnTextSurroundingSelectionRequest(size_t max_length) {
+ blink::WebSurroundingText surroundingText;
+ surroundingText.initialize(frame_->selectionRange(), max_length);
+
+ if (surroundingText.isNull()) {
+ // |surroundingText| might not be correctly initialized, for example if
+ // |frame_->selectionRange().isNull()|, in other words, if there was no
+ // selection.
+ Send(new FrameHostMsg_TextSurroundingSelectionResponse(
+ routing_id_, base::string16(), 0, 0));
+ return;
+ }
+
+ Send(new FrameHostMsg_TextSurroundingSelectionResponse(
+ routing_id_,
+ surroundingText.textContent(),
+ surroundingText.startOffsetInTextContent(),
+ surroundingText.endOffsetInTextContent()));
+}
+
bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams(
const base::string16& selection_text,
size_t selection_text_offset,
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698