| Index: ash/common/system/audio/tray_audio.cc
|
| diff --git a/ash/common/system/audio/tray_audio.cc b/ash/common/system/audio/tray_audio.cc
|
| index 8ff0987aadc01be209d8ef02a09d83a1fd738b8a..3c356eb783f9f1b6c756c273fce19021402a9d86 100644
|
| --- a/ash/common/system/audio/tray_audio.cc
|
| +++ b/ash/common/system/audio/tray_audio.cc
|
| @@ -38,6 +38,10 @@
|
| #include "ui/views/layout/box_layout.h"
|
| #include "ui/views/view.h"
|
|
|
| +#if defined(OS_CHROMEOS)
|
| +#include "chromeos/audio/cras_audio_handler.h"
|
| +#endif
|
| +
|
| namespace ash {
|
|
|
| TrayAudio::TrayAudio(SystemTray* system_tray,
|
| @@ -45,14 +49,20 @@ TrayAudio::TrayAudio(SystemTray* system_tray,
|
| : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_VOLUME_MUTE, UMA_AUDIO),
|
| audio_delegate_(std::move(audio_delegate)),
|
| volume_view_(NULL),
|
| - pop_up_volume_view_(false) {
|
| - WmShell::Get()->system_tray_notifier()->AddAudioObserver(this);
|
| + pop_up_volume_view_(false),
|
| + hide_popup_(false),
|
| + saved_volume_percent_(0) {
|
| + SystemTrayNotifier* notifier = WmShell::Get()->system_tray_notifier();
|
| + notifier->AddAudioObserver(this);
|
| + notifier->AddMaxModeScreenshotObserver(this);
|
| display::Screen::GetScreen()->AddObserver(this);
|
| }
|
|
|
| TrayAudio::~TrayAudio() {
|
| display::Screen::GetScreen()->RemoveObserver(this);
|
| - WmShell::Get()->system_tray_notifier()->RemoveAudioObserver(this);
|
| + SystemTrayNotifier* notifier = WmShell::Get()->system_tray_notifier();
|
| + notifier->RemoveMaxModeScreenshotObserver(this);
|
| + notifier->RemoveAudioObserver(this);
|
| }
|
|
|
| // static
|
| @@ -110,7 +120,12 @@ void TrayAudio::OnOutputNodeVolumeChanged(uint64_t /* node_id */,
|
| return;
|
| }
|
| pop_up_volume_view_ = true;
|
| - PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false);
|
| + // When the OutputNodeVolumeChanged is caused by a volume restore after
|
| + // maximize mode screenshot, it should not cause UI popup.
|
| + if (!hide_popup_)
|
| + PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false);
|
| + else
|
| + hide_popup_ = false;
|
| }
|
|
|
| void TrayAudio::OnOutputMuteChanged(bool /* mute_on */, bool system_adjust) {
|
| @@ -138,6 +153,22 @@ void TrayAudio::OnActiveInputNodeChanged() {
|
| Update();
|
| }
|
|
|
| +void TrayAudio::OnWillTakeScreenshot(int volume_percent) {
|
| + saved_volume_percent_ = volume_percent;
|
| + HideDetailedView();
|
| +}
|
| +
|
| +void TrayAudio::OnDidTakeScreenshot() {
|
| + hide_popup_ = true;
|
| +#if defined(OS_CHROMEOS)
|
| + // Restore the volume to the value before volume-down modifier key is pressed
|
| + // to wait for power button.
|
| + chromeos::CrasAudioHandler* audio_handler = chromeos::CrasAudioHandler::Get();
|
| + DCHECK(audio_handler->IsInitialized());
|
| + audio_handler->SetOutputVolumePercent(saved_volume_percent_);
|
| +#endif
|
| +}
|
| +
|
| void TrayAudio::ChangeInternalSpeakerChannelMode() {
|
| // Swap left/right channel only if it is in Yoga mode.
|
| system::TrayAudioDelegate::AudioChannelMode channel_mode =
|
|
|