[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / extensions / browser_actions_controller.h
blobedb3471cf431465295a33e637b1f02ee6244e9a1
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_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_
8 #import <Cocoa/Cocoa.h>
10 #import "base/mac/scoped_nsobject.h"
11 #include "base/memory/scoped_ptr.h"
13 class Browser;
14 @class BrowserActionButton;
15 @class BrowserActionsContainerView;
16 @class ExtensionPopupController;
17 class ExtensionServiceObserverBridge;
18 @class MenuButton;
19 class Profile;
21 namespace extensions {
22 class Extension;
23 class ExtensionToolbarModel;
26 // Sent when the visibility of the Browser Actions changes.
27 extern NSString* const kBrowserActionVisibilityChangedNotification;
29 // Handles state and provides an interface for controlling the Browser Actions
30 // container within the Toolbar.
31 @interface BrowserActionsController : NSObject<NSMenuDelegate> {
32 @private
33 // Reference to the current browser. Weak.
34 Browser* browser_;
36 // The view from Toolbar.xib we'll be rendering our browser actions in. Weak.
37 BrowserActionsContainerView* containerView_;
39 // The current profile. Weak.
40 Profile* profile_;
42 // The model that tracks the order of the toolbar icons. Weak.
43 extensions::ExtensionToolbarModel* toolbarModel_;
45 // The observer for the ExtensionService we're getting events from.
46 scoped_ptr<ExtensionServiceObserverBridge> observer_;
48 // A dictionary of Extension ID -> BrowserActionButton pairs representing the
49 // buttons present in the container view. The ID is a string unique to each
50 // extension.
51 base::scoped_nsobject<NSMutableDictionary> buttons_;
53 // Array of hidden buttons in the correct order in which the user specified.
54 base::scoped_nsobject<NSMutableArray> hiddenButtons_;
56 // The currently running chevron animation (fade in/out).
57 base::scoped_nsobject<NSViewAnimation> chevronAnimation_;
59 // The chevron button used when Browser Actions are hidden.
60 base::scoped_nsobject<MenuButton> chevronMenuButton_;
62 // The Browser Actions overflow menu.
63 base::scoped_nsobject<NSMenu> overflowMenu_;
66 @property(readonly, nonatomic) BrowserActionsContainerView* containerView;
68 // Initializes the controller given the current browser and container view that
69 // will hold the browser action buttons.
70 - (id)initWithBrowser:(Browser*)browser
71 containerView:(BrowserActionsContainerView*)container;
73 // Update the display of all buttons.
74 - (void)update;
76 // Returns the current number of browser action buttons within the container,
77 // whether or not they are displayed.
78 - (NSUInteger)buttonCount;
80 // Returns the current number of browser action buttons displayed in the
81 // container.
82 - (NSUInteger)visibleButtonCount;
84 // Resizes the container given the number of visible buttons, taking into
85 // account the size of the grippy. Also updates the persistent width preference.
86 - (void)resizeContainerAndAnimate:(BOOL)animate;
88 // Returns the NSView for the action button associated with an extension.
89 - (NSView*)browserActionViewForExtension:(
90 const extensions::Extension*)extension;
92 // Returns the saved width determined by the number of shown Browser Actions
93 // preference property. If no preference is found, then the width for the
94 // container is returned as if all buttons are shown.
95 - (CGFloat)savedWidth;
97 // Returns where the popup arrow should point to for a given Browser Action. If
98 // it is passed an extension that is not a Browser Action, then it will return
99 // NSZeroPoint.
100 - (NSPoint)popupPointForBrowserAction:(const extensions::Extension*)extension;
102 // Returns whether the chevron button is currently hidden or in the process of
103 // being hidden (fading out). Will return NO if it is not hidden or is in the
104 // process of fading in.
105 - (BOOL)chevronIsHidden;
107 // Activates the browser action for the extension that has the given id.
108 - (void)activateBrowserAction:(const std::string&)extension_id;
110 @end // @interface BrowserActionsController
112 @interface BrowserActionsController(TestingAPI)
113 - (NSButton*)buttonWithIndex:(NSUInteger)index;
114 @end
116 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_