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