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

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: Removed need for espv=1 for search term extraction. Created 8 years, 2 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 c37d46177f3efcd8a82357b79e520873a33911e5..3a6864f758cf45f2841542cf0c2e3f16a07c0f63 100644
--- a/chrome/browser/ui/toolbar/toolbar_model.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model.cc
@@ -6,9 +6,11 @@
#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.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 +200,25 @@ 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();
+
+ string16 result;
Peter Kasting 2012/10/02 21:47:59 Nit: Declare this at the very bottom and return st
beaudoin 2012/10/03 22:46:52 Done.
+
+ // Ensure instant extended API is enabled.
+ if (!profile || !chrome::search::IsInstantExtendedAPIEnabled(profile))
+ return result;
+
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile);
+
+ if (!template_url_service)
Peter Kasting 2012/10/02 21:47:59 Can this ever be NULL?
beaudoin 2012/10/03 22:46:52 Upon checking, it is created if it does not alread
+ return result;
+
+ TemplateURL *template_url = template_url_service->GetDefaultSearchProvider();
+ if (!template_url)
+ return result;
+
+ template_url->ExtractSearchTermsFromURL(url, &result);
+ return result;
}
Profile* ToolbarModel::GetProfile() const {

Powered by Google App Engine
This is Rietveld 408576698