| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 shipping_address.Pass(), | 150 shipping_address.Pass(), |
| 151 std::vector<RequiredAction>())); // no required actions in clear text. | 151 std::vector<RequiredAction>())); // no required actions in clear text. |
| 152 wallet->pan_ = pan; | 152 wallet->pan_ = pan; |
| 153 wallet->cvn_ = cvn; | 153 wallet->cvn_ = cvn; |
| 154 return wallet.Pass(); | 154 return wallet.Pass(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 base::string16 FullWallet::GetInfo(const AutofillType& type) { | 157 base::string16 FullWallet::GetInfo(const AutofillType& type) { |
| 158 switch (type.GetStorableType()) { | 158 switch (type.GetStorableType()) { |
| 159 case CREDIT_CARD_NUMBER: | 159 case CREDIT_CARD_NUMBER: |
| 160 return UTF8ToUTF16(GetPan()); | 160 return base::UTF8ToUTF16(GetPan()); |
| 161 | 161 |
| 162 case CREDIT_CARD_NAME: | 162 case CREDIT_CARD_NAME: |
| 163 return billing_address()->recipient_name(); | 163 return billing_address()->recipient_name(); |
| 164 | 164 |
| 165 case CREDIT_CARD_VERIFICATION_CODE: | 165 case CREDIT_CARD_VERIFICATION_CODE: |
| 166 return UTF8ToUTF16(GetCvn()); | 166 return base::UTF8ToUTF16(GetCvn()); |
| 167 | 167 |
| 168 case CREDIT_CARD_EXP_MONTH: | 168 case CREDIT_CARD_EXP_MONTH: |
| 169 if (expiration_month() == 0) | 169 if (expiration_month() == 0) |
| 170 return base::string16(); | 170 return base::string16(); |
| 171 return base::IntToString16(expiration_month()); | 171 return base::IntToString16(expiration_month()); |
| 172 | 172 |
| 173 case CREDIT_CARD_EXP_4_DIGIT_YEAR: | 173 case CREDIT_CARD_EXP_4_DIGIT_YEAR: |
| 174 if (expiration_year() == 0) | 174 if (expiration_year() == 0) |
| 175 return base::string16(); | 175 return base::string16(); |
| 176 return base::IntToString16(expiration_year()); | 176 return base::IntToString16(expiration_year()); |
| 177 | 177 |
| 178 case CREDIT_CARD_EXP_2_DIGIT_YEAR: | 178 case CREDIT_CARD_EXP_2_DIGIT_YEAR: |
| 179 if (expiration_year() == 0) | 179 if (expiration_year() == 0) |
| 180 return base::string16(); | 180 return base::string16(); |
| 181 return base::IntToString16(expiration_year() % 100); | 181 return base::IntToString16(expiration_year() % 100); |
| 182 | 182 |
| 183 case CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR: | 183 case CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR: |
| 184 if (expiration_month() == 0 || expiration_year() == 0) | 184 if (expiration_month() == 0 || expiration_year() == 0) |
| 185 return base::string16(); | 185 return base::string16(); |
| 186 return base::IntToString16(expiration_month()) + ASCIIToUTF16("/") + | 186 return base::IntToString16(expiration_month()) + base::ASCIIToUTF16("/") + |
| 187 base::IntToString16(expiration_year() % 100); | 187 base::IntToString16(expiration_year() % 100); |
| 188 | 188 |
| 189 case CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR: | 189 case CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR: |
| 190 if (expiration_month() == 0 || expiration_year() == 0) | 190 if (expiration_month() == 0 || expiration_year() == 0) |
| 191 return base::string16(); | 191 return base::string16(); |
| 192 return base::IntToString16(expiration_month()) + ASCIIToUTF16("/") + | 192 return base::IntToString16(expiration_month()) + base::ASCIIToUTF16("/") + |
| 193 base::IntToString16(expiration_year()); | 193 base::IntToString16(expiration_year()); |
| 194 | 194 |
| 195 case CREDIT_CARD_TYPE: { | 195 case CREDIT_CARD_TYPE: { |
| 196 std::string internal_type = | 196 std::string internal_type = |
| 197 CreditCard::GetCreditCardType(UTF8ToUTF16(GetPan())); | 197 CreditCard::GetCreditCardType(base::UTF8ToUTF16(GetPan())); |
| 198 if (internal_type == kGenericCard) | 198 if (internal_type == kGenericCard) |
| 199 return base::string16(); | 199 return base::string16(); |
| 200 return CreditCard::TypeForDisplay(internal_type); | 200 return CreditCard::TypeForDisplay(internal_type); |
| 201 } | 201 } |
| 202 | 202 |
| 203 default: | 203 default: |
| 204 NOTREACHED(); | 204 NOTREACHED(); |
| 205 } | 205 } |
| 206 | 206 |
| 207 return base::string16(); | 207 return base::string16(); |
| (...skipping 106 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 |