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

Side by Side Diff: chrome/browser/autofill/wallet/full_wallet.cc

Issue 11777007: Adds wallet::RequiredAction for when we start interacting with Online Wallet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: class -> namespace Created 7 years, 11 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 (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/full_wallet.h" 5 #include "chrome/browser/autofill/wallet/full_wallet.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/autofill/wallet/required_action.h"
10 11
11 namespace { 12 namespace {
12 13
13 const size_t kPanSize = 16; 14 const size_t kPanSize = 16;
14 const size_t kBinSize = 6; 15 const size_t kBinSize = 6;
15 const size_t kCvnSize = 3; 16 const size_t kCvnSize = 3;
16 17
17 } // anonymous namespace 18 } // anonymous namespace
18 19
19 namespace wallet { 20 namespace wallet {
20 21
21 FullWallet::FullWallet(int expiration_month, 22 FullWallet::FullWallet(int expiration_month,
22 int expiration_year, 23 int expiration_year,
23 const std::string& iin, 24 const std::string& iin,
24 const std::string& encrypted_rest, 25 const std::string& encrypted_rest,
25 scoped_ptr<Address> billing_address, 26 scoped_ptr<Address> billing_address,
26 scoped_ptr<Address> shipping_address, 27 scoped_ptr<Address> shipping_address,
27 const std::vector<std::string>& required_actions) 28 const std::vector<RequiredAction>& required_actions)
28 : expiration_month_(expiration_month), 29 : expiration_month_(expiration_month),
29 expiration_year_(expiration_year), 30 expiration_year_(expiration_year),
30 iin_(iin), 31 iin_(iin),
31 encrypted_rest_(encrypted_rest), 32 encrypted_rest_(encrypted_rest),
32 billing_address_(billing_address.Pass()), 33 billing_address_(billing_address.Pass()),
33 shipping_address_(shipping_address.Pass()), 34 shipping_address_(shipping_address.Pass()),
34 required_actions_(required_actions) { 35 required_actions_(required_actions) {
35 DCHECK(required_actions_.size() > 0 || billing_address_.get()); 36 DCHECK(required_actions_.size() > 0 || billing_address_.get());
36 } 37 }
37 38
38 FullWallet::~FullWallet() {} 39 FullWallet::~FullWallet() {}
39 40
40 scoped_ptr<FullWallet> 41 scoped_ptr<FullWallet>
41 FullWallet::CreateFullWallet(const DictionaryValue& dictionary) { 42 FullWallet::CreateFullWallet(const DictionaryValue& dictionary) {
42 const ListValue* required_actions_list; 43 const ListValue* required_actions_list;
43 std::vector<std::string> required_actions; 44 std::vector<RequiredAction> required_actions;
44 if (dictionary.GetList("required_action", &required_actions_list)) { 45 if (dictionary.GetList("required_action", &required_actions_list)) {
45 for (size_t i = 0; i < required_actions_list->GetSize(); ++i) { 46 for (size_t i = 0; i < required_actions_list->GetSize(); ++i) {
46 std::string action; 47 std::string action_string;
47 if (required_actions_list->GetString(i, &action)) 48 if (required_actions_list->GetString(i, &action_string)) {
48 required_actions.push_back(action); 49 RequiredAction action = ParseFromString(action_string);
50 if (AppliesToFullWallet(action))
51 required_actions.push_back(action);
52 }
49 } 53 }
50 if (required_actions.size() > 0) 54 if (required_actions.size() > 0) {
51 return scoped_ptr<FullWallet>(new FullWallet(-1, 55 return scoped_ptr<FullWallet>(new FullWallet(-1,
52 -1, 56 -1,
53 "", 57 "",
54 "", 58 "",
55 scoped_ptr<Address>(), 59 scoped_ptr<Address>(),
56 scoped_ptr<Address>(), 60 scoped_ptr<Address>(),
57 required_actions)); 61 required_actions));
62 }
58 } else { 63 } else {
59 DVLOG(1) << "Response from Google wallet missing required actions"; 64 DVLOG(1) << "Response from Google wallet missing required actions";
60 } 65 }
61 66
62 int expiration_month; 67 int expiration_month;
63 if (!dictionary.GetInteger("expiration_month", &expiration_month)) { 68 if (!dictionary.GetInteger("expiration_month", &expiration_month)) {
64 DLOG(ERROR) << "Response from Google wallet missing expiration month"; 69 DLOG(ERROR) << "Response from Google wallet missing expiration month";
65 return scoped_ptr<FullWallet>(); 70 return scoped_ptr<FullWallet>();
66 } 71 }
67 72
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 card_info.insert(card_info.begin(), padded_length - card_info.size(), '0'); 204 card_info.insert(card_info.begin(), padded_length - card_info.size(), '0');
200 205
201 // Separate out the PAN from the CVN. 206 // Separate out the PAN from the CVN.
202 size_t split = kPanSize - kBinSize; 207 size_t split = kPanSize - kBinSize;
203 cvn_ = card_info.substr(split); 208 cvn_ = card_info.substr(split);
204 pan_ = iin_ + card_info.substr(0, split); 209 pan_ = iin_ + card_info.substr(0, split);
205 } 210 }
206 211
207 } // namespace wallet 212 } // namespace wallet
208 213
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698