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

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

Issue 11741003: Remove PrefServiceSimple, replacing it with PrefService and PrefRegistrySimple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix double registration in Chrome Frame test. Created 7 years, 10 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 | 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/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #if defined(USE_CRAS) 15 #if defined(USE_CRAS)
16 #include "chrome/browser/chromeos/audio/audio_mixer_cras.h" 16 #include "chrome/browser/chromeos/audio/audio_mixer_cras.h"
17 #else 17 #else
18 #include "chrome/browser/chromeos/audio/audio_mixer_alsa.h" 18 #include "chrome/browser/chromeos/audio/audio_mixer_alsa.h"
19 #endif 19 #endif
20 #include "chrome/browser/prefs/pref_registry_simple.h"
20 #include "chrome/browser/prefs/pref_service.h" 21 #include "chrome/browser/prefs/pref_service.h"
21 #include "chrome/common/chrome_notification_types.h" 22 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
23 24
24 using std::max; 25 using std::max;
25 using std::min; 26 using std::min;
26 27
27 namespace chromeos { 28 namespace chromeos {
28 29
29 namespace { 30 namespace {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 73 }
73 74
74 // static 75 // static
75 AudioHandler* AudioHandler::GetInstance() { 76 AudioHandler* AudioHandler::GetInstance() {
76 VLOG_IF(1, !g_audio_handler) 77 VLOG_IF(1, !g_audio_handler)
77 << "AudioHandler::GetInstance() called with NULL global instance."; 78 << "AudioHandler::GetInstance() called with NULL global instance.";
78 return g_audio_handler; 79 return g_audio_handler;
79 } 80 }
80 81
81 // static 82 // static
82 void AudioHandler::RegisterPrefs(PrefServiceSimple* local_state) { 83 void AudioHandler::RegisterPrefs(PrefRegistrySimple* registry) {
83 if (!local_state->FindPreference(prefs::kAudioVolumePercent)) { 84 registry->RegisterDoublePref(prefs::kAudioVolumePercent,
84 local_state->RegisterDoublePref(prefs::kAudioVolumePercent, 85 kDefaultVolumePercent);
85 kDefaultVolumePercent); 86 registry->RegisterIntegerPref(prefs::kAudioMute, kPrefMuteOff);
86 } 87 // Register the prefs backing the audio muting policies.
87 if (!local_state->FindPreference(prefs::kAudioMute)) { 88 registry->RegisterBooleanPref(prefs::kAudioOutputAllowed, true);
88 local_state->RegisterIntegerPref(prefs::kAudioMute,
89 kPrefMuteOff);
90 }
91
92 if (!local_state->FindPreference(prefs::kAudioOutputAllowed)) {
93 // Register the prefs backing the audio muting policies.
94 local_state->RegisterBooleanPref(prefs::kAudioOutputAllowed,
95 true);
96 }
97 // This pref has moved to the media subsystem but we should verify it is there 89 // This pref has moved to the media subsystem but we should verify it is there
98 // before we use it. 90 // before we use it.
99 if (!local_state->FindPreference(prefs::kAudioCaptureAllowed)) { 91 registry->RegisterBooleanPref(prefs::kAudioCaptureAllowed, true);
100 local_state->RegisterBooleanPref(prefs::kAudioCaptureAllowed,
101 true);
102 }
103 } 92 }
104 93
105 double AudioHandler::GetVolumePercent() { 94 double AudioHandler::GetVolumePercent() {
106 return mixer_->GetVolumePercent(); 95 return mixer_->GetVolumePercent();
107 } 96 }
108 97
109 void AudioHandler::SetVolumePercent(double volume_percent) { 98 void AudioHandler::SetVolumePercent(double volume_percent) {
110 volume_percent = min(max(volume_percent, 0.0), 100.0); 99 volume_percent = min(max(volume_percent, 0.0), 100.0);
111 if (volume_percent <= kMuteThresholdPercent) 100 if (volume_percent <= kMuteThresholdPercent)
112 volume_percent = 0.0; 101 volume_percent = 0.0;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 mixer_->SetCaptureMuteLocked(false); 189 mixer_->SetCaptureMuteLocked(false);
201 if (local_state_->GetBoolean(prefs::kAudioCaptureAllowed)) { 190 if (local_state_->GetBoolean(prefs::kAudioCaptureAllowed)) {
202 mixer_->SetCaptureMuted(false); 191 mixer_->SetCaptureMuted(false);
203 } else { 192 } else {
204 mixer_->SetCaptureMuted(true); 193 mixer_->SetCaptureMuted(true);
205 mixer_->SetCaptureMuteLocked(true); 194 mixer_->SetCaptureMuteLocked(true);
206 } 195 }
207 } 196 }
208 197
209 } // namespace chromeos 198 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/audio/audio_handler.h ('k') | chrome/browser/chromeos/customization_document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698