Bug 1256186 - [EME] Show 'Enable EME' notification box only when MediaKeys requested for supported keysystem.; r=jwwang draft
authorKilik Kuo <kikuo@mozilla.com>
Fri, 01 Apr 2016 18:34:13 +0800
changeset 346554 e5f2b0e0d640d2c553661b2dd9b752d3a0918a46
parent 343894 b79f70a20d4a380715f1fc79a986aac6703d993a
child 347218 7c84c98af35288d975d80b294db93d2ddf749591
child 347654 3d1dcb159d5a40a0163f9be067dbdc8e32ea85d0
child 347952 03379467255dc7ea2b197d7b0859be94b4fefb0c
child 347972 380d52b75ee9a2bae387577d9345b900b8470844
push id14408
push userkikuo@mozilla.com
push dateFri, 01 Apr 2016 10:35:34 +0000
reviewersjwwang
bugs1256186
milestone48.0a1
Bug 1256186 - [EME] Show 'Enable EME' notification box only when MediaKeys requested for supported keysystem.; r=jwwang MozReview-Commit-ID: CxJbgzNKGJQ
dom/media/eme/MediaKeySystemAccessManager.cpp
--- a/dom/media/eme/MediaKeySystemAccessManager.cpp
+++ b/dom/media/eme/MediaKeySystemAccessManager.cpp
@@ -74,41 +74,39 @@ MediaKeySystemAccessManager::Request(Det
 
 void
 MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
                                      const nsAString& aKeySystem,
                                      const Sequence<MediaKeySystemConfiguration>& aConfigs,
                                      RequestType aType)
 {
   EME_LOG("MediaKeySystemAccessManager::Request %s", NS_ConvertUTF16toUTF8(aKeySystem).get());
+
+  // Parse keysystem, split it out into keySystem prefix, and version suffix.
+  nsAutoString keySystem;
+  int32_t minCdmVersion = NO_CDM_VERSION;
+  if (!ParseKeySystem(aKeySystem, keySystem, minCdmVersion)) {
+    // Not to inform user, because nothing to do if the keySystem is not
+    // supported.
+    aPromise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
+                          NS_LITERAL_CSTRING("Key system string is invalid,"
+                                             " or key system is unsupported"));
+    return;
+  }
+
   if (!Preferences::GetBool("media.eme.enabled", false)) {
-    // EME disabled by user, send notification to chrome so UI can
-    // inform user.
+    // EME disabled by user, send notification to chrome so UI can inform user.
     MediaKeySystemAccess::NotifyObservers(mWindow,
                                           aKeySystem,
                                           MediaKeySystemStatus::Api_disabled);
     aPromise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
                           NS_LITERAL_CSTRING("EME has been preffed off"));
     return;
   }
 
-  // Parse keysystem, split it out into keySystem prefix, and version suffix.
-  nsAutoString keySystem;
-  int32_t minCdmVersion = NO_CDM_VERSION;
-  if (!ParseKeySystem(aKeySystem,
-                      keySystem,
-                      minCdmVersion)) {
-    // Invalid keySystem string, or unsupported keySystem. Send notification
-    // to chrome to show a failure notice.
-    MediaKeySystemAccess::NotifyObservers(mWindow, aKeySystem, MediaKeySystemStatus::Cdm_not_supported);
-    aPromise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
-                          NS_LITERAL_CSTRING("Key system string is invalid, or key system is unsupported"));
-    return;
-  }
-
   nsAutoCString message;
   nsAutoCString cdmVersion;
   MediaKeySystemStatus status =
     MediaKeySystemAccess::GetKeySystemStatus(keySystem, minCdmVersion, message, cdmVersion);
 
   nsPrintfCString msg("MediaKeySystemAccess::GetKeySystemStatus(%s, minVer=%d) "
                       "result=%s version='%s' msg='%s'",
                       NS_ConvertUTF16toUTF8(keySystem).get(),
@@ -163,19 +161,20 @@ MediaKeySystemAccessManager::Request(Det
   // compatibility with initial implementation...
   if (MediaKeySystemAccess::GetSupportedConfig(keySystem, aConfigs, config) ||
       MediaKeySystemAccess::IsSupported(keySystem, aConfigs)) {
     RefPtr<MediaKeySystemAccess> access(
       new MediaKeySystemAccess(mWindow, keySystem, NS_ConvertUTF8toUTF16(cdmVersion), config));
     aPromise->MaybeResolve(access);
     return;
   }
-
+  // Not to inform user, because nothing to do if the corresponding keySystem
+  // configuration is not supported.
   aPromise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
-                        NS_LITERAL_CSTRING("Key system is not supported"));
+                        NS_LITERAL_CSTRING("Key system configuration is not supported"));
 }
 
 MediaKeySystemAccessManager::PendingRequest::PendingRequest(DetailedPromise* aPromise,
                                                             const nsAString& aKeySystem,
                                                             const Sequence<MediaKeySystemConfiguration>& aConfigs,
                                                             nsITimer* aTimer)
   : mPromise(aPromise)
   , mKeySystem(aKeySystem)