1 // Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be found 3 // in the LICENSE file. 4 5 #ifndef CEF_LIBCEF_COMMON_WIDEVINE_LOADER_H_ 6 #define CEF_LIBCEF_COMMON_WIDEVINE_LOADER_H_ 7 #pragma once 8 9 #include "build/build_config.h" 10 #include "media/media_buildflags.h" 11 #include "third_party/widevine/cdm/buildflags.h" 12 13 #if BUILDFLAG(ENABLE_WIDEVINE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) 14 15 #include <vector> 16 17 #include "include/cef_web_plugin.h" 18 19 #include "base/lazy_instance.h" 20 21 namespace content { 22 struct CdmInfo; 23 } 24 25 namespace media { 26 struct CdmHostFilePath; 27 } 28 29 class CefWidevineLoader { 30 public: 31 // Returns the singleton instance of this object. 32 static CefWidevineLoader* GetInstance(); 33 34 // Load the Widevine CDM. May be called before or after context creation. See 35 // comments in cef_web_plugin.h. 36 void LoadWidevineCdm(const base::FilePath& path, 37 CefRefPtr<CefRegisterCdmCallback> callback); 38 39 // Plugin registration is triggered here if LoadWidevineCdm() was called 40 // before context creation. 41 void OnContextInitialized(); 42 43 #if defined(OS_LINUX) 44 // The zygote process which is used when the sandbox is enabled on Linux 45 // requires early loading of CDM modules. Other processes will receive 46 // load notification in the usual way. 47 // Called from AlloyContentClient::AddContentDecryptionModules. 48 static void AddContentDecryptionModules( 49 std::vector<content::CdmInfo>* cdms, 50 std::vector<media::CdmHostFilePath>* cdm_host_file_paths); 51 path()52 const base::FilePath& path() { return path_; } 53 #endif 54 55 private: 56 friend struct base::LazyInstanceTraitsBase<CefWidevineLoader>; 57 58 // Members are only accessed before context initialization or on the UI 59 // thread. 60 bool load_pending_ = false; 61 base::FilePath path_; 62 CefRefPtr<CefRegisterCdmCallback> callback_; 63 64 CefWidevineLoader(); 65 ~CefWidevineLoader(); 66 }; 67 68 #endif // BUILDFLAG(ENABLE_WIDEVINE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) 69 70 #endif // CEF_LIBCEF_COMMON_WIDEVINE_LOADER_H_ 71