Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / tabs / media_indicator_button_cocoa.h
blob8216bc8430b01b38c48c03ed70032225408d6d23
1 // Copyright 2013 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_TABS_MEDIA_INDICATOR_BUTTON_COCOA_H_
6 #define CHROME_BROWSER_UI_COCOA_TABS_MEDIA_INDICATOR_BUTTON_COCOA_H_
8 #import "base/mac/scoped_nsobject.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/ui/tabs/tab_utils.h"
11 #import "ui/base/cocoa/hover_button.h"
13 namespace gfx {
14 class Animation;
15 class AnimationDelegate;
16 } // namespace gfx
18 // This is an HoverButton subclass that serves as both the media indicator icon
19 // (audio, tab capture, etc.), and as a mute button. It is meant to only be
20 // used as a subview of TabView.
22 // When the indicator is transitioned to the audio playing or muting state, the
23 // button functionality is enabled and begins handling mouse events. Otherwise,
24 // this view behaves like an image and all mouse events will be handled by the
25 // its superview.
27 // Note: Send the |-setClickTarget:withAction:| message instead of the
28 // |-setTarget:| and |-setAction:| messages to be notified of button clicks.
29 @interface MediaIndicatorButton : HoverButton {
30 @private
31 class FadeAnimationDelegate;
33 // Current TabMediaState. When animating fade-in/out, this reflects the
34 // indicator state at the end of the animation.
35 TabMediaState mediaState_;
37 // Media indicator fade-in/out animation (i.e., only on show/hide, not a
38 // continuous animation).
39 scoped_ptr<gfx::AnimationDelegate> fadeAnimationDelegate_;
40 scoped_ptr<gfx::Animation> fadeAnimation_;
41 TabMediaState showingMediaState_;
43 // Target and action invoked whenever a fade-in/out animation completes. This
44 // is used by TabController to layout the TabView after an indicator has
45 // completely faded out.
46 __weak id animationDoneTarget_;
47 SEL animationDoneAction_;
49 // The image to show when the mouse hovers over the button.
50 base::scoped_nsobject<NSImage> affordanceImage_;
52 // Target and action invoked whenever an enabled button is clicked.
53 __weak id clickTarget_;
54 SEL clickAction_;
57 @property(readonly, nonatomic) TabMediaState showingMediaState;
59 // Initialize a new MediaIndicatorButton in TAB_MEDIA_STATE_NONE (i.e., a
60 // non-active indicator).
61 - (id)init;
63 // Updates button images, starts fade animations, and activates/deactivates
64 // button functionality as appropriate.
65 - (void)transitionToMediaState:(TabMediaState)nextState;
67 // Determines whether the MediaIndicatorButtonCocoa will be clickable for
68 // toggling muting. This should be called whenever the frame of this view is
69 // changed, and also whenever the active/inactive state of the tab has changed.
70 // Internally, |-transitionToMediaState:| will call this.
71 - (void)updateEnabledForMuteToggle;
73 // Register a message be sent to |target| whenever fade animations complete. A
74 // weak reference on |target| is held.
75 - (void)setAnimationDoneTarget:(id)target withAction:(SEL)action;
77 // Request a message be sent to |target| whenever the enabled button has been
78 // clicked. A weak reference on |target| is held.
79 - (void)setClickTarget:(id)target withAction:(SEL)action;
81 @end
83 #endif // CHROME_BROWSER_UI_COCOA_TABS_MEDIA_INDICATOR_BUTTON_COCOA_H_