OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/content/browser/wallet/wallet_items.h" | 5 #include "components/autofill/content/browser/wallet/wallet_items.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 WalletItems::MaskedInstrument::~MaskedInstrument() {} | 121 WalletItems::MaskedInstrument::~MaskedInstrument() {} |
122 | 122 |
123 scoped_ptr<WalletItems::MaskedInstrument> | 123 scoped_ptr<WalletItems::MaskedInstrument> |
124 WalletItems::MaskedInstrument::CreateMaskedInstrument( | 124 WalletItems::MaskedInstrument::CreateMaskedInstrument( |
125 const base::DictionaryValue& dictionary) { | 125 const base::DictionaryValue& dictionary) { |
126 std::string type_string; | 126 std::string type_string; |
127 Type type; | 127 Type type; |
128 if (dictionary.GetString("type", &type_string)) { | 128 if (dictionary.GetString("type", &type_string)) { |
129 type = TypeFromString(type_string); | 129 type = TypeFromString(type_string); |
130 } else { | 130 } else { |
131 DLOG(ERROR) << "Response from Google Wallet missing card type"; | 131 DLOG(ERROR) << "Response from Google Payments missing card type"; |
Evan Stade
2015/05/29 19:34:26
it is arguable whether these are user-facing but I
please use gerrit instead
2015/05/29 19:37:52
Acknowledged.
| |
132 return scoped_ptr<MaskedInstrument>(); | 132 return scoped_ptr<MaskedInstrument>(); |
133 } | 133 } |
134 | 134 |
135 base::string16 last_four_digits; | 135 base::string16 last_four_digits; |
136 if (!dictionary.GetString("last_four_digits", &last_four_digits)) { | 136 if (!dictionary.GetString("last_four_digits", &last_four_digits)) { |
137 DLOG(ERROR) << "Response from Google Wallet missing last four digits"; | 137 DLOG(ERROR) << "Response from Google Payments missing last four digits"; |
138 return scoped_ptr<MaskedInstrument>(); | 138 return scoped_ptr<MaskedInstrument>(); |
139 } | 139 } |
140 | 140 |
141 std::string status_string; | 141 std::string status_string; |
142 Status status; | 142 Status status; |
143 if (dictionary.GetString("status", &status_string)) { | 143 if (dictionary.GetString("status", &status_string)) { |
144 status = StatusFromString(status_string); | 144 status = StatusFromString(status_string); |
145 } else { | 145 } else { |
146 DLOG(ERROR) << "Response from Google Wallet missing status"; | 146 DLOG(ERROR) << "Response from Google Payments missing status"; |
147 return scoped_ptr<MaskedInstrument>(); | 147 return scoped_ptr<MaskedInstrument>(); |
148 } | 148 } |
149 | 149 |
150 std::string object_id; | 150 std::string object_id; |
151 if (!dictionary.GetString("object_id", &object_id)) { | 151 if (!dictionary.GetString("object_id", &object_id)) { |
152 DLOG(ERROR) << "Response from Google Wallet missing object id"; | 152 DLOG(ERROR) << "Response from Google Payments missing object id"; |
153 return scoped_ptr<MaskedInstrument>(); | 153 return scoped_ptr<MaskedInstrument>(); |
154 } | 154 } |
155 | 155 |
156 const base::DictionaryValue* address_dict; | 156 const base::DictionaryValue* address_dict; |
157 if (!dictionary.GetDictionary("billing_address", &address_dict)) { | 157 if (!dictionary.GetDictionary("billing_address", &address_dict)) { |
158 DLOG(ERROR) << "Response from Google wallet missing address"; | 158 DLOG(ERROR) << "Response from Google wallet missing address"; |
159 return scoped_ptr<MaskedInstrument>(); | 159 return scoped_ptr<MaskedInstrument>(); |
160 } | 160 } |
161 scoped_ptr<Address> address = Address::CreateDisplayAddress(*address_dict); | 161 scoped_ptr<Address> address = Address::CreateDisplayAddress(*address_dict); |
162 | 162 |
163 if (!address) { | 163 if (!address) { |
164 DLOG(ERROR) << "Response from Google wallet contained malformed address"; | 164 DLOG(ERROR) << "Response from Google wallet contained malformed address"; |
165 return scoped_ptr<MaskedInstrument>(); | 165 return scoped_ptr<MaskedInstrument>(); |
166 } | 166 } |
167 | 167 |
168 int expiration_month; | 168 int expiration_month; |
169 if (!dictionary.GetInteger("expiration_month", &expiration_month)) | 169 if (!dictionary.GetInteger("expiration_month", &expiration_month)) |
170 DVLOG(1) << "Response from Google Wallet missing expiration month"; | 170 DVLOG(1) << "Response from Google Payments missing expiration month"; |
171 | 171 |
172 int expiration_year; | 172 int expiration_year; |
173 if (!dictionary.GetInteger("expiration_year", &expiration_year)) | 173 if (!dictionary.GetInteger("expiration_year", &expiration_year)) |
174 DVLOG(1) << "Response from Google Wallet missing expiration year"; | 174 DVLOG(1) << "Response from Google Payments missing expiration year"; |
175 | 175 |
176 base::string16 descriptive_name; | 176 base::string16 descriptive_name; |
177 if (!dictionary.GetString("descriptive_name", &descriptive_name)) | 177 if (!dictionary.GetString("descriptive_name", &descriptive_name)) |
178 DVLOG(1) << "Response from Google Wallet missing descriptive name"; | 178 DVLOG(1) << "Response from Google Payments missing descriptive name"; |
179 | 179 |
180 return scoped_ptr<MaskedInstrument>(new MaskedInstrument(descriptive_name, | 180 return scoped_ptr<MaskedInstrument>(new MaskedInstrument(descriptive_name, |
181 type, | 181 type, |
182 last_four_digits, | 182 last_four_digits, |
183 expiration_month, | 183 expiration_month, |
184 expiration_year, | 184 expiration_year, |
185 address.Pass(), | 185 address.Pass(), |
186 status, | 186 status, |
187 object_id)); | 187 object_id)); |
188 } | 188 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 return base::string16(); | 355 return base::string16(); |
356 } | 356 } |
357 | 357 |
358 WalletItems::LegalDocument::~LegalDocument() {} | 358 WalletItems::LegalDocument::~LegalDocument() {} |
359 | 359 |
360 scoped_ptr<WalletItems::LegalDocument> | 360 scoped_ptr<WalletItems::LegalDocument> |
361 WalletItems::LegalDocument::CreateLegalDocument( | 361 WalletItems::LegalDocument::CreateLegalDocument( |
362 const base::DictionaryValue& dictionary) { | 362 const base::DictionaryValue& dictionary) { |
363 std::string id; | 363 std::string id; |
364 if (!dictionary.GetString("legal_document_id", &id)) { | 364 if (!dictionary.GetString("legal_document_id", &id)) { |
365 DLOG(ERROR) << "Response from Google Wallet missing legal document id"; | 365 DLOG(ERROR) << "Response from Google Payments missing legal document id"; |
366 return scoped_ptr<LegalDocument>(); | 366 return scoped_ptr<LegalDocument>(); |
367 } | 367 } |
368 | 368 |
369 base::string16 display_name; | 369 base::string16 display_name; |
370 if (!dictionary.GetString("display_name", &display_name)) { | 370 if (!dictionary.GetString("display_name", &display_name)) { |
371 DLOG(ERROR) << "Response from Google Wallet missing display name"; | 371 DLOG(ERROR) << "Response from Google Payments missing display name"; |
372 return scoped_ptr<LegalDocument>(); | 372 return scoped_ptr<LegalDocument>(); |
373 } | 373 } |
374 | 374 |
375 std::string url; | 375 std::string url; |
376 if (!dictionary.GetString("url", &url)) { | 376 if (!dictionary.GetString("url", &url)) { |
377 DLOG(ERROR) << "Response from Google Wallet missing URL"; | 377 DLOG(ERROR) << "Response from Google Payments missing URL"; |
378 return scoped_ptr<LegalDocument>(); | 378 return scoped_ptr<LegalDocument>(); |
379 } | 379 } |
380 | 380 |
381 return scoped_ptr<LegalDocument>( | 381 return scoped_ptr<LegalDocument>( |
382 new LegalDocument(id, GURL(url), display_name)); | 382 new LegalDocument(id, GURL(url), display_name)); |
383 } | 383 } |
384 | 384 |
385 scoped_ptr<WalletItems::LegalDocument> | 385 scoped_ptr<WalletItems::LegalDocument> |
386 WalletItems::LegalDocument::CreatePrivacyPolicyDocument() { | 386 WalletItems::LegalDocument::CreatePrivacyPolicyDocument() { |
387 return scoped_ptr<LegalDocument>(new LegalDocument( | 387 return scoped_ptr<LegalDocument>(new LegalDocument( |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 other.legal_documents()) && | 587 other.legal_documents()) && |
588 allowed_shipping_countries() == other.allowed_shipping_countries(); | 588 allowed_shipping_countries() == other.allowed_shipping_countries(); |
589 } | 589 } |
590 | 590 |
591 bool WalletItems::operator!=(const WalletItems& other) const { | 591 bool WalletItems::operator!=(const WalletItems& other) const { |
592 return !(*this == other); | 592 return !(*this == other); |
593 } | 593 } |
594 | 594 |
595 } // namespace wallet | 595 } // namespace wallet |
596 } // namespace autofill | 596 } // namespace autofill |
OLD | NEW |