Backed out changesets 4cb1154b0190 and 506d33f3931e (bug 1090501) because it depends on another patch that was backed out.
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 31 Oct 2014 19:15:42 -0400
changeset 213548 940af94c4bc6c959fd124f56a4f8fdd3b7e89865
parent 213547 ccdbe0311cd68cca31e76c40e4c15e1daee30513
child 213549 37755124a2134aa542525b5820b9528f80016245
push idunknown
push userunknown
push dateunknown
bugs1090501
milestone36.0a1
backs out4cb1154b019067d2acfa9f66855d088aa6f105e8
506d33f3931e5d833e74e84340b7cb4c3331e27d
Backed out changesets 4cb1154b0190 and 506d33f3931e (bug 1090501) because it depends on another patch that was backed out.
dom/camera/CameraPreferences.cpp
dom/camera/CameraPreferences.h
dom/camera/DOMCameraControl.cpp
dom/camera/DOMCameraControl.h
dom/camera/DOMCameraManager.cpp
dom/camera/DOMCameraManager.h
dom/camera/GonkRecorderProfiles.h
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
--- a/dom/camera/CameraPreferences.cpp
+++ b/dom/camera/CameraPreferences.cpp
@@ -1,24 +1,19 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CameraPreferences.h"
 #include "CameraCommon.h"
-#include "DOMCameraManager.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/Preferences.h"
-#ifdef MOZ_WIDGET_GONK
-#include "mozilla/Services.h"
-#include "nsIObserverService.h"
-#endif
 
 using namespace mozilla;
 
 /* statics */
 static StaticAutoPtr<Monitor> sPrefMonitor;
 
 StaticAutoPtr<nsCString> CameraPreferences::sPrefTestEnabled;
 StaticAutoPtr<nsCString> CameraPreferences::sPrefHardwareTest;
@@ -26,22 +21,16 @@ StaticAutoPtr<nsCString> CameraPreferenc
 
 nsresult CameraPreferences::sPrefCameraControlMethodErrorOverride = NS_OK;
 nsresult CameraPreferences::sPrefCameraControlAsyncErrorOverride = NS_OK;
 
 uint32_t CameraPreferences::sPrefCameraControlLowMemoryThresholdMB = 0;
 
 bool CameraPreferences::sPrefCameraParametersIsLowMemory = false;
 
