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

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

Issue 11576044: Remove call to IsInstantExtendedAPIGoogleSearchUrl from ToolbarModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed browser tests Created 7 years, 11 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/search_engines/template_url.cc
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc
index 9944621aca20896d5e515b867439d72e57ca52f2..aeeed81883641fd21fb8cfe263160c7357fda725 100644
--- a/chrome/browser/search_engines/template_url.cc
+++ b/chrome/browser/search_engines/template_url.cc
@@ -60,6 +60,8 @@ const char kGoogleInstantExtendedEnabledParameter[] =
"google:instantExtendedEnabledParameter";
const char kGoogleInstantExtendedEnabledKey[] =
"google:instantExtendedEnabledKey";
+const char kGoogleInstantExtendedEnabledKeyFull[] =
+ "{google:instantExtendedEnabledKey}";
const char kGoogleOriginalQueryForSuggestionParameter[] =
"google:originalQueryForSuggestion";
const char kGoogleRLZParameter[] = "google:RLZ";
@@ -747,6 +749,11 @@ TemplateURL::TemplateURL(Profile* profile, const TemplateURLData& data)
instant_url_ref_(ALLOW_THIS_IN_INITIALIZER_LIST(this),
TemplateURLRef::INSTANT) {
SetPrepopulateId(data_.prepopulate_id);
+
+ if (data_.search_terms_replacement_key ==
+ kGoogleInstantExtendedEnabledKeyFull) {
+ data_.search_terms_replacement_key = google_util::kInstantExtendedAPIParam;
+ }
}
TemplateURL::~TemplateURL() {
@@ -821,8 +828,8 @@ const std::string& TemplateURL::GetURL(size_t index) const {
data_.alternate_urls[index] : url();
}
-bool TemplateURL::ExtractSearchTermsFromURL(
- const GURL& url, string16* search_terms) {
+bool TemplateURL::ExtractSearchTermsFromURL(const GURL& url,
+ string16* search_terms) {
DCHECK(search_terms);
search_terms->clear();
@@ -844,6 +851,25 @@ bool TemplateURL::ExtractSearchTermsFromURL(
return false;
}
+bool TemplateURL::HasSearchTermsReplacementKey(const GURL& url) const {
+ // Look for the key both in the query and the ref.
+ std::string params[] = {url.query(), url.ref()};
+
+ for (int i = 0; i < 2; ++i) {
+ url_parse::Component query, key, value;
+ query.len = static_cast<int>(params[i].size());
+ while (url_parse::ExtractQueryKeyValue(params[i].c_str(), &query, &key,
+ &value)) {
+ if (key.is_nonempty() &&
+ params[i].substr(key.begin, key.len) ==
+ search_terms_replacement_key()) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
void TemplateURL::CopyFrom(const TemplateURL& other) {
if (this == &other)
return;

Powered by Google App Engine
This is Rietveld 408576698