summaryrefslogtreecommitdiffstats
path: root/src/core/content_client_qt.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-05-09 17:25:22 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-06-26 08:17:30 +0000
commit7757ec1a562ae36b65a6cae93b3cd308247755ef (patch)
tree9da058ac021019317111dd1ad90c0a4a32529afe /src/core/content_client_qt.cpp
parent57c49df9c6fcbaaffc66900e191312d4e0a0edfa (diff)
Adaptations for Chromium 67
Change-Id: I13cedba56012f74651a044d6fa8f0957487bf3eb Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/core/content_client_qt.cpp')
-rw-r--r--src/core/content_client_qt.cpp197
1 files changed, 132 insertions, 65 deletions
diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp
index 584d6c0aa..46e1fa241 100644
--- a/src/core/content_client_qt.cpp
+++ b/src/core/content_client_qt.cpp
@@ -45,8 +45,13 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/version.h"
+#include "content/public/common/cdm_info.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/user_agent.h"
+#include "media/base/media_switches.h"
+#include "media/base/video_codecs.h"
+#include "media/media_buildflags.h"
#include "ui/base/layout.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -59,6 +64,42 @@
#include <QLibraryInfo>
#include <QString>
+#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
+#include "media/cdm/cdm_paths.h" // nogncheck
+#include "third_party/widevine/cdm/widevine_cdm_common.h"
+#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
+#define WIDEVINE_CDM_AVAILABLE
+#if defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT)
+#define WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT
+namespace switches {
+const char kCdmWidevinePath[] = "widevine-path";
+}
+// File name of the CDM on different platforms.
+const char kWidevineCdmFileName[] =
+#if defined(OS_MACOSX)
+ "widevinecdm.plugin";
+#elif defined(OS_WIN)
+ "widevinecdm.dll";
+#else // OS_LINUX, etc.
+ "libwidevinecdm.so";
+#endif
+#endif
+
+static QString webenginePluginsPath()
+{
+ // Look for plugins in /plugins/webengine or application dir.
+ static bool initialized = false;
+ static QString potentialPluginsPath = QLibraryInfo::location(QLibraryInfo::PluginsPath) % QLatin1String("/webengine");
+ if (!initialized) {
+ initialized = true;
+ if (!QFileInfo::exists(potentialPluginsPath))
+ potentialPluginsPath = QCoreApplication::applicationDirPath();
+ }
+ return potentialPluginsPath;
+}
+#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
+
+
#if defined(Q_OS_WIN)
#include <shlobj.h>
static QString getLocalAppDataDir()
@@ -81,8 +122,6 @@ static QString getLocalAppDataDir()
#include "content/public/common/pepper_plugin_info.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
-#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
-
static const int32_t kPepperFlashPermissions = ppapi::PERMISSION_DEV |
ppapi::PERMISSION_PRIVATE |
ppapi::PERMISSION_BYPASS_USER_GESTURE |
@@ -94,18 +133,6 @@ const char kPpapiFlashVersion[] = "ppapi-flash-version";
const char kPpapiWidevinePath[] = "ppapi-widevine-path";
}
-const char kCdmSupportedCodecsParamName[] = "codecs";
-const char kCdmSupportedCodecVp8[] = "vp8";
-const char kCdmSupportedCodecVp9[] = "vp9.0";
-#if BUILDFLAG(USE_PROPRIETARY_CODECS)
-const char kCdmSupportedCodecAvc1[] = "avc1";
-#endif
-
-static const char kWidevineCdmPluginExtension[] = "";
-
-static const int32_t kWidevineCdmPluginPermissions = ppapi::PERMISSION_DEV
- | ppapi::PERMISSION_PRIVATE;
-
static QString ppapiPluginsPath()
{
// Look for plugins in /plugins/ppapi or application dir.
@@ -208,22 +235,40 @@ void AddPepperFlashFromCommandLine(std::vector<content::PepperPluginInfo>* plugi
plugins->push_back(CreatePepperFlashInfo(base::FilePath(flash_path), flash_version));
}
-void AddPepperWidevine(std::vector<content::PepperPluginInfo>* plugins)
+namespace QtWebEngineCore {
+
+void ContentClientQt::AddPepperPlugins(std::vector<content::PepperPluginInfo>* plugins)
+{
+ AddPepperFlashFromSystem(plugins);
+ AddPepperFlashFromCommandLine(plugins);
+}
+
+} // namespace QtWebEngineCore
+#endif // BUILDFLAG(ENABLE_PLUGINS)
+
+namespace QtWebEngineCore {
+
+#if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
+static bool IsWidevineAvailable(base::FilePath *cdm_path,
+ std::vector<media::VideoCodec> *codecs_supported,
+ bool *supports_persistent_license)
{
-#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) && !defined(WIDEVINE_CDM_IS_COMPONENT)
QStringList pluginPaths;
- const base::CommandLine::StringType widevine_argument = base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(switches::kPpapiWidevinePath);
+ const base::CommandLine::StringType widevine_argument = base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(switches::kCdmWidevinePath);
if (!widevine_argument.empty())
pluginPaths << QtWebEngineCore::toQt(widevine_argument);
else {
- pluginPaths << ppapiPluginsPath() + QStringLiteral("/") + QString::fromLatin1(kWidevineCdmAdapterFileName);
+ pluginPaths << webenginePluginsPath() + QStringLiteral("/") + QString::fromLatin1(kWidevineCdmFileName);
+#if BUILDFLAG(ENABLE_PLUGINS)
+ pluginPaths << ppapiPluginsPath() + QStringLiteral("/") + QString::fromLatin1(kWidevineCdmFileName);
+#endif
#if defined(Q_OS_OSX)
QDir potentialWidevineDir(QDir::homePath() + "/Library/Application Support/Google/Chrome/WidevineCDM");
if (potentialWidevineDir.exists()) {
QFileInfoList widevineVersionDirs = potentialWidevineDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::Reversed);
for (int i = 0; i < widevineVersionDirs.size(); ++i) {
QString versionDirPath(widevineVersionDirs.at(i).absoluteFilePath());
- QString potentialWidevinePluginPath = versionDirPath + "/_platform_specific/mac_x64/" + QString::fromLatin1(kWidevineCdmAdapterFileName);
+ QString potentialWidevinePluginPath = versionDirPath + "/_platform_specific/mac_x64/" + QString::fromLatin1(kWidevineCdmFileName);
pluginPaths << potentialWidevinePluginPath;
}
}
@@ -234,71 +279,93 @@ void AddPepperWidevine(std::vector<content::PepperPluginInfo>* plugins)
for (int i = 0; i < widevineVersionDirs.size(); ++i) {
QString versionDirPath(widevineVersionDirs.at(i).absoluteFilePath());
#ifdef WIN64
- QString potentialWidevinePluginPath = versionDirPath + "/_platform_specific/win_x64/" + QString::fromLatin1(kWidevineCdmAdapterFileName);
+ QString potentialWidevinePluginPath = versionDirPath + "/_platform_specific/win_x64/" + QString::fromLatin1(kWidevineCdmFileName);
#else
- QString potentialWidevinePluginPath = versionDirPath + "/_platform_specific/win_x86/" + QString::fromLatin1(kWidevineCdmAdapterFileName);
+ QString potentialWidevinePluginPath = versionDirPath + "/_platform_specific/win_x86/" + QString::fromLatin1(kWidevineCdmFileName);
#endif
pluginPaths << potentialWidevinePluginPath;
}
}
#elif defined(Q_OS_LINUX)
- pluginPaths << QStringLiteral("/opt/google/chrome/libwidevinecdmadapter.so") // Google Chrome
- << QStringLiteral("/usr/lib/chromium/libwidevinecdmadapter.so") // Arch
- << QStringLiteral("/usr/lib/chromium-browser/libwidevinecdmadapter.so") // Ubuntu/neon
- << QStringLiteral("/usr/lib64/chromium/libwidevinecdmadapter.so"); // OpenSUSE style
+ pluginPaths << QStringLiteral("/opt/google/chrome/libwidevinecdm.so") // Google Chrome
+ << QStringLiteral("/usr/lib/chromium/libwidevinecdm.so") // Arch
+ << QStringLiteral("/usr/lib/chromium-browser/libwidevinecdm.so") // Ubuntu/neon
+ << QStringLiteral("/usr/lib64/chromium/libwidevinecdm.so"); // OpenSUSE style
#endif
}
for (const QString &pluginPath : qAsConst(pluginPaths)) {
- base::FilePath path = QtWebEngineCore::toFilePath(pluginPath);
- if (base::PathExists(path)) {
- content::PepperPluginInfo widevine_cdm;
- widevine_cdm.is_out_of_process = true;
- widevine_cdm.path = path;
- widevine_cdm.name = kWidevineCdmDisplayName;
- widevine_cdm.description = kWidevineCdmDescription;
- content::WebPluginMimeType widevine_cdm_mime_type(
- kWidevineCdmPluginMimeType,
- kWidevineCdmPluginExtension,
- kWidevineCdmPluginMimeTypeDescription);
-
+ *cdm_path = QtWebEngineCore::toFilePath(pluginPath);
+ if (base::PathExists(*cdm_path)) {
// Add the supported codecs as if they came from the component manifest.
- std::vector<std::string> codecs;
- codecs.push_back(kCdmSupportedCodecVp8);
- codecs.push_back(kCdmSupportedCodecVp9);
+ // This list must match the CDM that is being bundled with Chrome.
+ codecs_supported->push_back(media::VideoCodec::kCodecVP8);
+ codecs_supported->push_back(media::VideoCodec::kCodecVP9);
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
- codecs.push_back(kCdmSupportedCodecAvc1);
-#endif // defined(USE_PROPRIETARY_CODECS)
- std::string codec_string =
- base::JoinString(codecs, ",");
- widevine_cdm_mime_type.additional_params.emplace_back(
- base::ASCIIToUTF16(kCdmSupportedCodecsParamName),
- base::ASCIIToUTF16(codec_string));
- widevine_cdm.mime_types.push_back(widevine_cdm_mime_type);
- widevine_cdm.permissions = kWidevineCdmPluginPermissions;
- plugins->push_back(widevine_cdm);
- break;
+ codecs_supported->push_back(media::VideoCodec::kCodecH264);
+#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
+
+ *supports_persistent_license = false;
+
+ return true;
}
}
-#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) &&
- // !defined(WIDEVINE_CDM_IS_COMPONENT)
+ return false;
}
+#endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
-namespace QtWebEngineCore {
-void ContentClientQt::AddPepperPlugins(std::vector<content::PepperPluginInfo>* plugins)
+void ContentClientQt::AddContentDecryptionModules(std::vector<content::CdmInfo> *cdms,
+ std::vector<media::CdmHostFilePath> *cdm_host_file_paths)
{
- AddPepperFlashFromSystem(plugins);
- AddPepperFlashFromCommandLine(plugins);
- AddPepperWidevine(plugins);
-}
-
+ Q_UNUSED(cdm_host_file_paths);
+ if (cdms) {
+#if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
+ base::FilePath cdm_path;
+ std::vector<media::VideoCodec> video_codecs_supported;
+ bool supports_persistent_license = false;
+ if (IsWidevineAvailable(&cdm_path, &video_codecs_supported,
+ &supports_persistent_license)) {
+ const base::Version version;
+ cdms->push_back(content::CdmInfo(kWidevineCdmDisplayName, kWidevineCdmGuid, version, cdm_path,
+ kWidevineCdmFileSystemId, video_codecs_supported,
+ supports_persistent_license, kWidevineKeySystem, false));
+ }
+#endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
+
+#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
+ // Register Clear Key CDM if specified in command line.
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ base::FilePath clear_key_cdm_path = command_line->GetSwitchValuePath(switches::kClearKeyCdmPathForTesting);
+ if (!clear_key_cdm_path.empty() && base::PathExists(clear_key_cdm_path)) {
+ // TODO(crbug.com/764480): Remove these after we have a central place for
+ // External Clear Key (ECK) related information.
+ // Normal External Clear Key key system.
+ const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey";
+ // A variant of ECK key system that has a different GUID.
+ const char kExternalClearKeyDifferentGuidTestKeySystem[] =
+ "org.chromium.externalclearkey.differentguid";
+ // ECK implementation supports persistent licenses.
+ constexpr bool supports_persistent_license = true;
+
+ // Register kExternalClearKeyDifferentGuidTestKeySystem first separately.
+ // Otherwise, it'll be treated as a sub-key-system of normal
+ // kExternalClearKeyKeySystem. See MultipleCdmTypes test in
+ // ECKEncryptedMediaTest.
+ cdms->push_back(content::CdmInfo(media::kClearKeyCdmDisplayName, media::kClearKeyCdmDifferentGuid,
+ base::Version("0.1.0.0"), clear_key_cdm_path,
+ media::kClearKeyCdmFileSystemId, {}, supports_persistent_license,
+ kExternalClearKeyDifferentGuidTestKeySystem, false));
+
+ // Supported codecs are hard-coded in ExternalClearKeyProperties.
+ cdms->push_back(content::CdmInfo(media::kClearKeyCdmDisplayName, media::kClearKeyCdmGuid,
+ base::Version("0.1.0.0"), clear_key_cdm_path,
+ media::kClearKeyCdmFileSystemId, {}, supports_persistent_license,
+ kExternalClearKeyKeySystem, true));
+ }
+#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
+ }
}
-#endif // BUILDFLAG(ENABLE_PLUGINS)
-
-#include <QCoreApplication>
-
-namespace QtWebEngineCore {
std::string ContentClientQt::getUserAgent()
{