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

Unified Diff: chrome/browser/ui/ash/volume_controller_chromeos.cc

Issue 115693004: Added volume adjust sound behind the flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix, rebase. Created 6 years, 11 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
« no previous file with comments | « chrome/browser/ui/ash/DEPS ('k') | chromeos/audio/chromeos_sounds.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f596301e6c861a30e1ae3fcd636b86a9153c2559..3502301fe1f02a27b8a7f64c775b4a7227deb1e7 100644
--- a/chrome/browser/ui/ash/volume_controller_chromeos.cc
+++ b/chrome/browser/ui/ash/volume_controller_chromeos.cc
@@ -5,9 +5,16 @@
#include "chrome/browser/ui/ash/volume_controller_chromeos.h"
#include "ash/ash_switches.h"
+#include "ash/audio/sounds.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 +23,22 @@ 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)) {
+ ash::PlaySystemSound(chromeos::SOUND_VOLUME_ADJUST,
+ true /* honor_spoken_feedback */);
+ }
+}
+
} // 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() {
@@ -46,6 +65,8 @@ bool VolumeController::HandleVolumeDown(const ui::Accelerator& accelerator) {
audio_handler->AdjustOutputVolumeByPercent(-kStepPercentage);
if (audio_handler->IsOutputVolumeBelowDefaultMuteLvel())
audio_handler->SetOutputMute(true);
+ else
+ PlayVolumeAdjustSound();
}
return true;
}
@@ -55,13 +76,18 @@ bool VolumeController::HandleVolumeUp(const ui::Accelerator& accelerator) {
content::RecordAction(base::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)
+ PlayVolumeAdjustSound();
return true;
}
« no previous file with comments | « chrome/browser/ui/ash/DEPS ('k') | chromeos/audio/chromeos_sounds.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698