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 "chrome/browser/autofill/autofill_dialog.h" | 11 #include "chrome/browser/autofill/autofill_dialog.h" |
12 #include "chrome/browser/autofill/autofill_profile.h" | 12 #include "chrome/browser/autofill/autofill_profile.h" |
13 #include "chrome/browser/autofill/credit_card.h" | 13 #include "chrome/browser/autofill/credit_card.h" |
14 | 14 |
15 @class AutoFillAddressViewController; | 15 @class AutoFillAddressViewController; |
16 @class AutoFillCreditCardViewController; | 16 @class AutoFillCreditCardViewController; |
| 17 class Profile; |
17 @class SectionSeparatorView; | 18 @class SectionSeparatorView; |
18 @class WindowSizeAutosaver; | 19 @class WindowSizeAutosaver; |
19 | 20 |
20 // A window controller for managing the autofill options dialog. | 21 // A window controller for managing the autofill options dialog. |
21 // Application modally presents a dialog allowing the user to store | 22 // Application modally presents a dialog allowing the user to store |
22 // personal address and credit card information. | 23 // personal address and credit card information. |
23 @interface AutoFillDialogController : NSWindowController { | 24 @interface AutoFillDialogController : NSWindowController { |
24 @private | 25 @private |
25 IBOutlet NSView* childView_; | 26 IBOutlet NSView* childView_; |
26 IBOutlet NSView* addressSection_; | 27 IBOutlet NSView* addressSection_; |
27 IBOutlet SectionSeparatorView* addressSectionBox_; | 28 IBOutlet SectionSeparatorView* addressSectionBox_; |
28 IBOutlet NSView* creditCardSection_; | 29 IBOutlet NSView* creditCardSection_; |
29 | 30 |
30 // Note on ownership: the controllers are strongly owned by the dialog | 31 // Note on ownership: the controllers are strongly owned by the dialog |
31 // controller. Their views are inserted into the dialog's view hierarcy | 32 // controller. Their views are inserted into the dialog's view hierarcy |
32 // but are retained by these controllers as well. | 33 // but are retained by these controllers as well. |
33 | 34 |
34 // Array of |AutoFillAddressViewController|. | 35 // Array of |AutoFillAddressViewController|. |
35 scoped_nsobject<NSMutableArray> addressFormViewControllers_; | 36 scoped_nsobject<NSMutableArray> addressFormViewControllers_; |
36 | 37 |
37 // Array of |AutoFillCreditCardViewController|. | 38 // Array of |AutoFillCreditCardViewController|. |
38 scoped_nsobject<NSMutableArray> creditCardFormViewControllers_; | 39 scoped_nsobject<NSMutableArray> creditCardFormViewControllers_; |
39 | 40 |
40 AutoFillDialogObserver* observer_; // Weak, not retained. | 41 AutoFillDialogObserver* observer_; // Weak, not retained. |
41 std::vector<AutoFillProfile> profiles_; | 42 std::vector<AutoFillProfile> profiles_; |
42 std::vector<CreditCard> creditCards_; | 43 std::vector<CreditCard> creditCards_; |
43 | 44 Profile* profile_; // Weak, not retained. |
| 45 BOOL auxiliaryEnabled_; |
44 scoped_nsobject<WindowSizeAutosaver> sizeSaver_; | 46 scoped_nsobject<WindowSizeAutosaver> sizeSaver_; |
45 } | 47 } |
46 | 48 |
| 49 // Property representing state of Address Book "me" card usage. Checkbox is |
| 50 // bound to this in nib. |
| 51 @property (nonatomic) BOOL auxiliaryEnabled; |
| 52 |
47 // Main interface for displaying an application modal autofill dialog on screen. | 53 // Main interface for displaying an application modal autofill dialog on screen. |
48 // This class method creates a new |AutoFillDialogController| and runs it as a | 54 // This class method creates a new |AutoFillDialogController| and runs it as a |
49 // modal dialog. The controller autoreleases itself when the dialog is closed. | 55 // modal dialog. The controller autoreleases itself when the dialog is closed. |
50 // |observer| can be NULL, but if it is, then no notification is sent during | 56 // |observer| can be NULL, but if it is, then no notification is sent during |
51 // call to |save|. If |observer| is non-NULL then its |OnAutoFillDialogApply| | 57 // call to |save|. If |observer| is non-NULL then its |OnAutoFillDialogApply| |
52 // method is invoked during |save| with the new address and credit card | 58 // method is invoked during |save| with the new address and credit card |
53 // information. | 59 // information. |
54 // |profiles| and |creditCards| must have non-NULL entries (zero or more). | 60 // |profiles| and |creditCards| must have non-NULL entries (zero or more). |
55 // These provide the initial data that is presented to the user. | 61 // These provide the initial data that is presented to the user. |
| 62 // |profile| must be non-NULL. |
56 + (void)showAutoFillDialogWithObserver:(AutoFillDialogObserver*)observer | 63 + (void)showAutoFillDialogWithObserver:(AutoFillDialogObserver*)observer |
57 autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles | 64 autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles |
58 creditCards:(const std::vector<CreditCard*>&)creditCards; | 65 creditCards:(const std::vector<CreditCard*>&)creditCards |
| 66 profile:(Profile*)profile; |
59 | 67 |
60 // IBActions for the dialog buttons. | 68 // IBActions for the dialog buttons. |
61 - (IBAction)save:(id)sender; | 69 - (IBAction)save:(id)sender; |
62 - (IBAction)cancel:(id)sender; | 70 - (IBAction)cancel:(id)sender; |
63 | 71 |
64 // IBActions for adding new items. | 72 // IBActions for adding new items. |
65 - (IBAction)addNewAddress:(id)sender; | 73 - (IBAction)addNewAddress:(id)sender; |
66 - (IBAction)addNewCreditCard:(id)sender; | 74 - (IBAction)addNewCreditCard:(id)sender; |
67 | 75 |
68 // IBActions for deleting items. |sender| is expected to be either a | 76 // IBActions for deleting items. |sender| is expected to be either a |
(...skipping 11 matching lines...) Expand all Loading... |
80 @end | 88 @end |
81 | 89 |
82 // Interface exposed for unit testing. | 90 // Interface exposed for unit testing. |
83 @interface AutoFillDialogController (ExposedForUnitTests) | 91 @interface AutoFillDialogController (ExposedForUnitTests) |
84 // Returns an instance of AutoFillDialogController. See |-initWithObserver| | 92 // Returns an instance of AutoFillDialogController. See |-initWithObserver| |
85 // for details about arguments. | 93 // for details about arguments. |
86 // Note: controller is autoreleased when |-closeDialog| is called. | 94 // Note: controller is autoreleased when |-closeDialog| is called. |
87 + (AutoFillDialogController*)controllerWithObserver: | 95 + (AutoFillDialogController*)controllerWithObserver: |
88 (AutoFillDialogObserver*)observer | 96 (AutoFillDialogObserver*)observer |
89 autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles | 97 autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles |
90 creditCards:(const std::vector<CreditCard*>&)creditCards; | 98 creditCards:(const std::vector<CreditCard*>&)creditCards |
| 99 profile:(Profile*)profile; |
91 | 100 |
92 - (id)initWithObserver:(AutoFillDialogObserver*)observer | 101 - (id)initWithObserver:(AutoFillDialogObserver*)observer |
93 autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles | 102 autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles |
94 creditCards:(const std::vector<CreditCard*>&)creditCards; | 103 creditCards:(const std::vector<CreditCard*>&)creditCards |
| 104 profile:(Profile*)profile; |
95 - (NSMutableArray*)addressFormViewControllers; | 105 - (NSMutableArray*)addressFormViewControllers; |
96 - (NSMutableArray*)creditCardFormViewControllers; | 106 - (NSMutableArray*)creditCardFormViewControllers; |
97 - (void)closeDialog; | 107 - (void)closeDialog; |
98 @end | 108 @end |
99 | 109 |
100 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_MAC_ | 110 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_MAC_ |
OLD | NEW |