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

Unified Diff: chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.h

Issue 14801002: Switch Audio Preferences to per device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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: chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.h
diff --git a/chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.h b/chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..6db63267412e2ee3b0f111dfb7c0579131db1fc6
--- /dev/null
+++ b/chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.h
@@ -0,0 +1,74 @@
+// 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 CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_
+#define CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_
+
+#include "base/observer_list.h"
+#include "base/prefs/pref_change_registrar.h"
+#include "base/values.h"
+#include "chromeos/audio/audio_devices_pref_handler.h"
+
+class PrefRegistrySimple;
+class PrefService;
+
+namespace chromeos {
+
+// Class which implements AudioDevicesPrefHandler interface and register audio
+// preferences as well.
+class AudioDevicesPrefHandlerImpl : public AudioDevicesPrefHandler {
+ public:
+ explicit AudioDevicesPrefHandlerImpl(PrefService* local_state);
+
+ // Overridden from AudioDevicesPrefHandler.
+ virtual double GetOutputVolumeValue() OVERRIDE;
+ virtual bool GetOutputMuteValue() OVERRIDE;
+ virtual void SetOutputVolumeValue(double volume_percent) OVERRIDE;
+ virtual void SetOutputMuteValue(bool mute_on) OVERRIDE;
+ virtual bool GetAudioCaptureAllowedValue() OVERRIDE;
+ virtual bool GetAudioOutputAllowedValue() OVERRIDE;
+ virtual void AddAudioPrefObserver(AudioPrefObserver* observer) OVERRIDE;
+ virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) OVERRIDE;
+
+ // Registers volume and mute preferences.
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ protected:
+ virtual ~AudioDevicesPrefHandlerImpl();
+
+ private:
+ // Initializes the observers for the policy prefs.
+ void InitializePrefObservers();
+
+ // Update and save methods for the mute preferences for all devices.
+ void UpdateDevicesMutePref();
+ void SaveDevicesMutePref();
+
+ // Update and save methods for the volume preferences for all devices.
+ void UpdateDevicesVolumePref();
+ void SaveDevicesVolumePref();
+
+ // Methods to migrate the mute and volume settings for a device from the
+ // previous global pref value to the new per device pref value for the
+ // current active device. If a previous global setting doesn't exist, we'll
+ // use default values of mute=off and volume=75%.
stevenjb 2013/05/02 19:29:47 nit: ' ' around =
rkc 2013/05/02 19:43:44 Done.
+ void MigrateDeviceMuteSettings(std::string active_device);
+ void MigrateDeviceVolumeSettings(std::string active_device);
+
+ // Notifies the AudioPrefObserver for audio policy pref changes.
+ void NotifyAudioPolicyChange();
+
+ scoped_ptr<base::DictionaryValue> device_mute_settings_;
+ scoped_ptr<base::DictionaryValue> device_volume_settings_;
+
+ PrefService* local_state_; // not owned
+ PrefChangeRegistrar pref_change_registrar_;
+ ObserverList<AudioPrefObserver> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerImpl);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698