Bug 798966: Create a preference to bypass gUM permission; r=jesup
authorAnant Narayanan <anant@kix.in>
Sun, 07 Oct 2012 17:31:45 -0700
changeset 109583 959de7eea1ff4082cd79b69ab2fef4f73f65c175
parent 109582 3cf86586da0d439307495f42b14a7449fec19539
child 109585 cf1bb42b3420f2c81392b8404ec89695c58cc8f3
push id16091
push useranarayanan@mozilla.com
push dateMon, 08 Oct 2012 00:32:23 +0000
treeherdermozilla-inbound@959de7eea1ff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs798966
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 798966: Create a preference to bypass gUM permission; r=jesup
dom/media/MediaManager.cpp
modules/libpref/src/init/all.js
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -13,16 +13,18 @@
 
 // For PR_snprintf
 #include "prprf.h"
 
 #include "nsJSUtils.h"
 #include "nsDOMFile.h"
 #include "nsGlobalWindow.h"
 
+#include "mozilla/Preferences.h"
+
 /* Using WebRTC backend on Desktops (Mac, Windows, Linux), otherwise default */
 #include "MediaEngineDefault.h"
 #if defined(MOZ_WEBRTC)
 #include "MediaEngineWebRTC.h"
 #endif
 
 namespace mozilla {
 
@@ -668,16 +670,21 @@ MediaManager::GetUserMedia(bool aPrivile
   // when this window is closed or navigated away from.
   uint64_t windowID = aWindow->WindowID();
   StreamListeners* listeners = mActiveWindows.Get(windowID);
   if (!listeners) {
     listeners = new StreamListeners;
     mActiveWindows.Put(windowID, listeners);
   }
 
+  // Developer preference for turning off permission check.
+  if (Preferences::GetBool("media.navigator.permission.disabled", false)) {
+    aPrivileged = true;
+  }
+
   /**
    * Pass runnables along to GetUserMediaRunnable so it can add the
    * MediaStreamListener to the runnable list. The last argument can
    * optionally be a MediaDevice object, which should provided if one was
    * selected by the user via the UI, or was provided by privileged code
    * via the device: attribute via nsIMediaStreamOptions.
    *
    * If a fake stream was requested, we force the use of the default backend.
@@ -701,17 +708,17 @@ MediaManager::GetUserMedia(bool aPrivile
       audio, video, picture, onSuccess.forget(), onError.forget(), listeners,
       windowID
     );
   }
 
   if (picture) {
     // ShowFilePickerForMimeType() must run on the Main Thread! (on Android)
     NS_DispatchToMainThread(gUMRunnable);
-  } else if (aPrivileged) {
+  } else if (aPrivileged || fake) {
     if (!mMediaThread) {
       nsresult rv = NS_NewThread(getter_AddRefs(mMediaThread));
       NS_ENSURE_SUCCESS(rv, rv);
     }
     mMediaThread->Dispatch(gUMRunnable, NS_DISPATCH_NORMAL);
   } else {
     // Ask for user permission, and dispatch runnable (or not) when a response
     // is received via an observer notification. Each call is paired with its
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -169,16 +169,17 @@ pref("media.webm.enabled", true);
 pref("media.dash.enabled", true);
 #endif
 #ifdef MOZ_GSTREAMER
 pref("media.h264.enabled", true);
 #endif
 #ifdef MOZ_WEBRTC
 pref("media.navigator.enabled", false);
 pref("media.peerconnection.enabled", false);
+pref("media.navigator.permission.disabled", false);
 #else
 #ifdef ANDROID
 pref("media.navigator.enabled", true);
 #endif
 #endif
 
 // Whether to enable Web Audio support
 pref("media.webaudio.enabled", false);