| Index: content/browser/web_contents/web_contents_impl.cc
|
| diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
|
| index 3b300b6e4f774eeb75b2580c72714c9d6a11a20d..16346ff0aa224fd4cda5a572d10212b7460f90e7 100644
|
| --- a/content/browser/web_contents/web_contents_impl.cc
|
| +++ b/content/browser/web_contents/web_contents_impl.cc
|
| @@ -108,6 +108,7 @@
|
| #if defined(OS_ANDROID)
|
| #include "content/browser/android/content_video_view.h"
|
| #include "content/browser/android/date_time_chooser_android.h"
|
| +#include "content/browser/android/media_players_observer.h"
|
| #include "content/browser/media/android/browser_media_player_manager.h"
|
| #include "content/browser/web_contents/web_contents_android.h"
|
| #endif
|
| @@ -358,7 +359,6 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context,
|
| geolocation_service_context_(new GeolocationServiceContext()),
|
| accessibility_mode_(
|
| BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()),
|
| - audio_stream_monitor_(this),
|
| virtual_keyboard_requested_(false),
|
| loading_weak_factory_(this) {
|
| frame_tree_.SetFrameRemoveListener(
|
| @@ -367,6 +367,12 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context,
|
| #if defined(ENABLE_BROWSER_CDMS)
|
| media_web_contents_observer_.reset(new MediaWebContentsObserver(this));
|
| #endif
|
| +
|
| +#if defined(OS_ANDROID)
|
| + audio_state_provider_.reset(new MediaPlayersObserver(this));
|
| +#else
|
| + audio_state_provider_.reset(new AudioStreamMonitor(this));
|
| +#endif
|
| }
|
|
|
| WebContentsImpl::~WebContentsImpl() {
|
| @@ -1042,7 +1048,7 @@ void WebContentsImpl::NotifyNavigationStateChanged(
|
| // Create and release the audio power save blocker depending on whether the
|
| // tab is actively producing audio or not.
|
| if ((changed_flags & INVALIDATE_TYPE_TAB) &&
|
| - AudioStreamMonitor::monitoring_available()) {
|
| + AudioStateProvider::audio_state_available()) {
|
| if (WasRecentlyAudible()) {
|
| if (!audio_power_save_blocker_)
|
| CreateAudioPowerSaveBlocker();
|
| @@ -2496,7 +2502,7 @@ void WebContentsImpl::InsertCSS(const std::string& css) {
|
| }
|
|
|
| bool WebContentsImpl::WasRecentlyAudible() {
|
| - return audio_stream_monitor_.WasRecentlyAudible();
|
| + return audio_state_provider_->WasRecentlyAudible();
|
| }
|
|
|
| void WebContentsImpl::GetManifest(const GetManifestCallback& callback) {
|
| @@ -3188,7 +3194,7 @@ void WebContentsImpl::MaybeReleasePowerSaveBlockers() {
|
| // monitoring, release the audio power save blocker here instead of during
|
| // NotifyNavigationStateChanged().
|
| if (active_audio_players_.empty() &&
|
| - !AudioStreamMonitor::monitoring_available()) {
|
| + !AudioStateProvider::audio_state_available()) {
|
| audio_power_save_blocker_.reset();
|
| }
|
|
|
| @@ -3211,7 +3217,7 @@ void WebContentsImpl::OnMediaPlayingNotification(int64 player_cookie,
|
| // If we don't have audio stream monitoring, allocate the audio power save
|
| // blocker here instead of during NotifyNavigationStateChanged().
|
| if (!audio_power_save_blocker_ &&
|
| - !AudioStreamMonitor::monitoring_available()) {
|
| + !AudioStateProvider::audio_state_available()) {
|
| CreateAudioPowerSaveBlocker();
|
| }
|
| }
|
|
|