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 |
| 8 #import <Cocoa/Cocoa.h> |
| 9 #include <vector> |
| 10 #include "base/scoped_nsobject.h" |
| 11 #include "chrome/browser/autofill/autofill_dialog.h" |
| 12 #include "chrome/browser/autofill/autofill_profile.h" |
| 13 #include "chrome/browser/autofill/credit_card.h" |
| 14 |
| 15 @class AutoFillAddressViewController; |
| 16 @class AutoFillCreditCardViewController; |
| 17 @class SectionSeparatorView; |
| 18 |
| 19 // A window controller for managing the autofill options dialog. |
| 20 // Application modally presents a dialog allowing the user to store |
| 21 // personal address and credit card information. |
| 22 @interface AutoFillDialogController : NSWindowController { |
| 23 @private |
| 24 IBOutlet NSView* childView_; |
| 25 IBOutlet NSView* addressSection_; |
| 26 IBOutlet SectionSeparatorView* addressSectionBox_; |
| 27 IBOutlet NSView* creditCardSection_; |
| 28 |
| 29 // TODO(dhollowa): one each of these for now. Will be n of each |
| 30 // controller eventually, for n addresses and n credit cards. |
| 31 // Note on ownership: the controllers are strongly owned by the dialog |
| 32 // controller. Their views are inserted into the dialog's view hierarcy |
| 33 // but are retained by these controllers as well. |
| 34 // See http://crbug.com/33029. |
| 35 scoped_nsobject<AutoFillAddressViewController> |
| 36 addressFormViewController_; |
| 37 scoped_nsobject<AutoFillCreditCardViewController> |
| 38 creditCardFormViewController_; |
| 39 |
| 40 AutoFillDialogObserver* observer_; // (weak) not retained |
| 41 std::vector<AutoFillProfile> profiles_; |
| 42 std::vector<CreditCard> creditCards_; |
| 43 } |
| 44 |
| 45 // Main interface for displaying an application modal autofill dialog on screen. |
| 46 // This class method creates a new |AutoFillDialogController| and runs it as a |
| 47 // modal dialog. The controller autoreleases itself when the dialog is closed. |
| 48 // |observer| can be NULL, but if it is, then no notification is sent during |
| 49 // call to |save|. If |observer| is non-NULL then its |OnAutoFillDialogApply| |
| 50 // method is invoked during |save| with the new address and credit card |
| 51 // information. |
| 52 // |profiles| and |creditCards| must have non-NULL entries (zero or more). |
| 53 // These provide the initial data that is presented to the user. |
| 54 + (void)showAutoFillDialogWithObserver:(AutoFillDialogObserver*)observer |
| 55 autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles |
| 56 creditCards:(const std::vector<CreditCard*>&)creditCards; |
| 57 |
| 58 // IBActions for the dialog buttons. |
| 59 - (IBAction)save:(id)sender; |
| 60 - (IBAction)cancel:(id)sender; |
| 61 |
| 62 @end |
| 63 |
| 64 // Interface exposed for unit testing. |
| 65 @interface AutoFillDialogController (ExposedForUnitTests) |
| 66 // Returns an instance of AutoFillDialogController. See |-initWithObserver| |
| 67 // for details about arguments. |
| 68 // Note: controller is autoreleased when |-closeDialog| is called. |
| 69 + (AutoFillDialogController*)controllerWithObserver: |
| 70 (AutoFillDialogObserver*)observer |
| 71 autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles |
| 72 creditCards:(const std::vector<CreditCard*>&)creditCards; |
| 73 |
| 74 - (id)initWithObserver:(AutoFillDialogObserver*)observer |
| 75 autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles |
| 76 creditCards:(const std::vector<CreditCard*>&)creditCards; |
| 77 - (AutoFillAddressViewController*)addressFormViewController; |
| 78 - (AutoFillCreditCardViewController*)creditCardFormViewController; |
| 79 - (void)closeDialog; |
| 80 @end |
| 81 |
| 82 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_MAC_ |
OLD | NEW |