Backed out changeset c0b8f05a48d5 (bug 1246835) for bustage on a CLOSED TREE
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Tue, 09 Feb 2016 08:47:38 +0100
changeset 329788 35cdc40a44c45870ff5ba300ec504765eb87f0db
parent 329787 a5f6e1f0e0e807a615f4f3ce1c395d60b0a1323d
child 329789 bd5d1c3f3c1e6f8a6161a50657044829b573cca6
push id10611
push userdmitchell@mozilla.com
push dateTue, 09 Feb 2016 15:15:43 +0000
bugs1246835
milestone47.0a1
backs outc0b8f05a48d564dd81012d4c5e8239dec796c0f6
Backed out changeset c0b8f05a48d5 (bug 1246835) for bustage on a CLOSED TREE
dom/media/gmp/GMPChild.cpp
--- a/dom/media/gmp/GMPChild.cpp
+++ b/dom/media/gmp/GMPChild.cpp
@@ -60,29 +60,33 @@ 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;
@@ -93,93 +97,84 @@ 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.
-  aPluginDirectoryPath = GetNativeTarget(libDirectory);
-  aPluginFilePath = GetNativeTarget(libFile);
+  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);
+  }
 
   return true;
 }
 
 static bool
 GetAppPaths(nsCString &aAppPath, nsCString &aAppBinaryPath)
 {
   nsAutoCString appPath;
@@ -205,20 +200,29 @@ GetAppPaths(nsCString &aAppPath, nsCStri
     return false;
   }
   rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appBinaryPath),
                        true, getter_AddRefs(appBinary));
   if (NS_FAILED(rv)) {
     return false;
   }
 
-  // Mac sandbox rules expect paths to actual files and directories -- not
-  // soft links.
-  aAppPath = GetNativeTarget(app);
-  appBinaryPath = GetNativeTarget(appBinary);
+  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);
+  }
 
   return true;
 }
 
 bool
 GMPChild::SetMacSandboxInfo()
 {
   if (!mGMPLoader) {
@@ -579,17 +583,22 @@ 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;