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

Unified Diff: chrome/browser/android/contextualsearch/contextual_search_delegate.cc

Issue 2157793002: Remove ContentViewCore::RequestTextSurroundingSelection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | content/browser/android/content_view_core_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/contextualsearch/contextual_search_delegate.cc
diff --git a/chrome/browser/android/contextualsearch/contextual_search_delegate.cc b/chrome/browser/android/contextualsearch/contextual_search_delegate.cc
index 7c1d27a3030bf79bcc8f5e5618463d8504d597e7..133e089c04bb5764b97f26a059a0c4a0c6822084 100644
--- a/chrome/browser/android/contextualsearch/contextual_search_delegate.cc
+++ b/chrome/browser/android/contextualsearch/contextual_search_delegate.cc
@@ -26,6 +26,7 @@
#include "components/variations/net/variations_http_headers.h"
#include "components/variations/variations_associated_data.h"
#include "content/public/browser/android/content_view_core.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "net/base/escape.h"
#include "net/http/http_status_code.h"
@@ -33,6 +34,8 @@
#include "url/gurl.h"
using content::ContentViewCore;
+using content::RenderFrameHost;
+using content::WebContents;
namespace {
@@ -234,13 +237,24 @@ void ContextualSearchDelegate::GatherSurroundingTextWithCallback(
content::ContentViewCore* content_view_core,
bool may_send_base_page_url,
HandleSurroundingsCallback callback) {
+ DCHECK(content_view_core && content_view_core->GetWebContents());
+ DCHECK(!callback.is_null());
+ DCHECK(!selection.empty());
+ RenderFrameHost* focused_frame =
+ content_view_core->GetWebContents()->GetFocusedFrame();
+ // If already one request is in progress, then return immediately with empty
+ // result.
+ if (!focused_frame || focused_frame->HasTextSurroundingSelectionCallback()) {
no sievers 2016/07/18 22:41:18 Can you remove HasTextSurroundingSelectionCallback
AKV 2016/07/20 12:32:07 Done.
+ callback.Run(base::string16(), 0, 0);
+ return;
+ }
// Immediately cancel any request that's in flight, since we're building a new
// context (and the response disposes of any existing context).
search_term_fetcher_.reset();
BuildContext(selection, use_resolved_search_term, content_view_core,
may_send_base_page_url);
- content_view_core->RequestTextSurroundingSelection(
- field_trial_->GetSurroundingSize(), callback);
+ focused_frame->SendTextSurroundingSelectionRequest(
+ callback, field_trial_->GetSurroundingSize());
}
void ContextualSearchDelegate::BuildContext(
« no previous file with comments | « no previous file | content/browser/android/content_view_core_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698