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