permissions.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_PERMISSIONS_PERMISSIONS_H_
  5. #define THIRD_PARTY_BLINK_RENDERER_MODULES_PERMISSIONS_PERMISSIONS_H_
  6. #include "third_party/blink/public/mojom/permissions/permission.mojom-blink.h"
  7. #include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
  8. #include "third_party/blink/renderer/core/execution_context/execution_context.h"
  9. #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
  10. #include "third_party/blink/renderer/platform/heap/handle.h"
  11. #include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h"
  12. #include "third_party/blink/renderer/platform/mojo/heap_mojo_wrapper_mode.h"
  13. namespace blink {
  14. class ExecutionContext;
  15. class ScriptPromiseResolver;
  16. class ScriptState;
  17. class ScriptValue;
  18. class Permissions final : public ScriptWrappable {
  19. DEFINE_WRAPPERTYPEINFO();
  20. public:
  21. explicit Permissions(ExecutionContext* execution_context);
  22. ScriptPromise query(ScriptState*, const ScriptValue&, ExceptionState&);
  23. ScriptPromise request(ScriptState*, const ScriptValue&, ExceptionState&);
  24. ScriptPromise revoke(ScriptState*, const ScriptValue&, ExceptionState&);
  25. ScriptPromise requestAll(ScriptState*,
  26. const HeapVector<ScriptValue>&,
  27. ExceptionState&);
  28. void Trace(Visitor*) const override;
  29. private:
  30. mojom::blink::PermissionService* GetService(ExecutionContext*);
  31. void ServiceConnectionError();
  32. void TaskComplete(ScriptPromiseResolver*,
  33. mojom::blink::PermissionDescriptorPtr,
  34. mojom::blink::PermissionStatus);
  35. void BatchTaskComplete(ScriptPromiseResolver*,
  36. Vector<mojom::blink::PermissionDescriptorPtr>,
  37. Vector<int>,
  38. const Vector<mojom::blink::PermissionStatus>&);
  39. HeapMojoRemote<mojom::blink::PermissionService,
  40. HeapMojoWrapperMode::kWithoutContextObserver>
  41. service_;
  42. };
  43. } // namespace blink
  44. #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_PERMISSIONS_PERMISSIONS_H_