| Index: chrome/browser/search_engines/template_url_service.cc
|
| diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc
|
| index dacbf3002f6e04f217140a5db613fd2afcc811bd..135c5a6c47f570e03df186b7835086f300363e8b 100644
|
| --- a/chrome/browser/search_engines/template_url_service.cc
|
| +++ b/chrome/browser/search_engines/template_url_service.cc
|
| @@ -20,6 +20,7 @@
|
| #include "chrome/browser/extensions/extension_service.h"
|
| #include "chrome/browser/extensions/extension_system.h"
|
| #include "chrome/browser/google/google_url_tracker.h"
|
| +#include "chrome/browser/google/google_util.h"
|
| #include "chrome/browser/history/history.h"
|
| #include "chrome/browser/history/history_notifications.h"
|
| #include "chrome/browser/history/history_service_factory.h"
|
| @@ -37,6 +38,7 @@
|
| #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
|
| #include "chrome/browser/search_engines/template_url_service_observer.h"
|
| #include "chrome/browser/search_engines/util.h"
|
| +#include "chrome/browser/ui/search/search.h"
|
| #include "chrome/browser/webdata/web_data_service_factory.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "chrome/common/chrome_switches.h"
|
| @@ -438,6 +440,22 @@ void TemplateURLService::FindMatchingKeywords(
|
| }
|
| }
|
|
|
| +string16 TemplateURLService::TryToExtractSearchTermsFromURL(const GURL& url) {
|
| + TemplateURL *template_url = GetDefaultSearchProvider();
|
| + if (!template_url)
|
| + return string16();
|
| +
|
| + // Ensure instant extended API is enabled and query URL is HTTPS.
|
| + if (!profile_ || !chrome::search::IsInstantExtendedAPIEnabled(profile_) ||
|
| + !url.SchemeIs(chrome::kHttpsScheme) ||
|
| + !google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec()))
|
| + return string16();
|
| +
|
| + string16 result;
|
| + template_url->ExtractSearchTermsFromURL(url, &result);
|
| + return result;
|
| +}
|
| +
|
| TemplateURL* TemplateURLService::GetTemplateURLForKeyword(
|
| const string16& keyword) {
|
| KeywordToTemplateMap::const_iterator elem(
|
| @@ -645,7 +663,6 @@ void TemplateURLService::SetDefaultSearchProvider(TemplateURL* url) {
|
| TemplateURL* TemplateURLService::GetDefaultSearchProvider() {
|
| if (loaded_ && !load_failed_)
|
| return default_search_provider_;
|
| -
|
| // We're not loaded, rely on the default search provider stored in prefs.
|
| return initial_default_search_provider_.get();
|
| }
|
|
|