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 virtual bool IsAudioStateAvailable() const = 0; |
| 26 |
| 27 // If this provider uses monitoring (i.e. measure the signal), |
| 28 // return its monitor. |
| 29 virtual AudioStreamMonitor* audio_stream_monitor() = 0; |
| 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_; |
| 50 |
| 51 }; |
| 52 |
| 53 } // namespace content |
| 54 |
| 55 #endif // CONTENT_BROWSER_MEDIA_AUDIO_STATE_PROVIDER_H_ |
OLD | NEW |