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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/media_indicator_button.h

Issue 688523002: [Cocoa] Tab audio mute control, behind a switch (off by default). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Prevent TabStripController from unconditionally causing creation of MediaIndicatorButton. 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_TABS_MEDIA_INDICATOR_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_COCOA_TABS_MEDIA_INDICATOR_BUTTON_H_
6 #define CHROME_BROWSER_UI_COCOA_TABS_MEDIA_INDICATOR_VIEW_H_ 6 #define CHROME_BROWSER_UI_COCOA_TABS_MEDIA_INDICATOR_BUTTON_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import "base/mac/scoped_nsobject.h"
9
10 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/ui/tabs/tab_utils.h" 10 #include "chrome/browser/ui/tabs/tab_utils.h"
12 11 #import "ui/base/cocoa/hover_button.h"
13 class MediaIndicatorViewAnimationDelegate;
14 12
15 namespace gfx { 13 namespace gfx {
16 class Animation; 14 class Animation;
15 class AnimationDelegate;
17 } // namespace gfx 16 } // namespace gfx
18 17
19 @interface MediaIndicatorView : NSImageView { 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.
21 //
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.
26 //
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 {
20 @private 30 @private
31 class FadeAnimationDelegate;
32
33 // Current TabMediaState. When animating fade-in/out, this reflects the
34 // indicator state at the end of the animation.
21 TabMediaState mediaState_; 35 TabMediaState mediaState_;
22 scoped_ptr<MediaIndicatorViewAnimationDelegate> delegate_; 36
23 scoped_ptr<gfx::Animation> animation_; 37 // Media indicator fade-in/out animation (i.e., only on show/hide, not a
24 TabMediaState animatingMediaState_; 38 // continuous animation).
39 scoped_ptr<gfx::AnimationDelegate> fadeAnimationDelegate_;
40 scoped_ptr<gfx::Animation> fadeAnimation_;
41 TabMediaState showingMediaState_;
42
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_;
48
49 // The image to show when the mouse hovers over the button.
50 base::scoped_nsobject<NSImage> affordanceImage_;
51
52 // Target and action invoked whenever an enabled button is clicked.
53 __weak id clickTarget_;
54 SEL clickAction_;
25 } 55 }
26 56
27 @property(readonly, nonatomic) TabMediaState mediaState; 57 @property(readonly, nonatomic) TabMediaState showingMediaState;
28 @property(readonly, nonatomic) TabMediaState animatingMediaState;
29 58
30 // Initialize a new MediaIndicatorView in TAB_MEDIA_STATE_NONE (i.e., a 59 // Initialize a new MediaIndicatorButton in TAB_MEDIA_STATE_NONE (i.e., a
31 // non-active indicator). 60 // non-active indicator).
32 - (id)init; 61 - (id)init;
33 62
34 // Starts the animation to transition the indicator to the new |mediaState|. 63 // Updates button images, starts fade animations, and activates/deactivates
35 - (void)updateIndicator:(TabMediaState)mediaState; 64 // button functionality as appropriate.
65 - (void)transitionToMediaState:(TabMediaState)nextState;
36 66
37 // Register a callback to be invoked whenever the animation completes. 67 // Register a message be sent to |target| whenever fade animations complete. A
38 - (void)setAnimationDoneCallbackObject:(id)anObject withSelector:(SEL)selector; 68 // weak reference on |target| is held.
69 - (void)setAnimationDoneTarget:(id)target withAction:(SEL)action;
70
71 // Request a message be sent to |target| whenever the enabled button has been
72 // clicked. A weak reference on |target| is held.
73 - (void)setClickTarget:(id)target withAction:(SEL)action;
39 74
40 @end 75 @end
41 76
42 @interface MediaIndicatorView(TestingAPI) 77 #endif // CHROME_BROWSER_UI_COCOA_TABS_MEDIA_INDICATOR_BUTTON_H_
43 // Turns off animations for logic testing.
44 - (void)disableAnimations;
45 @end
46
47 #endif // CHROME_BROWSER_UI_COCOA_TABS_MEDIA_INDICATOR_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698