| 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 #ifndef CHROME_BROWSER_UI_COCOA_INFOBAR_CONTAINER_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_UI_COCOA_INFOBAR_CONTAINER_CONTROLLER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #import <Cocoa/Cocoa.h> | |
| 10 | |
| 11 #include "base/scoped_nsobject.h" | |
| 12 #include "base/scoped_ptr.h" | |
| 13 #import "chrome/browser/ui/cocoa/view_resizer.h" | |
| 14 #include "chrome/common/notification_registrar.h" | |
| 15 | |
| 16 @class InfoBarController; | |
| 17 class InfoBarDelegate; | |
| 18 class InfoBarNotificationObserver; | |
| 19 class TabContents; | |
| 20 class TabStripModel; | |
| 21 | |
| 22 // Protocol for basic container methods, as needed by an InfoBarController. | |
| 23 // This protocol exists to make mocking easier in unittests. | |
| 24 @protocol InfoBarContainer | |
| 25 - (void)removeDelegate:(InfoBarDelegate*)delegate; | |
| 26 - (void)removeController:(InfoBarController*)controller; | |
| 27 @end | |
| 28 | |
| 29 // Controller for the infobar container view, which is the superview | |
| 30 // of all the infobar views. This class owns zero or more | |
| 31 // InfoBarControllers, which manage the infobar views. This class | |
| 32 // also receives tab strip model notifications and handles | |
| 33 // adding/removing infobars when needed. | |
| 34 @interface InfoBarContainerController : NSViewController <ViewResizer, | |
| 35 InfoBarContainer> { | |
| 36 @private | |
| 37 // Needed to send resize messages when infobars are added or removed. | |
| 38 id<ViewResizer> resizeDelegate_; // weak | |
| 39 | |
| 40 // The TabContents we are currently showing infobars for. | |
| 41 TabContents* currentTabContents_; // weak | |
| 42 | |
| 43 // Holds the InfoBarControllers currently owned by this container. | |
| 44 scoped_nsobject<NSMutableArray> infobarControllers_; | |
| 45 | |
| 46 // Lets us registers for INFOBAR_ADDED/INFOBAR_REMOVED | |
| 47 // notifications. The actual notifications are sent to the | |
| 48 // InfoBarNotificationObserver object, which proxies them back to us. | |
| 49 NotificationRegistrar registrar_; | |
| 50 scoped_ptr<InfoBarNotificationObserver> infoBarObserver_; | |
| 51 } | |
| 52 | |
| 53 - (id)initWithResizeDelegate:(id<ViewResizer>)resizeDelegate; | |
| 54 | |
| 55 // Informs the selected TabContents that the infobars for the given | |
| 56 // |delegate| need to be removed. Does not remove any infobar views | |
| 57 // directly, as they will be removed when handling the subsequent | |
| 58 // INFOBAR_REMOVED notification. Does not notify |delegate| that the | |
| 59 // infobar was closed. | |
| 60 - (void)removeDelegate:(InfoBarDelegate*)delegate; | |
| 61 | |
| 62 // Removes |controller| from the list of controllers in this container and | |
| 63 // removes its view from the view hierarchy. This method is safe to call while | |
| 64 // |controller| is still on the call stack. | |
| 65 - (void)removeController:(InfoBarController*)controller; | |
| 66 | |
| 67 // Modifies this container to display infobars for the given | |
| 68 // |contents|. Registers for INFOBAR_ADDED and INFOBAR_REMOVED | |
| 69 // notifications for |contents|. If we are currently showing any | |
| 70 // infobars, removes them first and deregisters for any | |
| 71 // notifications. |contents| can be NULL, in which case no infobars | |
| 72 // are shown and no notifications are registered for. | |
| 73 - (void)changeTabContents:(TabContents*)contents; | |
| 74 | |
| 75 // Stripped down version of TabStripModelObserverBridge:tabDetachedWithContents. | |
| 76 // Forwarded by BWC. Removes all infobars and deregisters for any notifications | |
| 77 // if |contents| is the current tab contents. | |
| 78 - (void)tabDetachedWithContents:(TabContents*)contents; | |
| 79 | |
| 80 @end | |
| 81 | |
| 82 | |
| 83 @interface InfoBarContainerController (ForTheObserverAndTesting) | |
| 84 | |
| 85 // Adds an infobar view for the given delegate. | |
| 86 - (void)addInfoBar:(InfoBarDelegate*)delegate animate:(BOOL)animate; | |
| 87 | |
| 88 // Closes all the infobar views for a given delegate, either immediately or by | |
| 89 // starting a close animation. | |
| 90 - (void)closeInfoBarsForDelegate:(InfoBarDelegate*)delegate | |
| 91 animate:(BOOL)animate; | |
| 92 | |
| 93 // Replaces all info bars for the delegate with a new info bar. | |
| 94 // This simply calls closeInfoBarsForDelegate: and then addInfoBar:. | |
| 95 - (void)replaceInfoBarsForDelegate:(InfoBarDelegate*)old_delegate | |
| 96 with:(InfoBarDelegate*)new_delegate; | |
| 97 | |
| 98 // Positions the infobar views in the container view and notifies | |
| 99 // |browser_controller_| that it needs to resize the container view. | |
| 100 - (void)positionInfoBarsAndRedraw; | |
| 101 | |
| 102 @end | |
| 103 | |
| 104 | |
| 105 @interface InfoBarContainerController (JustForTesting) | |
| 106 | |
| 107 // Removes all infobar views. Callers must call | |
| 108 // positionInfoBarsAndRedraw() after calling this method. | |
| 109 - (void)removeAllInfoBars; | |
| 110 | |
| 111 @end | |
| 112 | |
| 113 #endif // CHROME_BROWSER_UI_COCOA_INFOBAR_CONTAINER_CONTROLLER_H_ | |
| OLD | NEW |