Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/core/payment_address.h" | |
| 6 | |
| 7 #include "base/strings/utf_string_conversions.h" | |
| 8 #include "base/values.h" | |
| 9 | |
| 10 namespace web { | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 // These are defined as part of the spec at: | |
| 15 // https://w3c.github.io/browser-payment-api/. | |
|
please use gerrit instead
2017/03/08 14:46:09
https://w3c.github.io/browser-payment-api/#payment
Mathieu
2017/03/08 18:04:25
Done.
| |
| 16 static const char kAddressAddressLine[] = "addressLine"; | |
| 17 static const char kAddressCity[] = "city"; | |
| 18 static const char kAddressCountry[] = "country"; | |
| 19 static const char kAddressDependentLocality[] = "dependentLocality"; | |
| 20 static const char kAddressLanguageCode[] = "languageCode"; | |
| 21 static const char kAddressOrganization[] = "organization"; | |
| 22 static const char kAddressPhone[] = "phone"; | |
| 23 static const char kAddressPostalCode[] = "postalCode"; | |
| 24 static const char kAddressRecipient[] = "recipient"; | |
| 25 static const char kAddressRegion[] = "region"; | |
| 26 static const char kAddressSortingCode[] = "sortingCode"; | |
| 27 | |
| 28 } // namespace | |
| 29 | |
| 30 PaymentAddress::PaymentAddress() {} | |
| 31 PaymentAddress::PaymentAddress(const PaymentAddress& other) = default; | |
| 32 PaymentAddress::~PaymentAddress() = default; | |
| 33 | |
| 34 bool PaymentAddress::operator==(const PaymentAddress& other) const { | |
| 35 return this->country == other.country && | |
| 36 this->address_line == other.address_line && | |
| 37 this->region == other.region && this->city == other.city && | |
| 38 this->dependent_locality == other.dependent_locality && | |
| 39 this->postal_code == other.postal_code && | |
| 40 this->sorting_code == other.sorting_code && | |
| 41 this->language_code == other.language_code && | |
| 42 this->organization == other.organization && | |
| 43 this->recipient == other.recipient && this->care_of == other.care_of && | |
| 44 this->phone == other.phone; | |
| 45 } | |
| 46 | |
| 47 bool PaymentAddress::operator!=(const PaymentAddress& other) const { | |
| 48 return !(*this == other); | |
| 49 } | |
| 50 | |
| 51 std::unique_ptr<base::DictionaryValue> PaymentAddress::ToDictionaryValue() | |
| 52 const { | |
| 53 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | |
| 54 | |
| 55 if (!this->country.empty()) | |
| 56 result->SetString(kAddressCountry, this->country); | |
| 57 | |
| 58 if (!this->address_line.empty()) { | |
| 59 std::unique_ptr<base::ListValue> address_line(new base::ListValue); | |
|
please use gerrit instead
2017/03/08 14:46:09
base::MakeUnique<base::ListValue>();
Mathieu
2017/03/08 18:04:25
Done.
| |
| 60 for (base::string16 address_line_string : this->address_line) { | |
|
please use gerrit instead
2017/03/08 14:46:09
Use "const base::string16&" instead of "base::stri
Mathieu
2017/03/08 18:04:25
Done.
| |
| 61 if (!address_line_string.empty()) | |
| 62 address_line->AppendString(address_line_string); | |
| 63 } | |
| 64 result->Set(kAddressAddressLine, std::move(address_line)); | |
| 65 } | |
| 66 | |
| 67 if (!this->region.empty()) | |
| 68 result->SetString(kAddressRegion, this->region); | |
| 69 if (!this->city.empty()) | |
| 70 result->SetString(kAddressCity, this->city); | |
| 71 if (!this->dependent_locality.empty()) | |
| 72 result->SetString(kAddressDependentLocality, this->dependent_locality); | |
| 73 if (!this->postal_code.empty()) | |
| 74 result->SetString(kAddressPostalCode, this->postal_code); | |
| 75 if (!this->sorting_code.empty()) | |
| 76 result->SetString(kAddressSortingCode, this->sorting_code); | |
| 77 if (!this->language_code.empty()) | |
| 78 result->SetString(kAddressLanguageCode, this->language_code); | |
| 79 if (!this->organization.empty()) | |
| 80 result->SetString(kAddressOrganization, this->organization); | |
| 81 if (!this->recipient.empty()) | |
| 82 result->SetString(kAddressRecipient, this->recipient); | |
| 83 if (!this->phone.empty()) | |
| 84 result->SetString(kAddressPhone, this->phone); | |
| 85 | |
| 86 return result; | |
| 87 } | |
| 88 | |
| 89 } // namespace web | |
| OLD | NEW |