Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1125)

Side by Side Diff: components/autofill/content/browser/wallet/full_wallet.cc

Issue 21928004: Add a FullWallet constructor for data obtained from SDK. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 23 matching lines...) Expand all
34 iin_(iin), 34 iin_(iin),
35 encrypted_rest_(encrypted_rest), 35 encrypted_rest_(encrypted_rest),
36 billing_address_(billing_address.Pass()), 36 billing_address_(billing_address.Pass()),
37 shipping_address_(shipping_address.Pass()), 37 shipping_address_(shipping_address.Pass()),
38 required_actions_(required_actions) { 38 required_actions_(required_actions) {
39 DCHECK(required_actions_.size() > 0 || billing_address_.get()); 39 DCHECK(required_actions_.size() > 0 || billing_address_.get());
40 } 40 }
41 41
42 FullWallet::~FullWallet() {} 42 FullWallet::~FullWallet() {}
43 43
44 // static
44 scoped_ptr<FullWallet> 45 scoped_ptr<FullWallet>
45 FullWallet::CreateFullWallet(const DictionaryValue& dictionary) { 46 FullWallet::CreateFullWallet(const DictionaryValue& dictionary) {
46 const ListValue* required_actions_list; 47 const ListValue* required_actions_list;
47 std::vector<RequiredAction> required_actions; 48 std::vector<RequiredAction> required_actions;
48 if (dictionary.GetList("required_action", &required_actions_list)) { 49 if (dictionary.GetList("required_action", &required_actions_list)) {
49 for (size_t i = 0; i < required_actions_list->GetSize(); ++i) { 50 for (size_t i = 0; i < required_actions_list->GetSize(); ++i) {
50 std::string action_string; 51 std::string action_string;
51 if (required_actions_list->GetString(i, &action_string)) { 52 if (required_actions_list->GetString(i, &action_string)) {
52 RequiredAction action = ParseRequiredActionFromString(action_string); 53 RequiredAction action = ParseRequiredActionFromString(action_string);
53 if (!ActionAppliesToFullWallet(action)) { 54 if (!ActionAppliesToFullWallet(action)) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 120
120 return scoped_ptr<FullWallet>(new FullWallet(expiration_month, 121 return scoped_ptr<FullWallet>(new FullWallet(expiration_month,
121 expiration_year, 122 expiration_year,
122 iin, 123 iin,
123 encrypted_rest, 124 encrypted_rest,
124 billing_address.Pass(), 125 billing_address.Pass(),
125 shipping_address.Pass(), 126 shipping_address.Pass(),
126 required_actions)); 127 required_actions));
127 } 128 }
128 129
130 // static
131 scoped_ptr<FullWallet>
132 FullWallet::CreateFullWalletFromClearText(
133 int expiration_month,
134 int expiration_year,
135 const std::string& pan,
136 const std::string& cvn,
137 scoped_ptr<Address> billing_address,
138 scoped_ptr<Address> shipping_address) {
139 DCHECK(billing_address);
140 DCHECK(!pan.empty());
141 DCHECK(!cvn.empty());
142
143 scoped_ptr<FullWallet> wallet(
144 new FullWallet(
145 expiration_month,
146 expiration_year,
147 std::string(),
148 std::string(),
149 billing_address.Pass(),
150 shipping_address.Pass(),
151 std::vector<RequiredAction>()));
Dan Beam 2013/08/06 03:38:17 nit: this seems to fit in 80 cols like this: sc
Dan Beam 2013/08/06 03:38:17 are you sure this can never has required actions?
aruslan 2013/08/07 18:21:16 Done.
aruslan 2013/08/07 18:21:16 Yes -- this is a final (non-negotiable) response;
152 wallet->pan_ = pan;
153 wallet->cvn_ = cvn;
Dan Beam 2013/08/06 03:38:17 this is kind of nasty...
aruslan 2013/08/07 18:21:16 Another option was to add a new constructor, and i
154 return wallet.Pass();
155 }
156
129 base::string16 FullWallet::GetInfo(AutofillFieldType type) { 157 base::string16 FullWallet::GetInfo(AutofillFieldType type) {
130 switch (type) { 158 switch (type) {
131 case CREDIT_CARD_NUMBER: 159 case CREDIT_CARD_NUMBER:
132 return UTF8ToUTF16(GetPan()); 160 return UTF8ToUTF16(GetPan());
133 161
134 case CREDIT_CARD_NAME: 162 case CREDIT_CARD_NAME:
135 return billing_address()->recipient_name(); 163 return billing_address()->recipient_name();
136 164
137 case CREDIT_CARD_VERIFICATION_CODE: 165 case CREDIT_CARD_VERIFICATION_CODE:
138 return UTF8ToUTF16(GetCvn()); 166 return UTF8ToUTF16(GetCvn());
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 313 }
286 314
287 const std::string& FullWallet::GetCvn() { 315 const std::string& FullWallet::GetCvn() {
288 if (cvn_.empty()) 316 if (cvn_.empty())
289 DecryptCardInfo(); 317 DecryptCardInfo();
290 return cvn_; 318 return cvn_;
291 } 319 }
292 320
293 } // namespace wallet 321 } // namespace wallet
294 } // namespace autofill 322 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698