Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Side by Side Diff: chromeos/audio/audio_devices_pref_handler_impl.h

Issue 2510093003: Handle audio node stable device ID change (Closed)
Patch Set: fix a typo Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/audio/audio_device.cc ('k') | chromeos/audio/audio_devices_pref_handler_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 void LoadDevicesVolumePref(); 66 void LoadDevicesVolumePref();
67 void SaveDevicesVolumePref(); 67 void SaveDevicesVolumePref();
68 68
69 // Load and save methods for the active state for all devices. 69 // Load and save methods for the active state for all devices.
70 void LoadDevicesStatePref(); 70 void LoadDevicesStatePref();
71 void SaveDevicesStatePref(); 71 void SaveDevicesStatePref();
72 72
73 double GetVolumeGainPrefValue(const AudioDevice& device); 73 double GetVolumeGainPrefValue(const AudioDevice& device);
74 double GetDeviceDefaultOutputVolume(const AudioDevice& device); 74 double GetDeviceDefaultOutputVolume(const AudioDevice& device);
75 75
76 // Methods to migrate the mute and volume settings for a device from the 76 // Migrates devices state pref for an audio device. Device settings are
77 // previous global pref value to the new per device pref value for the 77 // saved under device stable device ID - this method migrates device state
78 // current active device. If a previous global setting doesn't exist, we'll 78 // for a device that is saved under key derived from v1 stable device ID to
79 // use default values of mute = off and volume = 75%. 79 // |device_key|. Note that |device_key| should be the key derived from
80 void MigrateDeviceMuteSettings(const std::string& active_device); 80 // |device|'s v2 stable device ID.
81 void MigrateDeviceVolumeSettings(const std::string& active_device); 81 bool MigrateDevicesStatePref(const std::string& device_key,
82 const AudioDevice& device);
83
84 // Methods to migrate the mute and volume settings for an audio device.
85 // Migration is done in the folowing way:
86 // 1. If there is a setting for the device under |device_key|, do nothing.
87 // (Note that |device_key| is expected to be the key derived from
88 // |device's| v2 stable device ID).
89 // 2. If there is a setting for the device under the key derived from
90 // |device|'s v1 stable device ID, move the value to |device_key|.
91 // 3. If a previous global pref value exists, move it to the per device
92 // setting (under |device_key|).
93 // 4. If a previous global setting is not set, use default values of
94 // mute = off and volume = 75%.
95 void MigrateDeviceMuteSettings(const std::string& device_key,
96 const AudioDevice& device);
97 void MigrateDeviceVolumeGainSettings(const std::string& device_key,
98 const AudioDevice& device);
82 99
83 // Notifies the AudioPrefObserver for audio policy pref changes. 100 // Notifies the AudioPrefObserver for audio policy pref changes.
84 void NotifyAudioPolicyChange(); 101 void NotifyAudioPolicyChange();
85 102
86 std::unique_ptr<base::DictionaryValue> device_mute_settings_; 103 std::unique_ptr<base::DictionaryValue> device_mute_settings_;
87 std::unique_ptr<base::DictionaryValue> device_volume_settings_; 104 std::unique_ptr<base::DictionaryValue> device_volume_settings_;
88 std::unique_ptr<base::DictionaryValue> device_state_settings_; 105 std::unique_ptr<base::DictionaryValue> device_state_settings_;
89 106
90 PrefService* local_state_; // not owned 107 PrefService* local_state_; // not owned
91 108
92 PrefChangeRegistrar pref_change_registrar_; 109 PrefChangeRegistrar pref_change_registrar_;
93 base::ObserverList<AudioPrefObserver> observers_; 110 base::ObserverList<AudioPrefObserver> observers_;
94 111
95 DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerImpl); 112 DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerImpl);
96 }; 113 };
97 114
98 } // namespace chromeos 115 } // namespace chromeos
99 116
100 #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_ 117 #endif // CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_
OLDNEW
« no previous file with comments | « chromeos/audio/audio_device.cc ('k') | chromeos/audio/audio_devices_pref_handler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698