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

Side by Side Diff: chrome/browser/ui/search/instant_search_prerenderer.cc

Issue 1260033003: Partially componentize //chrome/browser/search/search.{h,cc} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation on iOS Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/search/instant_search_prerenderer.h" 5 #include "chrome/browser/ui/search/instant_search_prerenderer.h"
6 6
7 #include "chrome/browser/prerender/prerender_handle.h" 7 #include "chrome/browser/prerender/prerender_handle.h"
8 #include "chrome/browser/prerender/prerender_manager.h" 8 #include "chrome/browser/prerender/prerender_manager.h"
9 #include "chrome/browser/prerender/prerender_manager_factory.h" 9 #include "chrome/browser/prerender/prerender_manager_factory.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/search/instant_service.h" 11 #include "chrome/browser/search/instant_service.h"
12 #include "chrome/browser/search/instant_service_factory.h" 12 #include "chrome/browser/search/instant_service_factory.h"
13 #include "chrome/browser/search/search.h" 13 #include "chrome/browser/search/search.h"
14 #include "chrome/browser/search_engines/template_url_service_factory.h" 14 #include "chrome/browser/search_engines/template_url_service_factory.h"
15 #include "chrome/browser/ui/browser_navigator.h" 15 #include "chrome/browser/ui/browser_navigator.h"
16 #include "chrome/browser/ui/search/search_tab_helper.h" 16 #include "chrome/browser/ui/search/search_tab_helper.h"
17 #include "components/omnibox/browser/autocomplete_match.h" 17 #include "components/omnibox/browser/autocomplete_match.h"
18 #include "components/search/search.h"
18 #include "components/search_engines/template_url_service.h" 19 #include "components/search_engines/template_url_service.h"
19 20
20 namespace { 21 namespace {
21 22
22 // Returns true if the underlying page supports Instant search. 23 // Returns true if the underlying page supports Instant search.
23 bool PageSupportsInstantSearch(content::WebContents* contents) { 24 bool PageSupportsInstantSearch(content::WebContents* contents) {
24 // Search results page supports Instant search. 25 // Search results page supports Instant search.
25 return SearchTabHelper::FromWebContents(contents)->IsSearchResultsPage(); 26 return SearchTabHelper::FromWebContents(contents)->IsSearchResultsPage();
26 } 27 }
27 28
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 126
126 // InstantSearchPrerenderer can commit query to the prerendered page only if 127 // InstantSearchPrerenderer can commit query to the prerendered page only if
127 // the underlying |source| page doesn't support Instant search. 128 // the underlying |source| page doesn't support Instant search.
128 return !PageSupportsInstantSearch(source); 129 return !PageSupportsInstantSearch(source);
129 } 130 }
130 131
131 bool InstantSearchPrerenderer::UsePrerenderedPage( 132 bool InstantSearchPrerenderer::UsePrerenderedPage(
132 const GURL& url, 133 const GURL& url,
133 chrome::NavigateParams* params) { 134 chrome::NavigateParams* params) {
134 base::string16 search_terms = 135 base::string16 search_terms =
135 chrome::ExtractSearchTermsFromURL(profile_, url); 136 search::ExtractSearchTermsFromURL(profile_, url);
136 prerender::PrerenderManager* prerender_manager = 137 prerender::PrerenderManager* prerender_manager =
137 prerender::PrerenderManagerFactory::GetForProfile(profile_); 138 prerender::PrerenderManagerFactory::GetForProfile(profile_);
138 if (search_terms.empty() || !params->target_contents || 139 if (search_terms.empty() || !params->target_contents ||
139 !prerender_contents() || !prerender_manager || 140 !prerender_contents() || !prerender_manager ||
140 !QueryMatchesPrefetch(search_terms) || 141 !QueryMatchesPrefetch(search_terms) ||
141 params->disposition != CURRENT_TAB) { 142 params->disposition != CURRENT_TAB) {
142 Cancel(); 143 Cancel();
143 return false; 144 return false;
144 } 145 }
145 146
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 !PageSupportsInstantSearch(source); 185 !PageSupportsInstantSearch(source);
185 } 186 }
186 187
187 content::WebContents* InstantSearchPrerenderer::prerender_contents() const { 188 content::WebContents* InstantSearchPrerenderer::prerender_contents() const {
188 return (prerender_handle_ && prerender_handle_->contents()) ? 189 return (prerender_handle_ && prerender_handle_->contents()) ?
189 prerender_handle_->contents()->prerender_contents() : NULL; 190 prerender_handle_->contents()->prerender_contents() : NULL;
190 } 191 }
191 192
192 bool InstantSearchPrerenderer::QueryMatchesPrefetch( 193 bool InstantSearchPrerenderer::QueryMatchesPrefetch(
193 const base::string16& query) const { 194 const base::string16& query) const {
194 if (chrome::ShouldReuseInstantSearchBasePage()) 195 if (search::ShouldReuseInstantSearchBasePage())
195 return true; 196 return true;
196 return last_instant_suggestion_.text == query; 197 return last_instant_suggestion_.text == query;
197 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698