OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 @class InfoBarContainerController; | 7 @class AnimatableView; |
| 8 @protocol InfoBarContainer; |
8 class InfoBarDelegate; | 9 class InfoBarDelegate; |
9 | 10 |
10 // A controller for an infobar in the browser window. There is one | 11 // A controller for an infobar in the browser window. There is one |
11 // controller per infobar view. The base InfoBarController is able to | 12 // controller per infobar view. The base InfoBarController is able to |
12 // draw an icon, a text message, and a close button. Subclasses can | 13 // draw an icon, a text message, and a close button. Subclasses can |
13 // override addAdditionalControls to customize the UI. | 14 // override addAdditionalControls to customize the UI. |
14 @interface InfoBarController : NSViewController { | 15 @interface InfoBarController : NSViewController { |
15 @private | 16 @private |
16 InfoBarContainerController* containerController_; // weak, owns us | 17 id<InfoBarContainer> containerController_; // weak, owns us |
| 18 BOOL infoBarClosing_; |
17 | 19 |
18 @protected | 20 @protected |
19 InfoBarDelegate* delegate_; // weak | 21 InfoBarDelegate* delegate_; // weak |
| 22 IBOutlet NSView* infoBarView_; |
20 IBOutlet NSImageView* image_; | 23 IBOutlet NSImageView* image_; |
21 IBOutlet NSTextField* label_; | 24 IBOutlet NSTextField* label_; |
22 IBOutlet NSButton* okButton_; | 25 IBOutlet NSButton* okButton_; |
23 IBOutlet NSButton* cancelButton_; | 26 IBOutlet NSButton* cancelButton_; |
24 }; | 27 }; |
25 | 28 |
26 // Initializes a new InfoBarController. | 29 // Initializes a new InfoBarController. |
27 - (id)initWithDelegate:(InfoBarDelegate*)delegate; | 30 - (id)initWithDelegate:(InfoBarDelegate*)delegate; |
28 | 31 |
29 // Called when someone clicks on the ok or cancel buttons. Subclasses | 32 // Called when someone clicks on the ok or cancel buttons. Subclasses |
30 // must override if they do not hide the buttons. | 33 // must override if they do not hide the buttons. |
31 - (void)ok:(id)sender; | 34 - (void)ok:(id)sender; |
32 - (void)cancel:(id)sender; | 35 - (void)cancel:(id)sender; |
33 | 36 |
34 // Called when someone clicks on the close button. Dismisses the | 37 // Called when someone clicks on the close button. Dismisses the |
35 // infobar without taking any action. | 38 // infobar without taking any action. |
36 - (IBAction)dismiss:(id)sender; | 39 - (IBAction)dismiss:(id)sender; |
37 | 40 |
| 41 // Returns a pointer to this controller's view, cast as an AnimatableView. |
| 42 - (AnimatableView*)animatableView; |
| 43 |
| 44 // Open or animate open the infobar. |
| 45 - (void)open; |
| 46 - (void)animateOpen; |
| 47 |
| 48 // Close or animate close the infobar. |
| 49 - (void)close; |
| 50 - (void)animateClosed; |
| 51 |
38 // Subclasses can override this method to add additional controls to | 52 // Subclasses can override this method to add additional controls to |
39 // the infobar view. This method is called by awakeFromNib. The | 53 // the infobar view. This method is called by awakeFromNib. The |
40 // default implementation does nothing. | 54 // default implementation does nothing. |
41 - (void)addAdditionalControls; | 55 - (void)addAdditionalControls; |
42 | 56 |
43 @property(assign, nonatomic) InfoBarContainerController* containerController; | 57 @property(assign, nonatomic) id<InfoBarContainer> containerController; |
44 @property(readonly) InfoBarDelegate* delegate; | 58 @property(readonly) InfoBarDelegate* delegate; |
45 | 59 |
46 @end | 60 @end |
47 | 61 |
48 ///////////////////////////////////////////////////////////////////////// | 62 ///////////////////////////////////////////////////////////////////////// |
49 // InfoBarController subclasses, one for each InfoBarDelegate | 63 // InfoBarController subclasses, one for each InfoBarDelegate |
50 // subclass. Each of these subclasses overrides addAdditionalControls to | 64 // subclass. Each of these subclasses overrides addAdditionalControls to |
51 // configure its view as necessary. | 65 // configure its view as necessary. |
52 | 66 |
53 @interface AlertInfoBarController : InfoBarController | 67 @interface AlertInfoBarController : InfoBarController |
54 @end | 68 @end |
55 | 69 |
56 | 70 |
57 @interface LinkInfoBarController : InfoBarController | 71 @interface LinkInfoBarController : InfoBarController |
58 // Called when there is a click on the link in the infobar. | 72 // Called when there is a click on the link in the infobar. |
59 - (void)linkClicked; | 73 - (void)linkClicked; |
60 @end | 74 @end |
61 | 75 |
62 | 76 |
63 @interface ConfirmInfoBarController : InfoBarController | 77 @interface ConfirmInfoBarController : InfoBarController |
64 // Called when the ok and cancel buttons are clicked. | 78 // Called when the ok and cancel buttons are clicked. |
65 - (IBAction)ok:(id)sender; | 79 - (IBAction)ok:(id)sender; |
66 - (IBAction)cancel:(id)sender; | 80 - (IBAction)cancel:(id)sender; |
67 @end | 81 @end |
OLD | NEW |