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

Unified 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, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/tabs/media_indicator_button.h
diff --git a/chrome/browser/ui/cocoa/tabs/media_indicator_view.h b/chrome/browser/ui/cocoa/tabs/media_indicator_button.h
similarity index 13%
rename from chrome/browser/ui/cocoa/tabs/media_indicator_view.h
rename to chrome/browser/ui/cocoa/tabs/media_indicator_button.h
index 9dd91ebdeff75ae424fbe23f1eea949fba8b5089..61f21a8548b7a24298aa0c8e98b24028f37fc9f2 100644
--- a/chrome/browser/ui/cocoa/tabs/media_indicator_view.h
+++ b/chrome/browser/ui/cocoa/tabs/media_indicator_button.h
@@ -2,46 +2,76 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_COCOA_TABS_MEDIA_INDICATOR_VIEW_H_
-#define CHROME_BROWSER_UI_COCOA_TABS_MEDIA_INDICATOR_VIEW_H_
-
-#import <Cocoa/Cocoa.h>
+#ifndef CHROME_BROWSER_UI_COCOA_TABS_MEDIA_INDICATOR_BUTTON_H_
+#define CHROME_BROWSER_UI_COCOA_TABS_MEDIA_INDICATOR_BUTTON_H_
+#import "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/tabs/tab_utils.h"
-
-class MediaIndicatorViewAnimationDelegate;
+#import "ui/base/cocoa/hover_button.h"
namespace gfx {
class Animation;
+class AnimationDelegate;
} // namespace gfx
-@interface MediaIndicatorView : NSImageView {
+// This is an HoverButton subclass that serves as both the media indicator icon
+// (audio, tab capture, etc.), and as a mute button. It is meant to only be
+// used as a subview of TabView.
+//
+// When the indicator is transitioned to the audio playing or muting state, the
+// button functionality is enabled and begins handling mouse events. Otherwise,
+// this view behaves like an image and all mouse events will be handled by the
+// its superview.
+//
+// Note: Send the |-setClickTarget:withAction:| message instead of the
+// |-setTarget:| and |-setAction:| messages to be notified of button clicks.
+@interface MediaIndicatorButton : HoverButton {
@private
+ class FadeAnimationDelegate;
+
+ // Current TabMediaState. When animating fade-in/out, this reflects the
+ // indicator state at the end of the animation.
TabMediaState mediaState_;
- scoped_ptr<MediaIndicatorViewAnimationDelegate> delegate_;
- scoped_ptr<gfx::Animation> animation_;
- TabMediaState animatingMediaState_;
+
+ // Media indicator fade-in/out animation (i.e., only on show/hide, not a
+ // continuous animation).
+ scoped_ptr<gfx::AnimationDelegate> fadeAnimationDelegate_;
+ scoped_ptr<gfx::Animation> fadeAnimation_;
+ TabMediaState showingMediaState_;
+
+ // Target and action invoked whenever a fade-in/out animation completes. This
+ // is used by TabController to layout the TabView after an indicator has
+ // completely faded out.
+ __weak id animationDoneTarget_;
+ SEL animationDoneAction_;
+
+ // The image to show when the mouse hovers over the button.
+ base::scoped_nsobject<NSImage> affordanceImage_;
+
+ // Target and action invoked whenever an enabled button is clicked.
+ __weak id clickTarget_;
+ SEL clickAction_;
}
-@property(readonly, nonatomic) TabMediaState mediaState;
-@property(readonly, nonatomic) TabMediaState animatingMediaState;
+@property(readonly, nonatomic) TabMediaState showingMediaState;
-// Initialize a new MediaIndicatorView in TAB_MEDIA_STATE_NONE (i.e., a
+// Initialize a new MediaIndicatorButton in TAB_MEDIA_STATE_NONE (i.e., a
// non-active indicator).
- (id)init;
-// Starts the animation to transition the indicator to the new |mediaState|.
-- (void)updateIndicator:(TabMediaState)mediaState;
+// Updates button images, starts fade animations, and activates/deactivates
+// button functionality as appropriate.
+- (void)transitionToMediaState:(TabMediaState)nextState;
-// Register a callback to be invoked whenever the animation completes.
-- (void)setAnimationDoneCallbackObject:(id)anObject withSelector:(SEL)selector;
+// Register a message be sent to |target| whenever fade animations complete. A
+// weak reference on |target| is held.
+- (void)setAnimationDoneTarget:(id)target withAction:(SEL)action;
-@end
+// Request a message be sent to |target| whenever the enabled button has been
+// clicked. A weak reference on |target| is held.
+- (void)setClickTarget:(id)target withAction:(SEL)action;
-@interface MediaIndicatorView(TestingAPI)
-// Turns off animations for logic testing.
-- (void)disableAnimations;
@end
-#endif // CHROME_BROWSER_UI_COCOA_TABS_MEDIA_INDICATOR_VIEW_H_
+#endif // CHROME_BROWSER_UI_COCOA_TABS_MEDIA_INDICATOR_BUTTON_H_

Powered by Google App Engine
This is Rietveld 408576698