Bug 773847: Fix popupcontrol logic and take snapshots from main thread, enable Snapshots on Android by default r=mounir,blassey
authorRandell Jesup <rjesup@jesup.org>
Sun, 26 Aug 2012 01:33:08 -0400
changeset 103475 88755b34790a1f42fa05163210b05f080376770d
parent 103474 dbc34849f109bf134213e085cb02363f952a519d
child 103476 60a42d3210906150274a8dd16d00a2ee7993df14
push id13995
push userrjesup@wgate.com
push dateSun, 26 Aug 2012 05:33:49 +0000
treeherdermozilla-inbound@88755b34790a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir, blassey
bugs773847
milestone17.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 773847: Fix popupcontrol logic and take snapshots from main thread, enable Snapshots on Android by default r=mounir,blassey
dom/media/MediaManager.cpp
modules/libpref/src/init/all.js
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -370,34 +370,32 @@ MediaManager::GetUserMedia(nsPIDOMWindow
    * If we were asked to get a picture, before getting a snapshot, we check if
    * the calling page is allowed to open a popup. We do this because
    * {picture:true} will open a new "window" to let the user preview or select
    * an image, on Android. The desktop UI for {picture:true} is TBD, at which
    * may point we can decide whether to extend this test there as well.
    */
 #if !defined(MOZ_WEBRTC)
   if (picture) {
-    if (aWindow->GetPopupControlState() <= openControlled) {
-      return NS_ERROR_FAILURE;
-    }
-    nsCOMPtr<nsIPopupWindowManager> pm =
-      do_GetService(NS_POPUPWINDOWMANAGER_CONTRACTID);
-    if (!pm) {
-      return NS_ERROR_FAILURE;
-    }
+    if (aWindow->GetPopupControlState() > openControlled) {
+      nsCOMPtr<nsIPopupWindowManager> pm =
+        do_GetService(NS_POPUPWINDOWMANAGER_CONTRACTID);
+      if (!pm)
+        return NS_OK;
 
-    uint32_t permission;
-    nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
-    pm->TestPermission(doc->NodePrincipal(), &permission);
-    if (aWindow && (permission == nsIPopupWindowManager::DENY_POPUP)) {
-      nsCOMPtr<nsIDOMDocument> domDoc = aWindow->GetExtantDocument();
-      nsGlobalWindow::FirePopupBlockedEvent(
-        domDoc, aWindow, nullptr, EmptyString(), EmptyString()
-      );
-      return NS_ERROR_FAILURE;
+      uint32_t permission;
+      nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
+      pm->TestPermission(doc->NodePrincipal(), &permission);
+      if ((permission == nsIPopupWindowManager::DENY_POPUP)) {
+        nsCOMPtr<nsIDOMDocument> domDoc = aWindow->GetExtantDocument();
+        nsGlobalWindow::FirePopupBlockedEvent(
+          domDoc, aWindow, nullptr, EmptyString(), EmptyString()
+                                              );
+        return NS_OK;
+      }
     }
   }
 #endif
 
   rv = aParams->GetAudio(&audio);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = aParams->GetVideo(&video);
@@ -418,23 +416,28 @@ MediaManager::GetUserMedia(nsPIDOMWindow
   }
 
   // Pass runnables along to GetUserMediaRunnable so it can add the
   // MediaStreamListener to the runnable list.
   nsCOMPtr<nsIRunnable> gUMRunnable = new GetUserMediaRunnable(
     audio, video, picture, onSuccess, onError, listeners, windowID
   );
 
-  // Reuse the same thread to save memory.
-  if (!mMediaThread) {
-    rv = NS_NewThread(getter_AddRefs(mMediaThread));
-    NS_ENSURE_SUCCESS(rv, rv);
+  if (picture) {
+    // ShowFilePickerForMimeType() must run on the Main Thread! (on Android)
+    NS_DispatchToMainThread(gUMRunnable);
+  } else {
+    // Reuse the same thread to save memory.
+    if (!mMediaThread) {
+      rv = NS_NewThread(getter_AddRefs(mMediaThread));
+      NS_ENSURE_SUCCESS(rv, rv);
+    }
+
+    mMediaThread->Dispatch(gUMRunnable, NS_DISPATCH_NORMAL);
   }
-
-  mMediaThread->Dispatch(gUMRunnable, NS_DISPATCH_NORMAL);
   return NS_OK;
 }
 
 MediaEngine*
 MediaManager::GetBackend()
 {
   // Plugin backends as appropriate. The default engine also currently
   // includes picture support for Android.
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -165,16 +165,20 @@ pref("media.wave.enabled", true);
 #ifdef MOZ_WEBM
 pref("media.webm.enabled", true);
 #endif
 #ifdef MOZ_GSTREAMER
 pref("media.h264.enabled", true);
 #endif
 #ifdef MOZ_WEBRTC
 pref("media.navigator.enabled", false);
+#else
+#ifdef ANDROID
+pref("media.navigator.enabled", true);
+#endif
 #endif
 
 // Whether to autostart a media element with an |autoplay| attribute
 pref("media.autoplay.enabled", true);
 
 // 0 = Off, 1 = Full, 2 = Tagged Images Only. 
 // See eCMSMode in gfx/thebes/gfxPlatform.h
 pref("gfx.color_management.mode", 2);