Bug 1148307 - Part 5, pref off data channel session transport, r=smaug
authorJunior Hsu <juhsu@mozilla.com>
Mon, 11 Apr 2016 11:28:36 +0800
changeset 292786 ce7802ca68410504beb4c4d227423979a15b234c
parent 292785 e0a1ad6c114e2540b536f414d7d277a7aa683d1a
child 292787 b486146cd3fb4e770b1c57f9531c493e64733171
push idunknown
push userunknown
push dateunknown
reviewerssmaug
bugs1148307
milestone48.0a1
Bug 1148307 - Part 5, pref off data channel session transport, r=smaug
dom/presentation/PresentationSessionInfo.cpp
modules/libpref/init/all.js
--- a/dom/presentation/PresentationSessionInfo.cpp
+++ b/dom/presentation/PresentationSessionInfo.cpp
@@ -834,16 +834,18 @@ NS_IMETHODIMP
 PresentationPresentingInfo::OnError(nsresult reason)
 {
   return PresentationSessionInfo::OnError(reason);
 }
 
 nsresult
 PresentationPresentingInfo::InitTransportAndSendAnswer()
 {
+  MOZ_ASSERT(NS_IsMainThread());
+
   uint8_t type = 0;
   nsresult rv = mRequesterDescription->GetType(&type);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (type == nsIPresentationChannelDescription::TYPE_TCP) {
     // Establish a data transport channel |mTransport| to the sender and use
@@ -855,16 +857,19 @@ PresentationPresentingInfo::InitTranspor
     }
 
     mBuilder = builder;
     mTransportType = nsIPresentationChannelDescription::TYPE_TCP;
     return builder->BuildTCPReceiverTransport(mRequesterDescription, this);
   }
 
   if (type == nsIPresentationChannelDescription::TYPE_DATACHANNEL) {
+    if (!Preferences::GetBool("dom.presentation.session_transport.data_channel.enable")) {
+      return NS_ERROR_NOT_IMPLEMENTED;
+    }
     nsCOMPtr<nsIPresentationDataChannelSessionTransportBuilder> builder =
       do_CreateInstance("@mozilla.org/presentation/datachanneltransportbuilder;1");
 
     if (NS_WARN_IF(!builder)) {
       return NS_ERROR_NOT_AVAILABLE;
     }
 
     mBuilder = builder;
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5063,17 +5063,17 @@ pref("dom.udpsocket.enabled", false);
 pref("dom.beforeAfterKeyboardEvent.enabled", false);
 
 // Presentation API
 pref("dom.presentation.enabled", false);
 pref("dom.presentation.tcp_server.debug", false);
 pref("dom.presentation.discovery.enabled", false);
 pref("dom.presentation.discovery.timeout_ms", 10000);
 pref("dom.presentation.discoverable", false);
-pref("dom.presentation.session_transport.data_channel.enable", true);
+pref("dom.presentation.session_transport.data_channel.enable", false);
 
 #ifdef XP_MACOSX
 #if !defined(RELEASE_BUILD) || defined(DEBUG)
 // In non-release builds we crash by default on insecure text input (when a
 // password editor has focus but secure event input isn't enabled).  The
 // following pref, when turned on, disables this behavior.  See bug 1188425.
 pref("intl.allow-insecure-text-input", false);
 #endif