зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1623486 - part3 : add a method on ContentMediaController to propagate Picture-in-Picture status to the chrome process. r=chunmin
Differential Revision: https://phabricator.services.mozilla.com/D67711 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
9ec32fbe45
Коммит
44bd719954
|
@ -5786,6 +5786,19 @@ mozilla::ipc::IPCResult ContentParent::RecvNotifyMediaAudibleChanged(
|
|||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvNotifyPictureInPictureModeChanged(
|
||||
const MaybeDiscarded<BrowsingContext>& aContext, bool aEnabled) {
|
||||
if (aContext.IsNullOrDiscarded()) {
|
||||
return IPC_OK();
|
||||
}
|
||||
if (RefPtr<MediaController> controller =
|
||||
aContext.get_canonical()->GetMediaController()) {
|
||||
controller->SetIsInPictureInPictureMode(aEnabled);
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvUpdateSHEntriesInBC(
|
||||
PSHEntryParent* aNewLSHE, PSHEntryParent* aNewOSHE,
|
||||
const MaybeDiscarded<BrowsingContext>& aMaybeContext) {
|
||||
|
|
|
@ -1238,6 +1238,9 @@ class ContentParent final
|
|||
mozilla::ipc::IPCResult RecvNotifyMediaAudibleChanged(
|
||||
const MaybeDiscarded<BrowsingContext>& aContext, bool aAudible);
|
||||
|
||||
mozilla::ipc::IPCResult RecvNotifyPictureInPictureModeChanged(
|
||||
const MaybeDiscarded<BrowsingContext>& aContext, bool aEnabled);
|
||||
|
||||
mozilla::ipc::IPCResult RecvNotifyMediaSessionUpdated(
|
||||
const MaybeDiscarded<BrowsingContext>& aContext, bool aIsCreated);
|
||||
|
||||
|
|
|
@ -1485,6 +1485,13 @@ parent:
|
|||
async NotifyMediaAudibleChanged(MaybeDiscardedBrowsingContext aContext,
|
||||
bool aAudible);
|
||||
|
||||
/**
|
||||
* When media enabled or disabled the Picture-in-Picture mode, we have to
|
||||
* update that to the media controller in the chrome process.
|
||||
*/
|
||||
async NotifyPictureInPictureModeChanged(
|
||||
MaybeDiscardedBrowsingContext aContext, bool aEnabled);
|
||||
|
||||
/**
|
||||
* This method is used to update media session's status when it's being
|
||||
* created or destroyed.
|
||||
|
|
|
@ -145,6 +145,33 @@ void ContentMediaController::NotifyAudibleStateChanged(
|
|||
}
|
||||
}
|
||||
|
||||
void ContentMediaController::NotifyPictureInPictureModeChanged(
|
||||
const MediaControlKeysEventListener* aMedia, bool aEnabled) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!mListeners.Contains(aMedia)) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<BrowsingContext> bc = GetTopLevelBrowsingContext();
|
||||
if (!bc || bc->IsDiscarded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG("Notify media Picture-in-Picture mode '%s' in BC %" PRId64,
|
||||
aEnabled ? "enabled" : "disabled", bc->Id());
|
||||
if (XRE_IsContentProcess()) {
|
||||
ContentChild* contentChild = ContentChild::GetSingleton();
|
||||
Unused << contentChild->SendNotifyPictureInPictureModeChanged(bc, aEnabled);
|
||||
} else {
|
||||
// Currently this only happen when we disable e10s, otherwise all controlled
|
||||
// media would be run in the content process.
|
||||
if (RefPtr<MediaController> controller =
|
||||
bc->Canonical()->GetMediaController()) {
|
||||
controller->SetIsInPictureInPictureMode(aEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ContentMediaController::OnKeyPressed(MediaControlKeysEvent aEvent) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
LOG("Handle '%s' event, listener num=%zu", ToMediaControlKeysEventStr(aEvent),
|
||||
|
|
|
@ -64,6 +64,11 @@ class ContentMediaAgent : public MediaControlKeysEventSource {
|
|||
virtual void NotifyAudibleStateChanged(
|
||||
const MediaControlKeysEventListener* aMedia, bool aAudible) = 0;
|
||||
|
||||
// Use this method to update the picture in picture mode state of controlled
|
||||
// media, and it's safe to notify same state again.
|
||||
virtual void NotifyPictureInPictureModeChanged(
|
||||
const MediaControlKeysEventListener* aMedia, bool aEnabled) = 0;
|
||||
|
||||
private:
|
||||
// We don't need them in our case, so make them private to prevent usage.
|
||||
bool Open() override { return true; }
|
||||
|
@ -117,6 +122,8 @@ class ContentMediaController final : public ContentMediaAgent,
|
|||
ControlledMediaState aState) override;
|
||||
void NotifyAudibleStateChanged(const MediaControlKeysEventListener* aMedia,
|
||||
bool aAudible) override;
|
||||
void NotifyPictureInPictureModeChanged(
|
||||
const MediaControlKeysEventListener* aMedia, bool aEnabled) override;
|
||||
|
||||
// ContentControlKeyEventReceiver method
|
||||
void OnKeyPressed(MediaControlKeysEvent aEvent) override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче