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

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: 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
« 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..7e4ea34f4397890acaaecd7ceb47bf943758880f 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,7 @@
#include "url/gurl.h"
using content::ContentViewCore;
+using content::RenderFrameHost;
namespace {
@@ -234,13 +236,23 @@ void ContextualSearchDelegate::GatherSurroundingTextWithCallback(
content::ContentViewCore* content_view_core,
bool may_send_base_page_url,
HandleSurroundingsCallback callback) {
+ DCHECK(content_view_core);
+ DCHECK(content_view_core->GetWebContents());
+ DCHECK(!callback.is_null());
+ DCHECK(!selection.empty());
+ RenderFrameHost* focused_frame =
+ content_view_core->GetWebContents()->GetFocusedFrame();
+ if (!focused_frame) {
+ 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->RequestTextSurroundingSelection(
+ 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