Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Unified Diff: content/browser/media/audio_state_provider.h

Issue 896673003: Propagate audible state from player to the containing tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing copyright notice Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..5bd1b7189aa7fe37d213e75f65acb2a2aac01ec2
--- /dev/null
+++ b/content/browser/media/audio_state_provider.h
@@ -0,0 +1,57 @@
+// 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_
+
+#include "content/common/content_export.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 CONTENT_EXPORT AudioStateProvider {
+ public:
+ explicit AudioStateProvider(WebContents* web_contents);
+ virtual ~AudioStateProvider() {}
+
+ // Indicates whether this service is available on the system.
+ virtual bool IsAudioStateAvailable() const = 0;
+
+ // If this provider uses monitoring (i.e. measure the signal),
+ // return its monitor.
+ virtual AudioStreamMonitor* audio_stream_monitor() = 0;
+
+ // 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_;
+
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_MEDIA_AUDIO_STATE_PROVIDER_H_
« no previous file with comments | « content/browser/media/android/browser_media_player_manager.cc ('k') | content/browser/media/audio_state_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698