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

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 8d29386d448718d125b6b215d3cd58f965ffa081..e53de7163b2108e67aa6f7bc4c3f703bd862c021 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -1565,12 +1565,30 @@ void RenderFrameHostImpl::OnRunFileChooser(const FileChooserParams& params) {
delegate_->RunFileChooser(this, params);
}
+void RenderFrameHostImpl::RequestTextSurroundingSelection(
+ const TextSurroundingSelectionCallback& callback,
+ int max_length) {
+ // 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;
+ }
+ DCHECK(!callback.is_null());
no sievers 2016/07/20 21:14:32 nit: move the DCHECK() to the top since you run it
AKV 2016/07/21 09:13:52 Done.
+ 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() {

Powered by Google App Engine
This is Rietveld 408576698