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

Side by Side Diff: components/payments/content/payment_response_helper.cc

Issue 2779813003: [Payments] Add Ship. Addr. & Contact Info in Payment Response on Desktop. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/payments/content/payment_response_helper.h"
6
7 #include "base/strings/string_split.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "components/autofill/core/browser/autofill_type.h"
10
11 namespace payments {
12
13 PaymentResponseHelper::PaymentResponseHelper(){};
14 PaymentResponseHelper::~PaymentResponseHelper(){};
15
16 // static
17 mojom::PaymentAddressPtr
18 PaymentResponseHelper::GetMojomPaymentAddressFromAutofillProfile(
19 const autofill::AutofillProfile* const profile,
20 const std::string& app_locale) {
21 mojom::PaymentAddressPtr payment_address = mojom::PaymentAddress::New();
22
23 payment_address->country =
24 base::UTF16ToUTF8(profile->GetRawInfo(autofill::ADDRESS_HOME_COUNTRY));
25 payment_address->address_line = base::SplitString(
26 base::UTF16ToUTF8(profile->GetInfo(
27 autofill::AutofillType(autofill::ADDRESS_HOME_STREET_ADDRESS),
28 app_locale)),
29 "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
30 payment_address->region =
31 base::UTF16ToUTF8(profile->GetRawInfo(autofill::ADDRESS_HOME_STATE));
32 payment_address->city =
33 base::UTF16ToUTF8(profile->GetRawInfo(autofill::ADDRESS_HOME_CITY));
34 payment_address->dependent_locality = base::UTF16ToUTF8(
35 profile->GetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_LOCALITY));
36 payment_address->postal_code =
37 base::UTF16ToUTF8(profile->GetRawInfo(autofill::ADDRESS_HOME_ZIP));
38 payment_address->sorting_code = base::UTF16ToUTF8(
39 profile->GetRawInfo(autofill::ADDRESS_HOME_SORTING_CODE));
40 payment_address->language_code = profile->language_code();
41 payment_address->organization =
42 base::UTF16ToUTF8(profile->GetRawInfo(autofill::COMPANY_NAME));
43 payment_address->recipient = base::UTF16ToUTF8(profile->GetInfo(
44 autofill::AutofillType(autofill::NAME_FULL), app_locale));
45 payment_address->phone =
Mathieu 2017/03/27 23:42:42 TODO(crbug.com/xxxxxx): Format phone number accord
sebsg 2017/03/28 20:33:53 Done.
46 base::UTF16ToUTF8(profile->GetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER));
47
48 return payment_address;
49 }
50
51 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698