Bug 1315737 - Remove platform checking of screensharing whitelist
MozReview-Commit-ID: IosWOvEsIF8
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -153,101 +153,26 @@ using dom::Sequence;
using media::NewRunnableFrom;
using media::NewTaskFrom;
using media::Pledge;
using media::Refcountable;
static Atomic<bool> sInShutdown;
static bool
-HostInDomain(const nsCString &aHost, const nsCString &aPattern)
-{
- int32_t patternOffset = 0;
- int32_t hostOffset = 0;
-
- // Act on '*.' wildcard in the left-most position in a domain pattern.
- if (aPattern.Length() > 2 && aPattern[0] == '*' && aPattern[1] == '.') {
- patternOffset = 2;
-
- // Ignore the lowest level sub-domain for the hostname.
- hostOffset = aHost.FindChar('.') + 1;
-
- if (hostOffset <= 1) {
- // Reject a match between a wildcard and a TLD or '.foo' form.
- return false;
- }
- }
-
- nsDependentCString hostRoot(aHost, hostOffset);
- return hostRoot.EqualsIgnoreCase(aPattern.BeginReading() + patternOffset);
-}
-
-static bool
HostIsHttps(nsIURI &docURI)
{
bool isHttps;
nsresult rv = docURI.SchemeIs("https", &isHttps);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
return isHttps;
}
-static bool
-HostHasPermission(nsIURI &docURI)
-{
- nsAdoptingCString hostName;
- docURI.GetAsciiHost(hostName); //normalize UTF8 to ASCII equivalent
- nsAdoptingCString domainWhiteList =
- Preferences::GetCString("media.getusermedia.screensharing.allowed_domains");
- domainWhiteList.StripWhitespace();
-
- if (domainWhiteList.IsEmpty() || hostName.IsEmpty()) {
- return false;
- }
-
- // Get UTF8 to ASCII domain name normalization service
- nsresult rv;
- nsCOMPtr<nsIIDNService> idnService =
- do_GetService("@mozilla.org/network/idn-service;1", &rv);
- if (NS_WARN_IF(NS_FAILED(rv))) {
- return false;
- }
-
- uint32_t begin = 0;
- uint32_t end = 0;
- nsCString domainName;
- /*
- Test each domain name in the comma separated list
- after converting from UTF8 to ASCII. Each domain
- must match exactly or have a single leading '*.' wildcard
- */
- do {
- end = domainWhiteList.FindChar(',', begin);
- if (end == (uint32_t)-1) {
- // Last or only domain name in the comma separated list
- end = domainWhiteList.Length();
- }
-
- rv = idnService->ConvertUTF8toACE(Substring(domainWhiteList, begin, end - begin),
- domainName);
- if (NS_SUCCEEDED(rv)) {
- if (HostInDomain(hostName, domainName)) {
- return true;
- }
- } else {
- NS_WARNING("Failed to convert UTF-8 host to ASCII");
- }
-
- begin = end + 1;
- } while (end < domainWhiteList.Length());
-
- return false;
-}
-
/**
* This class is an implementation of MediaStreamListener. This is used
* to Start() and Stop() the underlying MediaEngineSource when MediaStreams
* are assigned and deassigned in content.
*/
class GetUserMediaCallbackMediaStreamListener : public MediaStreamListener
{
public:
@@ -2213,18 +2138,17 @@ if (privileged) {
false) ||
#if defined(XP_WIN)
(
// Allow tab sharing for all platforms including XP
(videoType != MediaSourceEnum::Browser) &&
!Preferences::GetBool("media.getusermedia.screensharing.allow_on_old_platforms",
false) && !IsVistaOrLater()) ||
#endif
- (!privileged && !HostIsHttps(*docURI)) ||
- (!isChrome && !HostHasPermission(*docURI))) {
+ (!privileged && !HostIsHttps(*docURI))) {
RefPtr<MediaStreamError> error =
new MediaStreamError(aWindow,
NS_LITERAL_STRING("NotAllowedError"));
onFailure->OnError(error);
return NS_OK;
}
break;