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

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: fix tests 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..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();
}

Powered by Google App Engine
This is Rietveld 408576698