summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/autofill_address_model_mac.h
blob: 9ea052f6d009487268ed51a0ddd43f08bd326c8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// 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.

#ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_ADDRESS_MODEL_MAC_
#define CHROME_BROWSER_AUTOFILL_AUTOFILL_ADDRESS_MODEL_MAC_

#import <Cocoa/Cocoa.h>

class AutoFillProfile;

// A "model" class used with bindings mechanism and the
// |AutoFillAddressViewController| to achieve the form-like view
// of autofill data in the Chrome options UI.
// Note that |summary| is a derived property.
// Model objects are initialized from a given profile using the designated
// initializer |initWithProfile:|.
// Users of this class must be prepared to handle nil string return values.
// The KVO/bindings mechanisms expect this and deal with nil string values
// appropriately.
@interface AutoFillAddressModel : NSObject {
 @private
  // These are not scoped_nsobjects because we use them via KVO/bindings.
  NSString* label_;
  NSString* firstName_;
  NSString* middleName_;
  NSString* lastName_;
  NSString* email_;
  NSString* companyName_;
  NSString* addressLine1_;
  NSString* addressLine2_;
  NSString* addressCity_;
  NSString* addressState_;
  NSString* addressZip_;
  NSString* addressCountry_;
  NSString* phoneWholeNumber_;
  NSString* faxWholeNumber_;
}

// |summary| is a derived property based on |firstName|, |lastName| and
// |addressLine1|.  KVO observers receive change notifications for |summary|
// when any of these properties change.
@property (readonly) NSString* summary;
@property (nonatomic, copy) NSString* label;
@property (nonatomic, copy) NSString* firstName;
@property (nonatomic, copy) NSString* middleName;
@property (nonatomic, copy) NSString* lastName;
@property (nonatomic, copy) NSString* email;
@property (nonatomic, copy) NSString* companyName;
@property (nonatomic, copy) NSString* addressLine1;
@property (nonatomic, copy) NSString* addressLine2;
@property (nonatomic, copy) NSString* addressCity;
@property (nonatomic, copy) NSString* addressState;
@property (nonatomic, copy) NSString* addressZip;
@property (nonatomic, copy) NSString* addressCountry;
@property (nonatomic, copy) NSString* phoneWholeNumber;
@property (nonatomic, copy) NSString* faxWholeNumber;

// The designated initializer. Initializes the property strings to values
// retrieved from the |profile|.
- (id)initWithProfile:(const AutoFillProfile&)profile;

// This method copies internal NSString property values into the
// |profile| object's fields as appropriate.  |profile| should never be NULL.
- (void)copyModelToProfile:(AutoFillProfile*)profile;

@end

#endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_ADDRESS_MODEL_MAC_