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"
15 class ExtensionAction
;
16 @
class ExtensionActionContextMenuController
;
17 class ExtensionActionIconFactoryBridge
;
19 namespace extensions
{
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
> {
30 // Bridge to proxy Chrome notifications to the Obj-C class as well as load the
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.
43 // Whether the button is currently being dragged.
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:|.
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
64 - (void)setFrame
:(NSRect
)frameRect animate
:(BOOL
)animate
;
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
;
80 @interface BrowserActionCell
: ImageButtonCell
{
82 // The current tab ID used when drawing the cell.
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
;
94 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTION_BUTTON_H_