| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_ |
| 7 |
| 8 #include "base/observer_list.h" |
| 9 #include "base/prefs/pref_change_registrar.h" |
| 10 #include "base/values.h" |
| 11 #include "chromeos/audio/audio_devices_pref_handler.h" |
| 12 |
| 13 class PrefRegistrySimple; |
| 14 class PrefService; |
| 15 |
| 16 namespace chromeos { |
| 17 |
| 18 // Class which implements AudioDevicesPrefHandler interface and register audio |
| 19 // preferences as well. |
| 20 class AudioDevicesPrefHandlerImpl : public AudioDevicesPrefHandler { |
| 21 public: |
| 22 explicit AudioDevicesPrefHandlerImpl(PrefService* local_state); |
| 23 |
| 24 // Overridden from AudioDevicesPrefHandler. |
| 25 virtual double GetOutputVolumeValue() OVERRIDE; |
| 26 virtual bool GetOutputMuteValue() OVERRIDE; |
| 27 virtual void SetOutputVolumeValue(double volume_percent) OVERRIDE; |
| 28 virtual void SetOutputMuteValue(bool mute_on) OVERRIDE; |
| 29 virtual bool GetAudioCaptureAllowedValue() OVERRIDE; |
| 30 virtual bool GetAudioOutputAllowedValue() OVERRIDE; |
| 31 virtual void AddAudioPrefObserver(AudioPrefObserver* observer) OVERRIDE; |
| 32 virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) OVERRIDE; |
| 33 |
| 34 // Registers volume and mute preferences. |
| 35 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 36 |
| 37 protected: |
| 38 virtual ~AudioDevicesPrefHandlerImpl(); |
| 39 |
| 40 private: |
| 41 // Initializes the observers for the policy prefs. |
| 42 void InitializePrefObservers(); |
| 43 |
| 44 // Update and save methods for the mute preferences for all devices. |
| 45 void UpdateDevicesMutePref(); |
| 46 void SaveDevicesMutePref(); |
| 47 |
| 48 // Update and save methods for the volume preferences for all devices. |
| 49 void UpdateDevicesVolumePref(); |
| 50 void SaveDevicesVolumePref(); |
| 51 |
| 52 // Methods to migrate the mute and volume settings for a device from the |
| 53 // previous global pref value to the new per device pref value for the |
| 54 // current active device. If a previous global setting doesn't exist, we'll |
| 55 // use default values of mute=off and volume=75%. |
| 56 void MigrateDeviceMuteSettings(std::string active_device); |
| 57 void MigrateDeviceVolumeSettings(std::string active_device); |
| 58 |
| 59 // Notifies the AudioPrefObserver for audio policy pref changes. |
| 60 void NotifyAudioPolicyChange(); |
| 61 |
| 62 scoped_ptr<base::DictionaryValue> device_mute_settings_; |
| 63 scoped_ptr<base::DictionaryValue> device_volume_settings_; |
| 64 |
| 65 PrefService* local_state_; // not owned |
| 66 PrefChangeRegistrar pref_change_registrar_; |
| 67 ObserverList<AudioPrefObserver> observers_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerImpl); |
| 70 }; |
| 71 |
| 72 } // namespace chromeos |
| 73 |
| 74 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_ |
| OLD | NEW |