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
;
18 class InfoBarDelegate
;
25 // Protocol for basic container methods, as needed by an InfoBarController.
26 // This protocol exists to make mocking easier in unittests.
27 @protocol InfoBarContainerControllerBase
28 - (BrowserWindowController
*)browserWindowController
;
29 - (BOOL
)shouldSuppressTopInfoBarTip
;
30 - (CGFloat
)infobarArrowX
;
33 // Controller for the infobar container view, which is the superview
34 // of all the infobar views. This class owns zero or more
35 // InfoBarControllers, which manage the infobar views. This class
36 // also receives tab strip model notifications and handles
37 // adding/removing infobars when needed.
38 @interface InfoBarContainerController
39 : NSViewController
<InfoBarContainerControllerBase
> {
41 // Needed to send resize messages when infobars are added or removed.
42 id
<ViewResizer
> resizeDelegate_
; // weak
44 // The WebContents we are currently showing infobars for.
45 content::WebContents
* currentWebContents_
; // weak
47 // Holds the InfoBarControllers currently owned by this container.
48 base::scoped_nsobject
<NSMutableArray
> infobarControllers_
;
50 // The C++ instance that bridges to the cross platform code.
51 scoped_ptr
<InfoBarContainerCocoa
> containerCocoa_
;
53 // If YES then the first info bar doesn't draw a tip.
54 BOOL shouldSuppressTopInfoBarTip_
;
56 // If YES then an infobar animation is in progress.
59 // The last overlap tip height. This is used to ensure that the info bar
60 // position is updated if the infobar height doesn't change but the overlap
62 int oldOverlappingTipHeight_
;
65 @
property(nonatomic
, assign
) BOOL shouldSuppressTopInfoBarTip
;
67 - (id
)initWithResizeDelegate
:(id
<ViewResizer
>)resizeDelegate
;
69 // Modifies this container to display infobars for the given |contents|.
70 - (void)changeWebContents
:(content::WebContents
*)contents
;
72 // Stripped down version of TabStripModelObserverBridge:tabDetachedWithContents.
73 // Forwarded by BWC. Removes all infobars if |contents| is the current tab
75 - (void)tabDetachedWithContents
:(content::WebContents
*)contents
;
77 // Returns the amount of additional height the container view needs to draw the
78 // anti-spoofing tip. This is the total amount of overlap for all infobars.
79 - (CGFloat
)overlappingTipHeight
;
81 // Adds the given infobar.
82 - (void)addInfoBar
:(InfoBarCocoa
*)infobar
83 position
:(NSUInteger
)position
;
85 // Removes the given infobar.
86 - (void)removeInfoBar
:(InfoBarCocoa
*)infobar
;
88 // Positions the infobar views in the container view and notifies
89 // |browser_controller_| that it needs to resize the container view.
90 - (void)positionInfoBarsAndRedraw
:(BOOL
)isAnimating
;
94 #endif // CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_