Bug 1267453 - Amazon Widevine rejects HDCP on MacBook Pro with or without an external display. r=gcp a=ritu

This commit is contained in:
Haik Aftandilian 2016-05-02 19:33:08 +02:00
parent b73538be4d
commit 2f67acefba
4 changed files with 31 additions and 8 deletions

View File

@ -213,7 +213,7 @@ GetAppPaths(nsCString &aAppPath, nsCString &aAppBinaryPath)
}
bool
GMPChild::SetMacSandboxInfo()
GMPChild::SetMacSandboxInfo(MacSandboxPluginType aPluginType)
{
if (!mGMPLoader) {
return false;
@ -229,7 +229,7 @@ GMPChild::SetMacSandboxInfo()
MacSandboxInfo info;
info.type = MacSandboxType_Plugin;
info.pluginInfo.type = MacSandboxPluginType_GMPlugin_Default;
info.pluginInfo.type = aPluginType;
info.pluginInfo.pluginPath.assign(pluginDirectoryPath.get());
info.pluginInfo.pluginBinaryPath.assign(pluginFilePath.get());
info.appPath.assign(appPath.get());
@ -373,8 +373,18 @@ GMPChild::AnswerStartPlugin(const nsString& aAdapter)
return false;
}
#ifdef MOZ_WIDEVINE_EME
bool isWidevine = aAdapter.EqualsLiteral("widevine");
#endif
#if defined(MOZ_GMP_SANDBOX) && defined(XP_MACOSX)
if (!SetMacSandboxInfo()) {
MacSandboxPluginType pluginType = MacSandboxPluginType_GMPlugin_Default;
#ifdef MOZ_WIDEVINE_EME
if (isWidevine) {
pluginType = MacSandboxPluginType_GMPlugin_EME_Widevine;
}
#endif
if (!SetMacSandboxInfo(pluginType)) {
NS_WARNING("Failed to set Mac GMP sandbox info");
delete platformAPI;
return false;
@ -383,7 +393,7 @@ GMPChild::AnswerStartPlugin(const nsString& aAdapter)
GMPAdapter* adapter = nullptr;
#ifdef MOZ_WIDEVINE_EME
if (aAdapter.EqualsLiteral("widevine")) {
if (isWidevine) {
adapter = new WidevineAdapter();
}
#endif

View File

@ -41,7 +41,7 @@ public:
void ShutdownComplete() override;
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
bool SetMacSandboxInfo();
bool SetMacSandboxInfo(MacSandboxPluginType aPluginType);
#endif
private:

View File

@ -17,9 +17,10 @@ enum MacSandboxType {
enum MacSandboxPluginType {
MacSandboxPluginType_Default = 0,
MacSandboxPluginType_GMPlugin_Default, // Any Gecko Media Plugin
MacSandboxPluginType_GMPlugin_OpenH264, // Gecko Media Plugin, OpenH264
MacSandboxPluginType_GMPlugin_EME, // Gecko Media Plugin, EME
MacSandboxPluginType_GMPlugin_Default, // Any Gecko Media Plugin
MacSandboxPluginType_GMPlugin_OpenH264, // Gecko Media Plugin, OpenH264
MacSandboxPluginType_GMPlugin_EME, // Gecko Media Plugin, EME
MacSandboxPluginType_GMPlugin_EME_Widevine, // Gecko Media Plugin, Widevine
MacSandboxPluginType_Invalid
};

View File

@ -150,6 +150,9 @@ static const char pluginSandboxRules[] =
" (literal \"%s\")\n"
" (literal \"%s\"))\n";
static const char widevinePluginSandboxRulesAddend[] =
"(allow mach-lookup (global-name \"com.apple.windowserver.active\"))\n";
static const char contentSandboxRules[] =
"(version 1)\n"
"\n"
@ -448,6 +451,15 @@ bool StartMacSandbox(MacSandboxInfo aInfo, std::string &aErrorMessage)
aInfo.appPath.c_str(),
aInfo.appBinaryPath.c_str());
}
if (profile &&
aInfo.pluginInfo.type == MacSandboxPluginType_GMPlugin_EME_Widevine) {
char *widevineProfile = NULL;
asprintf(&widevineProfile, "%s%s", profile,
widevinePluginSandboxRulesAddend);
free(profile);
profile = widevineProfile;
}
}
else if (aInfo.type == MacSandboxType_Content) {
asprintf(&profile, contentSandboxRules, aInfo.level,