Index: chrome/browser/search/search.cc |
diff --git a/chrome/browser/search/search.cc b/chrome/browser/search/search.cc |
index bb42ef0ea09612ad5016e7c9274ec533af65ee43..c3b4f205abcc8cbc9272e94d1648cdd0a72a6c42 100644 |
--- a/chrome/browser/search/search.cc |
+++ b/chrome/browser/search/search.cc |
@@ -210,7 +210,8 @@ bool IsRenderedInInstantProcess(const content::WebContents* contents, |
// (2) Either it has a secure scheme, or else the user has manually specified a |
// --google-base-url and it uses that base URL. (This allows testers to use |
// --google-base-url to point at non-HTTPS servers, which eases testing.) |
-bool IsSuitableURLForInstant(const GURL& url, const TemplateURL* template_url) { |
+bool IsSuitableURLForInstantImpl(const GURL& url, |
+ const TemplateURL* template_url) { |
return template_url->HasSearchTermsReplacementKey(url) && |
(url.SchemeIsSecure() || |
google_util::StartsWithCommandLineGoogleBaseURL(url)); |
@@ -233,7 +234,7 @@ bool IsInstantURL(const GURL& url, Profile* profile) { |
if (!template_url) |
return false; |
- if (!IsSuitableURLForInstant(url, template_url)) |
+ if (!IsSuitableURLForInstantImpl(url, template_url)) |
return false; |
const TemplateURLRef& instant_url_ref = template_url->instant_url_ref(); |
@@ -274,7 +275,9 @@ base::string16 GetSearchTermsImpl(const content::WebContents* contents, |
return search_terms; |
// Otherwise, extract from the URL. |
- return GetSearchTermsFromURL(profile, entry->GetVirtualURL()); |
+ return IsSuitableURLForInstant(profile, entry->GetVirtualURL()) ? |
Jered
2014/02/11 19:10:10
nit: This would be clearer as
if (!IsSuitableURLF
kmadhusu
2014/02/11 23:24:32
Done.
|
+ ExtractSearchTermsFromURL(profile, entry->GetVirtualURL()) : |
+ base::string16(); |
} |
bool IsURLAllowedForSupervisedUser(const GURL& url, Profile* profile) { |
@@ -381,7 +384,7 @@ bool IsQueryExtractionEnabled() { |
#endif // defined(OS_IOS) || defined(OS_ANDROID) |
} |
-base::string16 GetSearchTermsFromURL(Profile* profile, const GURL& url) { |
+base::string16 ExtractSearchTermsFromURL(Profile* profile, const GURL& url) { |
if (url.is_valid() && url == GetSearchResultPrefetchBaseURL(profile)) { |
// InstantSearchPrerenderer has the search query for the Instant search base |
// page. |
@@ -391,13 +394,18 @@ base::string16 GetSearchTermsFromURL(Profile* profile, const GURL& url) { |
return prerenderer->get_last_query(); |
} |
- base::string16 search_terms; |
TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); |
- if (template_url && IsSuitableURLForInstant(url, template_url)) |
+ base::string16 search_terms; |
+ if (template_url) |
template_url->ExtractSearchTermsFromURL(url, &search_terms); |
return search_terms; |
} |
+bool IsSuitableURLForInstant(Profile* profile, const GURL& url) { |
+ TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); |
+ return IsSuitableURLForInstantImpl(url, template_url); |
Jered
2014/02/11 19:10:10
template_url && ...
kmadhusu
2014/02/11 23:24:32
Done.
|
+} |
+ |
base::string16 GetSearchTermsFromNavigationEntry( |
const content::NavigationEntry* entry) { |
base::string16 search_terms; |
@@ -447,9 +455,9 @@ bool IsNTPURL(const GURL& url, Profile* profile) { |
if (!IsInstantExtendedAPIEnabled()) |
return url == GURL(chrome::kChromeUINewTabURL); |
+ const base::string16 search_terms = ExtractSearchTermsFromURL(profile, url); |
return profile && |
- ((IsInstantURL(url, profile) && |
- GetSearchTermsFromURL(profile, url).empty()) || |
+ ((IsInstantURL(url, profile) && search_terms.empty()) || |
url == GURL(chrome::kChromeSearchLocalNtpUrl)); |
} |
@@ -501,7 +509,7 @@ GURL GetInstantURL(Profile* profile, int start_margin, |
// Extended mode requires HTTPS. Force it unless the base URL was overridden |
// on the command line, in which case we allow HTTP (see comments on |
- // IsSuitableURLForInstant()). |
+ // IsSuitableURLForInstantImpl()). |
if (!instant_url.SchemeIsSecure() && |
!google_util::StartsWithCommandLineGoogleBaseURL(instant_url)) { |
GURL::Replacements replacements; |