Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / audio / audio_devices_pref_handler_impl.h
blobe6ecdc779dd604ea1f293c7063f12affba75198f
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.
5 #ifndef CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_
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"
13 class PrefRegistrySimple;
14 class PrefService;
16 namespace chromeos {
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);
24 // Overridden from AudioDevicesPrefHandler.
25 virtual double GetOutputVolumeValue(const AudioDevice* device) OVERRIDE;
26 virtual double GetInputGainValue(const AudioDevice* device) OVERRIDE;
27 virtual void SetVolumeGainValue(const AudioDevice& device,
28 double value) OVERRIDE;
30 virtual bool GetMuteValue(const AudioDevice& device) OVERRIDE;
31 virtual void SetMuteValue(const AudioDevice& device, bool mute_on) OVERRIDE;
33 virtual bool GetAudioCaptureAllowedValue() OVERRIDE;
34 virtual bool GetAudioOutputAllowedValue() OVERRIDE;
36 virtual void AddAudioPrefObserver(AudioPrefObserver* observer) OVERRIDE;
37 virtual void RemoveAudioPrefObserver(AudioPrefObserver* observer) OVERRIDE;
39 // Registers volume and mute preferences.
40 static void RegisterPrefs(PrefRegistrySimple* registry);
42 protected:
43 virtual ~AudioDevicesPrefHandlerImpl();
45 private:
46 // Initializes the observers for the policy prefs.
47 void InitializePrefObservers();
49 // Update and save methods for the mute preferences for all devices.
50 void UpdateDevicesMutePref();
51 void SaveDevicesMutePref();
53 // Update and save methods for the volume preferences for all devices.
54 void UpdateDevicesVolumePref();
55 void SaveDevicesVolumePref();
57 double GetVolumeGainPrefValue(const AudioDevice& device);
58 double GetDeviceDefaultOutputVolume(const AudioDevice& device);
60 // Methods to migrate the mute and volume settings for a device from the
61 // previous global pref value to the new per device pref value for the
62 // current active device. If a previous global setting doesn't exist, we'll
63 // use default values of mute = off and volume = 75%.
64 void MigrateDeviceMuteSettings(std::string active_device);
65 void MigrateDeviceVolumeSettings(std::string active_device);
67 // Notifies the AudioPrefObserver for audio policy pref changes.
68 void NotifyAudioPolicyChange();
70 scoped_ptr<base::DictionaryValue> device_mute_settings_;
71 scoped_ptr<base::DictionaryValue> device_volume_settings_;
73 PrefService* local_state_; // not owned
74 PrefChangeRegistrar pref_change_registrar_;
75 ObserverList<AudioPrefObserver> observers_;
77 DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerImpl);
80 } // namespace chromeos
82 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_