| 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 dd3fb1be5933d0b2b20143cc4bf857de803540d4..dce70a097abf6187a39aa0e8149a3d8ee4fb4702 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"
|
| @@ -159,11 +162,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))
|
| 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();
|
| }
|
|
|