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.
5 #ifndef CONTENT_BROWSER_MEDIA_AUDIO_STATE_PROVIDER_H_
6 #define CONTENT_BROWSER_MEDIA_AUDIO_STATE_PROVIDER_H_
8 #include "content/common/content_export.h"
12 class AudioStreamMonitor
;
14 // This class is associated with a WebContents, and maintains the audible
15 // state regarding all the players in it.
16 // The audible state is true if at least one player is playing a sound.
17 // Whenever the audible state of the WebContents as a whole changes, this
18 // class sends a notification to it.
20 // Each WebContentsImpl owns an AudioStateProvider
21 class CONTENT_EXPORT AudioStateProvider
{
23 explicit AudioStateProvider(WebContents
* web_contents
);
24 virtual ~AudioStateProvider() {}
26 // Indicates whether this service is available on the system.
27 virtual bool IsAudioStateAvailable() const = 0;
29 // If this provider uses monitoring (i.e. measure the signal),
30 // return its monitor.
31 virtual AudioStreamMonitor
* audio_stream_monitor() = 0;
33 // Returns true if the WebContents is playing or has recently been
35 virtual bool WasRecentlyAudible() const;
37 void set_was_recently_audible_for_testing(bool value
) {
38 was_recently_audible_
= value
;
42 // Notify WebContents that the audio state has changed.
43 void Notify(bool new_state
);
45 // The WebContents instance instance to receive indicator toggle
46 // notifications. This pointer should be valid for the lifetime of
47 // AudioStreamMonitor.
48 WebContents
* const web_contents_
;
50 // The audio state that is being maintained
51 bool was_recently_audible_
;
55 } // namespace content
57 #endif // CONTENT_BROWSER_MEDIA_AUDIO_STATE_PROVIDER_H_