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

Unified Diff: components/payments/content/payment_response_helper.cc

Issue 2779813003: [Payments] Add Ship. Addr. & Contact Info in Payment Response on Desktop. (Closed)
Patch Set: Addressed comments Created 3 years, 9 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/payments/content/payment_response_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/payments/content/payment_response_helper.cc
diff --git a/components/payments/content/payment_response_helper.cc b/components/payments/content/payment_response_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bbec2f34c690b7a6d85e3933ca77eb6e7e8235c1
--- /dev/null
+++ b/components/payments/content/payment_response_helper.cc
@@ -0,0 +1,54 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/payments/content/payment_response_helper.h"
+
+#include "base/strings/string_split.h"
+#include "base/strings/utf_string_conversions.h"
+#include "components/autofill/core/browser/autofill_profile.h"
+#include "components/autofill/core/browser/autofill_type.h"
+
+namespace payments {
+
+PaymentResponseHelper::PaymentResponseHelper(){};
+PaymentResponseHelper::~PaymentResponseHelper(){};
+
+// static
+mojom::PaymentAddressPtr
+PaymentResponseHelper::GetMojomPaymentAddressFromAutofillProfile(
+ const autofill::AutofillProfile* const profile,
+ const std::string& app_locale) {
+ mojom::PaymentAddressPtr payment_address = mojom::PaymentAddress::New();
+
+ payment_address->country =
+ base::UTF16ToUTF8(profile->GetRawInfo(autofill::ADDRESS_HOME_COUNTRY));
+ payment_address->address_line = base::SplitString(
+ base::UTF16ToUTF8(profile->GetInfo(
+ autofill::AutofillType(autofill::ADDRESS_HOME_STREET_ADDRESS),
+ app_locale)),
+ "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
+ payment_address->region =
+ base::UTF16ToUTF8(profile->GetRawInfo(autofill::ADDRESS_HOME_STATE));
+ payment_address->city =
+ base::UTF16ToUTF8(profile->GetRawInfo(autofill::ADDRESS_HOME_CITY));
+ payment_address->dependent_locality = base::UTF16ToUTF8(
+ profile->GetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_LOCALITY));
+ payment_address->postal_code =
+ base::UTF16ToUTF8(profile->GetRawInfo(autofill::ADDRESS_HOME_ZIP));
+ payment_address->sorting_code = base::UTF16ToUTF8(
+ profile->GetRawInfo(autofill::ADDRESS_HOME_SORTING_CODE));
+ payment_address->language_code = profile->language_code();
+ payment_address->organization =
+ base::UTF16ToUTF8(profile->GetRawInfo(autofill::COMPANY_NAME));
+ payment_address->recipient = base::UTF16ToUTF8(profile->GetInfo(
+ autofill::AutofillType(autofill::NAME_FULL), app_locale));
+
+ // TODO(crbug.com/705945): Format phone number according to spec.
+ payment_address->phone =
+ base::UTF16ToUTF8(profile->GetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER));
+
+ return payment_address;
+}
+
+} // namespace payments
« no previous file with comments | « components/payments/content/payment_response_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698