зеркало из https://github.com/mozilla/gecko-dev.git
Bug 820200 - Pass application directory to XRE_InitEmbedding2 in content process. r=bsmedberg
This commit is contained in:
Родитель
5e6610fecb
Коммит
d768d99a05
|
@ -13,6 +13,12 @@ using mozilla::ipc::IOThreadChild;
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
|
void
|
||||||
|
ContentProcess::SetAppDir(const nsACString& aPath)
|
||||||
|
{
|
||||||
|
mXREEmbed.SetAppDir(aPath);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ContentProcess::Init()
|
ContentProcess::Init()
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,6 +36,8 @@ public:
|
||||||
virtual bool Init() MOZ_OVERRIDE;
|
virtual bool Init() MOZ_OVERRIDE;
|
||||||
virtual void CleanUp() MOZ_OVERRIDE;
|
virtual void CleanUp() MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
void SetAppDir(const nsACString& aPath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ContentChild mContent;
|
ContentChild mContent;
|
||||||
mozilla::ipc::ScopedXREEmbed mXREEmbed;
|
mozilla::ipc::ScopedXREEmbed mXREEmbed;
|
||||||
|
|
|
@ -410,6 +410,40 @@ GeckoChildProcessHost::PerformAsyncLaunch(std::vector<std::string> aExtraOpts, b
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if defined(XP_WIN)
|
||||||
|
AddAppDirToCommandLine(CommandLine& aCmdLine)
|
||||||
|
#else
|
||||||
|
AddAppDirToCommandLine(std::vector<std::string>& aCmdLine)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
// Content processes need access to application resources, so pass
|
||||||
|
// the full application directory path to the child process.
|
||||||
|
if (ShouldHaveDirectoryService()) {
|
||||||
|
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
|
||||||
|
NS_ASSERTION(directoryService, "Expected XPCOM to be available");
|
||||||
|
if (directoryService) {
|
||||||
|
nsCOMPtr<nsIFile> appDir;
|
||||||
|
// NS_XPCOM_CURRENT_PROCESS_DIR really means the app dir, not the
|
||||||
|
// current process dir.
|
||||||
|
nsresult rv = directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||||
|
NS_GET_IID(nsIFile),
|
||||||
|
getter_AddRefs(appDir));
|
||||||
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
nsAutoCString path;
|
||||||
|
appDir->GetNativePath(path);
|
||||||
|
#if defined(XP_WIN)
|
||||||
|
aCmdLine.AppendLooseValue(UTF8ToWide("-appdir"));
|
||||||
|
aCmdLine.AppendLooseValue(UTF8ToWide(path.get()));
|
||||||
|
#else
|
||||||
|
aCmdLine.push_back("-appdir");
|
||||||
|
aCmdLine.push_back(path.get());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExtraOpts, base::ProcessArchitecture arch)
|
GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExtraOpts, base::ProcessArchitecture arch)
|
||||||
{
|
{
|
||||||
|
@ -575,6 +609,9 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the application directory path (-appdir path)
|
||||||
|
AddAppDirToCommandLine(childArgv);
|
||||||
|
|
||||||
childArgv.push_back(pidstring);
|
childArgv.push_back(pidstring);
|
||||||
|
|
||||||
#if defined(MOZ_CRASHREPORTER)
|
#if defined(MOZ_CRASHREPORTER)
|
||||||
|
@ -674,8 +711,6 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
|
||||||
cmdLine.AppendLooseValue(UTF8ToWide(*it));
|
cmdLine.AppendLooseValue(UTF8ToWide(*it));
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdLine.AppendLooseValue(std::wstring(mGroupId.get()));
|
|
||||||
|
|
||||||
if (Omnijar::IsInitialized()) {
|
if (Omnijar::IsInitialized()) {
|
||||||
// Make sure the child process can find the omnijar
|
// Make sure the child process can find the omnijar
|
||||||
// See XRE_InitCommandLine in nsAppRunner.cpp
|
// See XRE_InitCommandLine in nsAppRunner.cpp
|
||||||
|
@ -692,6 +727,17 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the application directory path (-appdir path)
|
||||||
|
AddAppDirToCommandLine(cmdLine);
|
||||||
|
|
||||||
|
// XXX Command line params past this point are expected to be at
|
||||||
|
// the end of the command line string, and in a specific order.
|
||||||
|
// See XRE_InitChildProcess in nsEmbedFunction.
|
||||||
|
|
||||||
|
// Win app model id
|
||||||
|
cmdLine.AppendLooseValue(std::wstring(mGroupId.get()));
|
||||||
|
|
||||||
|
// Process id
|
||||||
cmdLine.AppendLooseValue(UTF8ToWide(pidstring));
|
cmdLine.AppendLooseValue(UTF8ToWide(pidstring));
|
||||||
|
|
||||||
#if defined(MOZ_CRASHREPORTER)
|
#if defined(MOZ_CRASHREPORTER)
|
||||||
|
@ -699,6 +745,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
|
||||||
UTF8ToWide(CrashReporter::GetChildNotificationPipe()));
|
UTF8ToWide(CrashReporter::GetChildNotificationPipe()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Process type
|
||||||
cmdLine.AppendLooseValue(UTF8ToWide(childProcessType));
|
cmdLine.AppendLooseValue(UTF8ToWide(childProcessType));
|
||||||
|
|
||||||
base::LaunchApp(cmdLine, false, false, &process);
|
base::LaunchApp(cmdLine, false, false, &process);
|
||||||
|
|
|
@ -28,6 +28,19 @@ ScopedXREEmbed::~ScopedXREEmbed()
|
||||||
NS_LogTerm();
|
NS_LogTerm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ScopedXREEmbed::SetAppDir(const nsACString& aPath)
|
||||||
|
{
|
||||||
|
bool flag;
|
||||||
|
nsresult rv =
|
||||||
|
XRE_GetFileFromPath(aPath.BeginReading(), getter_AddRefs(mAppDir));
|
||||||
|
if (NS_FAILED(rv) ||
|
||||||
|
NS_FAILED(mAppDir->Exists(&flag)) || !flag) {
|
||||||
|
NS_WARNING("Invalid application directory passed to content process.");
|
||||||
|
mAppDir = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ScopedXREEmbed::Start()
|
ScopedXREEmbed::Start()
|
||||||
{
|
{
|
||||||
|
@ -80,7 +93,10 @@ ScopedXREEmbed::Start()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rv = XRE_InitEmbedding2(localFile, localFile, nullptr);
|
if (mAppDir)
|
||||||
|
rv = XRE_InitEmbedding2(localFile, mAppDir, nullptr);
|
||||||
|
else
|
||||||
|
rv = XRE_InitEmbedding2(localFile, localFile, nullptr);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
#ifndef __IPC_GLUE_SCOPEDXREEMBED_H__
|
#ifndef __IPC_GLUE_SCOPEDXREEMBED_H__
|
||||||
#define __IPC_GLUE_SCOPEDXREEMBED_H__
|
#define __IPC_GLUE_SCOPEDXREEMBED_H__
|
||||||
|
|
||||||
|
#include "nsString.h"
|
||||||
|
#include "nsAutoPtr.h"
|
||||||
|
#include "nsIFile.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace ipc {
|
namespace ipc {
|
||||||
|
|
||||||
|
@ -16,9 +20,11 @@ public:
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
|
void SetAppDir(const nsACString& aPath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mShouldKillEmbedding;
|
bool mShouldKillEmbedding;
|
||||||
|
nsCOMPtr<nsIFile> mAppDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ipc */
|
} /* namespace ipc */
|
||||||
|
|
|
@ -403,8 +403,7 @@ XRE_InitChildProcess(int aArgc,
|
||||||
// On Win7+, register the application user model id passed in by
|
// On Win7+, register the application user model id passed in by
|
||||||
// parent. This insures windows created by the container properly
|
// parent. This insures windows created by the container properly
|
||||||
// group with the parent app on the Win7 taskbar.
|
// group with the parent app on the Win7 taskbar.
|
||||||
const char* const appModelUserId = aArgv[aArgc-1];
|
const char* const appModelUserId = aArgv[--aArgc];
|
||||||
--aArgc;
|
|
||||||
if (appModelUserId) {
|
if (appModelUserId) {
|
||||||
// '-' implies no support
|
// '-' implies no support
|
||||||
if (*appModelUserId != '-') {
|
if (*appModelUserId != '-') {
|
||||||
|
@ -460,8 +459,18 @@ XRE_InitChildProcess(int aArgc,
|
||||||
process = new PluginProcessChild(parentHandle);
|
process = new PluginProcessChild(parentHandle);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GeckoProcessType_Content:
|
case GeckoProcessType_Content: {
|
||||||
process = new ContentProcess(parentHandle);
|
process = new ContentProcess(parentHandle);
|
||||||
|
// If passed in grab the application path for xpcom init
|
||||||
|
nsCString appDir;
|
||||||
|
for (int idx = aArgc; idx > 0; idx--) {
|
||||||
|
if (aArgv[idx] && !strcmp(aArgv[idx], "-appdir")) {
|
||||||
|
appDir.Assign(nsDependentCString(aArgv[idx+1]));
|
||||||
|
static_cast<ContentProcess*>(process.get())->SetAppDir(appDir);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GeckoProcessType_IPDLUnitTest:
|
case GeckoProcessType_IPDLUnitTest:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче