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

Unified Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2157793002: Remove ContentViewCore::RequestTextSurroundingSelection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the review comments. Created 4 years, 5 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/frame_host/render_frame_host_impl.cc
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index 4aceaf571b422a133f722bdcda44dd6ceb9b7b1b..d3da9bb308b384272349830e88436d8758f47592 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -1564,12 +1564,30 @@ void RenderFrameHostImpl::OnRunFileChooser(const FileChooserParams& params) {
delegate_->RunFileChooser(this, params);
}
+void RenderFrameHostImpl::RequestTextSurroundingSelection(
+ const TextSurroundingSelectionCallback& callback,
+ int max_length) {
+ DCHECK(!callback.is_null());
+ // Only one outstanding request is allowed at any given time.
+ // If already one request is in progress, then immediately release callback
+ // with empty result.
+ if (!text_surrounding_selection_callback_.is_null()) {
+ callback.Run(base::string16(), 0, 0);
+ return;
+ }
+ text_surrounding_selection_callback_ = callback;
+ Send(
+ new FrameMsg_TextSurroundingSelectionRequest(GetRoutingID(), max_length));
+}
+
void RenderFrameHostImpl::OnTextSurroundingSelectionResponse(
const base::string16& content,
uint32_t start_offset,
uint32_t end_offset) {
- render_view_host_->OnTextSurroundingSelectionResponse(
- content, start_offset, end_offset);
+ // Just Run the callback instead of propagating further.
+ text_surrounding_selection_callback_.Run(content, start_offset, end_offset);
+ // Reset the callback for enabling early exit from future request.
+ text_surrounding_selection_callback_.Reset();
}
void RenderFrameHostImpl::OnDidAccessInitialDocument() {
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/renderer_host/render_view_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698