зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1642715 - part3 : prevent controlling inactive controller. r=chunmin
This patch would - stop notifying media key to media in content process is the controller is inactive The advantage of doing this is - to prevent unexpectedly controlling an inactive controller Differential Revision: https://phabricator.services.mozilla.com/D79235
This commit is contained in:
Родитель
84619e1b6b
Коммит
b83eca9ce8
|
@ -124,9 +124,9 @@ bool MediaController::IsPlaying() const { return IsMediaPlaying(); }
|
||||||
|
|
||||||
void MediaController::UpdateMediaControlKeyToContentMediaIfNeeded(
|
void MediaController::UpdateMediaControlKeyToContentMediaIfNeeded(
|
||||||
MediaControlKey aKey) {
|
MediaControlKey aKey) {
|
||||||
// There is no controlled media existing or controller has been shutdown, we
|
// If the controller isn't active or it has been shutdown, we don't need to
|
||||||
// have no need to update media action to the content process.
|
// update media action to the content process.
|
||||||
if (!IsAnyMediaBeingControlled() || mShutdown) {
|
if (!mIsActive || mShutdown) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If we have an active media session, then we should directly notify the
|
// If we have an active media session, then we should directly notify the
|
||||||
|
@ -205,7 +205,7 @@ NS_IMETHODIMP MediaController::Notify(nsITimer* aTimer) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mIsRegisteredToService) {
|
if (!mIsActive) {
|
||||||
LOG("Cancel deactivation timer because controller has been deactivated");
|
LOG("Cancel deactivation timer because controller has been deactivated");
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -239,33 +239,33 @@ void MediaController::NotifyMediaAudibleChanged(uint64_t aBrowsingContextId,
|
||||||
|
|
||||||
bool MediaController::ShouldActivateController() const {
|
bool MediaController::ShouldActivateController() const {
|
||||||
MOZ_ASSERT(!mShutdown);
|
MOZ_ASSERT(!mShutdown);
|
||||||
return IsAnyMediaBeingControlled() && IsAudible() && !mIsRegisteredToService;
|
return IsAnyMediaBeingControlled() && IsAudible() && !mIsActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MediaController::ShouldDeactivateController() const {
|
bool MediaController::ShouldDeactivateController() const {
|
||||||
MOZ_ASSERT(!mShutdown);
|
MOZ_ASSERT(!mShutdown);
|
||||||
return !IsAnyMediaBeingControlled() && mIsRegisteredToService;
|
return !IsAnyMediaBeingControlled() && mIsActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaController::Activate() {
|
void MediaController::Activate() {
|
||||||
LOG("Activate");
|
|
||||||
MOZ_ASSERT(!mShutdown);
|
MOZ_ASSERT(!mShutdown);
|
||||||
RefPtr<MediaControlService> service = MediaControlService::GetService();
|
RefPtr<MediaControlService> service = MediaControlService::GetService();
|
||||||
if (service && !mIsRegisteredToService) {
|
if (service && !mIsActive) {
|
||||||
mIsRegisteredToService = service->RegisterActiveMediaController(this);
|
LOG("Activate");
|
||||||
MOZ_ASSERT(mIsRegisteredToService, "Fail to register controller!");
|
mIsActive = service->RegisterActiveMediaController(this);
|
||||||
|
MOZ_ASSERT(mIsActive, "Fail to register controller!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaController::Deactivate() {
|
void MediaController::Deactivate() {
|
||||||
LOG("Deactivate");
|
|
||||||
MOZ_ASSERT(!mShutdown);
|
MOZ_ASSERT(!mShutdown);
|
||||||
RefPtr<MediaControlService> service = MediaControlService::GetService();
|
RefPtr<MediaControlService> service = MediaControlService::GetService();
|
||||||
if (service) {
|
if (service) {
|
||||||
service->GetAudioFocusManager().RevokeAudioFocus(this);
|
service->GetAudioFocusManager().RevokeAudioFocus(this);
|
||||||
if (mIsRegisteredToService) {
|
if (mIsActive) {
|
||||||
mIsRegisteredToService = !service->UnregisterActiveMediaController(this);
|
LOG("Deactivate");
|
||||||
MOZ_ASSERT(!mIsRegisteredToService, "Fail to unregister controller!");
|
mIsActive = !service->UnregisterActiveMediaController(this);
|
||||||
|
MOZ_ASSERT(!mIsActive, "Fail to unregister controller!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ class MediaController final : public DOMEventTargetHelper,
|
||||||
|
|
||||||
void UpdateDeactivationTimerIfNeeded();
|
void UpdateDeactivationTimerIfNeeded();
|
||||||
|
|
||||||
bool mIsRegisteredToService = false;
|
bool mIsActive = false;
|
||||||
bool mShutdown = false;
|
bool mShutdown = false;
|
||||||
bool mIsInPictureInPictureMode = false;
|
bool mIsInPictureInPictureMode = false;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче