2012-07-31 01:59:05 +04:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
|
|
|
#ifndef DOM_CAMERA_DOMCAMERAMANAGER_H
|
|
|
|
#define DOM_CAMERA_DOMCAMERAMANAGER_H
|
|
|
|
|
2013-05-10 10:25:25 +04:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2012-07-31 01:59:05 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2012-10-01 04:37:47 +04:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsHashKeys.h"
|
2013-05-10 10:25:25 +04:00
|
|
|
#include "nsWrapperCache.h"
|
2012-10-01 04:37:47 +04:00
|
|
|
#include "nsWeakReference.h"
|
|
|
|
#include "nsClassHashtable.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2012-08-01 01:30:53 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-02-15 02:41:07 +04:00
|
|
|
|
|
|
|
class nsPIDOMWindow;
|
2012-09-21 14:32:18 +04:00
|
|
|
|
2012-10-01 04:37:47 +04:00
|
|
|
namespace mozilla {
|
2013-05-10 10:25:25 +04:00
|
|
|
class ErrorResult;
|
2014-02-15 02:41:07 +04:00
|
|
|
class nsDOMCameraControl;
|
|
|
|
namespace dom {
|
|
|
|
class CameraConfiguration;
|
|
|
|
class GetCameraCallback;
|
|
|
|
class CameraErrorCallback;
|
|
|
|
}
|
2012-10-01 04:37:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef nsTArray<nsRefPtr<mozilla::nsDOMCameraControl> > CameraControls;
|
|
|
|
typedef nsClassHashtable<nsUint64HashKey, CameraControls> WindowTable;
|
2014-04-02 08:08:42 +04:00
|
|
|
typedef mozilla::dom::Optional<mozilla::dom::OwningNonNull<mozilla::dom::CameraErrorCallback>>
|
|
|
|
OptionalNonNullCameraErrorCallback;
|
2012-10-01 04:37:47 +04:00
|
|
|
|
|
|
|
class nsDOMCameraManager MOZ_FINAL
|
2013-05-14 14:59:11 +04:00
|
|
|
: public nsIObserver
|
2012-10-01 04:37:47 +04:00
|
|
|
, public nsSupportsWeakReference
|
2013-05-10 10:25:25 +04:00
|
|
|
, public nsWrapperCache
|
2012-07-31 01:59:05 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-10-01 04:37:47 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2013-05-10 10:25:25 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDOMCameraManager,
|
2013-05-14 14:59:11 +04:00
|
|
|
nsIObserver)
|
2012-10-01 04:37:47 +04:00
|
|
|
NS_DECL_NSIOBSERVER
|
2012-07-31 01:59:05 +04:00
|
|
|
|
2014-04-09 19:53:34 +04:00
|
|
|
// Because this header's filename doesn't match its C++ or DOM-facing
|
|
|
|
// classname, we can't rely on the [Func="..."] WebIDL tag to implicitly
|
|
|
|
// include the right header for us; instead we must explicitly include a
|
|
|
|
// HasSupport() method in each header. We can get rid of these with the
|
|
|
|
// Great Renaming proposed in bug 983177.
|
|
|
|
static bool HasSupport(JSContext* aCx, JSObject* aGlobal);
|
|
|
|
|
2013-07-12 18:35:44 +04:00
|
|
|
static bool CheckPermission(nsPIDOMWindow* aWindow);
|
2012-09-21 14:32:18 +04:00
|
|
|
static already_AddRefed<nsDOMCameraManager>
|
2013-07-12 18:35:44 +04:00
|
|
|
CreateInstance(nsPIDOMWindow* aWindow);
|
2012-10-01 04:37:47 +04:00
|
|
|
static bool IsWindowStillActive(uint64_t aWindowId);
|
2012-07-31 01:59:05 +04:00
|
|
|
|
2012-10-01 04:37:47 +04:00
|
|
|
void Register(mozilla::nsDOMCameraControl* aDOMCameraControl);
|
2012-08-22 19:56:38 +04:00
|
|
|
void OnNavigation(uint64_t aWindowId);
|
2012-07-31 01:59:05 +04:00
|
|
|
|
2014-04-02 08:08:42 +04:00
|
|
|
void PermissionAllowed(uint32_t aCameraId,
|
|
|
|
const mozilla::dom::CameraConfiguration& aOptions,
|
|
|
|
mozilla::dom::GetCameraCallback* aOnSuccess,
|
|
|
|
mozilla::dom::CameraErrorCallback* aOnError);
|
|
|
|
|
|
|
|
void PermissionCancelled(uint32_t aCameraId,
|
|
|
|
const mozilla::dom::CameraConfiguration& aOptions,
|
|
|
|
mozilla::dom::GetCameraCallback* aOnSuccess,
|
|
|
|
mozilla::dom::CameraErrorCallback* aOnError);
|
|
|
|
|
2013-05-10 10:25:25 +04:00
|
|
|
// WebIDL
|
2014-02-15 02:41:07 +04:00
|
|
|
void GetCamera(const nsAString& aCamera,
|
|
|
|
const mozilla::dom::CameraConfiguration& aOptions,
|
|
|
|
mozilla::dom::GetCameraCallback& aOnSuccess,
|
2014-04-02 08:08:42 +04:00
|
|
|
const OptionalNonNullCameraErrorCallback& aOnError,
|
2013-05-10 10:25:25 +04:00
|
|
|
mozilla::ErrorResult& aRv);
|
|
|
|
void GetListOfCameras(nsTArray<nsString>& aList, mozilla::ErrorResult& aRv);
|
|
|
|
|
|
|
|
nsPIDOMWindow* GetParentObject() const { return mWindow; }
|
2014-04-09 02:27:18 +04:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx)
|
2013-05-10 10:25:25 +04:00
|
|
|
MOZ_OVERRIDE;
|
|
|
|
|
2012-10-01 04:37:47 +04:00
|
|
|
protected:
|
|
|
|
void XpComShutdown();
|
|
|
|
void Shutdown(uint64_t aWindowId);
|
|
|
|
~nsDOMCameraManager();
|
|
|
|
|
2012-07-31 01:59:05 +04:00
|
|
|
private:
|
2013-02-15 12:04:11 +04:00
|
|
|
nsDOMCameraManager() MOZ_DELETE;
|
2013-05-10 10:25:25 +04:00
|
|
|
nsDOMCameraManager(nsPIDOMWindow* aWindow);
|
2012-07-31 01:59:05 +04:00
|
|
|
nsDOMCameraManager(const nsDOMCameraManager&) MOZ_DELETE;
|
|
|
|
nsDOMCameraManager& operator=(const nsDOMCameraManager&) MOZ_DELETE;
|
|
|
|
|
|
|
|
protected:
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t mWindowId;
|
2014-04-02 08:08:42 +04:00
|
|
|
uint32_t mPermission;
|
2013-05-10 10:25:25 +04:00
|
|
|
nsCOMPtr<nsPIDOMWindow> mWindow;
|
2012-10-01 04:37:47 +04:00
|
|
|
/**
|
2014-02-15 02:41:07 +04:00
|
|
|
* 'sActiveWindows' is only ever accessed while in the Main Thread,
|
2012-10-01 04:37:47 +04:00
|
|
|
* so it is not otherwise protected.
|
|
|
|
*/
|
2013-11-20 20:29:03 +04:00
|
|
|
static ::WindowTable* sActiveWindows;
|
2012-07-31 01:59:05 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DOM_CAMERA_DOMCAMERAMANAGER_H
|