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

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: 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 24 matching lines...) Expand all
35 iin_(iin), 35 iin_(iin),
36 encrypted_rest_(encrypted_rest), 36 encrypted_rest_(encrypted_rest),
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 scoped_ptr<FullWallet> 46 scoped_ptr<FullWallet>
46 FullWallet::CreateFullWallet(const DictionaryValue& dictionary) { 47 FullWallet::CreateFullWallet(const DictionaryValue& dictionary) {
47 const ListValue* required_actions_list; 48 const ListValue* required_actions_list;
48 std::vector<RequiredAction> required_actions; 49 std::vector<RequiredAction> required_actions;
49 if (dictionary.GetList("required_action", &required_actions_list)) { 50 if (dictionary.GetList("required_action", &required_actions_list)) {
50 for (size_t i = 0; i < required_actions_list->GetSize(); ++i) { 51 for (size_t i = 0; i < required_actions_list->GetSize(); ++i) {
51 std::string action_string; 52 std::string action_string;
52 if (required_actions_list->GetString(i, &action_string)) { 53 if (required_actions_list->GetString(i, &action_string)) {
53 RequiredAction action = ParseRequiredActionFromString(action_string); 54 RequiredAction action = ParseRequiredActionFromString(action_string);
54 if (!ActionAppliesToFullWallet(action)) { 55 if (!ActionAppliesToFullWallet(action)) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 121
121 return scoped_ptr<FullWallet>(new FullWallet(expiration_month, 122 return scoped_ptr<FullWallet>(new FullWallet(expiration_month,
122 expiration_year, 123 expiration_year,
123 iin, 124 iin,
124 encrypted_rest, 125 encrypted_rest,
125 billing_address.Pass(), 126 billing_address.Pass(),
126 shipping_address.Pass(), 127 shipping_address.Pass(),
127 required_actions)); 128 required_actions));
128 } 129 }
129 130
131 // static
132 scoped_ptr<FullWallet>
133 FullWallet::CreateFullWalletFromClearText(
134 int expiration_month,
135 int expiration_year,
136 const std::string& pan,
137 const std::string& cvn,
138 scoped_ptr<Address> billing_address,
139 scoped_ptr<Address> shipping_address) {
140 DCHECK(billing_address);
141 DCHECK(!pan.empty());
142 DCHECK(!cvn.empty());
143
144 scoped_ptr<FullWallet> wallet(new FullWallet(
145 expiration_month,
146 expiration_year,
147 std::string(), // no iin -- clear text pan/cvn are set below.
148 std::string(), // no encrypted_rest -- clear text pan/cvn are set below.
149 billing_address.Pass(),
150 shipping_address.Pass(),
151 std::vector<RequiredAction>())); // no required actions in clear text.
152 wallet->pan_ = pan;
153 wallet->cvn_ = cvn;
154 return wallet.Pass();
155 }
156
130 base::string16 FullWallet::GetInfo(const AutofillType& type) { 157 base::string16 FullWallet::GetInfo(const AutofillType& type) {
131 switch (type.GetStorableType()) { 158 switch (type.GetStorableType()) {
132 case CREDIT_CARD_NUMBER: 159 case CREDIT_CARD_NUMBER:
133 return UTF8ToUTF16(GetPan()); 160 return UTF8ToUTF16(GetPan());
134 161
135 case CREDIT_CARD_NAME: 162 case CREDIT_CARD_NAME:
136 return billing_address()->recipient_name(); 163 return billing_address()->recipient_name();
137 164
138 case CREDIT_CARD_VERIFICATION_CODE: 165 case CREDIT_CARD_VERIFICATION_CODE:
139 return UTF8ToUTF16(GetCvn()); 166 return UTF8ToUTF16(GetCvn());
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 314 }
288 315
289 const std::string& FullWallet::GetCvn() { 316 const std::string& FullWallet::GetCvn() {
290 if (cvn_.empty()) 317 if (cvn_.empty())
291 DecryptCardInfo(); 318 DecryptCardInfo();
292 return cvn_; 319 return cvn_;
293 } 320 }
294 321
295 } // namespace wallet 322 } // namespace wallet
296 } // namespace autofill 323 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698