Switch Audio Preferences to per device.
Currently Chrome stores one global audio volume pref; if a user switches devices, this value remains the same. Change this so that we remember what volume (and mute setting) a user switched to when on a particular device, so when we switch to that device, we can set the volume/mute setting back to it again.
[email protected], [email protected], [email protected]
BUG=175798
TEST=Switched between speakers and USB headphones to verify that audio settings were rememebered and switched to correctly.
Review URL: https://codereview.chromium.org/14801002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198011 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chromeos/audio/audio_devices_pref_handler.h b/chromeos/audio/audio_devices_pref_handler.h
new file mode 100644
index 0000000..63e3ed74
--- /dev/null
+++ b/chromeos/audio/audio_devices_pref_handler.h
@@ -0,0 +1,55 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_
+#define CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "chromeos/audio/audio_pref_observer.h"
+#include "chromeos/chromeos_export.h"
+
+class PrefRegistrySimple;
+
+namespace chromeos {
+
+// Interface that handles audio preference related work, reads and writes
+// audio preferences, and notifies AudioPrefObserver for audio preference
+// changes.
+class CHROMEOS_EXPORT AudioDevicesPrefHandler
+ : public base::RefCountedThreadSafe<AudioDevicesPrefHandler> {
+ public:
+ // Gets the audio output volume value from prefs for the active device.
+ virtual double GetOutputVolumeValue() = 0;
+ // Reads the audio output mute value from prefs for the active device.
+ virtual bool GetOutputMuteValue() = 0;
+
+ // Sets the output audio volume value to prefs for the active device.
+ virtual void SetOutputVolumeValue(double volume_percent) = 0;
+ // Sets the audio output mute value to prefs for the active device.
+ virtual void SetOutputMuteValue(bool mute_on) = 0;
+
+ // Reads the audio capture allowed value from prefs.
+ virtual bool GetAudioCaptureAllowedValue() = 0;
+ // Reads the audio output allowed value from prefs.
+ virtual bool GetAudioOutputAllowedValue() = 0;
+
+ // Adds an audio preference observer.
+ virtual void AddAudioPrefObserver(AudioPrefObserver* observer) = 0;
+ // Removes an audio preference observer.
+ virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) = 0;
+
+ // Creates the instance.
+ static AudioDevicesPrefHandler* Create(PrefService* local_state);
+
+ protected:
+ virtual ~AudioDevicesPrefHandler() {}
+
+ private:
+ friend class base::RefCountedThreadSafe<AudioDevicesPrefHandler>;
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_H_