| 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 5ec31a02c05612ac3f3807e8b0e0ed9d560352f4..e57a48a4d772dce7a8bd7e85c6a23d902fe3a9ad 100644
|
| --- a/content/browser/web_contents/web_contents_impl.cc
|
| +++ b/content/browser/web_contents/web_contents_impl.cc
|
| @@ -331,7 +331,8 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context,
|
| geolocation_service_context_(new GeolocationServiceContext()),
|
| accessibility_mode_(
|
| BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()),
|
| - audio_stream_monitor_(this),
|
| + audio_stream_monitor_(base::Bind(
|
| + &WebContentsImpl::NotifyAudibleStateChanged, base::Unretained(this))),
|
| loading_weak_factory_(this) {
|
| for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
|
| g_created_callbacks.Get().at(i).Run(this);
|
| @@ -949,14 +950,16 @@ bool WebContentsImpl::IsAudioMuted() const {
|
| return audio_muter_.get() && audio_muter_->is_muting();
|
| }
|
|
|
| -void WebContentsImpl::SetAudioMuted(bool mute) {
|
| - DVLOG(1) << "SetAudioMuted(mute=" << mute << "), was " << IsAudioMuted()
|
| - << " for WebContentsImpl@" << this;
|
| +void WebContentsImpl::SetAudioMuted(bool muted, const std::string& cause) {
|
| + DVLOG(1) << "SetAudioMuted(muted=" << muted << ", cause =" << cause
|
| + << "), was " << IsAudioMuted() << " for WebContentsImpl@" << this;
|
|
|
| - if (mute == IsAudioMuted())
|
| + if (muted == IsAudioMuted())
|
| return;
|
|
|
| - if (mute) {
|
| + NotifyMutedStateChanged(muted, cause);
|
| +
|
| + if (muted) {
|
| if (!audio_muter_)
|
| audio_muter_.reset(new WebContentsAudioMuter(this));
|
| audio_muter_->StartMuting();
|
| @@ -995,20 +998,32 @@ bool WebContentsImpl::IsBeingDestroyed() const {
|
|
|
| void WebContentsImpl::NotifyNavigationStateChanged(
|
| InvalidateTypes changed_flags) {
|
| + if (delegate_)
|
| + delegate_->NavigationStateChanged(this, changed_flags);
|
| +}
|
| +
|
| +void WebContentsImpl::NotifyAudibleStateChanged(bool is_audible) {
|
| + DCHECK(AudioStreamMonitor::monitoring_available());
|
| +
|
| // 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()) {
|
| - if (WasRecentlyAudible()) {
|
| - if (!audio_power_save_blocker_)
|
| - CreateAudioPowerSaveBlocker();
|
| - } else {
|
| - audio_power_save_blocker_.reset();
|
| - }
|
| + if (WasRecentlyAudible()) {
|
| + if (!audio_power_save_blocker_)
|
| + CreateAudioPowerSaveBlocker();
|
| + } else {
|
| + audio_power_save_blocker_.reset();
|
| }
|
|
|
| - if (delegate_)
|
| - delegate_->NavigationStateChanged(this, changed_flags);
|
| + // Notify delegate that a UI update may be needed for new tab media state.
|
| + NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
|
| +
|
| + FOR_EACH_OBSERVER(WebContentsObserver, observers_, TabAudible(is_audible));
|
| +}
|
| +
|
| +void WebContentsImpl::NotifyMutedStateChanged(
|
| + bool is_muted,
|
| + const std::string& cause) {
|
| + FOR_EACH_OBSERVER(WebContentsObserver, observers_, TabMuted(is_muted, cause));
|
| }
|
|
|
| base::TimeTicks WebContentsImpl::GetLastActiveTime() const {
|
|
|