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