Don't preload rarely seen large images
[chromium-blink-merge.git] / chromeos / audio / audio_devices_pref_handler_impl.h
blobaeb9f3ef1a0936cb73bbaa6a96370848e9f9aef8
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 CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_
6 #define CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_
8 #include <string>
10 #include "base/observer_list.h"
11 #include "base/prefs/pref_change_registrar.h"
12 #include "base/values.h"
13 #include "chromeos/audio/audio_devices_pref_handler.h"
14 #include "chromeos/chromeos_export.h"
16 class PrefRegistrySimple;
17 class PrefService;
19 namespace chromeos {
21 // Class which implements AudioDevicesPrefHandler interface and register audio
22 // preferences as well.
23 class CHROMEOS_EXPORT AudioDevicesPrefHandlerImpl
24 : public AudioDevicesPrefHandler {
25 public:
26 // |local_state| is the device-wide preference service.
27 explicit AudioDevicesPrefHandlerImpl(PrefService* local_state);
29 // Overridden from AudioDevicesPrefHandler.
30 double GetOutputVolumeValue(const AudioDevice* device) override;
31 double GetInputGainValue(const AudioDevice* device) override;
32 void SetVolumeGainValue(const AudioDevice& device, double value) override;
34 bool GetMuteValue(const AudioDevice& device) override;
35 void SetMuteValue(const AudioDevice& device, bool mute_on) override;
37 bool GetAudioOutputAllowedValue() override;
39 void AddAudioPrefObserver(AudioPrefObserver* observer) override;
40 void RemoveAudioPrefObserver(AudioPrefObserver* observer) override;
42 // Registers volume and mute preferences.
43 static void RegisterPrefs(PrefRegistrySimple* registry);
45 protected:
46 ~AudioDevicesPrefHandlerImpl() override;
48 private:
49 // Initializes the observers for the policy prefs.
50 void InitializePrefObservers();
52 // Update and save methods for the mute preferences for all devices.
53 void UpdateDevicesMutePref();
54 void SaveDevicesMutePref();
56 // Update and save methods for the volume preferences for all devices.
57 void UpdateDevicesVolumePref();
58 void SaveDevicesVolumePref();
60 double GetVolumeGainPrefValue(const AudioDevice& device);
61 double GetDeviceDefaultOutputVolume(const AudioDevice& device);
63 // 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
65 // current active device. If a previous global setting doesn't exist, we'll
66 // use default values of mute = off and volume = 75%.
67 void MigrateDeviceMuteSettings(std::string active_device);
68 void MigrateDeviceVolumeSettings(std::string active_device);
70 // Notifies the AudioPrefObserver for audio policy pref changes.
71 void NotifyAudioPolicyChange();
73 scoped_ptr<base::DictionaryValue> device_mute_settings_;
74 scoped_ptr<base::DictionaryValue> device_volume_settings_;
76 PrefService* local_state_; // not owned
78 PrefChangeRegistrar pref_change_registrar_;
79 base::ObserverList<AudioPrefObserver> observers_;
81 DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerImpl);
84 } // namespace chromeos
86 #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_