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 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_MODEL_MAC_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_MODEL_MAC_ |
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_MODEL_MAC_ | 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_MODEL_MAC_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 class CreditCard; | 10 class CreditCard; |
11 | 11 |
12 // A "model" class used with bindings mechanism and the | 12 // A "model" class used with bindings mechanism and the |
13 // |AutoFillCreditCardViewController| to achieve the form-like view | 13 // |AutoFillCreditCardViewController| to achieve the form-like view |
14 // of autofill data in the Chrome options UI. | 14 // of autofill data in the Chrome options UI. |
15 // Note that |summary| is a derived property. | |
16 // Model objects are initialized from the given |creditCard| using the | 15 // Model objects are initialized from the given |creditCard| using the |
17 // designated initializer |initWithCreditCard:|. | 16 // designated initializer |initWithCreditCard:|. |
18 // Users of this class must be prepared to handle nil string return values. | 17 // Users of this class must be prepared to handle nil string return values. |
19 // The KVO/bindings mechanisms expect this and deal with nil string values | 18 // The KVO/bindings mechanisms expect this and deal with nil string values |
20 // appropriately. | 19 // appropriately. |
21 @interface AutoFillCreditCardModel : NSObject { | 20 @interface AutoFillCreditCardModel : NSObject { |
22 @private | 21 @private |
23 // These are not scoped_nsobjects because we use them via KVO/bindings. | 22 // These are not scoped_nsobjects because we use them via KVO/bindings. |
24 NSString* label_; | 23 NSString* label_; |
25 NSString* nameOnCard_; | 24 NSString* nameOnCard_; |
26 NSString* creditCardNumber_; | 25 NSString* creditCardNumber_; |
27 NSString* expirationMonth_; | 26 NSString* expirationMonth_; |
28 NSString* expirationYear_; | 27 NSString* expirationYear_; |
29 NSString* cvcCode_; | 28 NSString* cvcCode_; |
30 NSString* billingAddress_; | 29 NSString* billingAddress_; |
31 NSString* shippingAddress_; | 30 NSString* shippingAddress_; |
32 } | 31 } |
33 | 32 |
34 // |summary| is a derived property based on |creditCardNumber|, | |
35 // |expirationMonth| and |expirationYear|. KVO observers receive change | |
36 // notifications for |summary| when any of these properties change. | |
37 @property (readonly) NSString* summary; | |
38 @property (nonatomic, copy) NSString* label; | 33 @property (nonatomic, copy) NSString* label; |
39 @property (nonatomic, copy) NSString* nameOnCard; | 34 @property (nonatomic, copy) NSString* nameOnCard; |
40 @property (nonatomic, copy) NSString* creditCardNumber; | 35 @property (nonatomic, copy) NSString* creditCardNumber; |
41 @property (nonatomic, copy) NSString* expirationMonth; | 36 @property (nonatomic, copy) NSString* expirationMonth; |
42 @property (nonatomic, copy) NSString* expirationYear; | 37 @property (nonatomic, copy) NSString* expirationYear; |
43 @property (nonatomic, copy) NSString* cvcCode; | 38 @property (nonatomic, copy) NSString* cvcCode; |
44 @property (nonatomic, copy) NSString* billingAddress; | 39 @property (nonatomic, copy) NSString* billingAddress; |
45 @property (nonatomic, copy) NSString* shippingAddress; | |
46 | 40 |
47 // Designated initializer. Initializes the property strings to values retrieved | 41 // Designated initializer. Initializes the property strings to values retrieved |
48 // from the |creditCard| object. | 42 // from the |creditCard| object. |
49 - (id)initWithCreditCard:(const CreditCard&)creditCard; | 43 - (id)initWithCreditCard:(const CreditCard&)creditCard; |
50 | 44 |
51 // This method copies internal NSString property values into the | 45 // This method copies internal NSString property values into the |
52 // |creditCard| object's fields as appropriate. |creditCard| should never | 46 // |creditCard| object's fields as appropriate. |creditCard| should never |
53 // be NULL. | 47 // be NULL. |
54 - (void)copyModelToCreditCard:(CreditCard*)creditCard; | 48 - (void)copyModelToCreditCard:(CreditCard*)creditCard; |
55 | 49 |
56 @end | 50 @end |
57 | 51 |
58 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_MODEL_MAC_ | 52 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_MODEL_MAC_ |
OLD | NEW |