Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: chrome/browser/ui/cocoa/extensions/browser_action_button.h

Issue 670463004: Make a platform-independent ToolbarActionViewController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/extensions/browser_action_button.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include <string>
11
10 #import "base/mac/scoped_nsobject.h" 12 #import "base/mac/scoped_nsobject.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
12 #import "chrome/browser/ui/cocoa/image_button_cell.h" 14 #import "chrome/browser/ui/cocoa/image_button_cell.h"
13 15
14 class Browser; 16 class Browser;
15 class ExtensionAction; 17 @class BrowserActionsController;
16 @class ExtensionActionContextMenuController; 18 @class ExtensionActionContextMenuController;
17 class ExtensionActionIconFactoryBridge; 19 class ToolbarActionViewController;
18 20 class ToolbarActionViewDelegateBridge;
19 namespace extensions {
20 class Extension;
21 }
22 21
23 // Fired on each drag event while the user is moving the button. 22 // Fired on each drag event while the user is moving the button.
24 extern NSString* const kBrowserActionButtonDraggingNotification; 23 extern NSString* const kBrowserActionButtonDraggingNotification;
25 // Fired when the user drops the button. 24 // Fired when the user drops the button.
26 extern NSString* const kBrowserActionButtonDragEndNotification; 25 extern NSString* const kBrowserActionButtonDragEndNotification;
27 26
28 @interface BrowserActionButton : NSButton<NSMenuDelegate> { 27 @interface BrowserActionButton : NSButton<NSMenuDelegate> {
29 @private 28 @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_;
33
34 // Used to move the button and query whether a button is currently animating. 29 // Used to move the button and query whether a button is currently animating.
35 base::scoped_nsobject<NSViewAnimation> moveAnimation_; 30 base::scoped_nsobject<NSViewAnimation> moveAnimation_;
36 31
37 // The extension for this button. Weak. 32 // The bridge between the view controller and this object.
38 const extensions::Extension* extension_; 33 scoped_ptr<ToolbarActionViewDelegateBridge> viewControllerDelegate_;
39 34
40 // The ID of the active tab. 35 // The controller that handles most non-view logic.
41 int tabId_; 36 scoped_ptr<ToolbarActionViewController> viewController_;
37
38 // The controller for the browser actions bar that owns this button. Weak.
39 BrowserActionsController* browserActionsController_;
42 40
43 // Whether the button is currently being dragged. 41 // Whether the button is currently being dragged.
44 BOOL isBeingDragged_; 42 BOOL isBeingDragged_;
45 43
46 // Drag events could be intercepted by other buttons, so to make sure that 44 // 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 45 // this is the only button moving if it ends up being dragged. This is set to
48 // YES upon |mouseDown:|. 46 // YES upon |mouseDown:|.
49 BOOL dragCouldStart_; 47 BOOL dragCouldStart_;
50 48
51 // The point where the mouse down event occurred. Used to prevent a drag from 49 // The point where the mouse down event occurred. Used to prevent a drag from
52 // starting until it moves at least kMinimumDragDistance. 50 // starting until it moves at least kMinimumDragDistance.
53 NSPoint dragStartPoint_; 51 NSPoint dragStartPoint_;
54 52
55 base::scoped_nsobject< 53 base::scoped_nsobject<
56 ExtensionActionContextMenuController> contextMenuController_; 54 ExtensionActionContextMenuController> contextMenuController_;
57 } 55 }
58 56
57 // Init the button with the frame. Takes ownership of |viewController| and
58 // |menuController|, does not own |controller|.
59 - (id)initWithFrame:(NSRect)frame 59 - (id)initWithFrame:(NSRect)frame
60 extension:(const extensions::Extension*)extension 60 viewController:(scoped_ptr<ToolbarActionViewController>)viewController
61 browser:(Browser*)browser 61 controller:(BrowserActionsController*)controller
62 tabId:(int)tabId; 62 menuController:(ExtensionActionContextMenuController*)menuController;
63 63
64 - (void)setFrame:(NSRect)frameRect animate:(BOOL)animate; 64 - (void)setFrame:(NSRect)frameRect animate:(BOOL)animate;
65 65
66 - (void)updateState; 66 - (void)updateState;
67 67
68 - (BOOL)isAnimating; 68 - (BOOL)isAnimating;
69 69
70 - (ToolbarActionViewController*)viewController;
71
70 // Returns a pointer to an autoreleased NSImage with the badge, shadow and 72 // Returns a pointer to an autoreleased NSImage with the badge, shadow and
71 // cell image drawn into it. 73 // cell image drawn into it.
72 - (NSImage*)compositedImage; 74 - (NSImage*)compositedImage;
73 75
74 @property(readonly, nonatomic) BOOL isBeingDragged; 76 @property(readonly, nonatomic) BOOL isBeingDragged;
75 @property(readonly, nonatomic) const extensions::Extension* extension;
76 @property(readwrite, nonatomic) int tabId;
77 77
78 @end 78 @end
79 79
80 @interface BrowserActionCell : ImageButtonCell { 80 @interface BrowserActionCell : ImageButtonCell {
81 @private 81 @private
82 // The current tab ID used when drawing the cell. 82 // The controller for the browser actions bar that owns the button. Weak.
83 int tabId_; 83 BrowserActionsController* browserActionsController_;
84 84
85 // The action we're drawing the cell for. Weak. 85 // The view controller for the parent button. Weak.
86 ExtensionAction* extensionAction_; 86 ToolbarActionViewController* viewController_;
87 } 87 }
88 88
89 @property(readwrite, nonatomic) int tabId; 89 @property(assign, nonatomic)
90 @property(readwrite, nonatomic) ExtensionAction* extensionAction; 90 BrowserActionsController* browserActionsController;
91 @property(readwrite, nonatomic) ToolbarActionViewController* viewController;
91 92
92 @end 93 @end
93 94
94 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTION_BUTTON_H_ 95 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTION_BUTTON_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/extensions/browser_action_button.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698