Bug 1133583 - pass window in EME notifications instead of null subject, r=cpearce a=lmandel
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 16 Feb 2015 21:25:11 +0000
changeset 250217 448ff154c5fd
parent 250216 e13431adabfd
child 250218 d8e655d11fc5
push id4521
push usercpearce@mozilla.com
push date2015-03-04 01:22 +0000
treeherdermozilla-beta@8abdbdecd2d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lmandel
bugs1133583
milestone37.0
Bug 1133583 - pass window in EME notifications instead of null subject, r=cpearce a=lmandel
dom/base/Navigator.cpp
dom/media/eme/MediaKeySystemAccess.cpp
dom/media/eme/MediaKeySystemAccess.h
dom/media/eme/MediaKeys.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -2579,17 +2579,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);
@@ -2597,17 +2597,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)
 {