Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / views / tabs / media_indicator_button.h
blobe605cca9d28660feaa45294909b118c425204fe6
1 // Copyright 2014 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_VIEWS_TABS_MEDIA_INDICATOR_BUTTON_H_
6 #define CHROME_BROWSER_UI_VIEWS_TABS_MEDIA_INDICATOR_BUTTON_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/ui/tabs/tab_utils.h"
10 #include "ui/views/controls/button/image_button.h"
11 #include "ui/views/view_targeter_delegate.h"
13 class Tab;
15 namespace gfx {
16 class Animation;
17 class AnimationDelegate;
20 // This is an ImageButton subclass that serves as both the media indicator icon
21 // (audio, tab capture, etc.), and as a mute button. It is meant to only be
22 // used as a child view of Tab.
24 // When the indicator is transitioned to the audio playing or muting state, the
25 // button functionality is enabled and begins handling mouse events. Otherwise,
26 // this view behaves like an image and all mouse events will be handled by the
27 // Tab (its parent View).
28 class MediaIndicatorButton : public views::ImageButton,
29 public views::ViewTargeterDelegate {
30 public:
31 // The MediaIndicatorButton's class name.
32 static const char kViewClassName[];
34 explicit MediaIndicatorButton(Tab* parent_tab);
35 ~MediaIndicatorButton() override;
37 // Returns the current TabMediaState except, while the indicator image is
38 // fading out, returns the prior TabMediaState.
39 TabMediaState showing_media_state() const {
40 return showing_media_state_;
43 // Updates ImageButton images, starts fade animations, and
44 // activates/deactivates button functionality as appropriate.
45 void TransitionToMediaState(TabMediaState next_state);
47 // Determines whether the MediaIndicatorButton will be clickable for toggling
48 // muting. This should be called whenever the active/inactive state of a tab
49 // has changed. Internally, TransitionToMediaState() and OnBoundsChanged()
50 // calls this when the TabMediaState or the bounds have changed.
51 void UpdateEnabledForMuteToggle();
53 protected:
54 // views::View:
55 const char* GetClassName() const override;
56 View* GetTooltipHandlerForPoint(const gfx::Point& point) override;
57 bool OnMousePressed(const ui::MouseEvent& event) override;
58 bool OnMouseDragged(const ui::MouseEvent& event) override;
59 void OnMouseEntered(const ui::MouseEvent& event) override;
60 void OnMouseMoved(const ui::MouseEvent& event) override;
61 void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
62 void OnPaint(gfx::Canvas* canvas) override;
64 // views::ViewTargeterDelegate
65 bool DoesIntersectRect(const View* target,
66 const gfx::Rect& rect) const override;
68 // views::Button:
69 void NotifyClick(const ui::Event& event) override;
71 // views::CustomButton:
72 bool IsTriggerableEvent(const ui::Event& event) override;
74 private:
75 class FadeAnimationDelegate;
77 // Returns the tab (parent view) of this MediaIndicatorButton.
78 Tab* GetTab() const;
80 Tab* const parent_tab_;
82 TabMediaState media_state_;
84 // Media indicator fade-in/out animation (i.e., only on show/hide, not a
85 // continuous animation).
86 scoped_ptr<gfx::AnimationDelegate> fade_animation_delegate_;
87 scoped_ptr<gfx::Animation> fade_animation_;
88 TabMediaState showing_media_state_;
90 DISALLOW_COPY_AND_ASSIGN(MediaIndicatorButton);
93 #endif // CHROME_BROWSER_UI_VIEWS_TABS_MEDIA_INDICATOR_BUTTON_H_