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

Unified Diff: components/autofill/core/browser/payments/payments_client.cc

Issue 2894333002: Pass active_chrome_experiments in payments RPC. (Closed)
Patch Set: Adds feature to active_chrome_experiments only if feature was triggered. 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
« no previous file with comments | « components/autofill/core/browser/payments/payments_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/payments/payments_client.cc
diff --git a/components/autofill/core/browser/payments/payments_client.cc b/components/autofill/core/browser/payments/payments_client.cc
index 75a735c40475483b61232b42773ab6de936f2b45..683a2f5449f58eb6cb083c123f8428ac33088de4 100644
--- a/components/autofill/core/browser/payments/payments_client.cc
+++ b/components/autofill/core/browser/payments/payments_client.cc
@@ -161,6 +161,22 @@ std::unique_ptr<base::DictionaryValue> BuildAddressDictionary(
return address;
}
+// Populates the list of active experiments that affect either the data sent in
+// payments RPCs or whether the RPCs are sent or not.
+void SetActiveExperiments(const std::vector<const char*>& active_experiments,
+ base::DictionaryValue* request_dict) {
+ if (active_experiments.empty())
+ return;
+
+ std::unique_ptr<base::ListValue> active_chrome_experiments(
+ base::MakeUnique<base::ListValue>());
+ for (const char* it : active_experiments)
+ active_chrome_experiments->AppendString(it);
+
+ request_dict->Set("active_chrome_experiments",
+ std::move(active_chrome_experiments));
+}
+
class UnmaskCardRequest : public PaymentsRequest {
public:
UnmaskCardRequest(const PaymentsClient::UnmaskRequestDetails& request_details)
@@ -222,8 +238,11 @@ class UnmaskCardRequest : public PaymentsRequest {
class GetUploadDetailsRequest : public PaymentsRequest {
public:
GetUploadDetailsRequest(const std::vector<AutofillProfile>& addresses,
+ const std::vector<const char*>& active_experiments,
const std::string& app_locale)
- : addresses_(addresses), app_locale_(app_locale) {}
+ : addresses_(addresses),
+ active_experiments_(active_experiments),
+ app_locale_(app_locale) {}
~GetUploadDetailsRequest() override {}
std::string GetRequestUrlPath() override {
@@ -250,6 +269,8 @@ class GetUploadDetailsRequest : public PaymentsRequest {
}
request_dict.Set("address", std::move(addresses));
+ SetActiveExperiments(active_experiments_, &request_dict);
+
std::string request_content;
base::JSONWriter::Write(request_dict, &request_content);
VLOG(3) << "getdetailsforsavecard request body: " << request_content;
@@ -274,7 +295,8 @@ class GetUploadDetailsRequest : public PaymentsRequest {
}
private:
- std::vector<AutofillProfile> addresses_;
+ const std::vector<AutofillProfile> addresses_;
+ const std::vector<const char*> active_experiments_;
std::string app_locale_;
base::string16 context_token_;
std::unique_ptr<base::DictionaryValue> legal_message_;
@@ -325,6 +347,8 @@ class UploadCardRequest : public PaymentsRequest {
if (base::StringToInt(exp_year, &value))
request_dict.SetInteger("expiration_year", value);
+ SetActiveExperiments(request_details_.active_experiments, &request_dict);
+
const base::string16 pan = request_details_.card.GetInfo(
AutofillType(CREDIT_CARD_NUMBER), app_locale);
std::string json_request;
@@ -352,7 +376,7 @@ class UploadCardRequest : public PaymentsRequest {
}
private:
- PaymentsClient::UploadRequestDetails request_details_;
+ const PaymentsClient::UploadRequestDetails request_details_;
std::string server_id_;
};
@@ -393,8 +417,10 @@ void PaymentsClient::UnmaskCard(
void PaymentsClient::GetUploadDetails(
const std::vector<AutofillProfile>& addresses,
+ const std::vector<const char*>& active_experiments,
const std::string& app_locale) {
- IssueRequest(base::MakeUnique<GetUploadDetailsRequest>(addresses, app_locale),
+ IssueRequest(base::MakeUnique<GetUploadDetailsRequest>(
+ addresses, active_experiments, app_locale),
false);
}
« no previous file with comments | « components/autofill/core/browser/payments/payments_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698