fix: ensure that requestMediaKeySystemAccess resolves (#34886)

When widevine was disabled at the build level we never dealt with the callback passed into GetSupportedKeySystems.  This was ok until requests became marked pending in https://chromium-review.googlesource.com/c/chromium/src/+/3430502 until the callback was called.  This resulted in a promise never resolving / rejecting and certain media websites (E.g. spotify) hanging on load waiting for a signal that would never arrive.
This commit is contained in:
Samuel Attard 2022-07-12 00:48:51 -07:00 committed by GitHub
commit 511ff8bc8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View file

@ -22,17 +22,18 @@
#include "ppapi/buildflags/buildflags.h" #include "ppapi/buildflags/buildflags.h"
#include "shell/common/electron_paths.h" #include "shell/common/electron_paths.h"
#include "shell/common/options_switches.h" #include "shell/common/options_switches.h"
#include "third_party/widevine/cdm/buildflags.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "url/url_constants.h" #include "url/url_constants.h"
// In SHARED_INTERMEDIATE_DIR. // In SHARED_INTERMEDIATE_DIR.
#include "widevine_cdm_version.h" // NOLINT(build/include_directory) #include "widevine_cdm_version.h" // NOLINT(build/include_directory)
#if defined(WIDEVINE_CDM_AVAILABLE) #if BUILDFLAG(ENABLE_WIDEVINE)
#include "base/native_library.h" #include "base/native_library.h"
#include "content/public/common/cdm_info.h" #include "content/public/common/cdm_info.h"
#include "media/base/video_codecs.h" #include "media/base/video_codecs.h"
#endif // defined(WIDEVINE_CDM_AVAILABLE) #endif // BUILDFLAG(ENABLE_WIDEVINE)
#if BUILDFLAG(ENABLE_PDF_VIEWER) #if BUILDFLAG(ENABLE_PDF_VIEWER)
#include "chrome/common/pdf_util.h" #include "chrome/common/pdf_util.h"
@ -58,7 +59,7 @@ enum class WidevineCdmFileCheck {
kNotFound, kNotFound,
}; };
#if defined(WIDEVINE_CDM_AVAILABLE) #if BUILDFLAG(ENABLE_WIDEVINE)
bool IsWidevineAvailable( bool IsWidevineAvailable(
base::FilePath* cdm_path, base::FilePath* cdm_path,
std::vector<media::VideoCodec>* codecs_supported, std::vector<media::VideoCodec>* codecs_supported,
@ -102,7 +103,7 @@ bool IsWidevineAvailable(
return false; return false;
} }
#endif // defined(WIDEVINE_CDM_AVAILABLE) #endif // BUILDFLAG(ENABLE_WIDEVINE)
#if BUILDFLAG(ENABLE_PLUGINS) #if BUILDFLAG(ENABLE_PLUGINS)
void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
@ -227,7 +228,7 @@ void ElectronContentClient::AddContentDecryptionModules(
std::vector<content::CdmInfo>* cdms, std::vector<content::CdmInfo>* cdms,
std::vector<media::CdmHostFilePath>* cdm_host_file_paths) { std::vector<media::CdmHostFilePath>* cdm_host_file_paths) {
if (cdms) { if (cdms) {
#if defined(WIDEVINE_CDM_AVAILABLE) #if BUILDFLAG(ENABLE_WIDEVINE)
base::FilePath cdm_path; base::FilePath cdm_path;
std::vector<media::VideoCodec> video_codecs_supported; std::vector<media::VideoCodec> video_codecs_supported;
base::flat_set<media::CdmSessionType> session_types_supported; base::flat_set<media::CdmSessionType> session_types_supported;
@ -252,7 +253,7 @@ void ElectronContentClient::AddContentDecryptionModules(
kWidevineCdmDisplayName, kWidevineCdmGuid, version, cdm_path, kWidevineCdmDisplayName, kWidevineCdmGuid, version, cdm_path,
kWidevineCdmFileSystemId, capability, kWidevineKeySystem, false)); kWidevineCdmFileSystemId, capability, kWidevineKeySystem, false));
} }
#endif // defined(WIDEVINE_CDM_AVAILABLE) #endif // BUILDFLAG(ENABLE_WIDEVINE)
} }
} }

View file

@ -47,6 +47,7 @@
#include "third_party/blink/public/web/web_view.h" #include "third_party/blink/public/web/web_view.h"
#include "third_party/blink/renderer/platform/media/multi_buffer_data_source.h" // nogncheck #include "third_party/blink/renderer/platform/media/multi_buffer_data_source.h" // nogncheck
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h" // nogncheck #include "third_party/blink/renderer/platform/weborigin/scheme_registry.h" // nogncheck
#include "third_party/widevine/cdm/buildflags.h"
#if BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_MAC)
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
@ -56,7 +57,7 @@
#include <shlobj.h> #include <shlobj.h>
#endif #endif
#if defined(WIDEVINE_CDM_AVAILABLE) #if BUILDFLAG(ENABLE_WIDEVINE)
#include "chrome/renderer/media/chrome_key_systems.h" // nogncheck #include "chrome/renderer/media/chrome_key_systems.h" // nogncheck
#endif #endif
@ -377,8 +378,10 @@ bool RendererClientBase::OverrideCreatePlugin(
void RendererClientBase::GetSupportedKeySystems( void RendererClientBase::GetSupportedKeySystems(
media::GetSupportedKeySystemsCB cb) { media::GetSupportedKeySystemsCB cb) {
#if defined(WIDEVINE_CDM_AVAILABLE) #if BUILDFLAG(ENABLE_WIDEVINE)
GetChromeKeySystems(std::move(cb)); GetChromeKeySystems(std::move(cb));
#else
std::move(cb).Run({});
#endif #endif
} }