| 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" |
| 11 #include "base/prefs/pref_change_registrar.h" | 11 #include "base/prefs/pref_change_registrar.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chromeos/audio/audio_devices_pref_handler.h" | 13 #include "chromeos/audio/audio_devices_pref_handler.h" |
| 14 #include "chromeos/chromeos_export.h" | 14 #include "chromeos/chromeos_export.h" |
| 15 | 15 |
| 16 class PrefRegistrySimple; | 16 class PrefRegistrySimple; |
| 17 class PrefService; | 17 class PrefService; |
| 18 | 18 |
| 19 namespace chromeos { | 19 namespace chromeos { |
| 20 | 20 |
| 21 // Class which implements AudioDevicesPrefHandler interface and register audio | 21 // Class which implements AudioDevicesPrefHandler interface and register audio |
| 22 // preferences as well. | 22 // preferences as well. |
| 23 class CHROMEOS_EXPORT AudioDevicesPrefHandlerImpl | 23 class CHROMEOS_EXPORT AudioDevicesPrefHandlerImpl |
| 24 : public AudioDevicesPrefHandler { | 24 : public AudioDevicesPrefHandler { |
| 25 public: | 25 public: |
| 26 AudioDevicesPrefHandlerImpl(PrefService* local_state, | 26 // |local_state| is the device-wide preference service. |
| 27 const std::string& audio_capture_allowed_pref); | 27 explicit AudioDevicesPrefHandlerImpl(PrefService* local_state); |
| 28 | 28 |
| 29 // Overridden from AudioDevicesPrefHandler. | 29 // Overridden from AudioDevicesPrefHandler. |
| 30 virtual double GetOutputVolumeValue(const AudioDevice* device) override; | 30 virtual double GetOutputVolumeValue(const AudioDevice* device) override; |
| 31 virtual double GetInputGainValue(const AudioDevice* device) override; | 31 virtual double GetInputGainValue(const AudioDevice* device) override; |
| 32 virtual void SetVolumeGainValue(const AudioDevice& device, | 32 virtual void SetVolumeGainValue(const AudioDevice& device, |
| 33 double value) override; | 33 double value) override; |
| 34 | 34 |
| 35 virtual bool GetMuteValue(const AudioDevice& device) override; | 35 virtual bool GetMuteValue(const AudioDevice& device) override; |
| 36 virtual void SetMuteValue(const AudioDevice& device, bool mute_on) override; | 36 virtual void SetMuteValue(const AudioDevice& device, bool mute_on) override; |
| 37 | 37 |
| 38 virtual bool GetAudioCaptureAllowedValue() override; | |
| 39 virtual bool GetAudioOutputAllowedValue() override; | 38 virtual bool GetAudioOutputAllowedValue() override; |
| 40 | 39 |
| 41 virtual void AddAudioPrefObserver(AudioPrefObserver* observer) override; | 40 virtual void AddAudioPrefObserver(AudioPrefObserver* observer) override; |
| 42 virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) override; | 41 virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) override; |
| 43 | 42 |
| 44 // Registers volume and mute preferences. | 43 // Registers volume and mute preferences. |
| 45 static void RegisterPrefs(PrefRegistrySimple* registry, | 44 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 46 const std::string& audio_capture_allowed_pref); | |
| 47 | 45 |
| 48 protected: | 46 protected: |
| 49 virtual ~AudioDevicesPrefHandlerImpl(); | 47 virtual ~AudioDevicesPrefHandlerImpl(); |
| 50 | 48 |
| 51 private: | 49 private: |
| 52 // Initializes the observers for the policy prefs. | 50 // Initializes the observers for the policy prefs. |
| 53 void InitializePrefObservers(); | 51 void InitializePrefObservers(); |
| 54 | 52 |
| 55 // Update and save methods for the mute preferences for all devices. | 53 // Update and save methods for the mute preferences for all devices. |
| 56 void UpdateDevicesMutePref(); | 54 void UpdateDevicesMutePref(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 71 void MigrateDeviceVolumeSettings(std::string active_device); | 69 void MigrateDeviceVolumeSettings(std::string active_device); |
| 72 | 70 |
| 73 // Notifies the AudioPrefObserver for audio policy pref changes. | 71 // Notifies the AudioPrefObserver for audio policy pref changes. |
| 74 void NotifyAudioPolicyChange(); | 72 void NotifyAudioPolicyChange(); |
| 75 | 73 |
| 76 scoped_ptr<base::DictionaryValue> device_mute_settings_; | 74 scoped_ptr<base::DictionaryValue> device_mute_settings_; |
| 77 scoped_ptr<base::DictionaryValue> device_volume_settings_; | 75 scoped_ptr<base::DictionaryValue> device_volume_settings_; |
| 78 | 76 |
| 79 PrefService* local_state_; // not owned | 77 PrefService* local_state_; // not owned |
| 80 | 78 |
| 81 // The name of the preferences to check if audio capture is allowed or the | |
| 82 // empty string if audio capture is always allowed. | |
| 83 const std::string audio_capture_allowed_pref_; | |
| 84 | |
| 85 PrefChangeRegistrar pref_change_registrar_; | 79 PrefChangeRegistrar pref_change_registrar_; |
| 86 ObserverList<AudioPrefObserver> observers_; | 80 ObserverList<AudioPrefObserver> observers_; |
| 87 | 81 |
| 88 DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerImpl); | 82 DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerImpl); |
| 89 }; | 83 }; |
| 90 | 84 |
| 91 } // namespace chromeos | 85 } // namespace chromeos |
| 92 | 86 |
| 93 #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_ | 87 #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_ |
| OLD | NEW |