OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/payments/PaymentAddress.h" | 5 #include "modules/payments/PaymentAddress.h" |
6 | 6 |
| 7 #include "bindings/core/v8/V8ObjectBuilder.h" |
7 #include "wtf/text/StringBuilder.h" | 8 #include "wtf/text/StringBuilder.h" |
8 | 9 |
9 namespace blink { | 10 namespace blink { |
10 | 11 |
11 PaymentAddress::PaymentAddress(mojom::blink::PaymentAddressPtr address) | 12 PaymentAddress::PaymentAddress(mojom::blink::PaymentAddressPtr address) |
12 : m_country(address->country) | 13 : m_country(address->country) |
13 , m_addressLine(address->address_line.PassStorage()) | 14 , m_addressLine(address->address_line.PassStorage()) |
14 , m_region(address->region) | 15 , m_region(address->region) |
15 , m_city(address->city) | 16 , m_city(address->city) |
16 , m_dependentLocality(address->dependent_locality) | 17 , m_dependentLocality(address->dependent_locality) |
17 , m_postalCode(address->postal_code) | 18 , m_postalCode(address->postal_code) |
18 , m_sortingCode(address->sorting_code) | 19 , m_sortingCode(address->sorting_code) |
19 , m_languageCode(address->language_code) | 20 , m_languageCode(address->language_code) |
20 , m_organization(address->organization) | 21 , m_organization(address->organization) |
21 , m_recipient(address->recipient) | 22 , m_recipient(address->recipient) |
22 , m_careOf(address->careOf) | 23 , m_careOf(address->careOf) |
23 , m_phone(address->phone) | 24 , m_phone(address->phone) |
24 { | 25 { |
25 if (!m_languageCode.isEmpty() && !address->script_code.isEmpty()) { | 26 if (!m_languageCode.isEmpty() && !address->script_code.isEmpty()) { |
26 StringBuilder builder; | 27 StringBuilder builder; |
27 builder.append(m_languageCode); | 28 builder.append(m_languageCode); |
28 builder.append('-'); | 29 builder.append('-'); |
29 builder.append(address->script_code); | 30 builder.append(address->script_code); |
30 m_languageCode = builder.toString(); | 31 m_languageCode = builder.toString(); |
31 } | 32 } |
32 } | 33 } |
33 | 34 |
34 PaymentAddress::~PaymentAddress() {} | 35 PaymentAddress::~PaymentAddress() {} |
35 | 36 |
| 37 ScriptValue PaymentAddress::toJSONForBinding(ScriptState* scriptState) const |
| 38 { |
| 39 V8ObjectBuilder result(scriptState); |
| 40 result.addString("country", country()); |
| 41 result.add("addressLine", addressLine()); |
| 42 result.addString("region", region()); |
| 43 result.addString("city", city()); |
| 44 result.addString("dependentLocality", dependentLocality()); |
| 45 result.addString("postalCode", postalCode()); |
| 46 result.addString("sortingCode", sortingCode()); |
| 47 result.addString("languageCode", languageCode()); |
| 48 result.addString("organization", organization()); |
| 49 result.addString("recipient", recipient()); |
| 50 result.addString("phone", phone()); |
| 51 return result.scriptValue(); |
| 52 } |
| 53 |
36 } // namespace blink | 54 } // namespace blink |
OLD | NEW |