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/full_wallet.h" | 5 #include "components/autofill/content/browser/wallet/full_wallet.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 billing_address_(billing_address.Pass()), | 37 billing_address_(billing_address.Pass()), |
38 shipping_address_(shipping_address.Pass()), | 38 shipping_address_(shipping_address.Pass()), |
39 required_actions_(required_actions) { | 39 required_actions_(required_actions) { |
40 DCHECK(required_actions_.size() > 0 || billing_address_.get()); | 40 DCHECK(required_actions_.size() > 0 || billing_address_.get()); |
41 } | 41 } |
42 | 42 |
43 FullWallet::~FullWallet() {} | 43 FullWallet::~FullWallet() {} |
44 | 44 |
45 // static | 45 // static |
46 scoped_ptr<FullWallet> | 46 scoped_ptr<FullWallet> |
47 FullWallet::CreateFullWallet(const DictionaryValue& dictionary) { | 47 FullWallet::CreateFullWallet(const base::DictionaryValue& dictionary) { |
48 const ListValue* required_actions_list; | 48 const base::ListValue* required_actions_list; |
49 std::vector<RequiredAction> required_actions; | 49 std::vector<RequiredAction> required_actions; |
50 if (dictionary.GetList("required_action", &required_actions_list)) { | 50 if (dictionary.GetList("required_action", &required_actions_list)) { |
51 for (size_t i = 0; i < required_actions_list->GetSize(); ++i) { | 51 for (size_t i = 0; i < required_actions_list->GetSize(); ++i) { |
52 std::string action_string; | 52 std::string action_string; |
53 if (required_actions_list->GetString(i, &action_string)) { | 53 if (required_actions_list->GetString(i, &action_string)) { |
54 RequiredAction action = ParseRequiredActionFromString(action_string); | 54 RequiredAction action = ParseRequiredActionFromString(action_string); |
55 if (!ActionAppliesToFullWallet(action)) { | 55 if (!ActionAppliesToFullWallet(action)) { |
56 DLOG(ERROR) << "Response from Google wallet with bad required action:" | 56 DLOG(ERROR) << "Response from Google wallet with bad required action:" |
57 " \"" << action_string << "\""; | 57 " \"" << action_string << "\""; |
58 return scoped_ptr<FullWallet>(); | 58 return scoped_ptr<FullWallet>(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 DLOG(ERROR) << "Response from Google wallet missing iin"; | 90 DLOG(ERROR) << "Response from Google wallet missing iin"; |
91 return scoped_ptr<FullWallet>(); | 91 return scoped_ptr<FullWallet>(); |
92 } | 92 } |
93 | 93 |
94 std::string encrypted_rest; | 94 std::string encrypted_rest; |
95 if (!dictionary.GetString("rest", &encrypted_rest)) { | 95 if (!dictionary.GetString("rest", &encrypted_rest)) { |
96 DLOG(ERROR) << "Response from Google wallet missing rest"; | 96 DLOG(ERROR) << "Response from Google wallet missing rest"; |
97 return scoped_ptr<FullWallet>(); | 97 return scoped_ptr<FullWallet>(); |
98 } | 98 } |
99 | 99 |
100 const DictionaryValue* billing_address_dict; | 100 const base::DictionaryValue* billing_address_dict; |
101 if (!dictionary.GetDictionary("billing_address", &billing_address_dict)) { | 101 if (!dictionary.GetDictionary("billing_address", &billing_address_dict)) { |
102 DLOG(ERROR) << "Response from Google wallet missing billing address"; | 102 DLOG(ERROR) << "Response from Google wallet missing billing address"; |
103 return scoped_ptr<FullWallet>(); | 103 return scoped_ptr<FullWallet>(); |
104 } | 104 } |
105 | 105 |
106 scoped_ptr<Address> billing_address = | 106 scoped_ptr<Address> billing_address = |
107 Address::CreateAddress(*billing_address_dict); | 107 Address::CreateAddress(*billing_address_dict); |
108 if (!billing_address.get()) { | 108 if (!billing_address.get()) { |
109 DLOG(ERROR) << "Response from Google wallet has malformed billing address"; | 109 DLOG(ERROR) << "Response from Google wallet has malformed billing address"; |
110 return scoped_ptr<FullWallet>(); | 110 return scoped_ptr<FullWallet>(); |
111 } | 111 } |
112 | 112 |
113 const DictionaryValue* shipping_address_dict; | 113 const base::DictionaryValue* shipping_address_dict; |
114 scoped_ptr<Address> shipping_address; | 114 scoped_ptr<Address> shipping_address; |
115 if (dictionary.GetDictionary("shipping_address", &shipping_address_dict)) { | 115 if (dictionary.GetDictionary("shipping_address", &shipping_address_dict)) { |
116 shipping_address = | 116 shipping_address = |
117 Address::CreateAddressWithID(*shipping_address_dict); | 117 Address::CreateAddressWithID(*shipping_address_dict); |
118 } else { | 118 } else { |
119 DVLOG(1) << "Response from Google wallet missing shipping address"; | 119 DVLOG(1) << "Response from Google wallet missing shipping address"; |
120 } | 120 } |
121 | 121 |
122 return scoped_ptr<FullWallet>(new FullWallet(expiration_month, | 122 return scoped_ptr<FullWallet>(new FullWallet(expiration_month, |
123 expiration_year, | 123 expiration_year, |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 314 } |
315 | 315 |
316 const std::string& FullWallet::GetCvn() { | 316 const std::string& FullWallet::GetCvn() { |
317 if (cvn_.empty()) | 317 if (cvn_.empty()) |
318 DecryptCardInfo(); | 318 DecryptCardInfo(); |
319 return cvn_; | 319 return cvn_; |
320 } | 320 } |
321 | 321 |
322 } // namespace wallet | 322 } // namespace wallet |
323 } // namespace autofill | 323 } // namespace autofill |
OLD | NEW |