ProcessExecutablePathGLib.cpp [plain text]
#include "config.h"
#include "ProcessExecutablePath.h"
#include <WebCore/FileSystem.h>
#include <glib.h>
#include <wtf/glib/GLibUtilities.h>
namespace WebKit {
using namespace WebCore;
#if ENABLE(DEVELOPER_MODE)
static String getExecutablePath()
{
CString executablePath = getCurrentExecutablePath();
if (!executablePath.isNull())
return FileSystem::directoryName(FileSystem::stringFromFileSystemRepresentation(executablePath.data()));
return { };
}
#endif
static String findWebKitProcess(const char* processName)
{
#if ENABLE(DEVELOPER_MODE)
static const char* execDirectory = g_getenv("WEBKIT_EXEC_PATH");
if (execDirectory) {
String processPath = FileSystem::pathByAppendingComponent(FileSystem::stringFromFileSystemRepresentation(execDirectory), processName);
if (FileSystem::fileExists(processPath))
return processPath;
}
static String executablePath = getExecutablePath();
if (!executablePath.isNull()) {
String processPath = FileSystem::pathByAppendingComponent(executablePath, processName);
if (FileSystem::fileExists(processPath))
return processPath;
}
#endif
return FileSystem::pathByAppendingComponent(FileSystem::stringFromFileSystemRepresentation(PKGLIBEXECDIR), processName);
}
String executablePathOfWebProcess()
{
#if PLATFORM(WPE)
return findWebKitProcess("WPEWebProcess");
#else
return findWebKitProcess("WebKitWebProcess");
#endif
}
String executablePathOfPluginProcess()
{
#if PLATFORM(WPE)
return findWebKitProcess("WPEPluginProcess");
#else
return findWebKitProcess("WebKitPluginProcess");
#endif
}
String executablePathOfNetworkProcess()
{
#if PLATFORM(WPE)
return findWebKitProcess("WPENetworkProcess");
#else
return findWebKitProcess("WebKitNetworkProcess");
#endif
}
String executablePathOfStorageProcess()
{
#if PLATFORM(WPE)
return findWebKitProcess("WPEStorageProcess");
#else
return findWebKitProcess("WebKitStorageProcess");
#endif
}
}