Chromium Code Reviews| Index: chrome/browser/ui/ash/volume_controller_chromeos.cc |
| diff --git a/chrome/browser/ui/ash/volume_controller_chromeos.cc b/chrome/browser/ui/ash/volume_controller_chromeos.cc |
| index b8fdff3ea36a3c838f1a38706e6ffcee1c9aefc0..52fc9b53a602f4fb30c477f1dd4bc3c90911d678 100644 |
| --- a/chrome/browser/ui/ash/volume_controller_chromeos.cc |
| +++ b/chrome/browser/ui/ash/volume_controller_chromeos.cc |
| @@ -5,9 +5,15 @@ |
| #include "chrome/browser/ui/ash/volume_controller_chromeos.h" |
| #include "ash/ash_switches.h" |
| +#include "base/command_line.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/extensions/api/system_private/system_private_api.h" |
| +#include "chromeos/audio/chromeos_sounds.h" |
| +#include "chromeos/chromeos_switches.h" |
| #include "content/public/browser/user_metrics.h" |
| +#include "grit/browser_resources.h" |
| +#include "media/audio/sounds/sounds_manager.h" |
| +#include "ui/base/resource/resource_bundle.h" |
| using chromeos::CrasAudioHandler; |
| @@ -16,10 +22,21 @@ namespace { |
| // Percent by which the volume should be changed when a volume key is pressed. |
| const double kStepPercentage = 4.0; |
| +void PlayVolumeAdjustSound() { |
| + if (CommandLine::ForCurrentProcess()->HasSwitch( |
| + chromeos::switches::kEnableVolumeAdjustSound)) { |
| + media::SoundsManager::Get()->Play(chromeos::SOUND_VOLUME_ADJUST); |
| + } |
| +} |
| + |
| } // namespace |
| VolumeController::VolumeController() { |
| CrasAudioHandler::Get()->AddAudioObserver(this); |
| + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| + media::SoundsManager::Get()->Initialize( |
| + chromeos::SOUND_VOLUME_ADJUST, |
| + bundle.GetRawDataResource(IDR_SOUND_VOLUME_ADJUST_WAV)); |
| } |
| VolumeController::~VolumeController() { |
| @@ -40,13 +57,19 @@ bool VolumeController::HandleVolumeDown(const ui::Accelerator& accelerator) { |
| content::RecordAction(content::UserMetricsAction("Accel_VolumeDown_F9")); |
| CrasAudioHandler* audio_handler = CrasAudioHandler::Get(); |
| + bool play_sound = false; |
| if (audio_handler->IsOutputMuted()) { |
| audio_handler->SetOutputVolumePercent(0); |
| } else { |
| + play_sound = audio_handler->GetOutputVolumePercent() != 0; |
| audio_handler->AdjustOutputVolumeByPercent(-kStepPercentage); |
| if (audio_handler->IsOutputVolumeBelowDefaultMuteLvel()) |
| audio_handler->SetOutputMute(true); |
| } |
| + |
| + if (play_sound) |
|
DaleCurtis
2014/01/09 19:58:26
Can you just move this into the else block above w
ygorshenin1
2014/01/13 10:00:55
Done.
|
| + PlayVolumeAdjustSound(); |
| + |
| return true; |
| } |
| @@ -55,13 +78,18 @@ bool VolumeController::HandleVolumeUp(const ui::Accelerator& accelerator) { |
| content::RecordAction(content::UserMetricsAction("Accel_VolumeUp_F10")); |
| CrasAudioHandler* audio_handler = CrasAudioHandler::Get(); |
| + bool play_sound = false; |
| if (audio_handler->IsOutputMuted()) { |
| - audio_handler->SetOutputMute(false); |
| - audio_handler->AdjustOutputVolumeToAudibleLevel(); |
| + audio_handler->SetOutputMute(false); |
| + audio_handler->AdjustOutputVolumeToAudibleLevel(); |
| + play_sound = true; |
| } else { |
| + play_sound = audio_handler->GetOutputVolumePercent() != 100; |
| audio_handler->AdjustOutputVolumeByPercent(kStepPercentage); |
| } |
| + if (play_sound) |
|
DaleCurtis
2014/01/09 19:58:26
Does just checking OutputVolume != 100 here work?
ygorshenin1
2014/01/13 10:00:55
No, because in this case user will not hear volume
|
| + PlayVolumeAdjustSound(); |
| return true; |
| } |