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_ADDRESS_VIEW_CONTROLLER_MAC_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_ADDRESS_SHEET_CONTROLLER_MAC_ |
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_ADDRESS_VIEW_CONTROLLER_MAC_ | 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_ADDRESS_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 AutoFillAddressModel; | 10 @class AutoFillAddressModel; |
12 @class AutoFillDialogController; | 11 @class AutoFillDialogController; |
13 class AutoFillProfile; | 12 class AutoFillProfile; |
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 kAutoFillAddressAddMode = 0, |
| 18 kAutoFillAddressEditMode = 1 |
| 19 }; |
| 20 typedef NSInteger AutoFillAddressMode; |
| 21 |
15 // A class that coordinates the |addressModel| and the associated view | 22 // A class that coordinates the |addressModel| and the associated view |
16 // held in AutoFillAddressFormView.xib. | 23 // held in AutoFillAddressSheet.xib. |
17 // |initWithProfile:| is the designated initializer. It takes |profile| | 24 // |initWithProfile:| is the designated initializer. It takes |profile| |
18 // and transcribes it to |addressModel| to which the view is bound. | 25 // and transcribes it to |addressModel| to which the view is bound. |
19 @interface AutoFillAddressViewController : DisclosureViewController { | 26 @interface AutoFillAddressSheetController : NSWindowController { |
20 @private | 27 @private |
| 28 // The caption at top of dialog. Text changes according to usage. Either |
| 29 // "New address" or "Edit address" depending on |mode_|. |
| 30 IBOutlet NSTextField* caption_; |
| 31 |
21 // The primary model for this controller. The model is instantiated | 32 // The primary model for this controller. The model is instantiated |
22 // from within |initWithProfile:|. We do not hold it as a scoped_nsobject | 33 // from within |initWithProfile:|. We do not hold it as a scoped_nsobject |
23 // because it is exposed as a KVO compliant property. | 34 // because it is exposed as a KVO compliant property. |
24 // Strong reference. | 35 // Strong reference. |
25 AutoFillAddressModel* addressModel_; | 36 AutoFillAddressModel* addressModel_; |
26 | 37 |
27 // A reference to our parent controller. Used for notifying parent if/when | 38 // Either "Add" or "Edit" mode of sheet. |
28 // deletion occurs. Also used to notify parent when the label of the address | 39 AutoFillAddressMode mode_; |
29 // changes. May be not be nil. | |
30 // Weak reference, owns us. | |
31 AutoFillDialogController* parentController_; | |
32 } | 40 } |
33 | 41 |
34 @property (nonatomic, retain) AutoFillAddressModel* addressModel; | 42 @property (nonatomic, retain) AutoFillAddressModel* addressModel; |
35 | 43 |
| 44 // IBActions for save and cancel buttons. Both invoke |endSheet:|. |
| 45 - (IBAction)save:(id)sender; |
| 46 - (IBAction)cancel:(id)sender; |
| 47 |
36 // Designated initializer. Takes a copy of the data in |profile|, | 48 // Designated initializer. Takes a copy of the data in |profile|, |
37 // it is not held as a reference. | 49 // it is not held as a reference. |
38 - (id)initWithProfile:(const AutoFillProfile&)profile | 50 - (id)initWithProfile:(const AutoFillProfile&)profile |
39 disclosure:(NSCellStateValue)disclosureState | 51 mode:(AutoFillAddressMode)mode; |
40 controller:(AutoFillDialogController*) parentController; | |
41 | |
42 // Action to remove this address from the dialog. Forwards the request to | |
43 // |parentController_| which does all the actual work. We have the action | |
44 // here so that the delete button in the AutoFillAddressViewFormView.xib has | |
45 // something to call. | |
46 - (IBAction)deleteAddress:(id)sender; | |
47 | 52 |
48 // Copy data from internal model to |profile|. | 53 // Copy data from internal model to |profile|. |
49 - (void)copyModelToProfile:(AutoFillProfile*)profile; | 54 - (void)copyModelToProfile:(AutoFillProfile*)profile; |
50 | 55 |
51 @end | 56 @end |
52 | 57 |
53 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_ADDRESS_VIEW_CONTROLLER_MAC_ | 58 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_ADDRESS_SHEET_CONTROLLER_MAC_ |
OLD | NEW |