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 "ash/system/audio/tray_audio.h" | 5 #include "ash/system/audio/tray_audio.h" |
6 | 6 |
7 #include "ash/resources/vector_icons/vector_icons.h" | 7 #include "ash/resources/vector_icons/vector_icons.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shell_port.h" |
9 #include "ash/system/audio/audio_detailed_view.h" | 10 #include "ash/system/audio/audio_detailed_view.h" |
10 #include "ash/system/audio/volume_view.h" | 11 #include "ash/system/audio/volume_view.h" |
11 #include "ash/system/tray/system_tray.h" | 12 #include "ash/system/tray/system_tray.h" |
12 #include "ash/system/tray/tray_constants.h" | 13 #include "ash/system/tray/tray_constants.h" |
13 #include "ash/wm_shell.h" | |
14 #include "ash/wm_window.h" | 14 #include "ash/wm_window.h" |
15 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
16 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
17 #include "ui/display/manager/managed_display_info.h" | 17 #include "ui/display/manager/managed_display_info.h" |
18 #include "ui/display/screen.h" | 18 #include "ui/display/screen.h" |
19 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
20 | 20 |
21 namespace ash { | 21 namespace ash { |
22 | 22 |
23 using chromeos::CrasAudioHandler; | 23 using chromeos::CrasAudioHandler; |
(...skipping 13 matching lines...) Expand all Loading... |
37 TrayAudio::~TrayAudio() { | 37 TrayAudio::~TrayAudio() { |
38 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 38 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
39 display::Screen::GetScreen()->RemoveObserver(this); | 39 display::Screen::GetScreen()->RemoveObserver(this); |
40 if (CrasAudioHandler::IsInitialized()) | 40 if (CrasAudioHandler::IsInitialized()) |
41 CrasAudioHandler::Get()->RemoveAudioObserver(this); | 41 CrasAudioHandler::Get()->RemoveAudioObserver(this); |
42 } | 42 } |
43 | 43 |
44 // static | 44 // static |
45 void TrayAudio::ShowPopUpVolumeView() { | 45 void TrayAudio::ShowPopUpVolumeView() { |
46 // Show the popup on all monitors with a system tray. | 46 // Show the popup on all monitors with a system tray. |
47 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) { | 47 for (WmWindow* root : ShellPort::Get()->GetAllRootWindows()) { |
48 SystemTray* system_tray = root->GetRootWindowController()->GetSystemTray(); | 48 SystemTray* system_tray = root->GetRootWindowController()->GetSystemTray(); |
49 if (!system_tray) | 49 if (!system_tray) |
50 continue; | 50 continue; |
51 // Show the popup by simulating a volume change. The provided node id and | 51 // Show the popup by simulating a volume change. The provided node id and |
52 // volume value are ignored. | 52 // volume value are ignored. |
53 system_tray->GetTrayAudio()->OnOutputNodeVolumeChanged(0, 0); | 53 system_tray->GetTrayAudio()->OnOutputNodeVolumeChanged(0, 0); |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 bool TrayAudio::GetInitialVisibility() { | 57 bool TrayAudio::GetInitialVisibility() { |
58 return CrasAudioHandler::Get()->IsOutputMuted(); | 58 return CrasAudioHandler::Get()->IsOutputMuted(); |
59 } | 59 } |
60 | 60 |
61 views::View* TrayAudio::CreateDefaultView(LoginStatus status) { | 61 views::View* TrayAudio::CreateDefaultView(LoginStatus status) { |
62 volume_view_ = new tray::VolumeView(this, true); | 62 volume_view_ = new tray::VolumeView(this, true); |
63 return volume_view_; | 63 return volume_view_; |
64 } | 64 } |
65 | 65 |
66 views::View* TrayAudio::CreateDetailedView(LoginStatus status) { | 66 views::View* TrayAudio::CreateDetailedView(LoginStatus status) { |
67 if (pop_up_volume_view_) { | 67 if (pop_up_volume_view_) { |
68 volume_view_ = new tray::VolumeView(this, false); | 68 volume_view_ = new tray::VolumeView(this, false); |
69 return volume_view_; | 69 return volume_view_; |
70 } else { | 70 } else { |
71 WmShell::Get()->RecordUserMetricsAction( | 71 ShellPort::Get()->RecordUserMetricsAction( |
72 UMA_STATUS_AREA_DETAILED_AUDIO_VIEW); | 72 UMA_STATUS_AREA_DETAILED_AUDIO_VIEW); |
73 audio_detail_view_ = new tray::AudioDetailedView(this); | 73 audio_detail_view_ = new tray::AudioDetailedView(this); |
74 return audio_detail_view_; | 74 return audio_detail_view_; |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 void TrayAudio::DestroyDefaultView() { | 78 void TrayAudio::DestroyDefaultView() { |
79 volume_view_ = NULL; | 79 volume_view_ = NULL; |
80 } | 80 } |
81 | 81 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 void TrayAudio::OnActiveInputNodeChanged() { | 131 void TrayAudio::OnActiveInputNodeChanged() { |
132 Update(); | 132 Update(); |
133 } | 133 } |
134 | 134 |
135 void TrayAudio::ChangeInternalSpeakerChannelMode() { | 135 void TrayAudio::ChangeInternalSpeakerChannelMode() { |
136 // Swap left/right channel only if it is in Yoga mode. | 136 // Swap left/right channel only if it is in Yoga mode. |
137 bool swap = false; | 137 bool swap = false; |
138 if (display::Display::HasInternalDisplay()) { | 138 if (display::Display::HasInternalDisplay()) { |
139 const display::ManagedDisplayInfo& display_info = | 139 const display::ManagedDisplayInfo& display_info = |
140 WmShell::Get()->GetDisplayInfo(display::Display::InternalDisplayId()); | 140 ShellPort::Get()->GetDisplayInfo(display::Display::InternalDisplayId()); |
141 if (display_info.GetActiveRotation() == display::Display::ROTATE_180) | 141 if (display_info.GetActiveRotation() == display::Display::ROTATE_180) |
142 swap = true; | 142 swap = true; |
143 } | 143 } |
144 CrasAudioHandler::Get()->SwapInternalSpeakerLeftRightChannel(swap); | 144 CrasAudioHandler::Get()->SwapInternalSpeakerLeftRightChannel(swap); |
145 } | 145 } |
146 | 146 |
147 void TrayAudio::OnDisplayAdded(const display::Display& new_display) { | 147 void TrayAudio::OnDisplayAdded(const display::Display& new_display) { |
148 if (!new_display.IsInternal()) | 148 if (!new_display.IsInternal()) |
149 return; | 149 return; |
150 ChangeInternalSpeakerChannelMode(); | 150 ChangeInternalSpeakerChannelMode(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 volume_view_->SetVolumeLevel( | 194 volume_view_->SetVolumeLevel( |
195 CrasAudioHandler::Get()->GetOutputVolumePercent() / 100.0f); | 195 CrasAudioHandler::Get()->GetOutputVolumePercent() / 100.0f); |
196 volume_view_->Update(); | 196 volume_view_->Update(); |
197 } | 197 } |
198 | 198 |
199 if (audio_detail_view_) | 199 if (audio_detail_view_) |
200 audio_detail_view_->Update(); | 200 audio_detail_view_->Update(); |
201 } | 201 } |
202 | 202 |
203 } // namespace ash | 203 } // namespace ash |
OLD | NEW |