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 - (BOOL
)shouldSuppressTopInfoBarTip
;
32 - (CGFloat
)infobarArrowX
;
35 // Controller for the infobar container view, which is the superview
36 // of all the infobar views. This class owns zero or more
37 // InfoBarControllers, which manage the infobar views. This class
38 // also receives tab strip model notifications and handles
39 // adding/removing infobars when needed.
40 @interface InfoBarContainerController
41 : NSViewController
<InfoBarContainerControllerBase
> {
43 // Needed to send resize messages when infobars are added or removed.
44 id
<ViewResizer
> resizeDelegate_
; // weak
46 // The WebContents we are currently showing infobars for.
47 content::WebContents
* currentWebContents_
; // weak
49 // Holds the InfoBarControllers currently owned by this container.
50 base::scoped_nsobject
<NSMutableArray
> infobarControllers_
;
52 // The C++ instance that bridges to the cross platform code.
53 scoped_ptr
<InfoBarContainerCocoa
> containerCocoa_
;
55 // If YES then the first info bar doesn't draw a tip.
56 BOOL shouldSuppressTopInfoBarTip_
;
58 // The x-position of the infobar arrow.
59 CGFloat infobarArrowX_
;
61 // If YES then an infobar animation is in progress.
65 @
property(nonatomic
, assign
) BOOL shouldSuppressTopInfoBarTip
;
66 @
property(nonatomic
, assign
) CGFloat infobarArrowX
;
68 - (id
)initWithResizeDelegate
:(id
<ViewResizer
>)resizeDelegate
;
70 // Modifies this container to display infobars for the given |contents|.
71 - (void)changeWebContents
:(content::WebContents
*)contents
;
73 // Stripped down version of TabStripModelObserverBridge:tabDetachedWithContents.
74 // Forwarded by BWC. Removes all infobars if |contents| is the current tab
76 - (void)tabDetachedWithContents
:(content::WebContents
*)contents
;
78 // Returns the amount of additional height the container view needs to draw the
79 // anti-spoofing tip. This is the total amount of overlap for all infobars.
80 - (CGFloat
)overlappingTipHeight
;
82 // Adds the given infobar.
83 - (void)addInfoBar
:(InfoBarCocoa
*)infobar
84 position
:(NSUInteger
)position
;
86 // Removes the given infobar.
87 - (void)removeInfoBar
:(InfoBarCocoa
*)infobar
;
89 // Positions the infobar views in the container view and notifies
90 // |browser_controller_| that it needs to resize the container view.
91 - (void)positionInfoBarsAndRedraw
:(BOOL
)isAnimating
;
93 // Set the max arrow height of the top infobar.
94 - (void)setMaxTopArrowHeight
:(NSInteger
)height
;
96 // The height of all the info bars. Does not include the top arrow.
97 - (CGFloat
)heightOfInfoBars
;
101 #endif // CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_