-#ifdef MOZ_WIDGET_GONK
-StaticRefPtr<CameraPreferences> CameraPreferences::sObserver;
-
-NS_IMPL_ISUPPORTS(CameraPreferences, nsIObserver);
-#endif
-
 #ifdef CAMERAPREFERENCES_HAVE_SEPARATE_UINT32_AND_NSRESULT
 /* static */
 nsresult
 CameraPreferences::UpdatePref(const char* aPref, nsresult& aVal)
 {
   uint32_t val;
   nsresult rv = Preferences::GetUint(aPref, &val);
   if (NS_SUCCEEDED(rv)) {
@@ -211,29 +200,16 @@ CameraPreferences::PreferenceChanged(con
 /* static */
 bool
 CameraPreferences::Initialize()
 {
   DOM_CAMERA_LOGI("Initializing camera preference callbacks\n");
 
   nsresult rv;
 
-#ifdef MOZ_WIDGET_GONK
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-  if (obs) {
-    sObserver = new CameraPreferences();
-    rv = obs->AddObserver(sObserver, "init-camera-hw", false);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      sObserver = nullptr;
-    }
-  } else {
-    DOM_CAMERA_LOGE("Could not get observer service\n");
-  }
-#endif
-
   sPrefMonitor = new Monitor("CameraPreferences.sPrefMonitor");
 
   sPrefTestEnabled = new nsCString();
   sPrefHardwareTest = new nsCString();
   sPrefGonkParameters = new nsCString();
 
   for (uint32_t i = 0; i < ArrayLength(sPrefs); ++i) {
     rv = Preferences::RegisterCallbackAndCall(CameraPreferences::PreferenceChanged,
@@ -258,52 +234,19 @@ CameraPreferences::Shutdown()
                                     sPrefs[i].mPref);
   }
 
   sPrefTestEnabled = nullptr;
   sPrefHardwareTest = nullptr;
   sPrefGonkParameters = nullptr;
   sPrefMonitor = nullptr;
 
-#ifdef MOZ_WIDGET_GONK
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-  if (obs) {
-    nsresult rv = obs->RemoveObserver(sObserver , "init-camera-hw");
-    if (NS_FAILED(rv)) {
-      DOM_CAMERA_LOGE("Failed to remove CameraPreferences observer (0x%x)\n", rv);
-    }
-    sObserver = nullptr;
-  } else {
-    DOM_CAMERA_LOGE("Could not get observer service\n");
-  }
-#endif
-
   DOM_CAMERA_LOGI("Camera preferences shut down\n");
 }
 
-#ifdef MOZ_WIDGET_GONK
-nsresult
-CameraPreferences::PreinitCameraHardware()
-{
-  nsDOMCameraManager::PreinitCameraHardware();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-CameraPreferences::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
-{
-  if (strcmp(aTopic, "init-camera-hw") == 0) {
-    return PreinitCameraHardware();
-  }
-
-  DOM_CAMERA_LOGE("Got unhandled topic '%s'\n", aTopic);
-  return NS_OK;
-}
-#endif
-
 /* static */
 bool
 CameraPreferences::GetPref(const char* aPref, nsACString& aVal)
 {
   MOZ_ASSERT(sPrefMonitor, "sPrefMonitor missing in CameraPreferences::GetPref()");
   MonitorAutoLock mon(*sPrefMonitor);
 
   uint32_t i = PrefToIndex(aPref);
--- a/dom/camera/CameraPreferences.h
+++ b/dom/camera/CameraPreferences.h
@@ -2,43 +2,31 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef DOM_CAMERA_CAMERAPREFERENCES_H
 #define DOM_CAMERA_CAMERAPREFERENCES_H
 
 #include "nsString.h"
-#include "nsIObserver.h"
-#ifdef MOZ_WIDGET_GONK
-#include "mozilla/StaticPtr.h"
-#endif
 
 #if defined(MOZ_HAVE_CXX11_STRONG_ENUMS) || defined(MOZ_HAVE_CXX11_ENUM_TYPE)
 // Older compilers that don't support strongly-typed enums
 // just typedef uint32_t to nsresult, which results in conflicting
 // overloaded members in CameraPreferences.
 #define CAMERAPREFERENCES_HAVE_SEPARATE_UINT32_AND_NSRESULT
 #endif
 
 namespace mozilla {
 
 template<class T> class StaticAutoPtr;
 
 class CameraPreferences
-#ifdef MOZ_WIDGET_GONK
-  : public nsIObserver
-#endif
 {
 public:
-#ifdef MOZ_WIDGET_GONK
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIOBSERVER
-#endif
-
   static bool Initialize();
   static void Shutdown();
 
   static bool GetPref(const char* aPref, nsACString& aVal);
 #ifdef CAMERAPREFERENCES_HAVE_SEPARATE_UINT32_AND_NSRESULT
   static bool GetPref(const char* aPref, nsresult& aVal);
 #endif
   static bool GetPref(const char* aPref, uint32_t& aVal);
@@ -86,28 +74,17 @@ protected:
 
   static nsresult sPrefCameraControlMethodErrorOverride;
   static nsresult sPrefCameraControlAsyncErrorOverride;
 
   static uint32_t sPrefCameraControlLowMemoryThresholdMB;
 
   static bool sPrefCameraParametersIsLowMemory;
 
-#ifdef MOZ_WIDGET_GONK
-  static StaticRefPtr<CameraPreferences> sObserver;
-
-  nsresult PreinitCameraHardware();
-
-protected:
-  // Objects may be instantiated for use as observers.
-  CameraPreferences() { }
-  virtual ~CameraPreferences() { }
-#else
 private:
-  // Static class only.
+  // static class only
   CameraPreferences();
   ~CameraPreferences();
-#endif
 };
 
 } // namespace mozilla
 
 #endif // DOM_CAMERA_CAMERAPREFERENCES_H
--- a/dom/camera/DOMCameraControl.cpp
+++ b/dom/camera/DOMCameraControl.cpp
@@ -41,22 +41,16 @@
 #include "DOMCameraDetectedFace.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "nsPrintfCString.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::ipc;
 
-#ifdef MOZ_WIDGET_GONK
-StaticRefPtr<ICameraControl> nsDOMCameraControl::sCachedCameraControl;
-/* static */ nsresult nsDOMCameraControl::sCachedCameraControlStartResult = NS_OK;
-/* static */ nsCOMPtr<nsITimer> nsDOMCameraControl::sDiscardCachedCameraControlTimer;
-#endif
-
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMCameraControl)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END_INHERITING(DOMMediaStream)
 
 NS_IMPL_ADDREF_INHERITED(nsDOMCameraControl, DOMMediaStream)
 NS_IMPL_RELEASE_INHERITED(nsDOMCameraControl, DOMMediaStream)
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(nsDOMCameraControl, DOMMediaStream,
@@ -145,70 +139,16 @@ nsDOMCameraControl::DOMCameraConfigurati
   MOZ_COUNT_CTOR(nsDOMCameraControl::DOMCameraConfiguration);
 }
 
 nsDOMCameraControl::DOMCameraConfiguration::~DOMCameraConfiguration()
 {
   MOZ_COUNT_DTOR(nsDOMCameraControl::DOMCameraConfiguration);
 }
 
-#ifdef MOZ_WIDGET_GONK
-// This shoudl be long enough for even our slowest platforms.
-static const unsigned long kCachedCameraTimeoutMs = 3500;
-
-// Open the battery-door-facing camera by default.
-static const uint32_t kDefaultCameraId = 0;
-
-/* static */ void
-nsDOMCameraControl::PreinitCameraHardware()
-{
-  // Assume a default, minimal configuration. This should initialize the
-  // hardware, but won't (can't) start the preview.
-  nsRefPtr<ICameraControl> cameraControl = ICameraControl::Create(kDefaultCameraId);
-  if (NS_WARN_IF(!cameraControl)) {
-    return;
-  }
-
-  sCachedCameraControlStartResult = cameraControl->Start();
-  if (NS_WARN_IF(NS_FAILED(sCachedCameraControlStartResult))) {
-    return;
-  }
-
-  sCachedCameraControl = cameraControl;
-
-  nsCOMPtr<nsITimer> timer = do_CreateInstance(NS_TIMER_CONTRACTID);
-  if (NS_WARN_IF(!timer)) {
-    return;
-  }
-
-  nsresult rv = timer->InitWithFuncCallback(DiscardCachedCameraInstance,
-                                            nullptr,
-                                            kCachedCameraTimeoutMs,
-                                            nsITimer::TYPE_ONE_SHOT);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    // If we can't start the timer, it's possible for an app to never grab the
-    // camera, leaving the hardware tied up indefinitely. Better to take the
-    // performance hit.
-    sCachedCameraControl = nullptr;
-    return;
-  }
-
-  sDiscardCachedCameraControlTimer = timer;
-}
-
-/* static */ void
-nsDOMCameraControl::DiscardCachedCameraInstance(nsITimer* aTimer, void* aClosure)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  sDiscardCachedCameraControlTimer = nullptr;
-  sCachedCameraControl = nullptr;
-}
-#endif
-
 nsDOMCameraControl::nsDOMCameraControl(uint32_t aCameraId,
                                        const CameraConfiguration& aInitialConfig,
                                        GetCameraCallback* aOnSuccess,
                                        CameraErrorCallback* aOnError,
                                        Promise* aPromise,
                                        nsPIDOMWindow* aWindow)
   : DOMMediaStream()
   , mCameraControl(nullptr)
@@ -269,56 +209,36 @@ nsDOMCameraControl::nsDOMCameraControl(u
   }
 
   if (haveInitialConfig) {
     config.mPreviewSize.width = aInitialConfig.mPreviewSize.mWidth;
     config.mPreviewSize.height = aInitialConfig.mPreviewSize.mHeight;
     config.mRecorderProfile = aInitialConfig.mRecorderProfile;
   }
 
-#ifdef MOZ_WIDGET_GONK
-  bool gotCached = false;
-  if (sCachedCameraControl && aCameraId == kDefaultCameraId) {
-    mCameraControl = sCachedCameraControl;
-    sCachedCameraControl = nullptr;
-    gotCached = true;
-  } else {
-    sCachedCameraControl = nullptr;
-#endif
-    mCameraControl = ICameraControl::Create(aCameraId);
-#ifdef MOZ_WIDGET_GONK
-  }
-#endif
+  mCameraControl = ICameraControl::Create(aCameraId);
   mCurrentConfiguration = initialConfig.forget();
 
   // Attach our DOM-facing media stream to our viewfinder stream.
   mStream = mInput;
   MOZ_ASSERT(mWindow, "Shouldn't be created with a null window!");
   if (mWindow->GetExtantDoc()) {
     CombineWithPrincipal(mWindow->GetExtantDoc()->NodePrincipal());
   }
 
   // Register a listener for camera events.
   mListener = new DOMCameraControlListener(this, mInput);
   mCameraControl->AddListener(mListener);
 
-#ifdef MOZ_WIDGET_GONK
-  if (!gotCached || NS_FAILED(sCachedCameraControlStartResult)) {
-#endif
-    // Start the camera...
-    if (haveInitialConfig) {
-      rv = mCameraControl->Start(&config);
-    } else {
-      rv = mCameraControl->Start();
-    }
-#ifdef MOZ_WIDGET_GONK
+  // Start the camera...
+  if (haveInitialConfig) {
+    rv = mCameraControl->Start(&config);
   } else {
-    rv = mCameraControl->SetConfiguration(config);
+    rv = mCameraControl->Start();
   }
-#endif
   if (NS_FAILED(rv)) {
     mListener->OnUserError(DOMCameraControlListener::kInStartCamera, rv);
   }
 }
 
 nsDOMCameraControl::~nsDOMCameraControl()
 {
   DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
--- a/dom/camera/DOMCameraControl.h
+++ b/dom/camera/DOMCameraControl.h
@@ -13,19 +13,16 @@
 #include "ICameraControl.h"
 #include "CameraCommon.h"
 #include "DOMMediaStream.h"
 #include "AudioChannelAgent.h"
 #include "nsProxyRelease.h"
 #include "nsHashPropertyBag.h"
 #include "DeviceStorage.h"
 #include "DOMCameraControlListener.h"
-#ifdef MOZ_WIDGET_GONK
-#include "nsITimer.h"
-#endif
 
 class nsDOMDeviceStorage;
 class nsPIDOMWindow;
 class nsIDOMBlob;
 
 namespace mozilla {
 
 namespace dom {
@@ -138,21 +135,16 @@ public:
   void ResumePreview(ErrorResult& aRv);
   already_AddRefed<dom::Promise> ReleaseHardware(const dom::Optional<dom::OwningNonNull<dom::CameraReleaseCallback> >& aOnSuccess,
                                                  const dom::Optional<dom::OwningNonNull<dom::CameraErrorCallback> >& aOnError,
                                                  ErrorResult& aRv);
   void ResumeContinuousFocus(ErrorResult& aRv);
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
-#ifdef MOZ_WIDGET_GONK
-  static void PreinitCameraHardware();
-  static void DiscardCachedCameraInstance(nsITimer* aTimer, void* aClosure);
-#endif
-
   IMPL_EVENT_HANDLER(facesdetected)
   IMPL_EVENT_HANDLER(shutter)
   IMPL_EVENT_HANDLER(close)
   IMPL_EVENT_HANDLER(recorderstatechange)
   IMPL_EVENT_HANDLER(previewstatechange)
   IMPL_EVENT_HANDLER(focus)
   IMPL_EVENT_HANDLER(picture)
   IMPL_EVENT_HANDLER(configurationchange)
@@ -256,23 +248,16 @@ protected:
 
   // set once when this object is created
   nsCOMPtr<nsPIDOMWindow>   mWindow;
 
   dom::CameraStartRecordingOptions mOptions;
   nsRefPtr<DeviceStorageFileDescriptor> mDSFileDescriptor;
   DOMCameraControlListener::PreviewState mPreviewState;
 
-#ifdef MOZ_WIDGET_GONK
-  // cached camera control, to improve start-up time
-  static StaticRefPtr<ICameraControl> sCachedCameraControl;
-  static nsresult sCachedCameraControlStartResult;
-  static nsCOMPtr<nsITimer> sDiscardCachedCameraControlTimer;
-#endif
-
 private:
   nsDOMCameraControl(const nsDOMCameraControl&) MOZ_DELETE;
   nsDOMCameraControl& operator=(const nsDOMCameraControl&) MOZ_DELETE;
 };
 
 } // namespace mozilla
 
 #endif // DOM_CAMERA_DOMCAMERACONTROL_H
--- a/dom/camera/DOMCameraManager.cpp
+++ b/dom/camera/DOMCameraManager.cpp
@@ -259,24 +259,16 @@ CameraPermissionRequest::GetTypes(nsIArr
 {
   nsTArray<nsString> emptyOptions;
   return nsContentPermissionUtils::CreatePermissionArray(NS_LITERAL_CSTRING("camera"),
                                                          NS_LITERAL_CSTRING("unused"),
                                                          emptyOptions,
                                                          aTypes);
 }
 
-#ifdef MOZ_WIDGET_GONK
-/* static */ void
-nsDOMCameraManager::PreinitCameraHardware()
-{
-  nsDOMCameraControl::PreinitCameraHardware();
-}
-#endif
-
 already_AddRefed<Promise>
 nsDOMCameraManager::GetCamera(const nsAString& aCamera,
                               const CameraConfiguration& aInitialConfig,
                               const OptionalNonNullGetCameraCallback& aOnSuccess,
                               const OptionalNonNullCameraErrorCallback& aOnError,
                               ErrorResult& aRv)
 {
   DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
--- a/dom/camera/DOMCameraManager.h
+++ b/dom/camera/DOMCameraManager.h
@@ -84,20 +84,16 @@ public:
             const OptionalNonNullCameraErrorCallback& aOnError,
             mozilla::ErrorResult& aRv);
   void GetListOfCameras(nsTArray<nsString>& aList, mozilla::ErrorResult& aRv);
 
   nsPIDOMWindow* GetParentObject() const { return mWindow; }
   virtual JSObject* WrapObject(JSContext* aCx)
     MOZ_OVERRIDE;
 
-#ifdef MOZ_WIDGET_GONK
-  static void PreinitCameraHardware();
-#endif
-
 protected:
   void XpComShutdown();
   void Shutdown(uint64_t aWindowId);
   ~nsDOMCameraManager();
 
 private:
   nsDOMCameraManager() MOZ_DELETE;
   explicit nsDOMCameraManager(nsPIDOMWindow* aWindow);
--- a/dom/camera/GonkRecorderProfiles.h
+++ b/dom/camera/GonkRecorderProfiles.h
@@ -2,18 +2,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef DOM_CAMERA_GONK_RECORDER_PROFILES_H
 #define DOM_CAMERA_GONK_RECORDER_PROFILES_H
 
 #include <media/MediaProfiles.h>
 #include "ICameraControl.h"
-#include "nsClassHashtable.h"
-#include "nsRefPtrHashtable.h"
 
 #ifndef CHECK_SETARG_RETURN
 #define CHECK_SETARG_RETURN(x, rv)      \
   do {                                  \
     if (x) {                            \
       DOM_CAMERA_LOGE(#x " failed\n");  \
       return rv;                        \
     }                                   \
@@ -94,17 +92,16 @@ protected:
   uint32_t mProfileIndex;
   bool mIsValid;
   android::audio_encoder mPlatformEncoder;
 };
 
 /**
  * class GonkRecorderProfile
  */
-class GonkRecorderProfile;
 typedef nsRefPtrHashtable<nsStringHashKey, GonkRecorderProfile> ProfileHashtable;
 
 class GonkRecorderProfile
   : public GonkRecorderProfileBase<GonkRecorderAudio, GonkRecorderVideo>
 {
 public:
   static nsresult GetAll(uint32_t aCameraId,
                          nsTArray<nsRefPtr<ICameraControl::RecorderProfile>>& aProfiles);
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -77,19 +77,16 @@
 #include "nsILoadContext.h"
 #include "ipc/nsGUIEventIPC.h"
 #include "mozilla/gfx/Matrix.h"
 #include "UnitTransforms.h"
 #include "ClientLayerManager.h"
 #include "LayersLogging.h"
 #include "nsIOService.h"
 #include "nsDOMClassInfoID.h"
-#include "nsIAppsService.h"
-#include "nsNetUtil.h"
-#include "nsIPermissionManager.h"
 
 #include "nsColorPickerProxy.h"
 
 #define BROWSER_ELEMENT_CHILD_SCRIPT \
     NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js")
 
 #define TABC_LOG(...)
 // #define TABC_LOG(...) printf_stderr("TABC: " __VA_ARGS__)
@@ -1812,74 +1809,16 @@ TabChild::CancelCachedFileDescriptorCall
 
 void
 TabChild::DoFakeShow()
 {
   RecvShow(nsIntSize(0, 0));
   mDidFakeShow = true;
 }
 
-#ifdef MOZ_WIDGET_GONK
-void
-TabChild::MaybeRequestPreinitCamera()
-{
-    // Check if this tab will use the `camera` permission.
-    nsCOMPtr<nsIAppsService> appsService = do_GetService("@mozilla.org/AppsService;1");
-    if (NS_WARN_IF(!appsService)) {
-      return;
-    }
-
-    nsString manifestUrl = EmptyString();
-    appsService->GetManifestURLByLocalId(OwnAppId(), manifestUrl);
-    nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
-    if (NS_WARN_IF(!secMan)) {
-      return;
-    }
-
-    nsCOMPtr<nsIURI> uri;
-    nsresult rv = NS_NewURI(getter_AddRefs(uri), manifestUrl);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return;
-    }
-
-    nsCOMPtr<nsIPrincipal> principal;
-    rv = secMan->GetAppCodebasePrincipal(uri, OwnAppId(), false,
-                                         getter_AddRefs(principal));
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return;
-    }
-
-    uint16_t status = nsIPrincipal::APP_STATUS_NOT_INSTALLED;
-    principal->GetAppStatus(&status);
-    bool isCertified = status == nsIPrincipal::APP_STATUS_CERTIFIED;
-    if (!isCertified) {
-      return;
-    }
-
-    nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
-    if (NS_WARN_IF(!permMgr)) {
-      return;
-    }
-
-    uint32_t permission = nsIPermissionManager::DENY_ACTION;
-    permMgr->TestPermissionFromPrincipal(principal, "camera", &permission);
-    bool hasPermission = permission == nsIPermissionManager::ALLOW_ACTION;
-    if (!hasPermission) {
-      return;
-    }
-
-    nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
-    if (NS_WARN_IF(!observerService)) {
-      return;
-    }
-
-    observerService->NotifyObservers(nullptr, "init-camera-hw", nullptr);
-}
-#endif
-
 bool
 TabChild::RecvShow(const nsIntSize& size)
 {
 
     if (mDidFakeShow) {
         return true;
     }
 
@@ -1894,20 +1833,16 @@ TabChild::RecvShow(const nsIntSize& size
         // remote> has already been destroyed, and we couldn't hook
         // into the parent-process's layer system.  That's not a fatal
         // error.
         return true;
     }
 
     baseWindow->SetVisibility(true);
 
-#ifdef MOZ_WIDGET_GONK
-    MaybeRequestPreinitCamera();
-#endif
-
     return InitTabChildGlobal();
 }
 
 bool
 TabChild::RecvUpdateDimensions(const nsIntRect& rect, const nsIntSize& size, const ScreenOrientation& orientation)
 {
     if (!mRemoteFrame) {
         return true;
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -493,20 +493,16 @@ protected:
                                                       bool* aSuccess) MOZ_OVERRIDE;
     virtual bool DeallocPRenderFrameChild(PRenderFrameChild* aFrame) MOZ_OVERRIDE;
     virtual bool RecvDestroy() MOZ_OVERRIDE;
     virtual bool RecvSetUpdateHitRegion(const bool& aEnabled) MOZ_OVERRIDE;
     virtual bool RecvSetIsDocShellActive(const bool& aIsActive) MOZ_OVERRIDE;
 
     virtual bool RecvRequestNotifyAfterRemotePaint();
 
-#ifdef MOZ_WIDGET_GONK
-    void MaybeRequestPreinitCamera();
-#endif
-
 private:
     /**
      * Create a new TabChild object.
      *
      * |aOwnOrContainingAppId| is the app-id of our frame or of the closest app
      * frame in the hierarchy which contains us.
      *
      * |aIsBrowserElement| indicates whether we're a browser (but not an app).