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_ADDRESS_MODEL_MAC_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_ADDRESS_MODEL_MAC_ |
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_ADDRESS_MODEL_MAC_ | 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_ADDRESS_MODEL_MAC_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 class AutoFillProfile; | 10 class AutoFillProfile; |
11 | 11 |
12 // A "model" class used with bindings mechanism and the | 12 // A "model" class used with bindings mechanism and the |
13 // |AutoFillAddressViewController| to achieve the form-like view | 13 // |AutoFillAddressViewController| 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 a given profile using the designated | 15 // Model objects are initialized from a given profile using the designated |
17 // initializer |initWithProfile:|. | 16 // initializer |initWithProfile:|. |
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 AutoFillAddressModel : NSObject { | 20 @interface AutoFillAddressModel : 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* firstName_; | 24 NSString* fullName_; |
26 NSString* middleName_; | |
27 NSString* lastName_; | |
28 NSString* email_; | 25 NSString* email_; |
29 NSString* companyName_; | 26 NSString* companyName_; |
30 NSString* addressLine1_; | 27 NSString* addressLine1_; |
31 NSString* addressLine2_; | 28 NSString* addressLine2_; |
32 NSString* addressCity_; | 29 NSString* addressCity_; |
33 NSString* addressState_; | 30 NSString* addressState_; |
34 NSString* addressZip_; | 31 NSString* addressZip_; |
35 NSString* addressCountry_; | 32 NSString* addressCountry_; |
36 NSString* phoneWholeNumber_; | 33 NSString* phoneWholeNumber_; |
37 NSString* faxWholeNumber_; | 34 NSString* faxWholeNumber_; |
38 } | 35 } |
39 | 36 |
40 // |summary| is a derived property based on |firstName|, |lastName| and | |
41 // |addressLine1|. KVO observers receive change notifications for |summary| | |
42 // when any of these properties change. | |
43 @property (readonly) NSString* summary; | |
44 @property (nonatomic, copy) NSString* label; | 37 @property (nonatomic, copy) NSString* label; |
45 @property (nonatomic, copy) NSString* firstName; | 38 @property (nonatomic, copy) NSString* fullName; |
46 @property (nonatomic, copy) NSString* middleName; | |
47 @property (nonatomic, copy) NSString* lastName; | |
48 @property (nonatomic, copy) NSString* email; | 39 @property (nonatomic, copy) NSString* email; |
49 @property (nonatomic, copy) NSString* companyName; | 40 @property (nonatomic, copy) NSString* companyName; |
50 @property (nonatomic, copy) NSString* addressLine1; | 41 @property (nonatomic, copy) NSString* addressLine1; |
51 @property (nonatomic, copy) NSString* addressLine2; | 42 @property (nonatomic, copy) NSString* addressLine2; |
52 @property (nonatomic, copy) NSString* addressCity; | 43 @property (nonatomic, copy) NSString* addressCity; |
53 @property (nonatomic, copy) NSString* addressState; | 44 @property (nonatomic, copy) NSString* addressState; |
54 @property (nonatomic, copy) NSString* addressZip; | 45 @property (nonatomic, copy) NSString* addressZip; |
55 @property (nonatomic, copy) NSString* addressCountry; | 46 @property (nonatomic, copy) NSString* addressCountry; |
56 @property (nonatomic, copy) NSString* phoneWholeNumber; | 47 @property (nonatomic, copy) NSString* phoneWholeNumber; |
57 @property (nonatomic, copy) NSString* faxWholeNumber; | 48 @property (nonatomic, copy) NSString* faxWholeNumber; |
58 | 49 |
59 // The designated initializer. Initializes the property strings to values | 50 // The designated initializer. Initializes the property strings to values |
60 // retrieved from the |profile|. | 51 // retrieved from the |profile|. |
61 - (id)initWithProfile:(const AutoFillProfile&)profile; | 52 - (id)initWithProfile:(const AutoFillProfile&)profile; |
62 | 53 |
63 // This method copies internal NSString property values into the | 54 // This method copies internal NSString property values into the |
64 // |profile| object's fields as appropriate. |profile| should never be NULL. | 55 // |profile| object's fields as appropriate. |profile| should never be NULL. |
65 - (void)copyModelToProfile:(AutoFillProfile*)profile; | 56 - (void)copyModelToProfile:(AutoFillProfile*)profile; |
66 | 57 |
67 @end | 58 @end |
68 | 59 |
69 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_ADDRESS_MODEL_MAC_ | 60 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_ADDRESS_MODEL_MAC_ |
OLD | NEW |