| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_ | 5 #ifndef CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_ |
| 6 #define CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_ | 6 #define CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 explicit AudioDevicesPrefHandlerImpl(PrefService* local_state); | 27 explicit AudioDevicesPrefHandlerImpl(PrefService* local_state); |
| 28 | 28 |
| 29 // Overridden from AudioDevicesPrefHandler. | 29 // Overridden from AudioDevicesPrefHandler. |
| 30 double GetOutputVolumeValue(const AudioDevice* device) override; | 30 double GetOutputVolumeValue(const AudioDevice* device) override; |
| 31 double GetInputGainValue(const AudioDevice* device) override; | 31 double GetInputGainValue(const AudioDevice* device) override; |
| 32 void SetVolumeGainValue(const AudioDevice& device, double value) override; | 32 void SetVolumeGainValue(const AudioDevice& device, double value) override; |
| 33 | 33 |
| 34 bool GetMuteValue(const AudioDevice& device) override; | 34 bool GetMuteValue(const AudioDevice& device) override; |
| 35 void SetMuteValue(const AudioDevice& device, bool mute_on) override; | 35 void SetMuteValue(const AudioDevice& device, bool mute_on) override; |
| 36 | 36 |
| 37 AudioDeviceState GetDeviceState(const AudioDevice &device) override; |
| 38 void SetDeviceState(const AudioDevice& device, |
| 39 AudioDeviceState state) override; |
| 40 |
| 37 bool GetAudioOutputAllowedValue() override; | 41 bool GetAudioOutputAllowedValue() override; |
| 38 | 42 |
| 39 void AddAudioPrefObserver(AudioPrefObserver* observer) override; | 43 void AddAudioPrefObserver(AudioPrefObserver* observer) override; |
| 40 void RemoveAudioPrefObserver(AudioPrefObserver* observer) override; | 44 void RemoveAudioPrefObserver(AudioPrefObserver* observer) override; |
| 41 | 45 |
| 42 // Registers volume and mute preferences. | 46 // Registers volume and mute preferences. |
| 43 static void RegisterPrefs(PrefRegistrySimple* registry); | 47 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 44 | 48 |
| 45 protected: | 49 protected: |
| 46 ~AudioDevicesPrefHandlerImpl() override; | 50 ~AudioDevicesPrefHandlerImpl() override; |
| 47 | 51 |
| 48 private: | 52 private: |
| 49 // Initializes the observers for the policy prefs. | 53 // Initializes the observers for the policy prefs. |
| 50 void InitializePrefObservers(); | 54 void InitializePrefObservers(); |
| 51 | 55 |
| 52 // Update and save methods for the mute preferences for all devices. | 56 // Update and save methods for the mute preferences for all devices. |
| 53 void UpdateDevicesMutePref(); | 57 void UpdateDevicesMutePref(); |
| 54 void SaveDevicesMutePref(); | 58 void SaveDevicesMutePref(); |
| 55 | 59 |
| 56 // Update and save methods for the volume preferences for all devices. | 60 // Update and save methods for the volume preferences for all devices. |
| 57 void UpdateDevicesVolumePref(); | 61 void UpdateDevicesVolumePref(); |
| 58 void SaveDevicesVolumePref(); | 62 void SaveDevicesVolumePref(); |
| 59 | 63 |
| 64 // Update and save methods for the active state for all devices. |
| 65 void UpdateDevicesStatePref(); |
| 66 void SaveDevicesStatePref(); |
| 67 |
| 60 double GetVolumeGainPrefValue(const AudioDevice& device); | 68 double GetVolumeGainPrefValue(const AudioDevice& device); |
| 61 double GetDeviceDefaultOutputVolume(const AudioDevice& device); | 69 double GetDeviceDefaultOutputVolume(const AudioDevice& device); |
| 62 | 70 |
| 63 // Methods to migrate the mute and volume settings for a device from the | 71 // Methods to migrate the mute and volume settings for a device from the |
| 64 // previous global pref value to the new per device pref value for the | 72 // previous global pref value to the new per device pref value for the |
| 65 // current active device. If a previous global setting doesn't exist, we'll | 73 // current active device. If a previous global setting doesn't exist, we'll |
| 66 // use default values of mute = off and volume = 75%. | 74 // use default values of mute = off and volume = 75%. |
| 67 void MigrateDeviceMuteSettings(const std::string& active_device); | 75 void MigrateDeviceMuteSettings(const std::string& active_device); |
| 68 void MigrateDeviceVolumeSettings(const std::string& active_device); | 76 void MigrateDeviceVolumeSettings(const std::string& active_device); |
| 69 | 77 |
| 70 // Notifies the AudioPrefObserver for audio policy pref changes. | 78 // Notifies the AudioPrefObserver for audio policy pref changes. |
| 71 void NotifyAudioPolicyChange(); | 79 void NotifyAudioPolicyChange(); |
| 72 | 80 |
| 73 scoped_ptr<base::DictionaryValue> device_mute_settings_; | 81 scoped_ptr<base::DictionaryValue> device_mute_settings_; |
| 74 scoped_ptr<base::DictionaryValue> device_volume_settings_; | 82 scoped_ptr<base::DictionaryValue> device_volume_settings_; |
| 83 scoped_ptr<base::DictionaryValue> device_state_settings_; |
| 75 | 84 |
| 76 PrefService* local_state_; // not owned | 85 PrefService* local_state_; // not owned |
| 77 | 86 |
| 78 PrefChangeRegistrar pref_change_registrar_; | 87 PrefChangeRegistrar pref_change_registrar_; |
| 79 base::ObserverList<AudioPrefObserver> observers_; | 88 base::ObserverList<AudioPrefObserver> observers_; |
| 80 | 89 |
| 81 DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerImpl); | 90 DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerImpl); |
| 82 }; | 91 }; |
| 83 | 92 |
| 84 } // namespace chromeos | 93 } // namespace chromeos |
| 85 | 94 |
| 86 #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_ | 95 #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_ |
| OLD | NEW |