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

Side by Side Diff: chrome/browser/chromeos/audio/audio_handler.cc

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/audio/audio_handler.h" 5 #include "chrome/browser/chromeos/audio/audio_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 // static 73 // static
74 AudioHandler* AudioHandler::GetInstance() { 74 AudioHandler* AudioHandler::GetInstance() {
75 VLOG_IF(1, !g_audio_handler) 75 VLOG_IF(1, !g_audio_handler)
76 << "AudioHandler::GetInstance() called with NULL global instance."; 76 << "AudioHandler::GetInstance() called with NULL global instance.";
77 return g_audio_handler; 77 return g_audio_handler;
78 } 78 }
79 79
80 // static 80 // static
81 void AudioHandler::RegisterPrefs(PrefService* local_state) { 81 void AudioHandler::RegisterPrefs(PrefServiceSimple* local_state) {
82 if (!local_state->FindPreference(prefs::kAudioVolumePercent)) { 82 if (!local_state->FindPreference(prefs::kAudioVolumePercent)) {
83 local_state->RegisterDoublePref(prefs::kAudioVolumePercent, 83 local_state->RegisterDoublePref(prefs::kAudioVolumePercent,
84 kDefaultVolumePercent, 84 kDefaultVolumePercent);
85 PrefService::UNSYNCABLE_PREF);
86 } 85 }
87 if (!local_state->FindPreference(prefs::kAudioMute)) { 86 if (!local_state->FindPreference(prefs::kAudioMute)) {
88 local_state->RegisterIntegerPref(prefs::kAudioMute, 87 local_state->RegisterIntegerPref(prefs::kAudioMute,
89 kPrefMuteOff, 88 kPrefMuteOff);
90 PrefService::UNSYNCABLE_PREF);
91 } 89 }
92 90
93 if (!local_state->FindPreference(prefs::kAudioOutputAllowed)) { 91 if (!local_state->FindPreference(prefs::kAudioOutputAllowed)) {
94 // Register the prefs backing the audio muting policies. 92 // Register the prefs backing the audio muting policies.
95 local_state->RegisterBooleanPref(prefs::kAudioOutputAllowed, 93 local_state->RegisterBooleanPref(prefs::kAudioOutputAllowed,
96 true, 94 true);
97 PrefService::UNSYNCABLE_PREF);
98 } 95 }
99 // This pref has moved to the media subsystem but we should verify it is there 96 // This pref has moved to the media subsystem but we should verify it is there
100 // before we use it. 97 // before we use it.
101 if (!local_state->FindPreference(prefs::kAudioCaptureAllowed)) { 98 if (!local_state->FindPreference(prefs::kAudioCaptureAllowed)) {
102 local_state->RegisterBooleanPref(prefs::kAudioCaptureAllowed, 99 local_state->RegisterBooleanPref(prefs::kAudioCaptureAllowed,
103 true, 100 true);
104 PrefService::UNSYNCABLE_PREF);
105 } 101 }
106 } 102 }
107 103
108 double AudioHandler::GetVolumePercent() { 104 double AudioHandler::GetVolumePercent() {
109 return mixer_->GetVolumePercent(); 105 return mixer_->GetVolumePercent();
110 } 106 }
111 107
112 void AudioHandler::SetVolumePercent(double volume_percent) { 108 void AudioHandler::SetVolumePercent(double volume_percent) {
113 volume_percent = min(max(volume_percent, 0.0), 100.0); 109 volume_percent = min(max(volume_percent, 0.0), 100.0);
114 if (volume_percent <= kMuteThresholdPercent) 110 if (volume_percent <= kMuteThresholdPercent)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 mixer_->SetCaptureMuteLocked(false); 199 mixer_->SetCaptureMuteLocked(false);
204 if (local_state_->GetBoolean(prefs::kAudioCaptureAllowed)) { 200 if (local_state_->GetBoolean(prefs::kAudioCaptureAllowed)) {
205 mixer_->SetCaptureMuted(false); 201 mixer_->SetCaptureMuted(false);
206 } else { 202 } else {
207 mixer_->SetCaptureMuted(true); 203 mixer_->SetCaptureMuted(true);
208 mixer_->SetCaptureMuteLocked(true); 204 mixer_->SetCaptureMuteLocked(true);
209 } 205 }
210 } 206 }
211 207
212 } // namespace chromeos 208 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698