| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/sys_string_conversions.h" | |
| 6 #import "chrome/browser/autofill/autofill_credit_card_model_mac.h" | |
| 7 #include "chrome/browser/autofill/credit_card.h" | |
| 8 #include "grit/generated_resources.h" | |
| 9 #include "ui/base/l10n/l10n_util.h" | |
| 10 | |
| 11 | |
| 12 @implementation AutoFillCreditCardModel | |
| 13 | |
| 14 @synthesize nameOnCard = nameOnCard_; | |
| 15 @synthesize creditCardNumber = creditCardNumber_; | |
| 16 @synthesize expirationMonth = expirationMonth_; | |
| 17 @synthesize expirationYear = expirationYear_; | |
| 18 | |
| 19 - (id)initWithCreditCard:(const CreditCard&)creditCard { | |
| 20 if ((self = [super init])) { | |
| 21 [self setNameOnCard:SysUTF16ToNSString( | |
| 22 creditCard.GetFieldText(AutofillType(CREDIT_CARD_NAME)))]; | |
| 23 [self setCreditCardNumber:SysUTF16ToNSString( | |
| 24 creditCard.GetFieldText(AutofillType(CREDIT_CARD_NUMBER)))]; | |
| 25 [self setExpirationMonth:SysUTF16ToNSString( | |
| 26 creditCard.GetFieldText(AutofillType(CREDIT_CARD_EXP_MONTH)))]; | |
| 27 [self setExpirationYear:SysUTF16ToNSString( | |
| 28 creditCard.GetFieldText(AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)))]; | |
| 29 } | |
| 30 return self; | |
| 31 } | |
| 32 | |
| 33 - (void)dealloc { | |
| 34 [nameOnCard_ release]; | |
| 35 [creditCardNumber_ release]; | |
| 36 [expirationMonth_ release]; | |
| 37 [expirationYear_ release]; | |
| 38 [super dealloc]; | |
| 39 } | |
| 40 | |
| 41 - (void)copyModelToCreditCard:(CreditCard*)creditCard { | |
| 42 DCHECK(creditCard); | |
| 43 creditCard->SetInfo(AutofillType(CREDIT_CARD_NAME), | |
| 44 base::SysNSStringToUTF16([self nameOnCard])); | |
| 45 creditCard->SetInfo(AutofillType(CREDIT_CARD_NUMBER), | |
| 46 base::SysNSStringToUTF16([self creditCardNumber])); | |
| 47 creditCard->SetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), | |
| 48 base::SysNSStringToUTF16([self expirationMonth])); | |
| 49 creditCard->SetInfo(AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), | |
| 50 base::SysNSStringToUTF16([self expirationYear])); | |
| 51 } | |
| 52 | |
| 53 @end | |
| OLD | NEW |