| 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/common/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" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "ui/gfx/font_list.h" | 31 #include "ui/gfx/font_list.h" |
| 32 #include "ui/gfx/image/image.h" | 32 #include "ui/gfx/image/image.h" |
| 33 #include "ui/gfx/image/image_skia_operations.h" | 33 #include "ui/gfx/image/image_skia_operations.h" |
| 34 #include "ui/views/controls/button/image_button.h" | 34 #include "ui/views/controls/button/image_button.h" |
| 35 #include "ui/views/controls/image_view.h" | 35 #include "ui/views/controls/image_view.h" |
| 36 #include "ui/views/controls/label.h" | 36 #include "ui/views/controls/label.h" |
| 37 #include "ui/views/controls/slider.h" | 37 #include "ui/views/controls/slider.h" |
| 38 #include "ui/views/layout/box_layout.h" | 38 #include "ui/views/layout/box_layout.h" |
| 39 #include "ui/views/view.h" | 39 #include "ui/views/view.h" |
| 40 | 40 |
| 41 #include "ui/views/widget/widget.h" |
| 42 |
| 41 namespace ash { | 43 namespace ash { |
| 42 | 44 |
| 43 TrayAudio::TrayAudio(SystemTray* system_tray, | 45 TrayAudio::TrayAudio(SystemTray* system_tray, |
| 44 std::unique_ptr<system::TrayAudioDelegate> audio_delegate) | 46 std::unique_ptr<system::TrayAudioDelegate> audio_delegate) |
| 45 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_VOLUME_MUTE, UMA_AUDIO), | 47 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_VOLUME_MUTE, UMA_AUDIO), |
| 46 audio_delegate_(std::move(audio_delegate)), | 48 audio_delegate_(std::move(audio_delegate)), |
| 47 volume_view_(NULL), | 49 volume_view_(NULL), |
| 48 pop_up_volume_view_(false) { | 50 pop_up_volume_view_(false) { |
| 49 WmShell::Get()->system_tray_notifier()->AddAudioObserver(this); | 51 SystemTrayNotifier* notifier = WmShell::Get()->system_tray_notifier(); |
| 52 notifier->AddAudioObserver(this); |
| 53 notifier->AddMaximizeModeScreenshotObserver(this); |
| 50 display::Screen::GetScreen()->AddObserver(this); | 54 display::Screen::GetScreen()->AddObserver(this); |
| 51 } | 55 } |
| 52 | 56 |
| 53 TrayAudio::~TrayAudio() { | 57 TrayAudio::~TrayAudio() { |
| 54 display::Screen::GetScreen()->RemoveObserver(this); | 58 display::Screen::GetScreen()->RemoveObserver(this); |
| 55 WmShell::Get()->system_tray_notifier()->RemoveAudioObserver(this); | 59 SystemTrayNotifier* notifier = WmShell::Get()->system_tray_notifier(); |
| 60 notifier->RemoveMaximizeModeScreenshotObserver(this); |
| 61 notifier->RemoveAudioObserver(this); |
| 56 } | 62 } |
| 57 | 63 |
| 58 // static | 64 // static |
| 59 bool TrayAudio::ShowAudioDeviceMenu() { | 65 bool TrayAudio::ShowAudioDeviceMenu() { |
| 60 #if defined(OS_CHROMEOS) | 66 #if defined(OS_CHROMEOS) |
| 61 return true; | 67 return true; |
| 62 #else | 68 #else |
| 63 return false; | 69 return false; |
| 64 #endif | 70 #endif |
| 65 } | 71 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 137 } |
| 132 | 138 |
| 133 void TrayAudio::OnActiveOutputNodeChanged() { | 139 void TrayAudio::OnActiveOutputNodeChanged() { |
| 134 Update(); | 140 Update(); |
| 135 } | 141 } |
| 136 | 142 |
| 137 void TrayAudio::OnActiveInputNodeChanged() { | 143 void TrayAudio::OnActiveInputNodeChanged() { |
| 138 Update(); | 144 Update(); |
| 139 } | 145 } |
| 140 | 146 |
| 147 void TrayAudio::OnWillTakeScreenshotInMaximizeMode() { |
| 148 HideDetailedView(false); |
| 149 } |
| 150 |
| 141 void TrayAudio::ChangeInternalSpeakerChannelMode() { | 151 void TrayAudio::ChangeInternalSpeakerChannelMode() { |
| 142 // Swap left/right channel only if it is in Yoga mode. | 152 // Swap left/right channel only if it is in Yoga mode. |
| 143 system::TrayAudioDelegate::AudioChannelMode channel_mode = | 153 system::TrayAudioDelegate::AudioChannelMode channel_mode = |
| 144 system::TrayAudioDelegate::NORMAL; | 154 system::TrayAudioDelegate::NORMAL; |
| 145 if (display::Display::HasInternalDisplay()) { | 155 if (display::Display::HasInternalDisplay()) { |
| 146 const DisplayInfo& display_info = | 156 const DisplayInfo& display_info = |
| 147 WmShell::Get()->GetDisplayInfo(display::Display::InternalDisplayId()); | 157 WmShell::Get()->GetDisplayInfo(display::Display::InternalDisplayId()); |
| 148 if (display_info.GetActiveRotation() == display::Display::ROTATE_180) | 158 if (display_info.GetActiveRotation() == display::Display::ROTATE_180) |
| 149 channel_mode = system::TrayAudioDelegate::LEFT_RIGHT_SWAPPED; | 159 channel_mode = system::TrayAudioDelegate::LEFT_RIGHT_SWAPPED; |
| 150 } | 160 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 177 if (tray_view()) | 187 if (tray_view()) |
| 178 tray_view()->SetVisible(GetInitialVisibility()); | 188 tray_view()->SetVisible(GetInitialVisibility()); |
| 179 if (volume_view_) { | 189 if (volume_view_) { |
| 180 volume_view_->SetVolumeLevel( | 190 volume_view_->SetVolumeLevel( |
| 181 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f); | 191 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f); |
| 182 volume_view_->Update(); | 192 volume_view_->Update(); |
| 183 } | 193 } |
| 184 } | 194 } |
| 185 | 195 |
| 186 } // namespace ash | 196 } // namespace ash |
| OLD | NEW |