chrome: Implement CefBrowserHost::SetAudioMuted/IsAudioMuted (fixes #3893)

This commit is contained in:
Marshall Greenblatt
2025-03-21 13:17:33 -04:00
parent 8cf30843f9
commit 49ac6882ec
6 changed files with 24 additions and 36 deletions

View File

@ -901,29 +901,6 @@ void AlloyBrowserHostImpl::DragSourceEndedAt(
}
}
void AlloyBrowserHostImpl::SetAudioMuted(bool mute) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::SetAudioMuted,
this, mute));
return;
}
if (!web_contents()) {
return;
}
web_contents()->SetAudioMuted(mute);
}
bool AlloyBrowserHostImpl::IsAudioMuted() {
if (!CEF_CURRENTLY_ON_UIT()) {
DCHECK(false) << "called on invalid thread";
return false;
}
if (!web_contents()) {
return false;
}
return web_contents()->IsAudioMuted();
}
// content::WebContentsDelegate methods.
// -----------------------------------------------------------------------------

View File

@ -115,8 +115,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
void DragTargetDrop(const CefMouseEvent& event) override;
void DragSourceSystemDragEnded() override;
void DragSourceEndedAt(int x, int y, DragOperationsMask op) override;
void SetAudioMuted(bool mute) override;
bool IsAudioMuted() override;
void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) override;

View File

@ -783,6 +783,28 @@ CefRefPtr<CefNavigationEntry> CefBrowserHostBase::GetVisibleNavigationEntry() {
return new CefNavigationEntryImpl(entry);
}
void CefBrowserHostBase::SetAudioMuted(bool mute) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostBase::SetAudioMuted,
this, mute));
return;
}
if (auto web_contents = GetWebContents()) {
web_contents->SetAudioMuted(mute);
}
}
bool CefBrowserHostBase::IsAudioMuted() {
if (!CEF_CURRENTLY_ON_UIT()) {
DCHECK(false) << "called on invalid thread";
return false;
}
if (auto web_contents = GetWebContents()) {
return web_contents->IsAudioMuted();
}
return false;
}
void CefBrowserHostBase::NotifyMoveOrResizeStarted() {
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC))
if (!CEF_CURRENTLY_ON_UIT()) {

View File

@ -262,6 +262,8 @@ class CefBrowserHostBase : public CefBrowserHost,
void GetNavigationEntries(CefRefPtr<CefNavigationEntryVisitor> visitor,
bool current_only) override;
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
void SetAudioMuted(bool mute) override;
bool IsAudioMuted() override;
void NotifyMoveOrResizeStarted() override;
bool IsFullscreen() override;
void ExitFullscreen(bool will_cause_resize) override;

View File

@ -327,15 +327,6 @@ void ChromeBrowserHostImpl::DragSourceEndedAt(int x,
NOTIMPLEMENTED();
}
void ChromeBrowserHostImpl::SetAudioMuted(bool mute) {
NOTIMPLEMENTED();
}
bool ChromeBrowserHostImpl::IsAudioMuted() {
NOTIMPLEMENTED();
return false;
}
void ChromeBrowserHostImpl::SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) {

View File

@ -109,8 +109,6 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
void DragTargetDrop(const CefMouseEvent& event) override;
void DragSourceSystemDragEnded() override;
void DragSourceEndedAt(int x, int y, DragOperationsMask op) override;
void SetAudioMuted(bool mute) override;
bool IsAudioMuted() override;
void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) override;