OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/views/tabs/media_indicator_button.h" | 5 #include "chrome/browser/ui/views/tabs/media_indicator_button.h" |
6 | 6 |
7 #include "chrome/browser/ui/views/tabs/tab.h" | 7 #include "chrome/browser/ui/views/tabs/tab.h" |
8 #include "chrome/browser/ui/views/tabs/tab_controller.h" | 8 #include "chrome/browser/ui/views/tabs/tab_controller.h" |
9 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" | 9 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" |
10 #include "content/public/browser/user_metrics.h" | 10 #include "content/public/browser/user_metrics.h" |
11 #include "ui/gfx/animation/animation_delegate.h" | 11 #include "ui/gfx/animation/animation_delegate.h" |
12 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
13 #include "ui/gfx/image/image.h" | 13 #include "ui/gfx/image/image.h" |
14 | 14 |
15 using base::UserMetricsAction; | 15 using base::UserMetricsAction; |
16 | 16 |
17 const char MediaIndicatorButton::kViewClassName[] = "MediaIndicatorButton"; | 17 const char MediaIndicatorButton::kViewClassName[] = "MediaIndicatorButton"; |
18 | 18 |
19 class MediaIndicatorButton::FadeAnimationDelegate | 19 class MediaIndicatorButton::FadeAnimationDelegate |
20 : public gfx::AnimationDelegate { | 20 : public gfx::AnimationDelegate { |
21 public: | 21 public: |
22 explicit FadeAnimationDelegate(MediaIndicatorButton* button) | 22 explicit FadeAnimationDelegate(MediaIndicatorButton* button) |
23 : button_(button) {} | 23 : button_(button) {} |
24 virtual ~FadeAnimationDelegate() {} | 24 virtual ~FadeAnimationDelegate() {} |
25 | 25 |
26 private: | 26 private: |
27 // gfx::AnimationDelegate | 27 // gfx::AnimationDelegate |
28 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE { | 28 virtual void AnimationProgressed(const gfx::Animation* animation) override { |
29 button_->SchedulePaint(); | 29 button_->SchedulePaint(); |
30 } | 30 } |
31 | 31 |
32 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE { | 32 virtual void AnimationCanceled(const gfx::Animation* animation) override { |
33 button_->showing_media_state_ = button_->media_state_; | 33 button_->showing_media_state_ = button_->media_state_; |
34 button_->SchedulePaint(); | 34 button_->SchedulePaint(); |
35 } | 35 } |
36 | 36 |
37 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE { | 37 virtual void AnimationEnded(const gfx::Animation* animation) override { |
38 button_->showing_media_state_ = button_->media_state_; | 38 button_->showing_media_state_ = button_->media_state_; |
39 button_->SchedulePaint(); | 39 button_->SchedulePaint(); |
40 } | 40 } |
41 | 41 |
42 MediaIndicatorButton* const button_; | 42 MediaIndicatorButton* const button_; |
43 | 43 |
44 DISALLOW_COPY_AND_ASSIGN(FadeAnimationDelegate); | 44 DISALLOW_COPY_AND_ASSIGN(FadeAnimationDelegate); |
45 }; | 45 }; |
46 | 46 |
47 MediaIndicatorButton::MediaIndicatorButton() | 47 MediaIndicatorButton::MediaIndicatorButton() |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 content::RecordAction(UserMetricsAction("MediaIndicatorButton_Mute")); | 150 content::RecordAction(UserMetricsAction("MediaIndicatorButton_Mute")); |
151 else if (media_state_ == TAB_MEDIA_STATE_AUDIO_MUTING) | 151 else if (media_state_ == TAB_MEDIA_STATE_AUDIO_MUTING) |
152 content::RecordAction(UserMetricsAction("MediaIndicatorButton_Unmute")); | 152 content::RecordAction(UserMetricsAction("MediaIndicatorButton_Unmute")); |
153 else | 153 else |
154 NOTREACHED(); | 154 NOTREACHED(); |
155 | 155 |
156 DCHECK(parent() && !strcmp(parent()->GetClassName(), Tab::kViewClassName)); | 156 DCHECK(parent() && !strcmp(parent()->GetClassName(), Tab::kViewClassName)); |
157 Tab* const tab = static_cast<Tab*>(parent()); | 157 Tab* const tab = static_cast<Tab*>(parent()); |
158 tab->controller()->ToggleTabAudioMute(tab); | 158 tab->controller()->ToggleTabAudioMute(tab); |
159 } | 159 } |
OLD | NEW |