OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_MAC_ | |
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_MAC_ | |
7 #pragma once | |
8 | |
9 #import <Cocoa/Cocoa.h> | |
10 #include <vector> | |
11 | |
12 #import "base/mac/cocoa_protocols.h" | |
13 #include "base/scoped_nsobject.h" | |
14 #include "base/scoped_ptr.h" | |
15 #include "chrome/browser/autofill/autofill_dialog.h" | |
16 #include "chrome/browser/autofill/autofill_profile.h" | |
17 #include "chrome/browser/autofill/credit_card.h" | |
18 #include "chrome/browser/prefs/pref_member.h" | |
19 | |
20 namespace AutoFillDialogControllerInternal { | |
21 class PersonalDataManagerObserver; | |
22 class PreferenceObserver; | |
23 } // AutoFillDialogControllerInternal | |
24 | |
25 @class AutoFillAddressSheetController; | |
26 @class AutoFillCreditCardSheetController; | |
27 @class AutoFillTableView; | |
28 class Profile; | |
29 @class WindowSizeAutosaver; | |
30 | |
31 // A window controller for managing the AutoFill options dialog. | |
32 // Modelessly presents a dialog allowing the user to store | |
33 // personal address and credit card information. | |
34 @interface AutoFillDialogController : NSWindowController <NSTableViewDelegate> { | |
35 @private | |
36 // Outlet to the main NSTableView object listing both addresses and credit | |
37 // cards with section headers for both. | |
38 IBOutlet AutoFillTableView* tableView_; | |
39 | |
40 // Outlet to "Edit..." button. Here for unit testing purposes. | |
41 IBOutlet NSButton* editButton_; | |
42 | |
43 // This observer is passed in by the caller of the dialog. When the dialog | |
44 // is dismissed |observer_| is called with new values for the addresses and | |
45 // credit cards. | |
46 // Weak, not retained. | |
47 AutoFillDialogObserver* observer_; | |
48 | |
49 // Reference to input parameter. | |
50 // Weak, not retained. | |
51 Profile* profile_; | |
52 | |
53 // Working list of input profiles. | |
54 std::vector<AutoFillProfile> profiles_; | |
55 | |
56 // Working list of input credit cards. | |
57 std::vector<CreditCard> creditCards_; | |
58 | |
59 // State of checkbox for enabling AutoFill in general. | |
60 BooleanPrefMember autoFillEnabled_; | |
61 | |
62 // Whether AutoFill is controlled by configuration management. | |
63 BOOL autoFillManaged_; | |
64 | |
65 // Whether AutoFill is managed and disabled. | |
66 BOOL autoFillManagedAndDisabled_; | |
67 | |
68 // State of checkbox for enabling Mac Address Book integration. | |
69 BooleanPrefMember auxiliaryEnabled_; | |
70 | |
71 // State for |itemIsSelected| property used in bindings for "Edit..." and | |
72 // "Remove" buttons. | |
73 BOOL itemIsSelected_; | |
74 | |
75 // State for |multipleSelected| property used in bindings for "Edit..." | |
76 // button. | |
77 BOOL multipleSelected_; | |
78 | |
79 // Utility object to save and restore dialog position. | |
80 scoped_nsobject<WindowSizeAutosaver> sizeSaver_; | |
81 | |
82 // Transient reference to address "Add" / "Edit" sheet for address | |
83 // information. | |
84 scoped_nsobject<AutoFillAddressSheetController> addressSheetController; | |
85 | |
86 // Transient reference to address "Add" / "Edit" sheet for credit card | |
87 // information. | |
88 scoped_nsobject<AutoFillCreditCardSheetController> creditCardSheetController; | |
89 | |
90 // Manages PersonalDataManager loading. | |
91 scoped_ptr<AutoFillDialogControllerInternal::PersonalDataManagerObserver> | |
92 personalDataManagerObserver_; | |
93 | |
94 // Watches for changes to the AutoFill enabled preference. | |
95 scoped_ptr<AutoFillDialogControllerInternal::PreferenceObserver> | |
96 preferenceObserver_; | |
97 } | |
98 | |
99 // Property representing state of the AutoFill enabled preference. Checkbox is | |
100 // bound to this in nib. Also, enabled state of other controls are also bound | |
101 // to this property. | |
102 @property(nonatomic) BOOL autoFillEnabled; | |
103 | |
104 // Property indicating whether AutoFill is under control of configuration | |
105 // management. The enabled state of the AutoFill enabled checkbox is bound to | |
106 // this property. | |
107 @property(nonatomic) BOOL autoFillManaged; | |
108 | |
109 // Property that is true iff AutoFill is managed and disabled. The save button's | |
110 // enabled state is bound to this property. | |
111 @property(nonatomic) BOOL autoFillManagedAndDisabled; | |
112 | |
113 // Property representing state of Address Book "me" card usage. Checkbox is | |
114 // bound to this in nib. | |
115 @property(nonatomic) BOOL auxiliaryEnabled; | |
116 | |
117 // Property representing selection state in |tableView_|. Enabled state of | |
118 // edit and delete buttons are bound to this property. | |
119 @property(nonatomic) BOOL itemIsSelected; | |
120 | |
121 // Property representing multiple selection state in |tableView_|. Enabled | |
122 // state of edit button is bound to this property. | |
123 @property(nonatomic) BOOL multipleSelected; | |
124 | |
125 // Main interface for displaying a modeless AutoFill dialog on screen. | |
126 // This class method creates a new |AutoFillDialogController| and runs it as a | |
127 // modeless dialog. The controller autoreleases itself when the dialog is | |
128 // closed. |observer| can be NULL, but if it is, then no notification is sent | |
129 // during modifications to data. If |observer| is non-NULL then its | |
130 // |OnAutoFillDialogApply| method is invoked with the new address and credit | |
131 // card information. | |
132 // |profile| must be non-NULL. | |
133 // AutoFill profile and credit card data is initialized from the | |
134 // |PersonalDataManager| that is associated with the input |profile|. | |
135 + (void)showAutoFillDialogWithObserver:(AutoFillDialogObserver*)observer | |
136 profile:(Profile*)profile; | |
137 | |
138 // IBActions for adding new items. | |
139 - (IBAction)addNewAddress:(id)sender; | |
140 - (IBAction)addNewCreditCard:(id)sender; | |
141 | |
142 // IBAction for deleting an item. |sender| is expected to be the "Remove" | |
143 // button. The deletion acts on the selected item in either the address or | |
144 // credit card list. | |
145 - (IBAction)deleteSelection:(id)sender; | |
146 | |
147 // IBAction for editing an item. |sender| is expected to be the "Edit..." | |
148 // button. The editing acts on the selected item in either the address or | |
149 // credit card list. | |
150 - (IBAction)editSelection:(id)sender; | |
151 | |
152 // IBAction for opening the help link. |sender| is expected to be the | |
153 // "About AutoFill" link. | |
154 - (IBAction)openHelp:(id)sender; | |
155 | |
156 // NSTableView data source methods. | |
157 - (id)tableView:(NSTableView *)tableView | |
158 objectValueForTableColumn:(NSTableColumn *)tableColumn | |
159 row:(NSInteger)rowIndex; | |
160 | |
161 - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView; | |
162 | |
163 @end | |
164 | |
165 // Interface exposed for unit testing. | |
166 @interface AutoFillDialogController (ExposedForUnitTests) | |
167 // Returns an instance of AutoFillDialogController. See |-initWithObserver| | |
168 // for details about arguments. | |
169 // Note: controller is autoreleased when |-closeDialog| is called. | |
170 + (AutoFillDialogController*)controllerWithObserver: | |
171 (AutoFillDialogObserver*)observer | |
172 profile:(Profile*)profile; | |
173 | |
174 - (id)initWithObserver:(AutoFillDialogObserver*)observer | |
175 profile:(Profile*)profile; | |
176 - (void)runModelessDialog; | |
177 - (void)closeDialog; | |
178 - (AutoFillAddressSheetController*)addressSheetController; | |
179 - (AutoFillCreditCardSheetController*)creditCardSheetController; | |
180 - (void)selectAddressAtIndex:(size_t)i; | |
181 - (void)selectCreditCardAtIndex:(size_t)i; | |
182 - (void)addSelectedAddressAtIndex:(size_t)i; | |
183 - (void)addSelectedCreditCardAtIndex:(size_t)i; | |
184 - (BOOL)editButtonEnabled; | |
185 - (std::vector<AutoFillProfile>&)profiles; | |
186 - (std::vector<CreditCard>&)creditCards; | |
187 @end | |
188 | |
189 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_MAC_ | |
OLD | NEW |