[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / extensions / browser_action_button.h
blob66827da58c3f3e5a16fbf67f7bfe285fd9d6eb92
1 // Copyright (c) 2012 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_ACTION_BUTTON_H_
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTION_BUTTON_H_
8 #import <Cocoa/Cocoa.h>
10 #import "base/mac/scoped_nsobject.h"
11 #include "base/memory/scoped_ptr.h"
12 #import "chrome/browser/ui/cocoa/image_button_cell.h"
14 class Browser;
15 class ExtensionAction;
16 @class ExtensionActionContextMenuController;
17 class ExtensionActionIconFactoryBridge;
19 namespace extensions {
20 class Extension;
23 // Fired on each drag event while the user is moving the button.
24 extern NSString* const kBrowserActionButtonDraggingNotification;
25 // Fired when the user drops the button.
26 extern NSString* const kBrowserActionButtonDragEndNotification;
28 @interface BrowserActionButton : NSButton<NSMenuDelegate> {
29 @private
30 // Bridge to proxy Chrome notifications to the Obj-C class as well as load the
31 // extension's icon.
32 scoped_ptr<ExtensionActionIconFactoryBridge> iconFactoryBridge_;
34 // Used to move the button and query whether a button is currently animating.
35 base::scoped_nsobject<NSViewAnimation> moveAnimation_;
37 // The extension for this button. Weak.
38 const extensions::Extension* extension_;
40 // The ID of the active tab.
41 int tabId_;
43 // Whether the button is currently being dragged.
44 BOOL isBeingDragged_;
46 // Drag events could be intercepted by other buttons, so to make sure that
47 // this is the only button moving if it ends up being dragged. This is set to
48 // YES upon |mouseDown:|.
49 BOOL dragCouldStart_;
51 // The point where the mouse down event occurred. Used to prevent a drag from
52 // starting until it moves at least kMinimumDragDistance.
53 NSPoint dragStartPoint_;
55 base::scoped_nsobject<
56 ExtensionActionContextMenuController> contextMenuController_;
59 - (id)initWithFrame:(NSRect)frame
60 extension:(const extensions::Extension*)extension
61 browser:(Browser*)browser
62 tabId:(int)tabId;
64 - (void)setFrame:(NSRect)frameRect animate:(BOOL)animate;
66 - (void)updateState;
68 - (BOOL)isAnimating;
70 // Returns a pointer to an autoreleased NSImage with the badge, shadow and
71 // cell image drawn into it.
72 - (NSImage*)compositedImage;
74 @property(readonly, nonatomic) BOOL isBeingDragged;
75 @property(readonly, nonatomic) const extensions::Extension* extension;
76 @property(readwrite, nonatomic) int tabId;
78 @end
80 @interface BrowserActionCell : ImageButtonCell {
81 @private
82 // The current tab ID used when drawing the cell.
83 int tabId_;
85 // The action we're drawing the cell for. Weak.
86 ExtensionAction* extensionAction_;
89 @property(readwrite, nonatomic) int tabId;
90 @property(readwrite, nonatomic) ExtensionAction* extensionAction;
92 @end
94 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTION_BUTTON_H_