Bug 1133583 - pass window in EME notifications instead of null subject, r=cpearce
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -2606,17 +2606,17 @@ Navigator::RequestMediaKeySystemAccess(c
nsRefPtr<Promise> p = Promise::Create(go, aRv);
if (aRv.Failed()) {
return nullptr;
}
if (!Preferences::GetBool("media.eme.enabled", false)) {
// EME disabled by user, send notification to chrome so UI can
// inform user.
- MediaKeySystemAccess::NotifyObservers(aKeySystem,
+ MediaKeySystemAccess::NotifyObservers(mWindow, aKeySystem,
MediaKeySystemStatus::Api_disabled);
p->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return p.forget();
}
if (aKeySystem.IsEmpty() ||
(aOptions.WasPassed() && aOptions.Value().IsEmpty())) {
p->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR);
@@ -2624,17 +2624,17 @@ Navigator::RequestMediaKeySystemAccess(c
}
MediaKeySystemStatus status = MediaKeySystemAccess::GetKeySystemStatus(aKeySystem);
if (status != MediaKeySystemStatus::Available) {
if (status != MediaKeySystemStatus::Error) {
// Failed due to user disabling something, send a notification to
// chrome, so we can show some UI to explain how the user can rectify
// the situation.
- MediaKeySystemAccess::NotifyObservers(aKeySystem, status);
+ MediaKeySystemAccess::NotifyObservers(mWindow, aKeySystem, status);
}
p->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return p.forget();
}
// TODO: Wait (async) until the CDM is downloaded, if it's not already.
if (!aOptions.WasPassed() ||
--- a/dom/media/eme/MediaKeySystemAccess.cpp
+++ b/dom/media/eme/MediaKeySystemAccess.cpp
@@ -221,24 +221,25 @@ MediaKeySystemAccess::IsSupported(const
return true;
}
return false;
}
/* static */
void
-MediaKeySystemAccess::NotifyObservers(const nsAString& aKeySystem,
+MediaKeySystemAccess::NotifyObservers(nsIDOMWindow* aWindow,
+ const nsAString& aKeySystem,
MediaKeySystemStatus aStatus)
{
RequestMediaKeySystemAccessNotification data;
data.mKeySystem = aKeySystem;
data.mStatus = aStatus;
nsAutoString json;
data.ToJSON(json);
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (obs) {
- obs->NotifyObservers(nullptr, "mediakeys-request", json.get());
+ obs->NotifyObservers(aWindow, "mediakeys-request", json.get());
}
}
} // namespace dom
} // namespace mozilla
--- a/dom/media/eme/MediaKeySystemAccess.h
+++ b/dom/media/eme/MediaKeySystemAccess.h
@@ -44,17 +44,18 @@ public:
already_AddRefed<Promise> CreateMediaKeys(ErrorResult& aRv);
static MediaKeySystemStatus GetKeySystemStatus(const nsAString& aKeySystem);
static bool IsSupported(const nsAString& aKeySystem,
const Sequence<MediaKeySystemOptions>& aOptions);
- static void NotifyObservers(const nsAString& aKeySystem,
+ static void NotifyObservers(nsIDOMWindow* aWindow,
+ const nsAString& aKeySystem,
MediaKeySystemStatus aStatus);
private:
nsCOMPtr<nsPIDOMWindow> mParent;
const nsString mKeySystem;
};
} // namespace dom
--- a/dom/media/eme/MediaKeys.cpp
+++ b/dom/media/eme/MediaKeys.cpp
@@ -362,17 +362,18 @@ MediaKeys::OnCDMCreated(PromiseId aId, c
}
mNodeId = aNodeId;
nsRefPtr<MediaKeys> keys(this);
promise->MaybeResolve(keys);
if (mCreatePromiseId == aId) {
Release();
}
- MediaKeySystemAccess::NotifyObservers(mKeySystem,
+ MediaKeySystemAccess::NotifyObservers(mParent,
+ mKeySystem,
MediaKeySystemStatus::Cdm_created);
}
already_AddRefed<MediaKeySession>
MediaKeys::CreateSession(JSContext* aCx,
SessionType aSessionType,
ErrorResult& aRv)
{