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