widevine: Use component updater with the Alloy runtime (fixes issue #3149)

Widevine CDM binaries will be downloaded on supported platforms shortly after
application startup. Widevine support will then become available within a few
seconds after successful installation on Windows or after the next application
restart on other platforms. The CDM files will be downloaded to a "WidevineCdm"
directory inside the `CefSettings.user_data_path` directory.

Pass the `--disable-component-update` command-line flag to disable Widevine
download and installation. Pass the `--component-updater=fast-update` command-
line flag to force Widevine download immediately after application startup.

See the related issue for additional usage details.
This commit is contained in:
Marshall Greenblatt
2021-08-09 17:18:43 -04:00
parent eaf581e544
commit 240b869db5
45 changed files with 201 additions and 1459 deletions

View File

@@ -6,7 +6,6 @@
#include "libcef/browser/context.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/widevine_loader.h"
#include "base/bind.h"
#include "base/files/file_path.h"
@@ -30,23 +29,6 @@ void PluginsCallbackImpl(
}
}
#if !(BUILDFLAG(ENABLE_WIDEVINE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)) || \
defined(OS_LINUX)
void DeliverWidevineCdmError(const std::string& error_message,
CefRefPtr<CefRegisterCdmCallback> callback) {
LOG(ERROR) << error_message;
if (callback.get()) {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&CefRegisterCdmCallback::OnCdmRegistrationComplete,
callback.get(), CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED,
error_message));
}
}
#endif
} // namespace
// CefWebPluginInfoImpl
@@ -166,24 +148,3 @@ void CefIsWebPluginUnstable(const CefString& path,
base::BindOnce(CefIsWebPluginUnstable, path, callback));
}
}
void CefRegisterWidevineCdm(const CefString& path,
CefRefPtr<CefRegisterCdmCallback> callback) {
#if BUILDFLAG(ENABLE_WIDEVINE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
#if defined(OS_LINUX)
// Enforce the requirement that CefRegisterWidevineCdm() is called before
// CefInitialize() on Linux. See comments in
// CefWidevineLoader::AddPepperPlugins for details.
if (CONTEXT_STATE_VALID()) {
DeliverWidevineCdmError(
"Widevine registration is not supported after context initialization",
callback);
return;
}
#endif // defined(OS_LINUX)
CefWidevineLoader::GetInstance()->LoadWidevineCdm(path, callback);
#else
DeliverWidevineCdmError("Widevine registration is not supported", callback);
#endif // BUILDFLAG(ENABLE_WIDEVINE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
}