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

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

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 #ifndef CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_
6 #define CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ 6 #define CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "base/prefs/public/pref_change_registrar.h" 11 #include "base/prefs/public/pref_change_registrar.h"
12 #include "base/prefs/public/pref_observer.h"
12 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
13 #include "content/public/browser/notification_details.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/notification_source.h"
17 14
18 template <typename T> struct DefaultSingletonTraits; 15 template <typename T> struct DefaultSingletonTraits;
19 16
20 class PrefChangeRegistrar; 17 class PrefChangeRegistrar;
21 class PrefService; 18 class PrefService;
22 19
23 namespace chromeos { 20 namespace chromeos {
24 21
25 class AudioMixer; 22 class AudioMixer;
26 23
27 class AudioHandler : public content::NotificationObserver { 24 class AudioHandler : public PrefObserver {
28 public: 25 public:
29 class VolumeObserver { 26 class VolumeObserver {
30 public: 27 public:
31 virtual void OnVolumeChanged() = 0; 28 virtual void OnVolumeChanged() = 0;
32 virtual void OnMuteToggled() = 0; 29 virtual void OnMuteToggled() = 0;
33 protected: 30 protected:
34 VolumeObserver() {} 31 VolumeObserver() {}
35 virtual ~VolumeObserver() {} 32 virtual ~VolumeObserver() {}
36 DISALLOW_COPY_AND_ASSIGN(VolumeObserver); 33 DISALLOW_COPY_AND_ASSIGN(VolumeObserver);
37 }; 34 };
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // Is the capture volume currently muted? 66 // Is the capture volume currently muted?
70 bool IsCaptureMuted(); 67 bool IsCaptureMuted();
71 68
72 // Mutes or unmutes all capture devices. If unmutes and the volume was set 69 // Mutes or unmutes all capture devices. If unmutes and the volume was set
73 // to 0, then increases volume to a minimum value (5%). 70 // to 0, then increases volume to a minimum value (5%).
74 void SetCaptureMuted(bool do_mute); 71 void SetCaptureMuted(bool do_mute);
75 72
76 void AddVolumeObserver(VolumeObserver* observer); 73 void AddVolumeObserver(VolumeObserver* observer);
77 void RemoveVolumeObserver(VolumeObserver* observer); 74 void RemoveVolumeObserver(VolumeObserver* observer);
78 75
79 // Overridden from content::NotificationObserver: 76 // Overridden from PrefObserver:
80 virtual void Observe(int type, 77 virtual void OnPreferenceChanged(PrefServiceBase* service,
81 const content::NotificationSource& source, 78 const std::string& pref_name) OVERRIDE;
82 const content::NotificationDetails& details) OVERRIDE;
83 79
84 private: 80 private:
85 // Defines the delete on exit Singleton traits we like. Best to have this 81 // Defines the delete on exit Singleton traits we like. Best to have this
86 // and constructor/destructor private as recommended for Singletons. 82 // and constructor/destructor private as recommended for Singletons.
87 friend struct DefaultSingletonTraits<AudioHandler>; 83 friend struct DefaultSingletonTraits<AudioHandler>;
88 84
89 // Takes ownership of |mixer|. 85 // Takes ownership of |mixer|.
90 explicit AudioHandler(AudioMixer* mixer); 86 explicit AudioHandler(AudioMixer* mixer);
91 virtual ~AudioHandler(); 87 virtual ~AudioHandler();
92 88
93 // Initializes the observers for the policy prefs. 89 // Initializes the observers for the policy prefs.
94 void InitializePrefObservers(); 90 void InitializePrefObservers();
95 91
96 // Applies the audio muting policies whenever the user logs in or policy 92 // Applies the audio muting policies whenever the user logs in or policy
97 // change notification is received. 93 // change notification is received.
98 void ApplyAudioPolicy(); 94 void ApplyAudioPolicy();
99 95
100 // Sets volume to specified value and notifies observers. 96 // Sets volume to specified value and notifies observers.
101 void SetVolumePercentInternal(double volume_percent); 97 void SetVolumePercentInternal(double volume_percent);
102 98
103 scoped_ptr<AudioMixer> mixer_; 99 scoped_ptr<AudioMixer> mixer_;
104 100
105 ObserverList<VolumeObserver> volume_observers_; 101 ObserverList<VolumeObserver> volume_observers_;
106 102
107 PrefService* local_state_; // not owned 103 PrefService* local_state_; // not owned
108 104
109 PrefChangeRegistrar pref_change_registrar_; 105 PrefChangeRegistrar pref_change_registrar_;
110 content::NotificationRegistrar registrar_;
111 106
112 DISALLOW_COPY_AND_ASSIGN(AudioHandler); 107 DISALLOW_COPY_AND_ASSIGN(AudioHandler);
113 }; 108 };
114 109
115 } // namespace chromeos 110 } // namespace chromeos
116 111
117 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ 112 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698