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

Unified Diff: components/search_engines/template_url.cc

Issue 2872453005: Add Yandex referral ID to search URL. (Closed)
Patch Set: Created 3 years, 7 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: components/search_engines/template_url.cc
diff --git a/components/search_engines/template_url.cc b/components/search_engines/template_url.cc
index b4fb151639c6799de44dc0008764ebc6a051e3c2..2bb5fe9f0c9cb8e983c0273b743de9ed57b95d20 100644
--- a/components/search_engines/template_url.cc
+++ b/components/search_engines/template_url.cc
@@ -649,6 +649,8 @@ bool TemplateURLRef::ParseParameter(size_t start,
replacements->push_back(Replacement(GOOGLE_SUGGEST_REQUEST_ID, start));
} else if (parameter == kGoogleUnescapedSearchTermsParameter) {
replacements->push_back(Replacement(GOOGLE_UNESCAPED_SEARCH_TERMS, start));
+ } else if (parameter == "yandex:referralID") {
+ replacements->push_back(Replacement(YANDEX_REFERRAL_ID, start));
} else if (parameter == "yandex:searchPath") {
switch (ui::GetDeviceFormFactor()) {
case ui::DEVICE_FORM_FACTOR_DESKTOP:
@@ -1125,6 +1127,18 @@ std::string TemplateURLRef::HandleReplacements(
#endif
break;
+ case YANDEX_REFERRAL_ID: {
+ DCHECK(!i->is_post_param);
Peter Kasting 2017/05/09 00:14:25 Is this important? Why?
Ted C 2017/05/09 04:38:32 this and the comment below were blatantly cribbed
+ // On platforms that don't have Referral ID, we still want this branch
+ // to happen so that we replace the Referral ID template with the
+ // empty string. (If we don't handle this case, we hit a
+ // NOTREACHED below.)
Peter Kasting 2017/05/09 00:14:25 I'm confused. Is this referring to having a case
+ std::string referral_id = search_terms_data.YandexReferralID();
+ if (!referral_id.empty())
+ HandleReplacement("clid", referral_id, *i, &url);
+ break;
+ }
+
default:
NOTREACHED();
break;
« components/search_engines/search_terms_data.h ('K') | « components/search_engines/template_url.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698