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..5b1836c17d6544afd48de8cae6ff0ba180fb6f94 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,23 @@ void TemplateURLService::FindMatchingKeywords( |
} |
} |
+string16 TemplateURLService::TryToExtractSearchTermsFromURL(GURL url) { |
sky
2012/12/12 22:41:57
How about making this a function in chrome/browser
Mathieu
2012/12/12 23:37:24
I thought it fit nicely here since it already used
sky
2012/12/13 00:48:18
This uses public state of TemplateURLService. Its
|
+ TemplateURL *template_url = GetDefaultSearchProvider(); |
+ if (!template_url) |
+ return string16(); |
+ |
+ // Ensure instant extended API is enabled and query URL is HTTPS. |
+ if (!template_url->profile_ || |
sky
2012/12/12 22:41:57
Why are you using template_url->profile_ instead o
Mathieu
2012/12/12 23:37:24
Done.
|
+ !chrome::search::IsInstantExtendedAPIEnabled(template_url->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( |