| 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" |
| 11 #include "components/autofill/core/browser/autofill_type.h" |
| 11 #include "components/autofill/core/browser/credit_card.h" | 12 #include "components/autofill/core/browser/credit_card.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 const size_t kPanSize = 16; | 16 const size_t kPanSize = 16; |
| 16 const size_t kBinSize = 6; | 17 const size_t kBinSize = 6; |
| 17 const size_t kCvnSize = 3; | 18 const size_t kCvnSize = 3; |
| 18 const size_t kEncryptedRestSize = 12; | 19 const size_t kEncryptedRestSize = 12; |
| 19 | 20 |
| 20 } // anonymous namespace | 21 } // anonymous namespace |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 129 base::string16 FullWallet::GetInfo(AutofillFieldType type) { | 130 base::string16 FullWallet::GetInfo(const AutofillType& type) { |
| 130 switch (type) { | 131 switch (type.server_type()) { |
| 131 case CREDIT_CARD_NUMBER: | 132 case CREDIT_CARD_NUMBER: |
| 132 return UTF8ToUTF16(GetPan()); | 133 return UTF8ToUTF16(GetPan()); |
| 133 | 134 |
| 134 case CREDIT_CARD_NAME: | 135 case CREDIT_CARD_NAME: |
| 135 return billing_address()->recipient_name(); | 136 return billing_address()->recipient_name(); |
| 136 | 137 |
| 137 case CREDIT_CARD_VERIFICATION_CODE: | 138 case CREDIT_CARD_VERIFICATION_CODE: |
| 138 return UTF8ToUTF16(GetCvn()); | 139 return UTF8ToUTF16(GetCvn()); |
| 139 | 140 |
| 140 case CREDIT_CARD_EXP_MONTH: | 141 case CREDIT_CARD_EXP_MONTH: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 182 |
| 182 bool FullWallet::HasRequiredAction(RequiredAction action) const { | 183 bool FullWallet::HasRequiredAction(RequiredAction action) const { |
| 183 DCHECK(ActionAppliesToFullWallet(action)); | 184 DCHECK(ActionAppliesToFullWallet(action)); |
| 184 return std::find(required_actions_.begin(), | 185 return std::find(required_actions_.begin(), |
| 185 required_actions_.end(), | 186 required_actions_.end(), |
| 186 action) != required_actions_.end(); | 187 action) != required_actions_.end(); |
| 187 } | 188 } |
| 188 | 189 |
| 189 base::string16 FullWallet::TypeAndLastFourDigits() { | 190 base::string16 FullWallet::TypeAndLastFourDigits() { |
| 190 CreditCard card; | 191 CreditCard card; |
| 191 card.SetRawInfo(CREDIT_CARD_NUMBER, GetInfo(CREDIT_CARD_NUMBER)); | 192 card.SetRawInfo(CREDIT_CARD_NUMBER, |
| 193 GetInfo(AutofillType(CREDIT_CARD_NUMBER))); |
| 192 return card.TypeAndLastFourDigits(); | 194 return card.TypeAndLastFourDigits(); |
| 193 } | 195 } |
| 194 | 196 |
| 195 bool FullWallet::operator==(const FullWallet& other) const { | 197 bool FullWallet::operator==(const FullWallet& other) const { |
| 196 if (expiration_month_ != other.expiration_month_) | 198 if (expiration_month_ != other.expiration_month_) |
| 197 return false; | 199 return false; |
| 198 | 200 |
| 199 if (expiration_year_ != other.expiration_year_) | 201 if (expiration_year_ != other.expiration_year_) |
| 200 return false; | 202 return false; |
| 201 | 203 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 287 } |
| 286 | 288 |
| 287 const std::string& FullWallet::GetCvn() { | 289 const std::string& FullWallet::GetCvn() { |
| 288 if (cvn_.empty()) | 290 if (cvn_.empty()) |
| 289 DecryptCardInfo(); | 291 DecryptCardInfo(); |
| 290 return cvn_; | 292 return cvn_; |
| 291 } | 293 } |
| 292 | 294 |
| 293 } // namespace wallet | 295 } // namespace wallet |
| 294 } // namespace autofill | 296 } // namespace autofill |
| OLD | NEW |