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