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

Side by Side Diff: ash/common/system/audio/tray_audio.cc

Issue 2084533008: mash: Migrate tray audio and deps to common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup IWYU. Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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 "ash/system/audio/tray_audio.h" 5 #include "ash/common/system/audio/tray_audio.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/ash_constants.h" 10 #include "ash/common/ash_constants.h"
11 #include "ash/common/display/display_info.h"
12 #include "ash/common/system/audio/tray_audio_delegate.h"
13 #include "ash/common/system/audio/volume_view.h"
11 #include "ash/common/system/tray/actionable_view.h" 14 #include "ash/common/system/tray/actionable_view.h"
12 #include "ash/common/system/tray/fixed_sized_scroll_view.h" 15 #include "ash/common/system/tray/fixed_sized_scroll_view.h"
13 #include "ash/common/system/tray/hover_highlight_view.h" 16 #include "ash/common/system/tray/hover_highlight_view.h"
14 #include "ash/common/system/tray/system_tray_delegate.h" 17 #include "ash/common/system/tray/system_tray_delegate.h"
15 #include "ash/common/system/tray/tray_constants.h" 18 #include "ash/common/system/tray/tray_constants.h"
19 #include "ash/common/system/tray/wm_system_tray_notifier.h"
16 #include "ash/common/system/volume_control_delegate.h" 20 #include "ash/common/system/volume_control_delegate.h"
17 #include "ash/display/display_manager.h" 21 #include "ash/common/wm_shell.h"
18 #include "ash/metrics/user_metrics_recorder.h"
19 #include "ash/shell.h"
20 #include "ash/system/audio/tray_audio_delegate.h"
21 #include "ash/system/audio/volume_view.h"
22 #include "ash/system/tray/system_tray.h"
23 #include "ash/system/tray/system_tray_notifier.h"
24 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
25 #include "grit/ash_resources.h" 23 #include "grit/ash_resources.h"
26 #include "third_party/skia/include/core/SkCanvas.h" 24 #include "third_party/skia/include/core/SkCanvas.h"
27 #include "third_party/skia/include/core/SkPaint.h" 25 #include "third_party/skia/include/core/SkPaint.h"
28 #include "third_party/skia/include/core/SkRect.h" 26 #include "third_party/skia/include/core/SkRect.h"
29 #include "third_party/skia/include/effects/SkGradientShader.h" 27 #include "third_party/skia/include/effects/SkGradientShader.h"
30 #include "ui/display/display.h" 28 #include "ui/display/display.h"
29 #include "ui/display/screen.h"
31 #include "ui/gfx/canvas.h" 30 #include "ui/gfx/canvas.h"
32 #include "ui/gfx/font_list.h" 31 #include "ui/gfx/font_list.h"
33 #include "ui/gfx/image/image.h" 32 #include "ui/gfx/image/image.h"
34 #include "ui/gfx/image/image_skia_operations.h" 33 #include "ui/gfx/image/image_skia_operations.h"
35 #include "ui/views/controls/button/image_button.h" 34 #include "ui/views/controls/button/image_button.h"
36 #include "ui/views/controls/image_view.h" 35 #include "ui/views/controls/image_view.h"
37 #include "ui/views/controls/label.h" 36 #include "ui/views/controls/label.h"
38 #include "ui/views/controls/slider.h" 37 #include "ui/views/controls/slider.h"
39 #include "ui/views/layout/box_layout.h" 38 #include "ui/views/layout/box_layout.h"
40 #include "ui/views/view.h" 39 #include "ui/views/view.h"
41 40
42 namespace ash { 41 namespace ash {
43 42
44 TrayAudio::TrayAudio(SystemTray* system_tray, 43 TrayAudio::TrayAudio(SystemTray* system_tray,
45 std::unique_ptr<system::TrayAudioDelegate> audio_delegate) 44 std::unique_ptr<system::TrayAudioDelegate> audio_delegate)
46 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_VOLUME_MUTE), 45 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_VOLUME_MUTE),
47 audio_delegate_(std::move(audio_delegate)), 46 audio_delegate_(std::move(audio_delegate)),
48 volume_view_(NULL), 47 volume_view_(NULL),
49 pop_up_volume_view_(false) { 48 pop_up_volume_view_(false) {
50 Shell::GetInstance()->system_tray_notifier()->AddAudioObserver(this); 49 WmShell::Get()->system_tray_notifier()->AddAudioObserver(this);
51 display::Screen::GetScreen()->AddObserver(this); 50 display::Screen::GetScreen()->AddObserver(this);
52 } 51 }
53 52
54 TrayAudio::~TrayAudio() { 53 TrayAudio::~TrayAudio() {
55 display::Screen::GetScreen()->RemoveObserver(this); 54 display::Screen::GetScreen()->RemoveObserver(this);
56 Shell::GetInstance()->system_tray_notifier()->RemoveAudioObserver(this); 55 WmShell::Get()->system_tray_notifier()->RemoveAudioObserver(this);
57 } 56 }
58 57
59 // static 58 // static
60 bool TrayAudio::ShowAudioDeviceMenu() { 59 bool TrayAudio::ShowAudioDeviceMenu() {
61 #if defined(OS_CHROMEOS) 60 #if defined(OS_CHROMEOS)
62 return true; 61 return true;
63 #else 62 #else
64 return false; 63 return false;
65 #endif 64 #endif
66 } 65 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 void TrayAudio::OnActiveInputNodeChanged() { 137 void TrayAudio::OnActiveInputNodeChanged() {
139 Update(); 138 Update();
140 } 139 }
141 140
142 void TrayAudio::ChangeInternalSpeakerChannelMode() { 141 void TrayAudio::ChangeInternalSpeakerChannelMode() {
143 // Swap left/right channel only if it is in Yoga mode. 142 // Swap left/right channel only if it is in Yoga mode.
144 system::TrayAudioDelegate::AudioChannelMode channel_mode = 143 system::TrayAudioDelegate::AudioChannelMode channel_mode =
145 system::TrayAudioDelegate::NORMAL; 144 system::TrayAudioDelegate::NORMAL;
146 if (display::Display::HasInternalDisplay()) { 145 if (display::Display::HasInternalDisplay()) {
147 const DisplayInfo& display_info = 146 const DisplayInfo& display_info =
148 Shell::GetInstance()->display_manager()->GetDisplayInfo( 147 WmShell::Get()->GetDisplayInfo(display::Display::InternalDisplayId());
149 display::Display::InternalDisplayId());
150 if (display_info.GetActiveRotation() == display::Display::ROTATE_180) 148 if (display_info.GetActiveRotation() == display::Display::ROTATE_180)
151 channel_mode = system::TrayAudioDelegate::LEFT_RIGHT_SWAPPED; 149 channel_mode = system::TrayAudioDelegate::LEFT_RIGHT_SWAPPED;
152 } 150 }
153 151
154 audio_delegate_->SetInternalSpeakerChannelMode(channel_mode); 152 audio_delegate_->SetInternalSpeakerChannelMode(channel_mode);
155 } 153 }
156 154
157 void TrayAudio::OnDisplayAdded(const display::Display& new_display) { 155 void TrayAudio::OnDisplayAdded(const display::Display& new_display) {
158 if (!new_display.IsInternal()) 156 if (!new_display.IsInternal())
159 return; 157 return;
(...skipping 19 matching lines...) Expand all
179 if (tray_view()) 177 if (tray_view())
180 tray_view()->SetVisible(GetInitialVisibility()); 178 tray_view()->SetVisible(GetInitialVisibility());
181 if (volume_view_) { 179 if (volume_view_) {
182 volume_view_->SetVolumeLevel( 180 volume_view_->SetVolumeLevel(
183 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f); 181 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f);
184 volume_view_->Update(); 182 volume_view_->Update();
185 } 183 }
186 } 184 }
187 185
188 } // namespace ash 186 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698