| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import "chrome/browser/autofill/autofill_credit_card_model_mac.h" | 5 #import "chrome/browser/autofill/autofill_credit_card_model_mac.h" |
| 6 #include "app/l10n_util.h" | 6 #include "app/l10n_util.h" |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/browser/autofill/credit_card.h" | 8 #include "chrome/browser/autofill/credit_card.h" |
| 9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
| 10 | 10 |
| 11 | 11 |
| 12 @implementation AutoFillCreditCardModel | 12 @implementation AutoFillCreditCardModel |
| 13 | 13 |
| 14 @synthesize label = label_; | 14 @synthesize label = label_; |
| 15 @synthesize nameOnCard = nameOnCard_; | 15 @synthesize nameOnCard = nameOnCard_; |
| 16 @synthesize creditCardNumber = creditCardNumber_; | 16 @synthesize creditCardNumber = creditCardNumber_; |
| 17 @synthesize expirationMonth = expirationMonth_; | 17 @synthesize expirationMonth = expirationMonth_; |
| 18 @synthesize expirationYear = expirationYear_; | 18 @synthesize expirationYear = expirationYear_; |
| 19 @synthesize cvcCode = cvcCode_; | |
| 20 @synthesize billingAddress = billingAddress_; | 19 @synthesize billingAddress = billingAddress_; |
| 21 | 20 |
| 22 - (id)initWithCreditCard:(const CreditCard&)creditCard { | 21 - (id)initWithCreditCard:(const CreditCard&)creditCard { |
| 23 if ((self = [super init])) { | 22 if ((self = [super init])) { |
| 24 [self setLabel:SysUTF16ToNSString(creditCard.Label())]; | 23 [self setLabel:SysUTF16ToNSString(creditCard.Label())]; |
| 25 [self setNameOnCard:SysUTF16ToNSString( | 24 [self setNameOnCard:SysUTF16ToNSString( |
| 26 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_NAME)))]; | 25 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_NAME)))]; |
| 27 [self setCreditCardNumber:SysUTF16ToNSString( | 26 [self setCreditCardNumber:SysUTF16ToNSString( |
| 28 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_NUMBER)))]; | 27 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_NUMBER)))]; |
| 29 [self setExpirationMonth:SysUTF16ToNSString( | 28 [self setExpirationMonth:SysUTF16ToNSString( |
| 30 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_EXP_MONTH)))]; | 29 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_EXP_MONTH)))]; |
| 31 [self setExpirationYear:SysUTF16ToNSString( | 30 [self setExpirationYear:SysUTF16ToNSString( |
| 32 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)))]; | 31 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)))]; |
| 33 [self setCvcCode:SysUTF16ToNSString( | |
| 34 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_VERIFICATION_CODE)))]; | |
| 35 [self setBillingAddress:SysUTF16ToNSString( | 32 [self setBillingAddress:SysUTF16ToNSString( |
| 36 creditCard.billing_address())]; | 33 creditCard.billing_address())]; |
| 37 } | 34 } |
| 38 return self; | 35 return self; |
| 39 } | 36 } |
| 40 | 37 |
| 41 - (void)dealloc { | 38 - (void)dealloc { |
| 42 [label_ release]; | 39 [label_ release]; |
| 43 [nameOnCard_ release]; | 40 [nameOnCard_ release]; |
| 44 [creditCardNumber_ release]; | 41 [creditCardNumber_ release]; |
| 45 [expirationMonth_ release]; | 42 [expirationMonth_ release]; |
| 46 [expirationYear_ release]; | 43 [expirationYear_ release]; |
| 47 [cvcCode_ release]; | |
| 48 [billingAddress_ release]; | 44 [billingAddress_ release]; |
| 49 [super dealloc]; | 45 [super dealloc]; |
| 50 } | 46 } |
| 51 | 47 |
| 52 - (void)copyModelToCreditCard:(CreditCard*)creditCard { | 48 - (void)copyModelToCreditCard:(CreditCard*)creditCard { |
| 53 DCHECK(creditCard); | 49 DCHECK(creditCard); |
| 54 creditCard->set_label(base::SysNSStringToUTF16([self label])); | 50 creditCard->set_label(base::SysNSStringToUTF16([self label])); |
| 55 creditCard->SetInfo(AutoFillType(CREDIT_CARD_NAME), | 51 creditCard->SetInfo(AutoFillType(CREDIT_CARD_NAME), |
| 56 base::SysNSStringToUTF16([self nameOnCard])); | 52 base::SysNSStringToUTF16([self nameOnCard])); |
| 57 creditCard->SetInfo(AutoFillType(CREDIT_CARD_NUMBER), | 53 creditCard->SetInfo(AutoFillType(CREDIT_CARD_NUMBER), |
| 58 base::SysNSStringToUTF16([self creditCardNumber])); | 54 base::SysNSStringToUTF16([self creditCardNumber])); |
| 59 creditCard->SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), | 55 creditCard->SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), |
| 60 base::SysNSStringToUTF16([self expirationMonth])); | 56 base::SysNSStringToUTF16([self expirationMonth])); |
| 61 creditCard->SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), | 57 creditCard->SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), |
| 62 base::SysNSStringToUTF16([self expirationYear])); | 58 base::SysNSStringToUTF16([self expirationYear])); |
| 63 creditCard->SetInfo(AutoFillType(CREDIT_CARD_VERIFICATION_CODE), | |
| 64 base::SysNSStringToUTF16([self cvcCode])); | |
| 65 creditCard->set_billing_address( | 59 creditCard->set_billing_address( |
| 66 base::SysNSStringToUTF16([self billingAddress])); | 60 base::SysNSStringToUTF16([self billingAddress])); |
| 67 } | 61 } |
| 68 | 62 |
| 69 @end | 63 @end |
| OLD | NEW |