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_MediaKeySystemAccess_h
8 : #define mozilla_dom_MediaKeySystemAccess_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "mozilla/ErrorResult.h"
12 : #include "nsCycleCollectionParticipant.h"
13 : #include "nsWrapperCache.h"
14 :
15 : #include "mozilla/dom/Promise.h"
16 : #include "mozilla/dom/MediaKeySystemAccessBinding.h"
17 : #include "mozilla/dom/MediaKeysRequestStatusBinding.h"
18 :
19 : #include "js/TypeDecls.h"
20 :
21 : namespace mozilla {
22 :
23 : class DecoderDoctorDiagnostics;
24 :
25 : namespace dom {
26 :
27 : class MediaKeySystemAccess final : public nsISupports,
28 : public nsWrapperCache
29 : {
30 : public:
31 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
32 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaKeySystemAccess)
33 :
34 : public:
35 : explicit MediaKeySystemAccess(nsPIDOMWindowInner* aParent,
36 : const nsAString& aKeySystem,
37 : const MediaKeySystemConfiguration& aConfig);
38 :
39 : protected:
40 : ~MediaKeySystemAccess();
41 :
42 : public:
43 : nsPIDOMWindowInner* GetParentObject() const;
44 :
45 : JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
46 :
47 : void GetKeySystem(nsString& aRetVal) const;
48 :
49 : void GetConfiguration(MediaKeySystemConfiguration& aConfig);
50 :
51 : already_AddRefed<Promise> CreateMediaKeys(ErrorResult& aRv);
52 :
53 : static MediaKeySystemStatus GetKeySystemStatus(const nsAString& aKeySystem,
54 : nsACString& aOutExceptionMessage);
55 :
56 : static bool IsSupported(const nsAString& aKeySystem,
57 : const Sequence<MediaKeySystemConfiguration>& aConfigs,
58 : DecoderDoctorDiagnostics* aDiagnostics);
59 :
60 : static void NotifyObservers(nsPIDOMWindowInner* aWindow,
61 : const nsAString& aKeySystem,
62 : MediaKeySystemStatus aStatus);
63 :
64 : static bool GetSupportedConfig(
65 : const nsAString& aKeySystem,
66 : const Sequence<MediaKeySystemConfiguration>& aConfigs,
67 : MediaKeySystemConfiguration& aOutConfig,
68 : DecoderDoctorDiagnostics* aDiagnostics,
69 : bool aIsPrivateBrowsing,
70 : const std::function<void(const char*)>& aDeprecationLogFn);
71 :
72 : static bool KeySystemSupportsInitDataType(const nsAString& aKeySystem,
73 : const nsAString& aInitDataType);
74 :
75 : static nsCString ToCString(
76 : const Sequence<MediaKeySystemConfiguration>& aConfig);
77 :
78 : private:
79 : nsCOMPtr<nsPIDOMWindowInner> mParent;
80 : const nsString mKeySystem;
81 : const MediaKeySystemConfiguration mConfig;
82 : };
83 :
84 : } // namespace dom
85 : } // namespace mozilla
86 :
87 : #endif // mozilla_dom_MediaKeySystemAccess_h
|