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