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

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

Issue 896673003: Propagate audible state from player to the containing tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: AudioStreamMonitor and corresponding Android monitor now have common base class 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.cc
diff --git a/content/browser/media/audio_state_provider.cc b/content/browser/media/audio_state_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bc811287a0799910bdc9bb16ecebf64449525808
--- /dev/null
+++ b/content/browser/media/audio_state_provider.cc
@@ -0,0 +1,36 @@
+#include "content/browser/media/audio_state_provider.h"
+
+#include "base/logging.h"
+#include "content/browser/media/audio_stream_monitor.h"
+#include "content/public/browser/web_contents.h"
+
+namespace content {
+
+AudioStateProvider::AudioStateProvider(WebContents* contents)
+ : web_contents_(contents),
+ was_recently_audible_(false) {
+ DCHECK(web_contents_);
+}
+
+
+// static
+bool AudioStateProvider::audio_state_available() {
+#if defined OS_ANDROID
+ return true;
+#else
+ return AudioStreamMonitor::monitoring_available();
+#endif // !defined OS_ANDROID
+}
+
+bool AudioStateProvider::WasRecentlyAudible() const {
+ return was_recently_audible_;
+}
+
+void AudioStateProvider::Notify(bool new_state) {
+ if (was_recently_audible_ != new_state) {
+ was_recently_audible_ = new_state;
+ web_contents_->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
+ }
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698