| 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 #include "content/common/content_export.h" | |
| 9 | |
| 10 namespace content { | |
| 11 class WebContents; | |
| 12 class AudioStreamMonitor; | |
| 13 | |
| 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. | |
| 19 // | |
| 20 // Each WebContentsImpl owns an AudioStateProvider | |
| 21 class CONTENT_EXPORT AudioStateProvider { | |
| 22 public: | |
| 23 explicit AudioStateProvider(WebContents* web_contents); | |
| 24 virtual ~AudioStateProvider() {} | |
| 25 | |
| 26 // Indicates whether this service is available on the system. | |
| 27 virtual bool IsAudioStateAvailable() const = 0; | |
| 28 | |
| 29 // If this provider uses monitoring (i.e. measure the signal), | |
| 30 // return its monitor. | |
| 31 virtual AudioStreamMonitor* audio_stream_monitor() = 0; | |
| 32 | |
| 33 // Returns true if the WebContents is playing or has recently been | |
| 34 // playing the sound. | |
| 35 virtual bool WasRecentlyAudible() const; | |
| 36 | |
| 37 void set_was_recently_audible_for_testing(bool value) { | |
| 38 was_recently_audible_ = value; | |
| 39 } | |
| 40 | |
| 41 protected: | |
| 42 // Notify WebContents that the audio state has changed. | |
| 43 void Notify(bool new_state); | |
| 44 | |
| 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_; | |
| 49 | |
| 50 // The audio state that is being maintained | |
| 51 bool was_recently_audible_; | |
| 52 | |
| 53 }; | |
| 54 | |
| 55 } // namespace content | |
| 56 | |
| 57 #endif // CONTENT_BROWSER_MEDIA_AUDIO_STATE_PROVIDER_H_ | |
| OLD | NEW |