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

Unified Diff: chrome/browser/ui/search/search_tab_helper.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: Fixed keyword_table_unittest 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/search/search_tab_helper.cc
diff --git a/chrome/browser/ui/search/search_tab_helper.cc b/chrome/browser/ui/search/search_tab_helper.cc
index 3f59cfc4bb0f91481350810570d502f22173d461..5f76f386478a226df08ed521eec9ad9ff01a3e96 100644
--- a/chrome/browser/ui/search/search_tab_helper.cc
+++ b/chrome/browser/ui/search/search_tab_helper.cc
@@ -6,6 +6,9 @@
#include "chrome/browser/google/google_util.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/ui/search/search.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/navigation_controller.h"
@@ -163,11 +166,33 @@ void SearchTabHelper::UpdateModelBasedOnURL(const GURL& url,
Mode::Type type = Mode::MODE_DEFAULT;
if (IsNTP(url))
type = load_state == PAINTED ? Mode::MODE_NTP : Mode::MODE_NTP_LOADING;
- else if (google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec()))
+ else if (CanExtractSearchTerms(url))
dhollowa 2012/09/28 18:06:29 Instant extended is not equivalent to search term
beaudoin 2012/10/02 17:43:29 QQ: Should I check for espv=1 for search term repl
dhollowa 2012/10/02 18:14:13 That's not quite true. I believe you're referring
type = Mode::MODE_SEARCH_RESULTS;
model_.SetMode(Mode(type, animate));
}
+bool SearchTabHelper::CanExtractSearchTerms(const GURL& url) {
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents()->GetBrowserContext());
+
+ // Ensure instant extended API is enabled.
+ if (!profile || !chrome::search::IsInstantExtendedAPIEnabled(profile))
+ return false;
+
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile);
+
+ if (!template_url_service)
+ return false;
+
+ TemplateURL *template_url = template_url_service->GetDefaultSearchProvider();
+ if (!template_url)
+ return false;
+
+ string16 dummy;
+ return template_url->ExtractSearchTermsFromInstantExtendedURL(url, &dummy);
+}
+
const content::WebContents* SearchTabHelper::web_contents() const {
return model_.web_contents();
}

Powered by Google App Engine
This is Rietveld 408576698