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

Unified Diff: ash/common/system/audio/tray_audio.cc

Issue 2190773002: Fix Volume slider is captured in screenshot done in touchview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
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 =

Powered by Google App Engine
This is Rietveld 408576698