Index: chrome/browser/ui/search/search_tab_helper.cc |
diff --git a/chrome/browser/ui/search/search_tab_helper.cc b/chrome/browser/ui/search/search_tab_helper.cc |
index 3f59cfc4bb0f91481350810570d502f22173d461..5f76f386478a226df08ed521eec9ad9ff01a3e96 100644 |
--- a/chrome/browser/ui/search/search_tab_helper.cc |
+++ b/chrome/browser/ui/search/search_tab_helper.cc |
@@ -6,6 +6,9 @@ |
#include "chrome/browser/google/google_util.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/search_engines/template_url.h" |
+#include "chrome/browser/search_engines/template_url_service.h" |
+#include "chrome/browser/search_engines/template_url_service_factory.h" |
#include "chrome/browser/ui/search/search.h" |
#include "chrome/common/url_constants.h" |
#include "content/public/browser/navigation_controller.h" |
@@ -163,11 +166,33 @@ void SearchTabHelper::UpdateModelBasedOnURL(const GURL& url, |
Mode::Type type = Mode::MODE_DEFAULT; |
if (IsNTP(url)) |
type = load_state == PAINTED ? Mode::MODE_NTP : Mode::MODE_NTP_LOADING; |
- else if (google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec())) |
+ else if (CanExtractSearchTerms(url)) |
dhollowa
2012/09/28 18:06:29
Instant extended is not equivalent to search term
beaudoin
2012/10/02 17:43:29
QQ: Should I check for espv=1 for search term repl
dhollowa
2012/10/02 18:14:13
That's not quite true. I believe you're referring
|
type = Mode::MODE_SEARCH_RESULTS; |
model_.SetMode(Mode(type, animate)); |
} |
+bool SearchTabHelper::CanExtractSearchTerms(const GURL& url) { |
+ Profile* profile = |
+ Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
+ |
+ // Ensure instant extended API is enabled. |
+ if (!profile || !chrome::search::IsInstantExtendedAPIEnabled(profile)) |
+ return false; |
+ |
+ TemplateURLService* template_url_service = |
+ TemplateURLServiceFactory::GetForProfile(profile); |
+ |
+ if (!template_url_service) |
+ return false; |
+ |
+ TemplateURL *template_url = template_url_service->GetDefaultSearchProvider(); |
+ if (!template_url) |
+ return false; |
+ |
+ string16 dummy; |
+ return template_url->ExtractSearchTermsFromInstantExtendedURL(url, &dummy); |
+} |
+ |
const content::WebContents* SearchTabHelper::web_contents() const { |
return model_.web_contents(); |
} |