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

Side by Side Diff: chrome/browser/autofill/autofill_credit_card_model_mac.mm

Issue 558066: Autofill dialog for the Mac. This is UI only at this point. The UI is not h... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "chrome/browser/autofill/autofill_credit_card_model_mac.h"
6 #include "app/l10n_util.h"
7 #include "base/sys_string_conversions.h"
8 #include "chrome/browser/autofill/credit_card.h"
9 #include "grit/generated_resources.h"
10
11
12 @implementation AutoFillCreditCardModel
13
14 @dynamic summary;
15 @synthesize label = label_;
16 @synthesize nameOnCard = nameOnCard_;
17 @synthesize creditCardNumber = creditCardNumber_;
18 @synthesize expirationMonth = expirationMonth_;
19 @synthesize expirationYear = expirationYear_;
20 @synthesize cvcCode = cvcCode_;
21 @synthesize billingAddress = billingAddress_;
22 @synthesize shippingAddress = shippingAddress_;
23
24 // Sets up the KVO dependency between "summary" and dependent fields.
25 + (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key {
26 NSSet* keyPaths = [super keyPathsForValuesAffectingValueForKey:key];
27
28 if ([key isEqualToString:@"summary"]) {
29 NSSet* affectingKeys = [NSSet setWithObjects:@"creditCardNumber",
30 @"expirationMonth", @"expirationYear", nil];
31 keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKeys];
32 }
33 return keyPaths;
34 }
35
36 - (id)initWithCreditCard:(const CreditCard&)creditCard {
37 if ((self = [super init])) {
38 [self setLabel:SysUTF16ToNSString(creditCard.Label())];
39 [self setNameOnCard:SysUTF16ToNSString(
40 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_NAME)))];
41 [self setCreditCardNumber:SysUTF16ToNSString(
42 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_NUMBER)))];
43 [self setExpirationMonth:SysUTF16ToNSString(
44 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_EXP_MONTH)))];
45 [self setExpirationYear:SysUTF16ToNSString(
46 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)))];
47 [self setCvcCode:SysUTF16ToNSString(
48 creditCard.GetFieldText(AutoFillType(CREDIT_CARD_VERIFICATION_CODE)))] ;
49 }
50 return self;
51 }
52
53 - (void)dealloc {
54 [label_ release];
55 [nameOnCard_ release];
56 [creditCardNumber_ release];
57 [expirationMonth_ release];
58 [expirationYear_ release];
59 [cvcCode_ release];
60 [billingAddress_ release];
61 [shippingAddress_ release];
62 [super dealloc];
63 }
64
65 - (NSString*)summary {
66 // TODO(dhollowa): This has been pulled into cross platform code.
67 // Will hook up in separate CL. See http://crbug.com/33029.
68 return @"";
69 }
70
71 - (void)copyModelToCreditCard:(CreditCard*)creditCard {
72 DCHECK(creditCard);
73 creditCard->set_label(base::SysNSStringToUTF16([self label]));
74 creditCard->SetInfo(AutoFillType(CREDIT_CARD_NAME),
75 base::SysNSStringToUTF16([self nameOnCard]));
76 creditCard->SetInfo(AutoFillType(CREDIT_CARD_NUMBER),
77 base::SysNSStringToUTF16([self creditCardNumber]));
78 creditCard->SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH),
79 base::SysNSStringToUTF16([self expirationMonth]));
80 creditCard->SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR),
81 base::SysNSStringToUTF16([self expirationYear]));
82 creditCard->SetInfo(AutoFillType(CREDIT_CARD_VERIFICATION_CODE),
83 base::SysNSStringToUTF16([self cvcCode]));
84 }
85
86 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698