Bug 1119463 - Enable MSE for youtube-nocookie.com. r=kinetik
Follow-up to
bug 1119463. This is used by some sites for embedding.
--- 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);