OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTION_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTION_BUTTON_H_ |
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTION_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTION_BUTTON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
10 | 10 |
11 #import "base/memory/scoped_nsobject.h" | 11 #import "base/memory/scoped_nsobject.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #import "chrome/browser/ui/cocoa/gradient_button_cell.h" | 13 #import "chrome/browser/ui/cocoa/gradient_button_cell.h" |
14 | 14 |
15 class Extension; | |
16 class ExtensionAction; | 15 class ExtensionAction; |
17 class ExtensionImageTrackerBridge; | 16 class ExtensionImageTrackerBridge; |
18 class Profile; | 17 class Profile; |
19 | 18 |
| 19 namespace extensions { |
| 20 class Extension; |
| 21 } |
| 22 |
20 // Fired when the Browser Action's state has changed. Usually the image needs to | 23 // Fired when the Browser Action's state has changed. Usually the image needs to |
21 // be updated. | 24 // be updated. |
22 extern NSString* const kBrowserActionButtonUpdatedNotification; | 25 extern NSString* const kBrowserActionButtonUpdatedNotification; |
23 | 26 |
24 // Fired on each drag event while the user is moving the button. | 27 // Fired on each drag event while the user is moving the button. |
25 extern NSString* const kBrowserActionButtonDraggingNotification; | 28 extern NSString* const kBrowserActionButtonDraggingNotification; |
26 // Fired when the user drops the button. | 29 // Fired when the user drops the button. |
27 extern NSString* const kBrowserActionButtonDragEndNotification; | 30 extern NSString* const kBrowserActionButtonDragEndNotification; |
28 | 31 |
29 @interface BrowserActionButton : NSButton { | 32 @interface BrowserActionButton : NSButton { |
30 @private | 33 @private |
31 // Bridge to proxy Chrome notifications to the Obj-C class as well as load the | 34 // Bridge to proxy Chrome notifications to the Obj-C class as well as load the |
32 // extension's icon. | 35 // extension's icon. |
33 scoped_ptr<ExtensionImageTrackerBridge> imageLoadingBridge_; | 36 scoped_ptr<ExtensionImageTrackerBridge> imageLoadingBridge_; |
34 | 37 |
35 // The default icon of the Button. | 38 // The default icon of the Button. |
36 scoped_nsobject<NSImage> defaultIcon_; | 39 scoped_nsobject<NSImage> defaultIcon_; |
37 | 40 |
38 // The icon specific to the active tab. | 41 // The icon specific to the active tab. |
39 scoped_nsobject<NSImage> tabSpecificIcon_; | 42 scoped_nsobject<NSImage> tabSpecificIcon_; |
40 | 43 |
41 // Used to move the button and query whether a button is currently animating. | 44 // Used to move the button and query whether a button is currently animating. |
42 scoped_nsobject<NSViewAnimation> moveAnimation_; | 45 scoped_nsobject<NSViewAnimation> moveAnimation_; |
43 | 46 |
44 // The extension for this button. Weak. | 47 // The extension for this button. Weak. |
45 const Extension* extension_; | 48 const extensions::Extension* extension_; |
46 | 49 |
47 // The ID of the active tab. | 50 // The ID of the active tab. |
48 int tabId_; | 51 int tabId_; |
49 | 52 |
50 // Whether the button is currently being dragged. | 53 // Whether the button is currently being dragged. |
51 BOOL isBeingDragged_; | 54 BOOL isBeingDragged_; |
52 | 55 |
53 // Drag events could be intercepted by other buttons, so to make sure that | 56 // Drag events could be intercepted by other buttons, so to make sure that |
54 // this is the only button moving if it ends up being dragged. This is set to | 57 // this is the only button moving if it ends up being dragged. This is set to |
55 // YES upon |mouseDown:|. | 58 // YES upon |mouseDown:|. |
56 BOOL dragCouldStart_; | 59 BOOL dragCouldStart_; |
57 } | 60 } |
58 | 61 |
59 - (id)initWithFrame:(NSRect)frame | 62 - (id)initWithFrame:(NSRect)frame |
60 extension:(const Extension*)extension | 63 extension:(const extensions::Extension*)extension |
61 profile:(Profile*)profile | 64 profile:(Profile*)profile |
62 tabId:(int)tabId; | 65 tabId:(int)tabId; |
63 | 66 |
64 - (void)setFrame:(NSRect)frameRect animate:(BOOL)animate; | 67 - (void)setFrame:(NSRect)frameRect animate:(BOOL)animate; |
65 | 68 |
66 - (void)setDefaultIcon:(NSImage*)image; | 69 - (void)setDefaultIcon:(NSImage*)image; |
67 | 70 |
68 - (void)setTabSpecificIcon:(NSImage*)image; | 71 - (void)setTabSpecificIcon:(NSImage*)image; |
69 | 72 |
70 - (void)updateState; | 73 - (void)updateState; |
71 | 74 |
72 - (BOOL)isAnimating; | 75 - (BOOL)isAnimating; |
73 | 76 |
74 // Returns a pointer to an autoreleased NSImage with the badge, shadow and | 77 // Returns a pointer to an autoreleased NSImage with the badge, shadow and |
75 // cell image drawn into it. | 78 // cell image drawn into it. |
76 - (NSImage*)compositedImage; | 79 - (NSImage*)compositedImage; |
77 | 80 |
78 @property(readonly, nonatomic) BOOL isBeingDragged; | 81 @property(readonly, nonatomic) BOOL isBeingDragged; |
79 @property(readonly, nonatomic) const Extension* extension; | 82 @property(readonly, nonatomic) const extensions::Extension* extension; |
80 @property(readwrite, nonatomic) int tabId; | 83 @property(readwrite, nonatomic) int tabId; |
81 | 84 |
82 @end | 85 @end |
83 | 86 |
84 @interface BrowserActionCell : GradientButtonCell { | 87 @interface BrowserActionCell : GradientButtonCell { |
85 @private | 88 @private |
86 // The current tab ID used when drawing the cell. | 89 // The current tab ID used when drawing the cell. |
87 int tabId_; | 90 int tabId_; |
88 | 91 |
89 // The action we're drawing the cell for. Weak. | 92 // The action we're drawing the cell for. Weak. |
90 ExtensionAction* extensionAction_; | 93 ExtensionAction* extensionAction_; |
91 } | 94 } |
92 | 95 |
93 @property(readwrite, nonatomic) int tabId; | 96 @property(readwrite, nonatomic) int tabId; |
94 @property(readwrite, nonatomic) ExtensionAction* extensionAction; | 97 @property(readwrite, nonatomic) ExtensionAction* extensionAction; |
95 | 98 |
96 @end | 99 @end |
97 | 100 |
98 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTION_BUTTON_H_ | 101 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTION_BUTTON_H_ |
OLD | NEW |