Bug 1377614 - Part 1 - Move IsDevelopmentBuild() to common code. r=Alex_Gaynor

MozReview-Commit-ID: AcO0XaMS4Gp

--HG--
extra : rebase_source : ec40a94545fa78ce0210a0614db82b7bcb7e8a97
This commit is contained in:
Gian-Carlo Pascutto 2017-07-03 11:17:04 -07:00
parent df77fb2e20
commit 84f7ba492b
3 changed files with 15 additions and 14 deletions

View File

@ -62,7 +62,6 @@
#include "mozilla/loader/ScriptCacheActors.h"
#include "mozilla/net/NeckoChild.h"
#include "mozilla/net/CaptivePortalService.h"
#include "mozilla/Omnijar.h"
#include "mozilla/plugins/PluginInstanceParent.h"
#include "mozilla/plugins/PluginModuleParent.h"
#include "mozilla/widget/ScreenManager.h"
@ -1425,18 +1424,6 @@ GetAppPaths(nsCString &aAppPath, nsCString &aAppBinaryPath, nsCString &aAppDir)
return true;
}
// Returns whether or not the currently running build is a development build -
// where development build means "the files in the .app are symlinks to the src
// directory". This check is implemented by looking for omni.ja in
// .app/Contents/Resources/.
static bool
IsDevelopmentBuild()
{
nsCOMPtr<nsIFile> path = mozilla::Omnijar::GetPath(mozilla::Omnijar::GRE);
// If the path doesn't exist, we're a dev build.
return path == nullptr;
}
// This function is only used in an |#ifdef DEBUG| path.
#ifdef DEBUG
// Given a path to a file, return the directory which contains it.
@ -1506,7 +1493,7 @@ StartMacOSContentSandbox()
bool isFileProcess = cc->GetRemoteType().EqualsLiteral(FILE_REMOTE_TYPE);
char *developer_repo_dir = nullptr;
if (IsDevelopmentBuild()) {
if (mozilla::IsDevelopmentBuild()) {
// If this is a developer build the resources in the .app are symlinks to
// outside of the .app. Therefore in non-release builds we allow reads from
// the whole repository. MOZ_DEVELOPER_REPO_DIR is set by mach run.

View File

@ -6,11 +6,19 @@
#include "mozISandboxSettings.h"
#include "mozilla/Omnijar.h"
#include "mozilla/ModuleUtils.h"
#include "mozilla/Preferences.h"
namespace mozilla {
bool IsDevelopmentBuild()
{
nsCOMPtr<nsIFile> path = mozilla::Omnijar::GetPath(mozilla::Omnijar::GRE);
// If the path doesn't exist, we're a dev build.
return path == nullptr;
}
int GetEffectiveContentSandboxLevel() {
int level = Preferences::GetInt("security.sandbox.content.level");
// On Windows and macOS, enforce a minimum content sandbox level of 1 (except on

View File

@ -13,5 +13,11 @@ namespace mozilla {
// minimum allowed level.
int GetEffectiveContentSandboxLevel();
// Returns whether or not the currently running build is a development build -
// where development build means "the files in the .app are symlinks to the src
// directory". This check is implemented by looking for omni.ja in
// .app/Contents/Resources/.
bool IsDevelopmentBuild();
}
#endif // mozilla_SandboxPolicies_h