Commit 8e80f239 authored by Brad Lassey's avatar Brad Lassey
Browse files

backout b51259905d85 because it needs sr

parent 6c1b8cde
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -149,10 +149,6 @@ CPPSRCS = \
	Navigator.cpp \
	$(NULL)

ifeq ($(OS_TARGET),Android)
CPPSRCS += NavigatorUserMediaAndroid.cpp
endif

include $(topsrcdir)/dom/dom-config.mk

ifdef MOZ_JSDEBUGGER
+0 −7
Original line number Diff line number Diff line
@@ -79,10 +79,6 @@
#include "mozilla/ClearOnShutdown.h"
#include "Connection.h"

#ifdef ANDROID
#include "nsIDOMNavigatorUserMedia.h"
#endif

#ifdef MOZ_B2G_RIL
#include "TelephonyFactory.h"
#endif
@@ -145,9 +141,6 @@ NS_INTERFACE_MAP_BEGIN(Navigator)
  NS_INTERFACE_MAP_ENTRY(nsIDOMMozNavigatorNetwork)
#ifdef MOZ_B2G_BT
  NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorBluetooth)
#endif
#ifdef ANDROID
  NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorUserMedia)
#endif
  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Navigator)
NS_INTERFACE_MAP_END
+0 −11
Original line number Diff line number Diff line
@@ -69,10 +69,6 @@ class nsIDOMTelephony;
#include "nsIDOMNavigatorBluetooth.h"
#endif

#ifdef ANDROID
#include "nsIDOMNavigatorUserMedia.h"
#endif

class nsIDOMAdapter;
//*****************************************************************************
// Navigator: Script "navigator" object
@@ -110,9 +106,6 @@ class Navigator : public nsIDOMNavigator
#ifdef MOZ_B2G_BT
                , public nsIDOMNavigatorBluetooth
#endif
#ifdef ANDROID
                , public nsIDOMNavigatorUserMedia
#endif
{
public:
  Navigator(nsPIDOMWindow *aInnerWindow);
@@ -134,10 +127,6 @@ public:
  NS_DECL_NSIDOMNAVIGATORBLUETOOTH
#endif

#ifdef ANDROID
  NS_DECL_NSIDOMNAVIGATORUSERMEDIA
#endif

  static void Init();

  void Invalidate();
+0 −76
Original line number Diff line number Diff line
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=2 et sw=2 tw=40: */
/* 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 "AndroidBridge.h"
#include "nsDOMFile.h"
#include "Navigator.h"

namespace mozilla {
namespace dom {

class GetUserMediaCallback: public nsFilePickerCallback {
public:
  GetUserMediaCallback(nsIDOMMediaCallback* aCallback, nsIDOMErrorCallback *aError) :
    mCallback(aCallback) , mError(aError){}

  virtual void handleResult(nsAString& filePath) {
    nsCOMPtr<nsILocalFile> file;
    NS_NewLocalFile(filePath, true, getter_AddRefs(file));
    bool exists;
    if (!file || NS_FAILED(file->Exists(&exists)) || !exists) {
      if (mError) {
        mError->Callback(NS_LITERAL_STRING("ERROR_NO_FILE"));
      }
    } else {
      mCallback->Callback(new nsDOMFileFile(file));
    }
  }

private:
  nsCOMPtr<nsIDOMMediaCallback> mCallback;
  nsCOMPtr<nsIDOMErrorCallback> mError;
};

class ErrorCallbackRunnable : public nsRunnable {
public:
  ErrorCallbackRunnable(nsIDOMErrorCallback* aErrorCallback, const nsString& aErrorMsg) :
    mErrorCallback(aErrorCallback), mErrorMsg(aErrorMsg) {}
  NS_IMETHOD Run() {
    mErrorCallback->Callback(mErrorMsg);
    return NS_OK;
  }
private:
  nsCOMPtr<nsIDOMErrorCallback> mErrorCallback;
  const nsString mErrorMsg;
};

NS_IMETHODIMP
Navigator::MozGetUserMedia(nsIMediaStreamOptions *params, nsIDOMMediaCallback *callback, nsIDOMErrorCallback *error)
{
  bool picture;
  if (!params || !callback || NS_FAILED(params->GetPicture(&picture))) {
    if (error) {
      NS_DispatchToMainThread(new ErrorCallbackRunnable(error, NS_LITERAL_STRING("BAD_ARGS")));
    }
    return NS_OK;
  }

  if (!picture) {
    if (error) {
      NS_DispatchToMainThread(new ErrorCallbackRunnable(error, NS_LITERAL_STRING("NOT_IMPLEMENTED")));
    }
    return NS_OK;
  }

  if (mozilla::AndroidBridge::Bridge()) {
    mozilla::AndroidBridge::Bridge()->ShowFilePickerAsync(NS_LITERAL_STRING("image/*"), new GetUserMediaCallback(callback, error));
  } else if (error) {
    NS_DispatchToMainThread(new ErrorCallbackRunnable(error, NS_LITERAL_STRING("INTERNAL_ERROR")));
  }
  return NS_OK;
}
}
}
+0 −1
Original line number Diff line number Diff line
@@ -70,7 +70,6 @@ XPIDLSRCS = \
	nsIDOMMimeType.idl			\
	nsIDOMMimeTypeArray.idl			\
	nsIDOMNavigator.idl			\
	nsIDOMNavigatorUserMedia.idl		\
	nsIDOMPkcs11.idl			\
	nsIDOMPlugin.idl			\
	nsIDOMPluginArray.idl			\
Loading