Bug 1119463 - Enable MSE for youtube-nocookie.com. r=kinetik a=mse
authorRalph Giles <giles@mozilla.com>
Thu, 08 Jan 2015 12:34:00 -0800
changeset 242774 3adeb981ced70b669d61e97321ccba83210ed988
parent 242773 73e32e8ac465c6968e77217fde6dca983e35395e
child 242775 aa13772c45f64b200b7367d49a943d708986047b
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik, mse
bugs1119463
milestone36.0a2
Bug 1119463 - Enable MSE for youtube-nocookie.com. r=kinetik a=mse Follow-up to bug 1119463. This is used by some sites for embedding.
dom/media/mediasource/MediaSource.cpp
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -325,37 +325,41 @@ MediaSource::Enabled(JSContext* cx, JSOb
   }
 
   // Check whether it's enabled everywhere or just YouTube.
   bool restrict = Preferences::GetBool("media.mediasource.youtubeonly", false);
   if (!restrict) {
     return true;
   }
 
-  // We want to restrict to YouTube only.  We define that as the
-  // origin being https://*.youtube.com.
+  // We want to restrict to YouTube only.
+  // We define that as the origin being https://*.youtube.com.
+  // We also support https://*.youtube-nocookie.com.
   nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(global);
   nsCOMPtr<nsIURI> uri;
   if (NS_FAILED(principal->GetURI(getter_AddRefs(uri))) || !uri) {
     return false;
   }
 
   bool isHttps = false;
   if (NS_FAILED(uri->SchemeIs("https", &isHttps)) || !isHttps) {
     return false;
   }
 
   nsCOMPtr<nsIEffectiveTLDService> tldServ =
     do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
   NS_ENSURE_TRUE(tldServ, false);
 
   nsAutoCString eTLDplusOne;
-  return
-    NS_SUCCEEDED(tldServ->GetBaseDomain(uri, 0, eTLDplusOne)) &&
-    eTLDplusOne.EqualsLiteral("youtube.com");
+   if (NS_FAILED(tldServ->GetBaseDomain(uri, 0, eTLDplusOne))) {
+     return false;
+   }
+
+   return eTLDplusOne.EqualsLiteral("youtube.com") ||
+          eTLDplusOne.EqualsLiteral("youtube-nocookie.com");
 }
 
 bool
 MediaSource::Attach(MediaSourceDecoder* aDecoder)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MSE_DEBUG("MediaSource(%p)::Attach(aDecoder=%p) owner=%p", this, aDecoder, aDecoder->GetOwner());
   MOZ_ASSERT(aDecoder);