| Index: chrome/browser/search/search.cc
|
| diff --git a/chrome/browser/search/search.cc b/chrome/browser/search/search.cc
|
| index 16e74fadbe60a34e4277a101aaebf91c07df5119..bee3190c947f29296cc0bd6d04cbcb5dde5e36d7 100644
|
| --- a/chrome/browser/search/search.cc
|
| +++ b/chrome/browser/search/search.cc
|
| @@ -203,13 +203,9 @@ bool IsRenderedInInstantProcess(const content::WebContents* contents,
|
| return instant_service->IsInstantProcess(process_host->GetID());
|
| }
|
|
|
| -// Returns true if |url| passes some basic checks that must succeed for it to be
|
| -// usable as an instant URL:
|
| -// (1) It contains the search terms replacement key of |template_url|, which is
|
| -// expected to be the TemplateURL* for the default search provider.
|
| -// (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.)
|
| +// |url| should either have a secure scheme or have a non-HTTPS base URL that
|
| +// the user specified using --google-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) {
|
| return template_url->HasSearchTermsReplacementKey(url) &&
|
| (url.SchemeIsSecure() ||
|
| @@ -273,8 +269,11 @@ base::string16 GetSearchTermsImpl(const content::WebContents* contents,
|
| if (!search_terms.empty())
|
| return search_terms;
|
|
|
| + if (!IsQueryExtractionAllowedForURL(profile, entry->GetVirtualURL()))
|
| + return base::string16();
|
| +
|
| // Otherwise, extract from the URL.
|
| - return GetSearchTermsFromURL(profile, entry->GetVirtualURL());
|
| + return ExtractSearchTermsFromURL(profile, entry->GetVirtualURL());
|
| }
|
|
|
| bool IsURLAllowedForSupervisedUser(const GURL& url, Profile* profile) {
|
| @@ -381,7 +380,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 +390,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 IsQueryExtractionAllowedForURL(Profile* profile, const GURL& url) {
|
| + TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile);
|
| + return template_url && IsSuitableURLForInstant(url, template_url);
|
| +}
|
| +
|
| base::string16 GetSearchTermsFromNavigationEntry(
|
| const content::NavigationEntry* entry) {
|
| base::string16 search_terms;
|
| @@ -447,9 +451,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));
|
| }
|
|
|
|
|