OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/autofill/wallet/wallet_address.h" | 5 #include "chrome/browser/autofill/wallet/wallet_address.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/utf_string_conversions.h" | |
8 #include "base/values.h" | 9 #include "base/values.h" |
9 | 10 |
10 namespace wallet { | 11 namespace wallet { |
11 | 12 |
12 Address::Address() {} | 13 Address::Address() {} |
13 | 14 |
14 Address::Address(const std::string& country_name_code, | 15 Address::Address(const std::string& country_name_code, |
15 const std::string& recipient_name, | 16 const std::string& recipient_name, |
16 const std::string& address_line_1, | 17 const std::string& address_line_1, |
17 const std::string& address_line_2, | 18 const std::string& address_line_2, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 dict->SetString("country_name_code", country_name_code_); | 56 dict->SetString("country_name_code", country_name_code_); |
56 dict->SetString("recipient_name", recipient_name_); | 57 dict->SetString("recipient_name", recipient_name_); |
57 dict->SetString("locality_name", locality_name_); | 58 dict->SetString("locality_name", locality_name_); |
58 dict->SetString("administrative_area_name", | 59 dict->SetString("administrative_area_name", |
59 administrative_area_name_); | 60 administrative_area_name_); |
60 dict->SetString("postal_code_number", postal_code_number_); | 61 dict->SetString("postal_code_number", postal_code_number_); |
61 | 62 |
62 return dict.Pass(); | 63 return dict.Pass(); |
63 } | 64 } |
64 | 65 |
66 string16 Address::DisplayName() const { | |
67 // TODO(estade): improve this stub implementation. | |
68 return UTF8ToUTF16(recipient_name() + ", " + address_line_1()); | |
69 } | |
70 | |
71 string16 Address::GetInfo(AutofillFieldType type) const { | |
Ilya Sherman
2013/02/12 22:50:34
Optional nit: Mebbe add a DCHECK that the type is
Evan Stade
2013/02/13 00:11:58
Done.
| |
72 switch (type) { | |
73 case NAME_FULL: | |
74 return UTF8ToUTF16(recipient_name()); | |
75 | |
76 case ADDRESS_HOME_LINE1: | |
77 return UTF8ToUTF16(address_line_1()); | |
78 | |
79 case ADDRESS_HOME_LINE2: | |
80 return UTF8ToUTF16(address_line_2()); | |
81 | |
82 case ADDRESS_HOME_CITY: | |
83 return UTF8ToUTF16(locality_name()); | |
84 | |
85 case ADDRESS_HOME_STATE: | |
86 return UTF8ToUTF16(admin_area_name()); | |
87 | |
88 case ADDRESS_HOME_ZIP: | |
89 return UTF8ToUTF16(postal_code_number()); | |
90 | |
91 // TODO(estade): implement more. | |
92 default: | |
93 return string16(); | |
94 } | |
95 } | |
65 | 96 |
66 scoped_ptr<Address> | 97 scoped_ptr<Address> |
67 Address::CreateAddressWithID(const base::DictionaryValue& dictionary) { | 98 Address::CreateAddressWithID(const base::DictionaryValue& dictionary) { |
68 std::string object_id; | 99 std::string object_id; |
69 if (!dictionary.GetString("id", &object_id)) { | 100 if (!dictionary.GetString("id", &object_id)) { |
70 DLOG(ERROR) << "Response from Google Wallet missing object id"; | 101 DLOG(ERROR) << "Response from Google Wallet missing object id"; |
71 return scoped_ptr<Address>(); | 102 return scoped_ptr<Address>(); |
72 } | 103 } |
73 | 104 |
74 std::string country_name_code; | 105 std::string country_name_code; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 phone_number_ == other.phone_number_ && | 225 phone_number_ == other.phone_number_ && |
195 object_id_ == other.object_id_; | 226 object_id_ == other.object_id_; |
196 } | 227 } |
197 | 228 |
198 bool Address::operator!=(const Address& other) const { | 229 bool Address::operator!=(const Address& other) const { |
199 return !(*this == other); | 230 return !(*this == other); |
200 } | 231 } |
201 | 232 |
202 } // namespace wallet | 233 } // namespace wallet |
203 | 234 |
OLD | NEW |