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

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

Issue 1349783006: Cleanup: Pass std::string as const reference if possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert third_party changes Created 5 years, 3 months 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
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 #include "chromeos/audio/audio_devices_pref_handler_impl.h" 5 #include "chromeos/audio/audio_devices_pref_handler_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 while (!it.IsAtEnd()) { 180 while (!it.IsAtEnd()) {
181 double volume = kDefaultOutputVolumePercent; 181 double volume = kDefaultOutputVolumePercent;
182 bool success = it.value().GetAsDouble(&volume); 182 bool success = it.value().GetAsDouble(&volume);
183 DCHECK(success); 183 DCHECK(success);
184 dict_update->SetDouble(it.key(), volume); 184 dict_update->SetDouble(it.key(), volume);
185 it.Advance(); 185 it.Advance();
186 } 186 }
187 } 187 }
188 188
189 void AudioDevicesPrefHandlerImpl::MigrateDeviceMuteSettings( 189 void AudioDevicesPrefHandlerImpl::MigrateDeviceMuteSettings(
190 std::string active_device) { 190 const std::string& active_device) {
191 int old_mute = local_state_->GetInteger(prefs::kAudioMute); 191 int old_mute = local_state_->GetInteger(prefs::kAudioMute);
192 device_mute_settings_->SetInteger(active_device, old_mute); 192 device_mute_settings_->SetInteger(active_device, old_mute);
193 SaveDevicesMutePref(); 193 SaveDevicesMutePref();
194 } 194 }
195 195
196 void AudioDevicesPrefHandlerImpl::MigrateDeviceVolumeSettings( 196 void AudioDevicesPrefHandlerImpl::MigrateDeviceVolumeSettings(
197 std::string active_device) { 197 const std::string& active_device) {
198 double old_volume = local_state_->GetDouble(prefs::kAudioVolumePercent); 198 double old_volume = local_state_->GetDouble(prefs::kAudioVolumePercent);
199 device_volume_settings_->SetDouble(active_device, old_volume); 199 device_volume_settings_->SetDouble(active_device, old_volume);
200 SaveDevicesVolumePref(); 200 SaveDevicesVolumePref();
201 } 201 }
202 202
203 void AudioDevicesPrefHandlerImpl::NotifyAudioPolicyChange() { 203 void AudioDevicesPrefHandlerImpl::NotifyAudioPolicyChange() {
204 FOR_EACH_OBSERVER(AudioPrefObserver, 204 FOR_EACH_OBSERVER(AudioPrefObserver,
205 observers_, 205 observers_,
206 OnAudioPolicyPrefChanged()); 206 OnAudioPolicyPrefChanged());
207 } 207 }
208 208
209 // static 209 // static
210 void AudioDevicesPrefHandlerImpl::RegisterPrefs(PrefRegistrySimple* registry) { 210 void AudioDevicesPrefHandlerImpl::RegisterPrefs(PrefRegistrySimple* registry) {
211 registry->RegisterDictionaryPref(prefs::kAudioDevicesVolumePercent); 211 registry->RegisterDictionaryPref(prefs::kAudioDevicesVolumePercent);
212 registry->RegisterDictionaryPref(prefs::kAudioDevicesMute); 212 registry->RegisterDictionaryPref(prefs::kAudioDevicesMute);
213 213
214 // Register the prefs backing the audio muting policies. 214 // Register the prefs backing the audio muting policies.
215 // Policy for audio input is handled by kAudioCaptureAllowed in the Chrome 215 // Policy for audio input is handled by kAudioCaptureAllowed in the Chrome
216 // media system. 216 // media system.
217 registry->RegisterBooleanPref(prefs::kAudioOutputAllowed, true); 217 registry->RegisterBooleanPref(prefs::kAudioOutputAllowed, true);
218 218
219 // Register the legacy audio prefs for migration. 219 // Register the legacy audio prefs for migration.
220 registry->RegisterDoublePref(prefs::kAudioVolumePercent, 220 registry->RegisterDoublePref(prefs::kAudioVolumePercent,
221 kDefaultOutputVolumePercent); 221 kDefaultOutputVolumePercent);
222 registry->RegisterIntegerPref(prefs::kAudioMute, kPrefMuteOff); 222 registry->RegisterIntegerPref(prefs::kAudioMute, kPrefMuteOff);
223 } 223 }
224 224
225 } // namespace chromeos 225 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698