OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_MEDIA_AUDIO_STATE_PROVIDER_H_ | |
6 #define CONTENT_BROWSER_MEDIA_AUDIO_STATE_PROVIDER_H_ | |
7 | |
8 namespace content { | |
9 class WebContents; | |
10 class AudioStreamMonitor; | |
11 | |
12 // This class is associated with a WebContents, and maintains the audible | |
13 // state regarding all the players in it. | |
14 // The audible state is true if at least one player is playing a sound. | |
15 // Whenever the audible state of the WebContents as a whole changes, this | |
16 // class sends a notification to it. | |
17 // | |
18 // Each WebContentsImpl owns an AudioStateProvider | |
19 class AudioStateProvider { | |
20 public: | |
21 explicit AudioStateProvider(WebContents* web_contents); | |
22 virtual ~AudioStateProvider() {} | |
23 | |
24 // Indicates whether this service is available on the system. | |
25 static bool audio_state_available(); | |
Tima Vaisburd
2015/02/24 03:06:50
Does it have to be static?
qinmin
2015/02/24 18:02:19
I think static is fine, but would prefer this to b
no sievers
2015/02/25 21:22:04
'virtual' would maybe be a tiny bit nicer since it
Tima Vaisburd
2015/02/28 03:16:05
Made pure virtual method IsAudioStateAvailable().
| |
26 | |
27 // If this provider use monitoring (i.e. measure the signal), | |
qinmin
2015/02/24 18:02:19
nit: s/use/uses/
Tima Vaisburd
2015/02/28 03:16:05
Done.
| |
28 // return its monitor. | |
29 virtual AudioStreamMonitor* audio_stream_monitor() = 0; | |
no sievers
2015/02/25 21:22:04
Only used for testing, i.e. GetAudioStreamMonitorF
Tima Vaisburd
2015/02/28 03:16:05
It is also used in AudioStreamMonitorFromRenderFra
| |
30 | |
31 // Returns true if the WebContents is playing or has recently been | |
32 // playing the sound. | |
33 virtual bool WasRecentlyAudible() const; | |
34 | |
35 void set_was_recently_audible_for_testing(bool value) { | |
36 was_recently_audible_ = value; | |
37 } | |
38 | |
39 protected: | |
40 // Notify WebContents that the audio state has changed. | |
41 void Notify(bool new_state); | |
42 | |
43 // The WebContents instance instance to receive indicator toggle | |
44 // notifications. This pointer should be valid for the lifetime of | |
45 // AudioStreamMonitor. | |
46 WebContents* const web_contents_; | |
47 | |
48 // The audio state that is being maintained | |
49 bool was_recently_audible_; | |
no sievers
2015/02/25 21:22:04
nit: extra space
Tima Vaisburd
2015/02/28 03:16:05
Done.
| |
50 }; | |
51 | |
52 } // namespace content | |
53 | |
54 #endif // CONTENT_BROWSER_MEDIA_AUDIO_STATE_PROVIDER_H_ | |
OLD | NEW |