Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4913)

Unified Diff: chrome/browser/search_engines/template_url_service.cc

Issue 11415292: [Search] No longer reverting omnibox text on instant search (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: indent Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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(

Powered by Google App Engine
This is Rietveld 408576698