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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autofill/autofill_credit_card_model_mac.mm
===================================================================
--- chrome/browser/autofill/autofill_credit_card_model_mac.mm (revision 0)
+++ chrome/browser/autofill/autofill_credit_card_model_mac.mm (revision 0)
@@ -0,0 +1,86 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/autofill/autofill_credit_card_model_mac.h"
+#include "app/l10n_util.h"
+#include "base/sys_string_conversions.h"
+#include "chrome/browser/autofill/credit_card.h"
+#include "grit/generated_resources.h"
+
+
+@implementation AutoFillCreditCardModel
+
+@dynamic summary;
+@synthesize label = label_;
+@synthesize nameOnCard = nameOnCard_;
+@synthesize creditCardNumber = creditCardNumber_;
+@synthesize expirationMonth = expirationMonth_;
+@synthesize expirationYear = expirationYear_;
+@synthesize cvcCode = cvcCode_;
+@synthesize billingAddress = billingAddress_;
+@synthesize shippingAddress = shippingAddress_;
+
+// Sets up the KVO dependency between "summary" and dependent fields.
++ (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key {
+ NSSet* keyPaths = [super keyPathsForValuesAffectingValueForKey:key];
+
+ if ([key isEqualToString:@"summary"]) {
+ NSSet* affectingKeys = [NSSet setWithObjects:@"creditCardNumber",
+ @"expirationMonth", @"expirationYear", nil];
+ keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKeys];
+ }
+ return keyPaths;
+}
+
+- (id)initWithCreditCard:(const CreditCard&)creditCard {
+ if ((self = [super init])) {
+ [self setLabel:SysUTF16ToNSString(creditCard.Label())];
+ [self setNameOnCard:SysUTF16ToNSString(
+ creditCard.GetFieldText(AutoFillType(CREDIT_CARD_NAME)))];
+ [self setCreditCardNumber:SysUTF16ToNSString(
+ creditCard.GetFieldText(AutoFillType(CREDIT_CARD_NUMBER)))];
+ [self setExpirationMonth:SysUTF16ToNSString(
+ creditCard.GetFieldText(AutoFillType(CREDIT_CARD_EXP_MONTH)))];
+ [self setExpirationYear:SysUTF16ToNSString(
+ creditCard.GetFieldText(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)))];
+ [self setCvcCode:SysUTF16ToNSString(
+ creditCard.GetFieldText(AutoFillType(CREDIT_CARD_VERIFICATION_CODE)))];
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [label_ release];
+ [nameOnCard_ release];
+ [creditCardNumber_ release];
+ [expirationMonth_ release];
+ [expirationYear_ release];
+ [cvcCode_ release];
+ [billingAddress_ release];
+ [shippingAddress_ release];
+ [super dealloc];
+}
+
+- (NSString*)summary {
+ // TODO(dhollowa): This has been pulled into cross platform code.
+ // Will hook up in separate CL. See http://crbug.com/33029.
+ return @"";
+}
+
+- (void)copyModelToCreditCard:(CreditCard*)creditCard {
+ DCHECK(creditCard);
+ creditCard->set_label(base::SysNSStringToUTF16([self label]));
+ creditCard->SetInfo(AutoFillType(CREDIT_CARD_NAME),
+ base::SysNSStringToUTF16([self nameOnCard]));
+ creditCard->SetInfo(AutoFillType(CREDIT_CARD_NUMBER),
+ base::SysNSStringToUTF16([self creditCardNumber]));
+ creditCard->SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH),
+ base::SysNSStringToUTF16([self expirationMonth]));
+ creditCard->SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR),
+ base::SysNSStringToUTF16([self expirationYear]));
+ creditCard->SetInfo(AutoFillType(CREDIT_CARD_VERIFICATION_CODE),
+ base::SysNSStringToUTF16([self cvcCode]));
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698