зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1246835 - Reduce #ifdefs pain in GMPChild.cpp. r=gerald
This commit is contained in:
Родитель
774871bbdd
Коммит
c098d0e875
|
@ -65,9 +65,7 @@ GMPChild::~GMPChild()
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
GetFileBase(const nsAString& aPluginPath,
|
GetFileBase(const nsAString& aPluginPath,
|
||||||
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
|
|
||||||
nsCOMPtr<nsIFile>& aLibDirectory,
|
nsCOMPtr<nsIFile>& aLibDirectory,
|
||||||
#endif
|
|
||||||
nsCOMPtr<nsIFile>& aFileBase,
|
nsCOMPtr<nsIFile>& aFileBase,
|
||||||
nsAutoString& aBaseName)
|
nsAutoString& aBaseName)
|
||||||
{
|
{
|
||||||
|
@ -77,11 +75,9 @@ GetFileBase(const nsAString& aPluginPath,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
|
|
||||||
if (NS_FAILED(aFileBase->Clone(getter_AddRefs(aLibDirectory)))) {
|
if (NS_FAILED(aFileBase->Clone(getter_AddRefs(aLibDirectory)))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
nsCOMPtr<nsIFile> parent;
|
nsCOMPtr<nsIFile> parent;
|
||||||
rv = aFileBase->GetParent(getter_AddRefs(parent));
|
rv = aFileBase->GetParent(getter_AddRefs(parent));
|
||||||
|
@ -101,19 +97,22 @@ GetFileBase(const nsAString& aPluginPath,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
GetFileBase(const nsAString& aPluginPath,
|
||||||
|
nsCOMPtr<nsIFile>& aFileBase,
|
||||||
|
nsAutoString& aBaseName)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIFile> unusedLibDir;
|
||||||
|
return GetFileBase(aPluginPath, unusedLibDir, aFileBase, aBaseName);
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
GetPluginFile(const nsAString& aPluginPath,
|
GetPluginFile(const nsAString& aPluginPath,
|
||||||
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
|
|
||||||
nsCOMPtr<nsIFile>& aLibDirectory,
|
nsCOMPtr<nsIFile>& aLibDirectory,
|
||||||
#endif
|
|
||||||
nsCOMPtr<nsIFile>& aLibFile)
|
nsCOMPtr<nsIFile>& aLibFile)
|
||||||
{
|
{
|
||||||
nsAutoString baseName;
|
nsAutoString baseName;
|
||||||
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
|
|
||||||
GetFileBase(aPluginPath, aLibDirectory, aLibFile, baseName);
|
GetFileBase(aPluginPath, aLibDirectory, aLibFile, baseName);
|
||||||
#else
|
|
||||||
GetFileBase(aPluginPath, aLibFile, baseName);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(XP_MACOSX)
|
#if defined(XP_MACOSX)
|
||||||
nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".dylib");
|
nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".dylib");
|
||||||
|
@ -128,23 +127,42 @@ GetPluginFile(const nsAString& aPluginPath,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(XP_MACOSX)
|
||||||
|
static bool
|
||||||
|
GetPluginFile(const nsAString& aPluginPath,
|
||||||
|
nsCOMPtr<nsIFile>& aLibFile)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIFile> unusedlibDir;
|
||||||
|
return GetPluginFile(aPluginPath, unusedlibDir, aLibFile);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
GetInfoFile(const nsAString& aPluginPath,
|
GetInfoFile(const nsAString& aPluginPath,
|
||||||
nsCOMPtr<nsIFile>& aInfoFile)
|
nsCOMPtr<nsIFile>& aInfoFile)
|
||||||
{
|
{
|
||||||
nsAutoString baseName;
|
nsAutoString baseName;
|
||||||
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
|
|
||||||
nsCOMPtr<nsIFile> unusedLibDir;
|
|
||||||
GetFileBase(aPluginPath, unusedLibDir, aInfoFile, baseName);
|
|
||||||
#else
|
|
||||||
GetFileBase(aPluginPath, aInfoFile, baseName);
|
GetFileBase(aPluginPath, aInfoFile, baseName);
|
||||||
#endif
|
|
||||||
nsAutoString infoFileName = baseName + NS_LITERAL_STRING(".info");
|
nsAutoString infoFileName = baseName + NS_LITERAL_STRING(".info");
|
||||||
aInfoFile->AppendRelativePath(infoFileName);
|
aInfoFile->AppendRelativePath(infoFileName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
|
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
|
||||||
|
static nsCString
|
||||||
|
GetNativeTarget(nsIFile* aFile)
|
||||||
|
{
|
||||||
|
bool isLink;
|
||||||
|
nsCString path;
|
||||||
|
aFile->IsSymlink(&isLink);
|
||||||
|
if (isLink) {
|
||||||
|
aFile->GetNativeTarget(path);
|
||||||
|
} else {
|
||||||
|
aFile->GetNativePath(path);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
GetPluginPaths(const nsAString& aPluginPath,
|
GetPluginPaths(const nsAString& aPluginPath,
|
||||||
nsCString &aPluginDirectoryPath,
|
nsCString &aPluginDirectoryPath,
|
||||||
|
@ -157,19 +175,8 @@ GetPluginPaths(const nsAString& aPluginPath,
|
||||||
|
|
||||||
// Mac sandbox rules expect paths to actual files and directories -- not
|
// Mac sandbox rules expect paths to actual files and directories -- not
|
||||||
// soft links.
|
// soft links.
|
||||||
bool isLink;
|
aPluginDirectoryPath = GetNativeTarget(libDirectory);
|
||||||
libDirectory->IsSymlink(&isLink);
|
aPluginFilePath = GetNativeTarget(libFile);
|
||||||
if (isLink) {
|
|
||||||
libDirectory->GetNativeTarget(aPluginDirectoryPath);
|
|
||||||
} else {
|
|
||||||
libDirectory->GetNativePath(aPluginDirectoryPath);
|
|
||||||
}
|
|
||||||
libFile->IsSymlink(&isLink);
|
|
||||||
if (isLink) {
|
|
||||||
libFile->GetNativeTarget(aPluginFilePath);
|
|
||||||
} else {
|
|
||||||
libFile->GetNativePath(aPluginFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -205,19 +212,10 @@ GetAppPaths(nsCString &aAppPath, nsCString &aAppBinaryPath)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isLink;
|
// Mac sandbox rules expect paths to actual files and directories -- not
|
||||||
app->IsSymlink(&isLink);
|
// soft links.
|
||||||
if (isLink) {
|
aAppPath = GetNativeTarget(app);
|
||||||
app->GetNativeTarget(aAppPath);
|
appBinaryPath = GetNativeTarget(appBinary);
|
||||||
} else {
|
|
||||||
app->GetNativePath(aAppPath);
|
|
||||||
}
|
|
||||||
appBinary->IsSymlink(&isLink);
|
|
||||||
if (isLink) {
|
|
||||||
appBinary->GetNativeTarget(aAppBinaryPath);
|
|
||||||
} else {
|
|
||||||
appBinary->GetNativePath(aAppBinaryPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -588,12 +586,7 @@ GetPluginVoucherFile(const nsAString& aPluginPath,
|
||||||
nsCOMPtr<nsIFile>& aOutVoucherFile)
|
nsCOMPtr<nsIFile>& aOutVoucherFile)
|
||||||
{
|
{
|
||||||
nsAutoString baseName;
|
nsAutoString baseName;
|
||||||
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
|
|
||||||
nsCOMPtr<nsIFile> libDir;
|
|
||||||
GetFileBase(aPluginPath, aOutVoucherFile, libDir, baseName);
|
|
||||||
#else
|
|
||||||
GetFileBase(aPluginPath, aOutVoucherFile, baseName);
|
GetFileBase(aPluginPath, aOutVoucherFile, baseName);
|
||||||
#endif
|
|
||||||
nsAutoString infoFileName = baseName + NS_LITERAL_STRING(".voucher");
|
nsAutoString infoFileName = baseName + NS_LITERAL_STRING(".voucher");
|
||||||
aOutVoucherFile->AppendRelativePath(infoFileName);
|
aOutVoucherFile->AppendRelativePath(infoFileName);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче