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_CREDIT_CARD_VIEW_CONTROLLER_MAC_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_SHEET_CONTROLLER_MAC_ |
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_VIEW_CONTROLLER_MAC_ | 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_SHEET_CONTROLLER_MAC_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #import "chrome/browser/cocoa/disclosure_view_controller.h" | |
10 | 9 |
11 @class AutoFillCreditCardModel; | 10 @class AutoFillCreditCardModel; |
12 @class AutoFillDialogController; | 11 @class AutoFillDialogController; |
13 class CreditCard; | 12 class CreditCard; |
14 | 13 |
| 14 // The sheet can be invoked in "Add" or "Edit" mode. This dictates the caption |
| 15 // seen at the top of the sheet. |
| 16 enum { |
| 17 kAutoFillCreditCardAddMode = 0, |
| 18 kAutoFillCreditCardEditMode = 1 |
| 19 }; |
| 20 typedef NSInteger AutoFillCreditCardMode; |
| 21 |
15 // A class that coordinates the |creditCardModel| and the associated view | 22 // A class that coordinates the |creditCardModel| and the associated view |
16 // held in AutoFillCreditCardFormView.xib. | 23 // held in AutoFillCreditCardSheet.xib. |
17 // |initWithCreditCard:| is the designated initializer. It takes |creditCard| | 24 // |initWithCreditCard:| is the designated initializer. It takes |creditCard| |
18 // and transcribes it to |creditCardModel| to which the view is bound. | 25 // and transcribes it to |creditCardModel| to which the view is bound. |
19 @interface AutoFillCreditCardViewController : DisclosureViewController { | 26 @interface AutoFillCreditCardSheetController : NSWindowController { |
20 @private | 27 @private |
21 IBOutlet NSPopUpButton* billingAddressPopup_; | 28 IBOutlet NSPopUpButton* billingAddressPopup_; |
22 IBOutlet NSPopUpButton* shippingAddressPopup_; | 29 IBOutlet NSPopUpButton* expirationMonthPopup_; |
| 30 IBOutlet NSPopUpButton* expirationYearPopup_; |
| 31 |
| 32 // The caption at top of dialog. Text changes according to usage. Either |
| 33 // "New credit card" or "Edit credit card" depending on context. |
| 34 IBOutlet NSTextField* caption_; |
23 | 35 |
24 // The primary model for this controller. The model is instantiated | 36 // The primary model for this controller. The model is instantiated |
25 // from within |initWithCreditCard:|. We do not hold it as a scoped_nsobject | 37 // from within |initWithCreditCard:|. We do not hold it as a scoped_nsobject |
26 // because it is exposed as a KVO compliant property. | 38 // because it is exposed as a KVO compliant property. |
27 AutoFillCreditCardModel* creditCardModel_; | 39 AutoFillCreditCardModel* creditCardModel_; |
28 | 40 |
29 // Array of strings that populate the |billingAddressPopup_| control. We | 41 // Array of strings that populate the |billingAddressPopup_| control. We |
30 // do not hold this as scoped_nsobject because it is exposed as a KVO | 42 // do not hold this as scoped_nsobject because it is exposed as a KVO |
31 // compliant property. The values of this array may change as the list | 43 // compliant property. The values of this array may change as the list |
32 // of addresses change in the |parentController_|. | 44 // of addresses change in the |parentController_|. |
33 NSArray* billingAddressContents_; | 45 NSArray* billingAddressContents_; |
34 | 46 |
35 // Array of strings that populate the |shippingAddressPopup_| control. We | 47 // Contents of the expiration month and year popups. Strongly owned. We do |
36 // do not hold this as scoped_nsobject because it is exposed as a KVO | 48 // not hold them as scoped_nsobjects because they are exposed as KVO compliant |
37 // compliant property. The values of this array may change as the list | 49 // properties. |
38 // of addresses change in the |parentController_|. | 50 NSArray* expirationMonthContents_; |
39 NSArray* shippingAddressContents_; | 51 NSArray* expirationYearContents_; |
40 | 52 |
41 // A reference to our parent controller. Used for notifying parent if/when | 53 // A reference to our parent controller. Used for fetching billing address |
42 // deletion occurs. May be not be nil. | 54 // labels. May be not be nil. |
43 // Weak reference, owns us. | 55 // Weak reference, owns us. |
44 AutoFillDialogController* parentController_; | 56 AutoFillDialogController* parentController_; |
| 57 |
| 58 // Either "Add" or "Edit" mode of sheet. |
| 59 AutoFillCreditCardMode mode_; |
45 } | 60 } |
46 | 61 |
47 @property (nonatomic, retain) AutoFillCreditCardModel* creditCardModel; | 62 @property (nonatomic, retain) AutoFillCreditCardModel* creditCardModel; |
48 @property (nonatomic, retain) NSArray* billingAddressContents; | 63 @property (nonatomic, retain) NSArray* billingAddressContents; |
49 @property (nonatomic, retain) NSArray* shippingAddressContents; | 64 @property (nonatomic, retain) NSArray* expirationMonthContents; |
| 65 @property (nonatomic, retain) NSArray* expirationYearContents; |
50 | 66 |
51 // Designated initializer. Takes a copy of the data in |creditCard|, | 67 // Designated initializer. Takes a copy of the data in |creditCard|, |
52 // it is not held as a reference. | 68 // it is not held as a reference. |
53 - (id)initWithCreditCard:(const CreditCard&)creditCard | 69 - (id)initWithCreditCard:(const CreditCard&)creditCard |
54 disclosure:(NSCellStateValue)disclosureState | 70 mode:(AutoFillCreditCardMode)mode |
55 controller:(AutoFillDialogController*)parentController; | 71 controller:(AutoFillDialogController*)parentController; |
56 | 72 |
57 // Action to remove this credit card from the dialog. Forwards the request to | 73 // IBActions for save and cancel buttons. Both invoke |endSheet:|. |
58 // |parentController_| which does all the actual work. We have the action | 74 - (IBAction)save:(id)sender; |
59 // here so that the delete button in the AutoFillCreditCardViewFormView.xib has | 75 - (IBAction)cancel:(id)sender; |
60 // something to call. | |
61 - (IBAction)deleteCreditCard:(id)sender; | |
62 | |
63 // Action to notify observers of the address list when changes have occured. | |
64 // For the credit card controller this means rebuild the popup menus. | |
65 - (IBAction)onAddressesChanged:(id)sender; | |
66 | 76 |
67 // Copy data from internal model to |creditCard|. | 77 // Copy data from internal model to |creditCard|. |
68 - (void)copyModelToCreditCard:(CreditCard*)creditCard; | 78 - (void)copyModelToCreditCard:(CreditCard*)creditCard; |
69 | 79 |
70 @end | 80 @end |
71 | 81 |
72 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_VIEW_CONTROLLER_MAC_ | 82 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_SHEET_CONTROLLER_MAC_ |
OLD | NEW |