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

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

Issue 7230053: Modify TemplateURLRef to remove unknown URL parameters, but only when it represents a prepopulate... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
===================================================================
--- chrome/browser/search_engines/template_url.cc (revision 90805)
+++ chrome/browser/search_engines/template_url.cc (working copy)
@@ -85,7 +85,8 @@
page_offset_(page_offset),
parsed_(false),
valid_(false),
- supports_replacements_(false) {
+ supports_replacements_(false),
+ prepopulated_(false) {
}
void TemplateURLRef::Set(const std::string& url,
@@ -150,8 +151,11 @@
} else if (parameter == kGoogleUnescapedSearchTermsParameter) {
replacements->push_back(Replacement(GOOGLE_UNESCAPED_SEARCH_TERMS, start));
} else {
- // It can be some garbage but can also be a javascript block. Put it back.
- url->insert(start, full_parameter);
+ // If it's a prepopulated URL, we know that it's safe to remove unknown
+ // parameters. Otherwise it could be some garbage but can also be a
+ // javascript block. Put it back.
+ if (!prepopulated_)
+ url->insert(start, full_parameter);
return false;
}
return true;
@@ -685,6 +689,14 @@
return GURL();
}
+void TemplateURL::SetPrepopulateId(int id) {
+ prepopulate_id_ = id;
+ if (id > 0)
sky 2011/06/28 21:02:26 Convert these to SetTemplateURLRefsPrepopulate(id
+ SetTemplateURLRefsPrepopulated(true);
+ else
+ SetTemplateURLRefsPrepopulated(false);
+}
+
void TemplateURL::InvalidateCachedValues() const {
url_.InvalidateCachedValues();
suggestions_url_.InvalidateCachedValues();
@@ -694,6 +706,12 @@
}
}
+void TemplateURL::SetTemplateURLRefsPrepopulated(bool prepopulated) {
+ suggestions_url_.set_prepopulated(prepopulated);
+ url_.set_prepopulated(prepopulated);
+ instant_url_.set_prepopulated(prepopulated);
+}
+
std::string TemplateURL::GetExtensionId() const {
DCHECK(IsExtensionKeyword());
return GURL(url_.url()).host();

Powered by Google App Engine
This is Rietveld 408576698