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/ExceptionStatePlaceholder.h" | |
please use gerrit instead
2016/09/20 08:15:46
Why is this included?
zino
2016/09/20 16:55:43
Done.
| |
8 #include "bindings/core/v8/V8ObjectBuilder.h" | |
7 #include "wtf/text/StringBuilder.h" | 9 #include "wtf/text/StringBuilder.h" |
8 | 10 |
9 namespace blink { | 11 namespace blink { |
10 | 12 |
11 PaymentAddress::PaymentAddress(mojom::blink::PaymentAddressPtr address) | 13 PaymentAddress::PaymentAddress(mojom::blink::PaymentAddressPtr address) |
12 : m_country(address->country) | 14 : m_country(address->country) |
13 , m_addressLine(address->address_line.PassStorage()) | 15 , m_addressLine(address->address_line.PassStorage()) |
14 , m_region(address->region) | 16 , m_region(address->region) |
15 , m_city(address->city) | 17 , m_city(address->city) |
16 , m_dependentLocality(address->dependent_locality) | 18 , m_dependentLocality(address->dependent_locality) |
17 , m_postalCode(address->postal_code) | 19 , m_postalCode(address->postal_code) |
18 , m_sortingCode(address->sorting_code) | 20 , m_sortingCode(address->sorting_code) |
19 , m_languageCode(address->language_code) | 21 , m_languageCode(address->language_code) |
20 , m_organization(address->organization) | 22 , m_organization(address->organization) |
21 , m_recipient(address->recipient) | 23 , m_recipient(address->recipient) |
22 , m_careOf(address->careOf) | 24 , m_careOf(address->careOf) |
23 , m_phone(address->phone) | 25 , m_phone(address->phone) |
24 { | 26 { |
25 if (!m_languageCode.isEmpty() && !address->script_code.isEmpty()) { | 27 if (!m_languageCode.isEmpty() && !address->script_code.isEmpty()) { |
26 StringBuilder builder; | 28 StringBuilder builder; |
27 builder.append(m_languageCode); | 29 builder.append(m_languageCode); |
28 builder.append('-'); | 30 builder.append('-'); |
29 builder.append(address->script_code); | 31 builder.append(address->script_code); |
30 m_languageCode = builder.toString(); | 32 m_languageCode = builder.toString(); |
31 } | 33 } |
32 } | 34 } |
33 | 35 |
34 PaymentAddress::~PaymentAddress() {} | 36 PaymentAddress::~PaymentAddress() {} |
35 | 37 |
38 ScriptValue PaymentAddress::toJSONForBinding(ScriptState* scriptState) const | |
39 { | |
40 V8ObjectBuilder result(scriptState); | |
41 result.addString("country", country()); | |
42 result.add("addressLine", addressLine()); | |
43 result.addString("region", region()); | |
44 result.addString("city", city()); | |
45 result.addString("dependentLocality", dependentLocality()); | |
46 result.addString("postalCode", postalCode()); | |
47 result.addString("sortingCode", sortingCode()); | |
48 result.addString("languageCode", languageCode()); | |
49 result.addString("organization", organization()); | |
50 result.addString("recipient", recipient()); | |
51 result.addString("phone", phone()); | |
52 return result.scriptValue(); | |
53 } | |
54 | |
36 } // namespace blink | 55 } // namespace blink |
OLD | NEW |