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

Unified Diff: chrome/browser/ui/toolbar/toolbar_model.cc

Issue 10908226: Introduces a search term extraction mechanism working for arbitrary search providers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 3 months 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/ui/toolbar/toolbar_model.cc
diff --git a/chrome/browser/ui/toolbar/toolbar_model.cc b/chrome/browser/ui/toolbar/toolbar_model.cc
index c7a164686d0c41e4488dbc116da6034ec47c45cb..11793f3f74d77a28976a441e3cc8117e677928f3 100644
--- a/chrome/browser/ui/toolbar/toolbar_model.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model.cc
@@ -6,9 +6,10 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete_input.h"
-#include "chrome/browser/google/google_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ssl/ssl_error_info.h"
#include "chrome/browser/ui/search/search.h"
#include "chrome/browser/ui/toolbar/toolbar_model_delegate.h"
@@ -198,14 +199,21 @@ NavigationController* ToolbarModel::GetNavigationController() const {
string16 ToolbarModel::TryToExtractSearchTermsFromURL(const GURL& url) const {
Profile* profile = GetProfile();
- if (profile &&
- chrome::search::IsInstantExtendedAPIEnabled(profile) &&
- google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec())) {
- // TODO(dominich): http://crbug.com/135106 - Replace this with whatever the
- // final solution is as per http://crbug.com/139176.
- return google_util::GetSearchTermsFromGoogleSearchURL(url.spec());
- }
- return string16();
+
+ if (!profile || !chrome::search::IsInstantExtendedAPIEnabled(profile))
+ return string16();
+
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile);
+
+ if (!template_url_service)
+ return string16();
+
+ TemplateURL *template_url = template_url_service->GetDefaultSearchProvider();
+ if (!template_url)
+ return string16();
+
+ return template_url->ExtractSearchTermsFromURL(url);
}
Profile* ToolbarModel::GetProfile() const {

Powered by Google App Engine
This is Rietveld 408576698