1 // Copyright (c) 2011 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.
5 #ifndef CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_
8 #import <Cocoa/Cocoa.h>
10 #include "base/mac/scoped_nsobject.h"
11 #include "base/memory/scoped_ptr.h"
12 #import "chrome/browser/ui/cocoa/view_resizer.h"
14 @class BrowserWindowController;
15 @class InfoBarController;
17 class InfoBarContainerCocoa;
25 class InfoBarDelegate;
28 // Protocol for basic container methods, as needed by an InfoBarController.
29 // This protocol exists to make mocking easier in unittests.
30 @protocol InfoBarContainerControllerBase
31 - (BrowserWindowController*)browserWindowController;
32 - (BOOL)shouldSuppressTopInfoBarTip;
33 - (CGFloat)infobarArrowX;
36 // Controller for the infobar container view, which is the superview
37 // of all the infobar views. This class owns zero or more
38 // InfoBarControllers, which manage the infobar views. This class
39 // also receives tab strip model notifications and handles
40 // adding/removing infobars when needed.
41 @interface InfoBarContainerController
42 : NSViewController<InfoBarContainerControllerBase> {
44 // Needed to send resize messages when infobars are added or removed.
45 id<ViewResizer> resizeDelegate_; // weak
47 // The WebContents we are currently showing infobars for.
48 content::WebContents* currentWebContents_; // weak
50 // Holds the InfoBarControllers currently owned by this container.
51 base::scoped_nsobject<NSMutableArray> infobarControllers_;
53 // The C++ instance that bridges to the cross platform code.
54 scoped_ptr<InfoBarContainerCocoa> containerCocoa_;
56 // If YES then the first info bar doesn't draw a tip.
57 BOOL shouldSuppressTopInfoBarTip_;
59 // If YES then an infobar animation is in progress.
63 @property(nonatomic, assign) BOOL shouldSuppressTopInfoBarTip;
65 - (id)initWithResizeDelegate:(id<ViewResizer>)resizeDelegate;
67 // Modifies this container to display infobars for the given |contents|.
68 - (void)changeWebContents:(content::WebContents*)contents;
70 // Stripped down version of TabStripModelObserverBridge:tabDetachedWithContents.
71 // Forwarded by BWC. Removes all infobars if |contents| is the current tab
73 - (void)tabDetachedWithContents:(content::WebContents*)contents;
75 // Returns the amount of additional height the container view needs to draw the
76 // anti-spoofing tip. This is the total amount of overlap for all infobars.
77 - (CGFloat)overlappingTipHeight;
79 // Adds the given infobar.
80 - (void)addInfoBar:(InfoBarCocoa*)infobar
81 position:(NSUInteger)position;
83 // Removes the given infobar.
84 - (void)removeInfoBar:(InfoBarCocoa*)infobar;
86 // Positions the infobar views in the container view and notifies
87 // |browser_controller_| that it needs to resize the container view.
88 - (void)positionInfoBarsAndRedraw:(BOOL)isAnimating;
90 // Set the max arrow height of the top infobar.
91 - (void)setMaxTopArrowHeight:(NSInteger)height;
93 // The height of all the info bars. Does not include the top arrow.
94 - (CGFloat)heightOfInfoBars;
98 #endif // CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_