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 "ios/web/public/payments/payment_request.h" | 5 #include "ios/web/public/payments/payment_request.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
11 // All of these are defined here (even though most are only used once each) so | 11 // All of these are defined here (even though most are only used once each) so |
12 // the format details are easy to locate and update or compare to the spec doc. | 12 // the format details are easy to locate and update or compare to the spec doc. |
13 // (https://w3c.github.io/browser-payment-api/). | 13 // (https://w3c.github.io/browser-payment-api/). |
14 static const char kAddressCountry[] = "country"; | 14 static const char kAddressCountry[] = "country"; |
15 static const char kAddressAddressLine[] = "addressLine"; | 15 static const char kAddressAddressLine[] = "addressLine"; |
16 static const char kAddressRegion[] = "region"; | 16 static const char kAddressRegion[] = "region"; |
17 static const char kAddressCity[] = "city"; | 17 static const char kAddressCity[] = "city"; |
18 static const char kAddressDependentLocality[] = "dependentLocality"; | 18 static const char kAddressDependentLocality[] = "dependentLocality"; |
19 static const char kAddressPostalCode[] = "postalCode"; | 19 static const char kAddressPostalCode[] = "postalCode"; |
20 static const char kAddressSortingCode[] = "sortingCode"; | 20 static const char kAddressSortingCode[] = "sortingCode"; |
21 static const char kAddressLanguageCode[] = "languageCode"; | 21 static const char kAddressLanguageCode[] = "languageCode"; |
22 static const char kAddressOrganization[] = "organization"; | 22 static const char kAddressOrganization[] = "organization"; |
23 static const char kAddressRecipient[] = "recipient"; | 23 static const char kAddressRecipient[] = "recipient"; |
24 static const char kAddressCareOf[] = "careOf"; | |
25 static const char kAddressPhone[] = "phone"; | 24 static const char kAddressPhone[] = "phone"; |
26 static const char kMethodData[] = "methodData"; | 25 static const char kMethodData[] = "methodData"; |
27 static const char kSupportedMethods[] = "supportedMethods"; | 26 static const char kSupportedMethods[] = "supportedMethods"; |
28 static const char kData[] = "data"; | 27 static const char kData[] = "data"; |
29 static const char kPaymentDetails[] = "details"; | 28 static const char kPaymentDetails[] = "details"; |
30 static const char kPaymentDetailsTotal[] = "total"; | 29 static const char kPaymentDetailsTotal[] = "total"; |
31 static const char kPaymentDetailsTotalAmount[] = "amount"; | 30 static const char kPaymentDetailsTotalAmount[] = "amount"; |
32 static const char kPaymentDetailsTotalAmountCurrency[] = "currency"; | 31 static const char kPaymentDetailsTotalAmountCurrency[] = "currency"; |
33 static const char kPaymentDetailsTotalAmountValue[] = "value"; | 32 static const char kPaymentDetailsTotalAmountValue[] = "value"; |
34 static const char kMethodName[] = "methodName"; | 33 static const char kMethodName[] = "methodName"; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 if (!this->postal_code.empty()) | 87 if (!this->postal_code.empty()) |
89 result->SetString(kAddressPostalCode, this->postal_code); | 88 result->SetString(kAddressPostalCode, this->postal_code); |
90 if (!this->sorting_code.empty()) | 89 if (!this->sorting_code.empty()) |
91 result->SetString(kAddressSortingCode, this->sorting_code); | 90 result->SetString(kAddressSortingCode, this->sorting_code); |
92 if (!this->language_code.empty()) | 91 if (!this->language_code.empty()) |
93 result->SetString(kAddressLanguageCode, this->language_code); | 92 result->SetString(kAddressLanguageCode, this->language_code); |
94 if (!this->organization.empty()) | 93 if (!this->organization.empty()) |
95 result->SetString(kAddressOrganization, this->organization); | 94 result->SetString(kAddressOrganization, this->organization); |
96 if (!this->recipient.empty()) | 95 if (!this->recipient.empty()) |
97 result->SetString(kAddressRecipient, this->recipient); | 96 result->SetString(kAddressRecipient, this->recipient); |
98 if (!this->care_of.empty()) | |
99 result->SetString(kAddressCareOf, this->care_of); | |
100 if (!this->phone.empty()) | 97 if (!this->phone.empty()) |
101 result->SetString(kAddressPhone, this->phone); | 98 result->SetString(kAddressPhone, this->phone); |
102 | 99 |
103 return result; | 100 return result; |
104 } | 101 } |
105 | 102 |
106 PaymentMethodData::PaymentMethodData() {} | 103 PaymentMethodData::PaymentMethodData() {} |
107 PaymentMethodData::PaymentMethodData(const PaymentMethodData& other) = default; | 104 PaymentMethodData::PaymentMethodData(const PaymentMethodData& other) = default; |
108 PaymentMethodData::~PaymentMethodData() = default; | 105 PaymentMethodData::~PaymentMethodData() = default; |
109 | 106 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 325 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
329 | 326 |
330 if (!this->method_name.empty()) | 327 if (!this->method_name.empty()) |
331 result->SetString(kMethodName, this->method_name); | 328 result->SetString(kMethodName, this->method_name); |
332 result->Set(kPaymentDetails, this->details.ToDictionaryValue()); | 329 result->Set(kPaymentDetails, this->details.ToDictionaryValue()); |
333 | 330 |
334 return result; | 331 return result; |
335 } | 332 } |
336 | 333 |
337 } // namespace web | 334 } // namespace web |
OLD | NEW |