OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import <Cocoa/Cocoa.h> |
| 6 |
| 7 #include "base/scoped_nsobject.h" |
| 8 #include "base/scoped_ptr.h" |
| 9 #include "chrome/common/notification_registrar.h" |
| 10 |
| 11 @class BrowserWindowController; |
| 12 class InfoBarDelegate; |
| 13 class InfoBarNotificationObserver; |
| 14 class TabContents; |
| 15 class TabStripModel; |
| 16 class TabStripModelObserverBridge; |
| 17 |
| 18 // Controller for the infobar container view, which is the superview |
| 19 // of all the infobar views. This class owns zero or more |
| 20 // InfoBarControllers, which manage the infobar views. This class |
| 21 // also receives tab strip model notifications and handles |
| 22 // adding/removing infobars when needed. |
| 23 @interface InfoBarContainerController : NSViewController { |
| 24 @private |
| 25 // Needed to send resizeInfoBar: messages when infobars are added or removed. |
| 26 BrowserWindowController* browserController_; // weak, owns us. |
| 27 |
| 28 // The TabContents we are currently showing infobars for. |
| 29 TabContents* currentTabContents_; // weak |
| 30 |
| 31 // Holds the InfoBarControllers currently owned by this container. |
| 32 scoped_nsobject<NSMutableArray> infobarControllers_; |
| 33 |
| 34 // Lets us get TabChanged/TabDetachedAt notifications. |
| 35 scoped_ptr<TabStripModelObserverBridge> tabObserver_; |
| 36 |
| 37 // Lets us registers for INFOBAR_ADDED/INFOBAR_REMOVED |
| 38 // notifications. The actual notifications are sent to the |
| 39 // InfoBarNotificationObserver object, which proxies them back to us. |
| 40 NotificationRegistrar registrar_; |
| 41 scoped_ptr<InfoBarNotificationObserver> infoBarObserver_; |
| 42 } |
| 43 |
| 44 - (id)initWithTabStripModel:(TabStripModel*)model |
| 45 browserWindowController:(BrowserWindowController*)controller; |
| 46 |
| 47 // Informs the selected TabContents that the infobars for the given |
| 48 // |delegate| need to be removed. Does not remove any infobar views |
| 49 // directly, as they will be removed when handling the subsequent |
| 50 // INFOBAR_REMOVED notification. Does not notify |delegate| that the |
| 51 // infobar was closed. |
| 52 - (void)removeDelegate:(InfoBarDelegate*)delegate; |
| 53 |
| 54 @end |
| 55 |
| 56 |
| 57 @interface InfoBarContainerController (ForTheObserverAndTesting) |
| 58 |
| 59 // Adds an infobar view for the given delegate. Callers must call |
| 60 // positionInfoBarsAndRedraw after calling this method. |
| 61 - (void)addInfoBar:(InfoBarDelegate*)delegate; |
| 62 |
| 63 // Removes all the infobar views for a given delegate. Callers must |
| 64 // call positionInfoBarsAndRedraw after calling this method. |
| 65 - (void)removeInfoBarsForDelegate:(InfoBarDelegate*)delegate; |
| 66 |
| 67 // Positions the infobar views in the container view and notifies |
| 68 // |browser_controller_| that it needs to resize the container view. |
| 69 - (void)positionInfoBarsAndRedraw; |
| 70 |
| 71 @end |
| 72 |
| 73 |
| 74 @interface InfoBarContainerController (JustForTesting) |
| 75 |
| 76 // Removes all infobar views. Callers must call |
| 77 // positionInfoBarsAndRedraw() after calling this method. |
| 78 - (void)removeAllInfoBars; |
| 79 |
| 80 @end |
OLD | NEW |