Diff
Modified: trunk/Source/WebKit2/ChangeLog (136567 => 136568)
--- trunk/Source/WebKit2/ChangeLog 2012-12-04 22:11:38 UTC (rev 136567)
+++ trunk/Source/WebKit2/ChangeLog 2012-12-04 22:16:36 UTC (rev 136568)
@@ -1,3 +1,40 @@
+2012-12-04 Anders Carlsson <[email protected]>
+
+ Set the visible process name before entering the sandbox
+ https://bugs.webkit.org/show_bug.cgi?id=104030
+ <rdar://problem/12800317>
+
+ Reviewed by Sam Weinig.
+
+ Pass the UI process name along as a process initialization parameter so we can set it
+ before entering the sandbox. Remove the UI process name from WebProcessCreationParameters.
+
+ * Shared/WebProcessCreationParameters.cpp:
+ (WebKit::WebProcessCreationParameters::encode):
+ (WebKit::WebProcessCreationParameters::decode):
+ * Shared/WebProcessCreationParameters.h:
+ (WebProcessCreationParameters):
+ * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+ (WebKit::connectToWebProcessServiceForWebKitDevelopment):
+ (WebKit::createWebProcessService):
+ (WebKit::createProcess):
+ * UIProcess/mac/WebContextMac.mm:
+ (WebKit::WebContext::platformInitializeWebProcess):
+ * WebProcess/mac/WebProcessInitialization.h:
+ (WebProcessInitializationParameters):
+ * WebProcess/mac/WebProcessInitialization.mm:
+ (WebKit::initializeWebProcess):
+ * WebProcess/mac/WebProcessMac.mm:
+ (WebKit::WebProcess::platformInitializeWebProcess):
+ * WebProcess/mac/WebProcessMainMac.mm:
+ (WebKit::WebProcessMain):
+ * WebProcess/mac/WebProcessServiceEntryPoints.h:
+ * WebProcess/mac/WebProcessServiceEntryPoints.mm:
+ (WebKit::WebProcessServiceEventHandler):
+ (initializeWebProcessForWebProcessServiceForWebKitDevelopment):
+ * WebProcessServiceForWebKitDevelopment/WebProcessServiceForWebKitDevelopmentMain.mm:
+ (WebProcessServiceForWebKitDevelopmentEventHandler):
+
2012-12-03 Alexey Proskuryakov <[email protected]>
[WK2] Track private browsing session explicitly
Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp (136567 => 136568)
--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp 2012-12-04 22:11:38 UTC (rev 136567)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp 2012-12-04 22:16:36 UTC (rev 136568)
@@ -93,7 +93,6 @@
encoder << uiProcessBundleIdentifier;
#endif
#if PLATFORM(MAC)
- encoder << parentProcessName;
encoder << presenterApplicationPid;
encoder << nsURLCacheMemoryCapacity;
encoder << nsURLCacheDiskCapacity;
@@ -198,8 +197,6 @@
#endif
#if PLATFORM(MAC)
- if (!decoder->decode(parameters.parentProcessName))
- return false;
if (!decoder->decode(parameters.presenterApplicationPid))
return false;
if (!decoder->decode(parameters.nsURLCacheMemoryCapacity))
Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h (136567 => 136568)
--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h 2012-12-04 22:11:38 UTC (rev 136567)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h 2012-12-04 22:16:36 UTC (rev 136568)
@@ -102,8 +102,6 @@
#endif
#if PLATFORM(MAC)
- String parentProcessName;
-
pid_t presenterApplicationPid;
uint64_t nsURLCacheMemoryCapacity;
Modified: trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm (136567 => 136568)
--- trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm 2012-12-04 22:11:38 UTC (rev 136567)
+++ trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm 2012-12-04 22:16:36 UTC (rev 136568)
@@ -160,15 +160,16 @@
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
CString clientIdentifier = bundleIdentifier ? String([[NSBundle mainBundle] bundleIdentifier]).utf8() : *_NSGetProgname();
- xpc_object_t bootStrapMessage = xpc_dictionary_create(0, 0, 0);
- xpc_dictionary_set_string(bootStrapMessage, "message-name", "bootstrap");
- xpc_dictionary_set_string(bootStrapMessage, "framework-executable-path", [[[NSBundle bundleWithIdentifier:@"com.apple.WebKit2"] executablePath] fileSystemRepresentation]);
- xpc_dictionary_set_mach_send(bootStrapMessage, "server-port", listeningPort);
- xpc_dictionary_set_string(bootStrapMessage, "client-identifier", clientIdentifier.data());
+ xpc_object_t bootstrapMessage = xpc_dictionary_create(0, 0, 0);
+ xpc_dictionary_set_string(bootstrapMessage, "message-name", "bootstrap");
+ xpc_dictionary_set_string(bootstrapMessage, "framework-executable-path", [[[NSBundle bundleWithIdentifier:@"com.apple.WebKit2"] executablePath] fileSystemRepresentation]);
+ xpc_dictionary_set_mach_send(bootstrapMessage, "server-port", listeningPort);
+ xpc_dictionary_set_string(bootstrapMessage, "client-identifier", clientIdentifier.data());
+ xpc_dictionary_set_string(bootstrapMessage, "ui-process-name", [[[NSProcessInfo processInfo] processName] UTF8String]);
that->ref();
- xpc_connection_send_message_with_reply(connection, bootStrapMessage, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(xpc_object_t reply) {
+ xpc_connection_send_message_with_reply(connection, bootstrapMessage, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(xpc_object_t reply) {
xpc_type_t type = xpc_get_type(reply);
if (type == XPC_TYPE_ERROR) {
// We failed to launch. Release the send right.
@@ -191,7 +192,7 @@
that->deref();
});
- xpc_release(bootStrapMessage);
+ xpc_release(bootstrapMessage);
}
static void createWebProcessServiceForWebKitDevelopment(const ProcessLauncher::LaunchOptions& launchOptions, ProcessLauncher* that, DidFinishLaunchingProcessFunction didFinishLaunchingProcessFunction)
@@ -275,14 +276,15 @@
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
CString clientIdentifier = bundleIdentifier ? String([[NSBundle mainBundle] bundleIdentifier]).utf8() : *_NSGetProgname();
- xpc_object_t bootStrapMessage = xpc_dictionary_create(0, 0, 0);
- xpc_dictionary_set_string(bootStrapMessage, "message-name", "bootstrap");
- xpc_dictionary_set_mach_send(bootStrapMessage, "server-port", listeningPort);
- xpc_dictionary_set_string(bootStrapMessage, "client-identifier", clientIdentifier.data());
+ xpc_object_t bootstrapMessage = xpc_dictionary_create(0, 0, 0);
+ xpc_dictionary_set_string(bootstrapMessage, "message-name", "bootstrap");
+ xpc_dictionary_set_mach_send(bootstrapMessage, "server-port", listeningPort);
+ xpc_dictionary_set_string(bootstrapMessage, "client-identifier", clientIdentifier.data());
+ xpc_dictionary_set_string(bootstrapMessage, "ui-process-name", [[[NSProcessInfo processInfo] processName] UTF8String]);
that->ref();
- xpc_connection_send_message_with_reply(connection, bootStrapMessage, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(xpc_object_t reply) {
+ xpc_connection_send_message_with_reply(connection, bootstrapMessage, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(xpc_object_t reply) {
xpc_type_t type = xpc_get_type(reply);
if (type == XPC_TYPE_ERROR) {
// We failed to launch. Release the send right.
@@ -305,7 +307,7 @@
that->deref();
});
- xpc_release(bootStrapMessage);
+ xpc_release(bootstrapMessage);
}
#endif
@@ -405,7 +407,8 @@
// Make a unique, per pid, per process launcher web process service name.
CString serviceName = String::format("com.apple.WebKit.WebProcess-%d-%p", getpid(), that).utf8();
- const char* args[] = { [processAppExecutablePath fileSystemRepresentation], [frameworkExecutablePath fileSystemRepresentation], "-type", ProcessLauncher::processTypeAsString(launchOptions.processType), "-servicename", serviceName.data(), "-localization", localization.data(), "-client-identifier", clientIdentifier.data(), 0 };
+ const char* args[] = { [processAppExecutablePath fileSystemRepresentation], [frameworkExecutablePath fileSystemRepresentation], "-type", ProcessLauncher::processTypeAsString(launchOptions.processType), "-servicename", serviceName.data(), "-localization", localization.data(), "-client-identifier", clientIdentifier.data(),
+ "-ui-process-name", [[[NSProcessInfo processInfo] processName] UTF8String], 0 };
// Register ourselves.
kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.data()), listeningPort, 0);
Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm (136567 => 136568)
--- trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm 2012-12-04 22:11:38 UTC (rev 136567)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm 2012-12-04 22:16:36 UTC (rev 136568)
@@ -100,8 +100,6 @@
{
parameters.presenterApplicationPid = getpid();
- parameters.parentProcessName = [[NSProcessInfo processInfo] processName];
-
NSURLCache *urlCache = [NSURLCache sharedURLCache];
parameters.nsURLCacheMemoryCapacity = [urlCache memoryCapacity];
parameters.nsURLCacheDiskCapacity = [urlCache diskCapacity];
Modified: trunk/Source/WebKit2/WebProcess/mac/WebProcessInitialization.h (136567 => 136568)
--- trunk/Source/WebKit2/WebProcess/mac/WebProcessInitialization.h 2012-12-04 22:11:38 UTC (rev 136567)
+++ trunk/Source/WebKit2/WebProcess/mac/WebProcessInitialization.h 2012-12-04 22:16:36 UTC (rev 136568)
@@ -32,6 +32,8 @@
namespace WebKit {
struct WebProcessInitializationParameters {
+ String uiProcessName;
+
String clientIdentifier;
CoreIPC::Connection::Identifier connectionIdentifier;
};
Modified: trunk/Source/WebKit2/WebProcess/mac/WebProcessInitialization.mm (136567 => 136568)
--- trunk/Source/WebKit2/WebProcess/mac/WebProcessInitialization.mm 2012-12-04 22:11:38 UTC (rev 136567)
+++ trunk/Source/WebKit2/WebProcess/mac/WebProcessInitialization.mm 2012-12-04 22:16:36 UTC (rev 136568)
@@ -28,6 +28,7 @@
#import "WebProcess.h"
#import "WebSystemInterface.h"
+#import <WebCore/LocalizedStrings.h>
#import <WebCore/RunLoop.h>
#import <WebKitSystemInterface.h>
#import <runtime/InitializeThreading.h>
@@ -45,6 +46,11 @@
WTF::initializeMainThread();
RunLoop::initializeMainRunLoop();
+ if (!parameters.uiProcessName.isNull()) {
+ NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)parameters.uiProcessName];
+ WKSetVisibleApplicationName((CFStringRef)applicationName);
+ }
+
WebProcess& webProcess = WebProcess::shared();
webProcess.initializeShim();
webProcess.initializeSandbox(parameters.clientIdentifier);
Modified: trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm (136567 => 136568)
--- trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm 2012-12-04 22:11:38 UTC (rev 136567)
+++ trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm 2012-12-04 22:16:36 UTC (rev 136568)
@@ -264,11 +264,6 @@
SandboxExtension::consumePermanently(parameters.applicationCacheDirectoryExtensionHandle);
SandboxExtension::consumePermanently(parameters.diskCacheDirectoryExtensionHandle);
- if (!parameters.parentProcessName.isNull()) {
- NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)parameters.parentProcessName];
- WKSetVisibleApplicationName((CFStringRef)applicationName);
- }
-
if (!parameters.diskCacheDirectory.isNull()) {
NSUInteger cacheMemoryCapacity = parameters.nsURLCacheMemoryCapacity;
NSUInteger cacheDiskCapacity = parameters.nsURLCacheDiskCapacity;
Modified: trunk/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm (136567 => 136568)
--- trunk/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm 2012-12-04 22:11:38 UTC (rev 136567)
+++ trunk/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm 2012-12-04 22:16:36 UTC (rev 136568)
@@ -186,6 +186,7 @@
#endif
WebProcessInitializationParameters parameters;
+ parameters.uiProcessName = commandLine["ui-process-name"];
parameters.clientIdentifier = clientIdentifier;
parameters.connectionIdentifier = serverPort;
initializeWebProcess(parameters);
Modified: trunk/Source/WebKit2/WebProcess/mac/WebProcessServiceEntryPoints.h (136567 => 136568)
--- trunk/Source/WebKit2/WebProcess/mac/WebProcessServiceEntryPoints.h 2012-12-04 22:11:38 UTC (rev 136567)
+++ trunk/Source/WebKit2/WebProcess/mac/WebProcessServiceEntryPoints.h 2012-12-04 22:16:36 UTC (rev 136568)
@@ -41,7 +41,7 @@
// This entry point is used for the WebProcessServiceForWebKitDevelopment
// which needs to be re-exec, and can't link directly to WebKit2 requiring
// some DYLD fiddling.
-WK_EXPORT void initializeWebProcessForWebProcessServiceForWebKitDevelopment(const char* clientIdentifier, xpc_connection_t, mach_port_t serverPort);
+WK_EXPORT void initializeWebProcessForWebProcessServiceForWebKitDevelopment(const char* clientIdentifier, xpc_connection_t, mach_port_t serverPort, const char* uiProcessName);
#ifdef __cplusplus
}; // extern "C"
Modified: trunk/Source/WebKit2/WebProcess/mac/WebProcessServiceEntryPoints.mm (136567 => 136568)
--- trunk/Source/WebKit2/WebProcess/mac/WebProcessServiceEntryPoints.mm 2012-12-04 22:11:38 UTC (rev 136567)
+++ trunk/Source/WebKit2/WebProcess/mac/WebProcessServiceEntryPoints.mm 2012-12-04 22:16:36 UTC (rev 136568)
@@ -61,6 +61,7 @@
xpc_release(reply);
WebProcessInitializationParameters parameters;
+ parameters.uiProcessName = xpc_dictionary_get_string(event, "ui-process-name");
parameters.clientIdentifier = xpc_dictionary_get_string(event, "client-identifier");
parameters.connectionIdentifier = xpc_dictionary_copy_mach_send(event, "server-port");
initializeWebProcess(parameters);
@@ -83,13 +84,14 @@
return 0;
}
-void initializeWebProcessForWebProcessServiceForWebKitDevelopment(const char* clientIdentifier, xpc_connection_t connection, mach_port_t serverPort)
+void initializeWebProcessForWebProcessServiceForWebKitDevelopment(const char* clientIdentifier, xpc_connection_t connection, mach_port_t serverPort, const char* uiProcessName)
{
// Remove the WebProcess shim from the DYLD_INSERT_LIBRARIES environment variable so any processes spawned by
// the WebProcess don't try to insert the shim and crash.
WebKit::EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/WebProcessShim.dylib");
WebKit::WebProcessInitializationParameters parameters;
+ parameters.uiProcessName = uiProcessName;
parameters.clientIdentifier = clientIdentifier;
parameters.connectionIdentifier = CoreIPC::Connection::Identifier(serverPort, connection);
initializeWebProcess(parameters);
Modified: trunk/Source/WebKit2/WebProcessServiceForWebKitDevelopment/WebProcessServiceForWebKitDevelopmentMain.mm (136567 => 136568)
--- trunk/Source/WebKit2/WebProcessServiceForWebKitDevelopment/WebProcessServiceForWebKitDevelopmentMain.mm 2012-12-04 22:11:38 UTC (rev 136567)
+++ trunk/Source/WebKit2/WebProcessServiceForWebKitDevelopment/WebProcessServiceForWebKitDevelopmentMain.mm 2012-12-04 22:16:36 UTC (rev 136568)
@@ -123,9 +123,9 @@
exit(EXIT_FAILURE);
}
- typedef void (*InitializeWebProcessFunction)(const char* clientIdentifer, xpc_connection_t connection, mach_port_t serverPort);
- InitializeWebProcessFunction InitializeWebProcessFunctionPtr = reinterpret_cast<InitializeWebProcessFunction>(dlsym(frameworkLibrary, "initializeWebProcessForWebProcessServiceForWebKitDevelopment"));
- if (!InitializeWebProcessFunctionPtr) {
+ typedef void (*InitializeWebProcessFunction)(const char* clientIdentifer, xpc_connection_t connection, mach_port_t serverPort, const char* uiProcessName);
+ InitializeWebProcessFunction initializeWebProcessFunctionPtr = reinterpret_cast<InitializeWebProcessFunction>(dlsym(frameworkLibrary, "initializeWebProcessForWebProcessServiceForWebKitDevelopment"));
+ if (!initializeWebProcessFunctionPtr) {
NSLog(@"Unable to find entry point in WebKit2.framework: %s\n", dlerror());
exit(EXIT_FAILURE);
}
@@ -135,7 +135,7 @@
xpc_connection_send_message(xpc_dictionary_get_remote_connection(event), reply);
xpc_release(reply);
- InitializeWebProcessFunctionPtr(xpc_dictionary_get_string(event, "client-identifier"), peer, xpc_dictionary_copy_mach_send(event, "server-port"));
+ initializeWebProcessFunctionPtr(xpc_dictionary_get_string(event, "client-identifier"), peer, xpc_dictionary_copy_mach_send(event, "server-port"), xpc_dictionary_get_string(event, "ui-process-name"));
}
}
});