--- a/dom/media/gmp/GMPChild.cpp
+++ b/dom/media/gmp/GMPChild.cpp
@@ -60,33 +60,29 @@ GMPChild::GMPChild()
GMPChild::~GMPChild()
{
LOGD("GMPChild dtor");
}
static bool
GetFileBase(const nsAString& aPluginPath,
-#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
nsCOMPtr<nsIFile>& aLibDirectory,
-#endif
nsCOMPtr<nsIFile>& aFileBase,
nsAutoString& aBaseName)
{
nsresult rv = NS_NewLocalFile(aPluginPath,
true, getter_AddRefs(aFileBase));
if (NS_FAILED(rv)) {
return false;
}
-#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
if (NS_FAILED(aFileBase->Clone(getter_AddRefs(aLibDirectory)))) {
return false;
}
-#endif
nsCOMPtr<nsIFile> parent;
rv = aFileBase->GetParent(getter_AddRefs(parent));
if (NS_FAILED(rv)) {
return false;
}
nsAutoString parentLeafName;
@@ -97,84 +93,93 @@ GetFileBase(const nsAString& aPluginPath
aBaseName = Substring(parentLeafName,
4,
parentLeafName.Length() - 1);
return true;
}
static bool
+GetFileBase(const nsAString& aPluginPath,
+ nsCOMPtr<nsIFile>& aFileBase,
+ nsAutoString& aBaseName)
+{
+ nsCOMPtr<nsIFile> unusedLibDir;
+ return GetFileBase(aPluginPath, unusedLibDir, aFileBase, aBaseName);
+}
+
+static bool
GetPluginFile(const nsAString& aPluginPath,
-#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
nsCOMPtr<nsIFile>& aLibDirectory,
-#endif
nsCOMPtr<nsIFile>& aLibFile)
{
nsAutoString baseName;
-#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
GetFileBase(aPluginPath, aLibDirectory, aLibFile, baseName);
-#else
- GetFileBase(aPluginPath, aLibFile, baseName);
-#endif
#if defined(XP_MACOSX)
nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".dylib");
#elif defined(OS_POSIX)
nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".so");
#elif defined(XP_WIN)
nsAutoString binaryName = baseName + NS_LITERAL_STRING(".dll");
#else
#error not defined
#endif
aLibFile->AppendRelativePath(binaryName);
return true;
}
static bool
+GetPluginFile(const nsAString& aPluginPath,
+ nsCOMPtr<nsIFile>& aLibFile)
+{
+ nsCOMPtr<nsIFile> unusedlibDir;
+ return GetPluginFile(aPluginPath, unusedlibDir, aLibFile);
+}
+
+static bool
GetInfoFile(const nsAString& aPluginPath,
nsCOMPtr<nsIFile>& aInfoFile)
{
nsAutoString baseName;
-#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
- nsCOMPtr<nsIFile> unusedLibDir;
- GetFileBase(aPluginPath, unusedLibDir, aInfoFile, baseName);
-#else
GetFileBase(aPluginPath, aInfoFile, baseName);
-#endif
nsAutoString infoFileName = baseName + NS_LITERAL_STRING(".info");
aInfoFile->AppendRelativePath(infoFileName);
return true;
}
+static nsCString
+GetNativeTarget(nsIFile* aFile)
+{
+ bool isLink;
+ nsCString path;
+ aFile->IsSymlink(&isLink);
+ if (isLink) {
+ aFile->GetNativeTarget(path);
+ } else {
+ aFile->GetNativePath(path);
+ }
+ return path;
+}
+
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
static bool
GetPluginPaths(const nsAString& aPluginPath,
nsCString &aPluginDirectoryPath,
nsCString &aPluginFilePath)
{
nsCOMPtr<nsIFile> libDirectory, libFile;
if (!GetPluginFile(aPluginPath, libDirectory, libFile)) {
return false;
}
// Mac sandbox rules expect paths to actual files and directories -- not
// soft links.
- bool isLink;
- libDirectory->IsSymlink(&isLink);
- if (isLink) {
- libDirectory->GetNativeTarget(aPluginDirectoryPath);
- } else {
- libDirectory->GetNativePath(aPluginDirectoryPath);
- }
- libFile->IsSymlink(&isLink);
- if (isLink) {
- libFile->GetNativeTarget(aPluginFilePath);
- } else {
- libFile->GetNativePath(aPluginFilePath);
- }
+ aPluginDirectoryPath = GetNativeTarget(libDirectory);
+ aPluginFilePath = GetNativeTarget(libFile);
return true;
}
static bool
GetAppPaths(nsCString &aAppPath, nsCString &aAppBinaryPath)
{
nsAutoCString appPath;
@@ -200,29 +205,20 @@ GetAppPaths(nsCString &aAppPath, nsCStri
return false;
}
rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appBinaryPath),
true, getter_AddRefs(appBinary));
if (NS_FAILED(rv)) {
return false;
}
- bool isLink;
- app->IsSymlink(&isLink);
- if (isLink) {
- app->GetNativeTarget(aAppPath);
- } else {
- app->GetNativePath(aAppPath);
- }
- appBinary->IsSymlink(&isLink);
- if (isLink) {
- appBinary->GetNativeTarget(aAppBinaryPath);
- } else {
- appBinary->GetNativePath(aAppBinaryPath);
- }
+ // Mac sandbox rules expect paths to actual files and directories -- not
+ // soft links.
+ aAppPath = GetNativeTarget(app);
+ appBinaryPath = GetNativeTarget(appBinary);
return true;
}
bool
GMPChild::SetMacSandboxInfo()
{
if (!mGMPLoader) {
@@ -583,22 +579,17 @@ GMPChild::ShutdownComplete()
SendAsyncShutdownComplete();
}
static void
GetPluginVoucherFile(const nsAString& aPluginPath,
nsCOMPtr<nsIFile>& aOutVoucherFile)
{
nsAutoString baseName;
-#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
- nsCOMPtr<nsIFile> libDir;
- GetFileBase(aPluginPath, aOutVoucherFile, libDir, baseName);
-#else
GetFileBase(aPluginPath, aOutVoucherFile, baseName);
-#endif
nsAutoString infoFileName = baseName + NS_LITERAL_STRING(".voucher");
aOutVoucherFile->AppendRelativePath(infoFileName);
}
bool
GMPChild::PreLoadPluginVoucher()
{
nsCOMPtr<nsIFile> voucherFile;