Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_dom_PresentationRequest_h
8 : #define mozilla_dom_PresentationRequest_h
9 :
10 : #include "mozilla/dom/BindingDeclarations.h"
11 : #include "mozilla/DOMEventTargetHelper.h"
12 :
13 : class nsIDocument;
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : class Promise;
19 : class PresentationAvailability;
20 : class PresentationConnection;
21 :
22 : class PresentationRequest final : public DOMEventTargetHelper
23 : {
24 : public:
25 : NS_DECL_ISUPPORTS_INHERITED
26 :
27 : static already_AddRefed<PresentationRequest> Constructor(
28 : const GlobalObject& aGlobal,
29 : const nsAString& aUrl,
30 : ErrorResult& aRv);
31 :
32 : static already_AddRefed<PresentationRequest> Constructor(
33 : const GlobalObject& aGlobal,
34 : const Sequence<nsString>& aUrls,
35 : ErrorResult& aRv);
36 :
37 : virtual JSObject* WrapObject(JSContext* aCx,
38 : JS::Handle<JSObject*> aGivenProto) override;
39 :
40 : // WebIDL (public APIs)
41 : already_AddRefed<Promise> Start(ErrorResult& aRv);
42 :
43 : already_AddRefed<Promise> StartWithDevice(const nsAString& aDeviceId,
44 : ErrorResult& aRv);
45 :
46 : already_AddRefed<Promise> Reconnect(const nsAString& aPresentationId,
47 : ErrorResult& aRv);
48 :
49 : already_AddRefed<Promise> GetAvailability(ErrorResult& aRv);
50 :
51 0 : IMPL_EVENT_HANDLER(connectionavailable);
52 :
53 : nsresult DispatchConnectionAvailableEvent(PresentationConnection* aConnection);
54 :
55 : void NotifyPromiseSettled();
56 :
57 : private:
58 : PresentationRequest(nsPIDOMWindowInner* aWindow,
59 : nsTArray<nsString>&& aUrls);
60 :
61 : ~PresentationRequest();
62 :
63 : bool Init();
64 :
65 : void FindOrCreatePresentationConnection(const nsAString& aPresentationId,
66 : Promise* aPromise);
67 :
68 : void FindOrCreatePresentationAvailability(RefPtr<Promise>& aPromise);
69 :
70 : // Implement https://w3c.github.io/webappsec-mixed-content/#categorize-settings-object
71 : bool IsProhibitMixedSecurityContexts(nsIDocument* aDocument);
72 :
73 : // Implement https://w3c.github.io/webappsec-mixed-content/#a-priori-authenticated-url
74 : bool IsPrioriAuthenticatedURL(const nsAString& aUrl);
75 :
76 : bool IsAllURLAuthenticated();
77 :
78 : nsTArray<nsString> mUrls;
79 : };
80 :
81 : } // namespace dom
82 : } // namespace mozilla
83 :
84 : #endif // mozilla_dom_PresentationRequest_h
|