Index: content/browser/media/audio_state_provider.h |
diff --git a/content/browser/media/audio_state_provider.h b/content/browser/media/audio_state_provider.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..814d4e7fddee0e3a18bd09a8ffefef52617f34c3 |
--- /dev/null |
+++ b/content/browser/media/audio_state_provider.h |
@@ -0,0 +1,54 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_BROWSER_MEDIA_AUDIO_STATE_PROVIDER_H_ |
+#define CONTENT_BROWSER_MEDIA_AUDIO_STATE_PROVIDER_H_ |
+ |
+namespace content { |
+class WebContents; |
+class AudioStreamMonitor; |
+ |
+// This class is associated with a WebContents, and maintains the audible |
+// state regarding all the players in it. |
+// The audible state is true if at least one player is playing a sound. |
+// Whenever the audible state of the WebContents as a whole changes, this |
+// class sends a notification to it. |
+// |
+// Each WebContentsImpl owns an AudioStateProvider |
+class AudioStateProvider { |
+ public: |
+ explicit AudioStateProvider(WebContents* web_contents); |
+ virtual ~AudioStateProvider() {} |
+ |
+ // Indicates whether this service is available on the system. |
+ 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().
|
+ |
+ // 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.
|
+ // return its monitor. |
+ 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
|
+ |
+ // Returns true if the WebContents is playing or has recently been |
+ // playing the sound. |
+ virtual bool WasRecentlyAudible() const; |
+ |
+ void set_was_recently_audible_for_testing(bool value) { |
+ was_recently_audible_ = value; |
+ } |
+ |
+ protected: |
+ // Notify WebContents that the audio state has changed. |
+ void Notify(bool new_state); |
+ |
+ // The WebContents instance instance to receive indicator toggle |
+ // notifications. This pointer should be valid for the lifetime of |
+ // AudioStreamMonitor. |
+ WebContents* const web_contents_; |
+ |
+ // The audio state that is being maintained |
+ bool was_recently_audible_; |
no sievers
2015/02/25 21:22:04
nit: extra space
Tima Vaisburd
2015/02/28 03:16:05
Done.
|
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_MEDIA_AUDIO_STATE_PROVIDER_H_ |