[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / infobars / infobar_container_controller.h
blob59431444d15a32d1faf104fd08450cfa59295479
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;
16 class InfoBarCocoa;
17 class InfoBarContainerCocoa;
18 class TabStripModel;
20 namespace content {
21 class WebContents;
24 namespace infobars {
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;
34 @end
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> {
43 @private
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.
60 BOOL isAnimating_;
62 // The last overlap tip height. This is used to ensure that the info bar
63 // position is updated if the infobar height doesn't change but the overlap
64 // does change.
65 int oldOverlappingTipHeight_;
68 @property(nonatomic, assign) BOOL shouldSuppressTopInfoBarTip;
70 - (id)initWithResizeDelegate:(id<ViewResizer>)resizeDelegate;
72 // Modifies this container to display infobars for the given |contents|.
73 - (void)changeWebContents:(content::WebContents*)contents;
75 // Stripped down version of TabStripModelObserverBridge:tabDetachedWithContents.
76 // Forwarded by BWC. Removes all infobars if |contents| is the current tab
77 // contents.
78 - (void)tabDetachedWithContents:(content::WebContents*)contents;
80 // Returns the amount of additional height the container view needs to draw the
81 // anti-spoofing tip. This is the total amount of overlap for all infobars.
82 - (CGFloat)overlappingTipHeight;
84 // Adds the given infobar.
85 - (void)addInfoBar:(InfoBarCocoa*)infobar
86 position:(NSUInteger)position;
88 // Removes the given infobar.
89 - (void)removeInfoBar:(InfoBarCocoa*)infobar;
91 // Positions the infobar views in the container view and notifies
92 // |browser_controller_| that it needs to resize the container view.
93 - (void)positionInfoBarsAndRedraw:(BOOL)isAnimating;
95 @end
97 #endif // CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_CONTAINER_CONTROLLER_H_