Permissions.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  4. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_Permissions_h_
  6. #define mozilla_dom_Permissions_h_
  7. #include "nsISupports.h"
  8. #include "nsPIDOMWindow.h"
  9. #include "nsWrapperCache.h"
  10. namespace mozilla {
  11. class ErrorResult;
  12. namespace dom {
  13. class Promise;
  14. class Permissions final
  15. : public nsISupports
  16. , public nsWrapperCache
  17. {
  18. public:
  19. NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  20. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Permissions)
  21. explicit Permissions(nsPIDOMWindowInner* aWindow);
  22. nsPIDOMWindowInner* GetParentObject() const { return mWindow; }
  23. JSObject* WrapObject(JSContext* aCx,
  24. JS::Handle<JSObject*> aGivenProto) override;
  25. already_AddRefed<Promise> Query(JSContext* aCx,
  26. JS::Handle<JSObject*> aPermission,
  27. ErrorResult& aRv);
  28. static nsresult RemovePermission(nsIPrincipal* aPrincipal, const char* aPermissionType);
  29. already_AddRefed<Promise> Revoke(JSContext* aCx,
  30. JS::Handle<JSObject*> aPermission,
  31. ErrorResult& aRv);
  32. private:
  33. ~Permissions();
  34. nsCOMPtr<nsPIDOMWindowInner> mWindow;
  35. };
  36. } // namespace dom
  37. } // namespace mozilla
  38. #endif // mozilla_dom_permissions_h_