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_DIALOG_CONTROLLER_MAC_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_MAC_ |
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_MAC_ | 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_MAC_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #include <vector> | 9 #include <vector> |
10 #include "base/scoped_nsobject.h" | 10 #include "base/scoped_nsobject.h" |
11 #include "base/scoped_ptr.h" | |
12 #include "chrome/browser/autofill/autofill_dialog.h" | 11 #include "chrome/browser/autofill/autofill_dialog.h" |
13 #include "chrome/browser/autofill/autofill_profile.h" | 12 #include "chrome/browser/autofill/autofill_profile.h" |
14 #include "chrome/browser/autofill/credit_card.h" | 13 #include "chrome/browser/autofill/credit_card.h" |
15 | 14 |
16 namespace AutoFillDialogControllerInternal { | |
17 class PersonalDataManagerObserver; | |
18 } // AutoFillDialogControllerInternal | |
19 | |
20 @class AutoFillAddressViewController; | 15 @class AutoFillAddressViewController; |
21 @class AutoFillCreditCardViewController; | 16 @class AutoFillCreditCardViewController; |
22 class Profile; | 17 class Profile; |
23 @class SectionSeparatorView; | 18 @class SectionSeparatorView; |
24 @class WindowSizeAutosaver; | 19 @class WindowSizeAutosaver; |
25 | 20 |
26 // A window controller for managing the autofill options dialog. | 21 // A window controller for managing the autofill options dialog. |
27 // Application modally presents a dialog allowing the user to store | 22 // Application modally presents a dialog allowing the user to store |
28 // personal address and credit card information. | 23 // personal address and credit card information. |
29 @interface AutoFillDialogController : NSWindowController { | 24 @interface AutoFillDialogController : NSWindowController { |
(...skipping 10 matching lines...) Expand all Loading... |
40 // Array of |AutoFillAddressViewController|. | 35 // Array of |AutoFillAddressViewController|. |
41 scoped_nsobject<NSMutableArray> addressFormViewControllers_; | 36 scoped_nsobject<NSMutableArray> addressFormViewControllers_; |
42 | 37 |
43 // Array of |AutoFillCreditCardViewController|. | 38 // Array of |AutoFillCreditCardViewController|. |
44 scoped_nsobject<NSMutableArray> creditCardFormViewControllers_; | 39 scoped_nsobject<NSMutableArray> creditCardFormViewControllers_; |
45 | 40 |
46 scoped_nsobject<NSString> defaultAddressLabel_; | 41 scoped_nsobject<NSString> defaultAddressLabel_; |
47 scoped_nsobject<NSString> defaultCreditCardLabel_; | 42 scoped_nsobject<NSString> defaultCreditCardLabel_; |
48 | 43 |
49 AutoFillDialogObserver* observer_; // Weak, not retained. | 44 AutoFillDialogObserver* observer_; // Weak, not retained. |
50 Profile* profile_; // Weak, not retained. | |
51 AutoFillProfile* importedProfile_; // Weak, not retained. | |
52 CreditCard* importedCreditCard_; // Weak, not retained. | |
53 std::vector<AutoFillProfile> profiles_; | 45 std::vector<AutoFillProfile> profiles_; |
54 std::vector<CreditCard> creditCards_; | 46 std::vector<CreditCard> creditCards_; |
| 47 Profile* profile_; // Weak, not retained. |
55 BOOL auxiliaryEnabled_; | 48 BOOL auxiliaryEnabled_; |
56 scoped_nsobject<WindowSizeAutosaver> sizeSaver_; | 49 scoped_nsobject<WindowSizeAutosaver> sizeSaver_; |
57 | |
58 // Manages PersonalDataManager loading. | |
59 scoped_ptr<AutoFillDialogControllerInternal::PersonalDataManagerObserver> | |
60 personalDataManagerObserver_; | |
61 } | 50 } |
62 | 51 |
63 // Property representing state of Address Book "me" card usage. Checkbox is | 52 // Property representing state of Address Book "me" card usage. Checkbox is |
64 // bound to this in nib. | 53 // bound to this in nib. |
65 @property (nonatomic) BOOL auxiliaryEnabled; | 54 @property (nonatomic) BOOL auxiliaryEnabled; |
66 | 55 |
67 // Property representing the default profile and credit card. | 56 // Property representing the default profile and credit card. |
68 @property (nonatomic, copy) NSString* defaultAddressLabel; | 57 @property (nonatomic, copy) NSString* defaultAddressLabel; |
69 @property (nonatomic, copy) NSString* defaultCreditCardLabel; | 58 @property (nonatomic, copy) NSString* defaultCreditCardLabel; |
70 | 59 |
71 // Main interface for displaying an application modal autofill dialog on screen. | 60 // Main interface for displaying an application modal autofill dialog on screen. |
72 // This class method creates a new |AutoFillDialogController| and runs it as a | 61 // This class method creates a new |AutoFillDialogController| and runs it as a |
73 // modal dialog. The controller autoreleases itself when the dialog is closed. | 62 // modal dialog. The controller autoreleases itself when the dialog is closed. |
74 // |observer| can be NULL, but if it is, then no notification is sent during | 63 // |observer| can be NULL, but if it is, then no notification is sent during |
75 // call to |save|. If |observer| is non-NULL then its |OnAutoFillDialogApply| | 64 // call to |save|. If |observer| is non-NULL then its |OnAutoFillDialogApply| |
76 // method is invoked during |save| with the new address and credit card | 65 // method is invoked during |save| with the new address and credit card |
77 // information. | 66 // information. |
| 67 // |profiles| and |creditCards| must have non-NULL entries (zero or more). |
| 68 // These provide the initial data that is presented to the user. |
78 // |profile| must be non-NULL. | 69 // |profile| must be non-NULL. |
79 // AutoFill profile and credit card data is initialized from the | |
80 // |PersonalDataManager| that is associated with the input |profile|. | |
81 // If |importedProfile| or |importedCreditCard| parameters are supplied then | |
82 // the |PersonalDataManager| data is ignored. Both may be NULL. | |
83 + (void)showAutoFillDialogWithObserver:(AutoFillDialogObserver*)observer | 70 + (void)showAutoFillDialogWithObserver:(AutoFillDialogObserver*)observer |
84 profile:(Profile*)profile | 71 autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles |
85 importedProfile:(AutoFillProfile*)importedProfile | 72 creditCards:(const std::vector<CreditCard*>&)creditCards |
86 importedCreditCard:(CreditCard*)importedCreditCard; | 73 profile:(Profile*)profile; |
87 | 74 |
88 // IBActions for the dialog buttons. | 75 // IBActions for the dialog buttons. |
89 - (IBAction)save:(id)sender; | 76 - (IBAction)save:(id)sender; |
90 - (IBAction)cancel:(id)sender; | 77 - (IBAction)cancel:(id)sender; |
91 | 78 |
92 // IBActions for adding new items. | 79 // IBActions for adding new items. |
93 - (IBAction)addNewAddress:(id)sender; | 80 - (IBAction)addNewAddress:(id)sender; |
94 - (IBAction)addNewCreditCard:(id)sender; | 81 - (IBAction)addNewCreditCard:(id)sender; |
95 | 82 |
96 // IBActions for deleting items. |sender| is expected to be either a | 83 // IBActions for deleting items. |sender| is expected to be either a |
(...skipping 14 matching lines...) Expand all Loading... |
111 | 98 |
112 @end | 99 @end |
113 | 100 |
114 // Interface exposed for unit testing. | 101 // Interface exposed for unit testing. |
115 @interface AutoFillDialogController (ExposedForUnitTests) | 102 @interface AutoFillDialogController (ExposedForUnitTests) |
116 // Returns an instance of AutoFillDialogController. See |-initWithObserver| | 103 // Returns an instance of AutoFillDialogController. See |-initWithObserver| |
117 // for details about arguments. | 104 // for details about arguments. |
118 // Note: controller is autoreleased when |-closeDialog| is called. | 105 // Note: controller is autoreleased when |-closeDialog| is called. |
119 + (AutoFillDialogController*)controllerWithObserver: | 106 + (AutoFillDialogController*)controllerWithObserver: |
120 (AutoFillDialogObserver*)observer | 107 (AutoFillDialogObserver*)observer |
121 profile:(Profile*)profile | 108 autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles |
122 importedProfile:(AutoFillProfile*)importedProfile | 109 creditCards:(const std::vector<CreditCard*>&)creditCards |
123 importedCreditCard:(CreditCard*)importedCreditCard; | 110 profile:(Profile*)profile; |
124 | 111 |
125 - (id)initWithObserver:(AutoFillDialogObserver*)observer | 112 - (id)initWithObserver:(AutoFillDialogObserver*)observer |
126 profile:(Profile*)profile | 113 autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles |
127 importedProfile:(AutoFillProfile*)importedProfile | 114 creditCards:(const std::vector<CreditCard*>&)creditCards |
128 importedCreditCard:(CreditCard*)importedCreditCard; | 115 profile:(Profile*)profile; |
129 - (NSMutableArray*)addressFormViewControllers; | 116 - (NSMutableArray*)addressFormViewControllers; |
130 - (NSMutableArray*)creditCardFormViewControllers; | 117 - (NSMutableArray*)creditCardFormViewControllers; |
131 - (void)closeDialog; | 118 - (void)closeDialog; |
132 @end | 119 @end |
133 | 120 |
134 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_MAC_ | 121 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_MAC_ |
OLD | NEW |