Commit 18360517 authored by Tommy Steimel's avatar Tommy Steimel Committed by Commit Bot

Continue showing sound setting in Page Info until navigation

This CL adds a WasEverAudible method to WebContents which returns true
if audio has played since the last navigation. This is then used by the
Page Info bubble to decide whether or not to show the sound content
setting.

Bug: 779878
Change-Id: I66453161dfe17df6868e66f11e7fce0b3c3a87b8
Reviewed-on: https://chromium-review.googlesource.com/747069Reviewed-by: default avatarLucas Garron <lgarron@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Tommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513025}
parent 5b164a0a
......@@ -157,9 +157,9 @@ bool ShouldShowPermission(const PageInfoUI::PermissionInfo& info,
if (!base::FeatureList::IsEnabled(features::kSoundContentSetting))
return false;
// The sound content setting should show always show up when the tab is
// playing audio or has recently played audio.
if (web_contents && web_contents->WasRecentlyAudible())
// The sound content setting should always show up when the tab has played
// audio.
if (web_contents && web_contents->WasEverAudible())
return true;
}
......
......@@ -1471,6 +1471,8 @@ void WebContentsImpl::OnAudioStateChanged(bool is_audible) {
// Notification for UI updates in response to the changed audio state.
NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
was_ever_audible_ = was_ever_audible_ || is_audible;
if (delegate_)
delegate_->OnAudioStateChanged(this, is_audible);
}
......@@ -3601,6 +3603,10 @@ bool WebContentsImpl::WasRecentlyAudible() {
browser_plugin_embedder_->WereAnyGuestsRecentlyAudible());
}
bool WebContentsImpl::WasEverAudible() {
return was_ever_audible_;
}
void WebContentsImpl::GetManifest(const GetManifestCallback& callback) {
manifest_manager_host_->GetManifest(callback);
}
......@@ -3704,6 +3710,11 @@ void WebContentsImpl::DidFinishNavigation(NavigationHandle* navigation_handle) {
manager->NavigationSucceeded();
}
}
if (navigation_handle->IsInMainFrame() &&
!navigation_handle->IsSameDocument()) {
was_ever_audible_ = false;
}
}
}
......
......@@ -448,6 +448,7 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
const blink::WebFindOptions& options) override;
void StopFinding(StopFindAction action) override;
bool WasRecentlyAudible() override;
bool WasEverAudible() override;
void GetManifest(const GetManifestCallback& callback) override;
bool IsFullscreenForCurrentTab() const override;
void ExitFullscreen(bool will_cause_resize) override;
......@@ -1669,6 +1670,8 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
bool has_persistent_video_ = false;
bool was_ever_audible_ = false;
base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_;
base::WeakPtrFactory<WebContentsImpl> weak_factory_;
......
......@@ -738,6 +738,10 @@ class WebContents : public PageNavigator,
// Returns true if audio has recently been audible from the WebContents.
virtual bool WasRecentlyAudible() = 0;
// Returns true if audio has been audible from the WebContents since the last
// navigation.
virtual bool WasEverAudible() = 0;
// The callback invoked when the renderer responds to a request for the main
// frame document's manifest. The url will be empty if the document specifies
// no manifest, and the manifest will be empty if any other failures occurred.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment