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

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

Issue 10873085: Implement two new policies to control muting the audio I/O. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to ToT. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/app/policy/policy_templates.json ('k') | chrome/browser/chromeos/audio/audio_handler.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) 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/observer_list.h" 9 #include "base/observer_list.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
12 #include "chrome/browser/api/prefs/pref_change_registrar.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"
12 17
13 template <typename T> struct DefaultSingletonTraits; 18 template <typename T> struct DefaultSingletonTraits;
14 19
20 class PrefChangeRegistrar;
15 class PrefService; 21 class PrefService;
16 22
17 namespace chromeos { 23 namespace chromeos {
18 24
19 class AudioMixer; 25 class AudioMixer;
20 26
21 class AudioHandler { 27 class AudioHandler : public content::NotificationObserver {
22 public: 28 public:
23 class VolumeObserver { 29 class VolumeObserver {
24 public: 30 public:
25 virtual void OnVolumeChanged() = 0; 31 virtual void OnVolumeChanged() = 0;
26 virtual void OnMuteToggled() = 0; 32 virtual void OnMuteToggled() = 0;
27 protected: 33 protected:
28 VolumeObserver() {} 34 VolumeObserver() {}
29 virtual ~VolumeObserver() {} 35 virtual ~VolumeObserver() {}
30 DISALLOW_COPY_AND_ASSIGN(VolumeObserver); 36 DISALLOW_COPY_AND_ASSIGN(VolumeObserver);
31 }; 37 };
(...skipping 19 matching lines...) Expand all
51 57
52 // Adjusts volume up (positive percentage) or down (negative percentage). 58 // Adjusts volume up (positive percentage) or down (negative percentage).
53 void AdjustVolumeByPercent(double adjust_by_percent); 59 void AdjustVolumeByPercent(double adjust_by_percent);
54 60
55 // Is the volume currently muted? 61 // Is the volume currently muted?
56 bool IsMuted(); 62 bool IsMuted();
57 63
58 // Mutes or unmutes all audio. 64 // Mutes or unmutes all audio.
59 void SetMuted(bool do_mute); 65 void SetMuted(bool do_mute);
60 66
67 // Is the capture volume currently muted?
68 bool IsCaptureMuted();
69
70 // Mutes or unmutes all capture devices.
71 void SetCaptureMuted(bool do_mute);
72
61 void AddVolumeObserver(VolumeObserver* observer); 73 void AddVolumeObserver(VolumeObserver* observer);
62 void RemoveVolumeObserver(VolumeObserver* observer); 74 void RemoveVolumeObserver(VolumeObserver* observer);
63 75
76 // Overridden from content::NotificationObserver:
77 virtual void Observe(int type,
78 const content::NotificationSource& source,
79 const content::NotificationDetails& details) OVERRIDE;
80
64 private: 81 private:
65 // Defines the delete on exit Singleton traits we like. Best to have this 82 // Defines the delete on exit Singleton traits we like. Best to have this
66 // and constructor/destructor private as recommended for Singletons. 83 // and constructor/destructor private as recommended for Singletons.
67 friend struct DefaultSingletonTraits<AudioHandler>; 84 friend struct DefaultSingletonTraits<AudioHandler>;
68 85
69 // Takes ownership of |mixer|. 86 // Takes ownership of |mixer|.
70 explicit AudioHandler(AudioMixer* mixer); 87 explicit AudioHandler(AudioMixer* mixer);
71 virtual ~AudioHandler(); 88 virtual ~AudioHandler();
72 89
90 // Initializes the observers for the policy prefs.
91 void InitializePrefObservers();
92
93 // Applies the audio muting policies whenever the user logs in or policy
94 // change notification is received.
95 void ApplyAudioPolicy();
96
73 scoped_ptr<AudioMixer> mixer_; 97 scoped_ptr<AudioMixer> mixer_;
74 98
75 ObserverList<VolumeObserver> volume_observers_; 99 ObserverList<VolumeObserver> volume_observers_;
76 100
77 PrefService* prefs_; // not owned 101 PrefService* local_state_; // not owned
102
103 PrefChangeRegistrar pref_change_registrar_;
104 content::NotificationRegistrar registrar_;
78 105
79 DISALLOW_COPY_AND_ASSIGN(AudioHandler); 106 DISALLOW_COPY_AND_ASSIGN(AudioHandler);
80 }; 107 };
81 108
82 } // namespace chromeos 109 } // namespace chromeos
83 110
84 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ 111 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/app/policy/policy_templates.json ('k') | chrome/browser/chromeos/audio/audio_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698