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

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

Issue 2300753003: [TTS] Cleanup a potential issue introduced in CL 2157793002 (Closed)
Patch Set: Just a rebase. Created 4 years, 3 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 | no next file » | 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 e2dfe1c036ef21aaddf0605255522b500c07518a..c00aa10772e1c58d35188ba6fb0dcfe3016d441a 100644
--- a/chrome/browser/android/contextualsearch/contextual_search_delegate.cc
+++ b/chrome/browser/android/contextualsearch/contextual_search_delegate.cc
@@ -248,21 +248,19 @@ void ContextualSearchDelegate::GatherSurroundingTextWithCallback(
content::WebContents* web_contents,
bool may_send_base_page_url,
HandleSurroundingsCallback callback) {
- DCHECK(web_contents);
- DCHECK(!callback.is_null());
- DCHECK(!selection.empty());
- RenderFrameHost* focused_frame = web_contents->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, web_contents,
may_send_base_page_url);
- focused_frame->RequestTextSurroundingSelection(
- callback, field_trial_->GetSurroundingSize());
+ DCHECK(web_contents);
+ RenderFrameHost* focused_frame = web_contents->GetFocusedFrame();
+ if (focused_frame) {
+ focused_frame->RequestTextSurroundingSelection(
+ callback, field_trial_->GetSurroundingSize());
+ } else {
+ callback.Run(base::string16(), 0, 0);
+ }
}
void ContextualSearchDelegate::BuildContext(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698