mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 18:47:53 +00:00
Bug 1553328 - use browsing context to notify tab mute/unmute media. r=baku,farre
This bug will use the browsing context to notify content tab to mute/unmute media, instead of using MessageManager. We would use the top level canonical browsing context to set the media mute property for the top level window and propagate it to other top level windows in other processes. If we don't do so, we're not able to mute/unmute media in the different process when we we enable Fission, because the current way we use can only notify one process and would cause the media on other process can't be muted/unmuted. Differential Revision: https://phabricator.services.mozilla.com/D32077 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
31f6daf51c
commit
d6b68d2693
@ -178,6 +178,16 @@ void CanonicalBrowsingContext::NotifyStartDelayedAutoplayMedia() {
|
||||
});
|
||||
}
|
||||
|
||||
void CanonicalBrowsingContext::NotifyMediaMutedChanged(bool aMuted) {
|
||||
nsPIDOMWindowOuter* window = GetDOMWindow();
|
||||
if (window) {
|
||||
window->SetAudioMuted(aMuted);
|
||||
}
|
||||
Group()->EachParent([&](ContentParent* aParent) {
|
||||
Unused << aParent->SendSetMediaMuted(this, aMuted);
|
||||
});
|
||||
}
|
||||
|
||||
void CanonicalBrowsingContext::SetFieldEpochsForChild(
|
||||
ContentParent* aChild, const BrowsingContext::FieldEpochs& aEpochs) {
|
||||
mChildFieldEpochs.Put(aChild->ChildID(), aEpochs);
|
||||
|
@ -73,6 +73,11 @@ class CanonicalBrowsingContext final : public BrowsingContext {
|
||||
// autoplay media.
|
||||
void NotifyStartDelayedAutoplayMedia();
|
||||
|
||||
// This function is used to mute or unmute all media within a tab. It would
|
||||
// set the media mute property for the top level window and propagate it to
|
||||
// other top level windows in other processes.
|
||||
void NotifyMediaMutedChanged(bool aMuted);
|
||||
|
||||
// Validate that the given process is allowed to perform the given
|
||||
// transaction. aSource is |nullptr| if set in the parent process.
|
||||
bool ValidateTransaction(const Transaction& aTransaction,
|
||||
|
@ -2886,6 +2886,9 @@ void nsPIDOMWindowOuter::SetAudioMuted(bool aMuted) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("nsPIDOMWindowOuter %p, SetAudioMuted=%s", this,
|
||||
aMuted ? "muted" : "unmuted"));
|
||||
mAudioMuted = aMuted;
|
||||
RefreshMediaElementsVolume();
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ interface CanonicalBrowsingContext : BrowsingContext {
|
||||
readonly attribute WindowGlobalParent? embedderWindowGlobal;
|
||||
|
||||
void notifyStartDelayedAutoplayMedia();
|
||||
void notifyMediaMutedChanged(boolean muted);
|
||||
};
|
||||
|
||||
[Exposed=Window, ChromeOnly]
|
||||
|
@ -3627,6 +3627,16 @@ mozilla::ipc::IPCResult ContentChild::RecvStartDelayedAutoplayMediaComponents(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvSetMediaMuted(
|
||||
BrowsingContext* aContext, bool aMuted) {
|
||||
MOZ_ASSERT(aContext);
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = aContext->GetDOMWindow();
|
||||
if (window) {
|
||||
window->SetAudioMuted(aMuted);
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEventTarget> ContentChild::GetSpecificMessageEventTarget(
|
||||
const Message& aMsg) {
|
||||
switch (aMsg.type()) {
|
||||
|
@ -674,6 +674,9 @@ class ContentChild final : public PContentChild,
|
||||
mozilla::ipc::IPCResult RecvStartDelayedAutoplayMediaComponents(
|
||||
BrowsingContext* aContext);
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetMediaMuted(BrowsingContext* aContext,
|
||||
bool aMuted);
|
||||
|
||||
void HoldBrowsingContextGroup(BrowsingContextGroup* aBCG);
|
||||
|
||||
#ifdef NIGHTLY_BUILD
|
||||
|
@ -800,6 +800,11 @@ child:
|
||||
*/
|
||||
async StartDelayedAutoplayMediaComponents(BrowsingContext aContext);
|
||||
|
||||
/**
|
||||
* This method is used to notifty content process to mute or unmute media.
|
||||
*/
|
||||
async SetMediaMuted(BrowsingContext aContext, bool aMuted);
|
||||
|
||||
// Begin subscribing to a new BrowsingContextGroup, sending down the current
|
||||
// value for every individual BrowsingContext.
|
||||
async RegisterBrowsingContextGroup(BrowsingContextInitializer[] aInits);
|
||||
|
@ -979,12 +979,12 @@ class MozBrowser extends MozElements.MozElementMixin(XULFrameElement) {
|
||||
if (!transientState) {
|
||||
this._audioMuted = true;
|
||||
}
|
||||
this.messageManager.sendAsyncMessage("AudioPlayback", { type: "mute" });
|
||||
this.frameLoader.browsingContext.notifyMediaMutedChanged(true);
|
||||
}
|
||||
|
||||
unmute() {
|
||||
this._audioMuted = false;
|
||||
this.messageManager.sendAsyncMessage("AudioPlayback", { type: "unmute" });
|
||||
this.frameLoader.browsingContext.notifyMediaMutedChanged(false);
|
||||
}
|
||||
|
||||
pauseMedia(disposable) {
|
||||
|
Loading…
Reference in New Issue
Block a user