Changeset 141051 in webkit


Ignore:
Timestamp:
Jan 28, 2013 9:58:15 PM (11 years ago)
Author:
weinig@apple.com
Message:

Plug-ins should initialize their sandbox at creation time
https://bugs.webkit.org/show_bug.cgi?id=108098

Reviewed by Anders Carlsson.

Add the ability to add string key/value pairs to process creation parameters
to allow the plugin process to get passed the plugin path which in turn allows
the plugin to initialize its sandbox at the correct time.

  • NetworkProcess/EntryPoint/mac/XPCService/NetworkService.Development/NetworkServiceMain.Development.mm:
  • NetworkProcess/EntryPoint/mac/XPCService/NetworkService/NetworkServiceMain.mm:
  • NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm:

(NetworkServiceInitializer):

  • PluginProcess/EntryPoint/mac/LegacyProcess/PluginProcessMain.mm:

(WebKit::PluginProcessMainDelegate::getExtraData):
(PluginProcessMainDelegate):

  • PluginProcess/EntryPoint/mac/XPCService/PluginService.32/PluginService.32.Main.mm:
  • PluginProcess/EntryPoint/mac/XPCService/PluginService.64/PluginService.64.Main.mm:
  • PluginProcess/EntryPoint/mac/XPCService/PluginService.Development/PluginService.Development.Main.mm:
  • PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm:

(WebKit):
(PluginServiceInitializerDelegate):
(WebKit::PluginServiceInitializerDelegate::PluginServiceInitializerDelegate):
(WebKit::PluginServiceInitializerDelegate::getExtraData):
(PluginServiceInitializer):

  • PluginProcess/PluginProcess.cpp:

(WebKit::PluginProcess::initializeProcess):
(WebKit::PluginProcess::initializePluginProcess):
(WebKit::PluginProcess::initializeProcessName):
(WebKit::PluginProcess::initializeSandbox):

  • PluginProcess/PluginProcess.h:
  • PluginProcess/mac/PluginProcessMac.mm:

(WebKit::PluginProcess::platformInitializePluginProcess):
(WebKit::PluginProcess::platformInitializeProcess):
(WebKit::PluginProcess::initializeProcessName):
(WebKit::PluginProcess::initializeSandbox):

  • Shared/ChildProcess.h:

(ChildProcessInitializationParameters):

  • Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.h:

(ChildProcessMainDelegate):
(WebKit::ChildProcessMain):

  • Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.mm:

(WebKit::ChildProcessMainDelegate::getExtraData):

  • Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.Development.h:

(WebKit::XPCServiceEventHandler):

  • Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.h:

(WebKit::XPCServiceEventHandler):

  • Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h: Added.

(XPCServiceInitializerDelegate):
(WebKit::XPCServiceInitializerDelegate::XPCServiceInitializerDelegate):
(WebKit::XPCServiceInitializer):

  • Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm: Added.

(WebKit::XPCServiceInitializerDelegate::~XPCServiceInitializerDelegate):
(WebKit::XPCServiceInitializerDelegate::getConnectionIdentifier):
(WebKit::XPCServiceInitializerDelegate::getClientIdentifier):
(WebKit::XPCServiceInitializerDelegate::getClientProcessName):
(WebKit::XPCServiceInitializerDelegate::getExtraData):

  • Shared/Plugins/PluginProcessCreationParameters.cpp:

(WebKit::PluginProcessCreationParameters::encode):
(WebKit::PluginProcessCreationParameters::decode):

  • Shared/Plugins/PluginProcessCreationParameters.h:

(PluginProcessCreationParameters):

  • UIProcess/Launcher/ProcessLauncher.h:

(LaunchOptions):

  • UIProcess/Launcher/mac/ProcessLauncherMac.mm:

(WebKit::connectToService):
(WebKit::connectToReExecService):
(WebKit::createService):
(WebKit::createProcess):
(WebKit::ProcessLauncher::launchProcess):

  • UIProcess/Plugins/PluginProcessProxy.cpp:

(WebKit::PluginProcessProxy::didFinishLaunching):

  • UIProcess/Plugins/mac/PluginProcessProxyMac.mm:

(WebKit::PluginProcessProxy::platformInitializeLaunchOptions):
(WebKit::PluginProcessProxy::platformInitializePluginProcess):

  • WebKit2.xcodeproj/project.pbxproj:
  • WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/WebContentServiceMain.Development.mm:
  • WebProcess/EntryPoint/mac/XPCService/WebContentService/WebContentServiceMain.mm:
  • WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm:

(WebContentServiceInitializer):

Location:
trunk/Source/WebKit2
Files:
2 added
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r141045 r141051  
     12013-01-28  Sam Weinig  <sam@webkit.org>
     2
     3        Plug-ins should initialize their sandbox at creation time
     4        https://bugs.webkit.org/show_bug.cgi?id=108098
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Add the ability to add string key/value pairs to process creation parameters
     9        to allow the plugin process to get passed the plugin path which in turn allows
     10        the plugin to initialize its sandbox at the correct time.
     11
     12        * NetworkProcess/EntryPoint/mac/XPCService/NetworkService.Development/NetworkServiceMain.Development.mm:
     13        * NetworkProcess/EntryPoint/mac/XPCService/NetworkService/NetworkServiceMain.mm:
     14        * NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm:
     15        (NetworkServiceInitializer):
     16        * PluginProcess/EntryPoint/mac/LegacyProcess/PluginProcessMain.mm:
     17        (WebKit::PluginProcessMainDelegate::getExtraData):
     18        (PluginProcessMainDelegate):
     19        * PluginProcess/EntryPoint/mac/XPCService/PluginService.32/PluginService.32.Main.mm:
     20        * PluginProcess/EntryPoint/mac/XPCService/PluginService.64/PluginService.64.Main.mm:
     21        * PluginProcess/EntryPoint/mac/XPCService/PluginService.Development/PluginService.Development.Main.mm:
     22        * PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm:
     23        (WebKit):
     24        (PluginServiceInitializerDelegate):
     25        (WebKit::PluginServiceInitializerDelegate::PluginServiceInitializerDelegate):
     26        (WebKit::PluginServiceInitializerDelegate::getExtraData):
     27        (PluginServiceInitializer):
     28        * PluginProcess/PluginProcess.cpp:
     29        (WebKit::PluginProcess::initializeProcess):
     30        (WebKit::PluginProcess::initializePluginProcess):
     31        (WebKit::PluginProcess::initializeProcessName):
     32        (WebKit::PluginProcess::initializeSandbox):
     33        * PluginProcess/PluginProcess.h:
     34        * PluginProcess/mac/PluginProcessMac.mm:
     35        (WebKit::PluginProcess::platformInitializePluginProcess):
     36        (WebKit::PluginProcess::platformInitializeProcess):
     37        (WebKit::PluginProcess::initializeProcessName):
     38        (WebKit::PluginProcess::initializeSandbox):
     39        * Shared/ChildProcess.h:
     40        (ChildProcessInitializationParameters):
     41        * Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.h:
     42        (ChildProcessMainDelegate):
     43        (WebKit::ChildProcessMain):
     44        * Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.mm:
     45        (WebKit::ChildProcessMainDelegate::getExtraData):
     46        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.Development.h:
     47        (WebKit::XPCServiceEventHandler):
     48        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.h:
     49        (WebKit::XPCServiceEventHandler):
     50        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h: Added.
     51        (XPCServiceInitializerDelegate):
     52        (WebKit::XPCServiceInitializerDelegate::XPCServiceInitializerDelegate):
     53        (WebKit::XPCServiceInitializer):
     54        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm: Added.
     55        (WebKit::XPCServiceInitializerDelegate::~XPCServiceInitializerDelegate):
     56        (WebKit::XPCServiceInitializerDelegate::getConnectionIdentifier):
     57        (WebKit::XPCServiceInitializerDelegate::getClientIdentifier):
     58        (WebKit::XPCServiceInitializerDelegate::getClientProcessName):
     59        (WebKit::XPCServiceInitializerDelegate::getExtraData):
     60        * Shared/Plugins/PluginProcessCreationParameters.cpp:
     61        (WebKit::PluginProcessCreationParameters::encode):
     62        (WebKit::PluginProcessCreationParameters::decode):
     63        * Shared/Plugins/PluginProcessCreationParameters.h:
     64        (PluginProcessCreationParameters):
     65        * UIProcess/Launcher/ProcessLauncher.h:
     66        (LaunchOptions):
     67        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
     68        (WebKit::connectToService):
     69        (WebKit::connectToReExecService):
     70        (WebKit::createService):
     71        (WebKit::createProcess):
     72        (WebKit::ProcessLauncher::launchProcess):
     73        * UIProcess/Plugins/PluginProcessProxy.cpp:
     74        (WebKit::PluginProcessProxy::didFinishLaunching):
     75        * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
     76        (WebKit::PluginProcessProxy::platformInitializeLaunchOptions):
     77        (WebKit::PluginProcessProxy::platformInitializePluginProcess):
     78        * WebKit2.xcodeproj/project.pbxproj:
     79        * WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/WebContentServiceMain.Development.mm:
     80        * WebProcess/EntryPoint/mac/XPCService/WebContentService/WebContentServiceMain.mm:
     81        * WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm:
     82        (WebContentServiceInitializer):
     83
    1842013-01-28  Kiran Muppala  <cmuppala@apple.com>
    285
  • trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkService.Development/NetworkServiceMain.Development.mm

    r140924 r141051  
    2424 */
    2525
    26 #define WEBKIT_XPC_SERVICE_INITIALIZER initializeNetworkService
     26#define WEBKIT_XPC_SERVICE_INITIALIZER NetworkServiceInitializer
    2727#include "XPCServiceBootstrapper.Development.h"
    2828
  • trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkService/NetworkServiceMain.mm

    r140924 r141051  
    2424 */
    2525
    26 #define WEBKIT_XPC_SERVICE_INITIALIZER initializeNetworkService
     26#define WEBKIT_XPC_SERVICE_INITIALIZER NetworkServiceInitializer
    2727#include "XPCServiceBootstrapper.h"
    2828
  • trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm

    r140924 r141051  
    2929
    3030#import "EnvironmentUtilities.h"
     31#import "NetworkProcess.h"
    3132#import "WKBase.h"
    32 #import "WebKit2Initialize.h"
    33 #import "NetworkProcess.h"
    34 #import <WebCore/RunLoop.h>
    35 #import <stdio.h>
    36 #import <stdlib.h>
    37 #import <xpc/xpc.h>
     33#import "XPCServiceEntryPoint.h"
    3834
    39 using namespace WebCore;
    4035using namespace WebKit;
    4136
    42 extern "C" WK_EXPORT void initializeNetworkService(const char* clientIdentifier, xpc_connection_t connection, mach_port_t serverPort, const char* uiProcessName);
     37extern "C" WK_EXPORT void NetworkServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage);
    4338
    44 void initializeNetworkService(const char* clientIdentifier, xpc_connection_t connection, mach_port_t serverPort, const char* uiProcessName)
     39void NetworkServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage)
    4540{
    46     // Remove the SecItemShim shim from the DYLD_INSERT_LIBRARIES environment variable so any processes spawned by
     41    // Remove the SecItemShim from the DYLD_INSERT_LIBRARIES environment variable so any processes spawned by
    4742    // the this process don't try to insert the shim and crash.
    4843    EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/SecItemShim.dylib");
    4944
    50     InitializeWebKit2();
    51 
    52     ChildProcessInitializationParameters parameters;
    53     parameters.uiProcessName = uiProcessName;
    54     parameters.clientIdentifier = clientIdentifier;
    55     parameters.connectionIdentifier = CoreIPC::Connection::Identifier(serverPort, connection);
    56 
    57     NetworkProcess::shared().initialize(parameters);
     45    XPCServiceInitializer<NetworkProcess, XPCServiceInitializerDelegate>(connection, initializerMessage);
    5846}
    5947
  • trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/LegacyProcess/PluginProcessMain.mm

    r140915 r141051  
    8181    }
    8282
     83    virtual bool getExtraInitializationData(HashMap<String, String>& extraInitializationData)
     84    {
     85        String pluginPath = m_commandLine["plugin-path"];
     86        if (pluginPath.isEmpty())
     87            return false;
     88        extraInitializationData.add("plugin-path", pluginPath);
     89
     90        // FIXME: We should stop passing this and have it in a hard coded place. For now
     91        // though, let the absence of a sandboxProfileDirectoryPath indicate no plugin
     92        // sandboxing should take place.
     93        String sandboxProfileDirectoryPath = m_commandLine["sandbox-profile-directory-path"];
     94        extraInitializationData.add("sandbox-profile-directory-path", sandboxProfileDirectoryPath);
     95
     96        return true;
     97    }
     98
    8399    virtual void doPostRunWork()
    84100    {
  • trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginService.32/PluginService.32.Main.mm

    r140929 r141051  
    2424 */
    2525
    26 #define WEBKIT_XPC_SERVICE_INITIALIZER initializePluginService
     26#if defined(__i386__)
     27
     28#define WEBKIT_XPC_SERVICE_INITIALIZER PluginServiceInitializer
    2729#include "XPCServiceBootstrapper.h"
    2830
     
    3436    return 0;
    3537}
     38
     39#else
     40
     41int main(int argc, char** argv)
     42{
     43    return 0;
     44}
     45
     46#endif
  • trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginService.64/PluginService.64.Main.mm

    r140929 r141051  
    2424 */
    2525
    26 #define WEBKIT_XPC_SERVICE_INITIALIZER initializePluginService
     26#define WEBKIT_XPC_SERVICE_INITIALIZER PluginServiceInitializer
    2727#include "XPCServiceBootstrapper.h"
    2828
  • trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginService.Development/PluginService.Development.Main.mm

    r140929 r141051  
    2424 */
    2525
    26 #define WEBKIT_XPC_SERVICE_INITIALIZER initializePluginService
     26#define WEBKIT_XPC_SERVICE_INITIALIZER PluginServiceInitializer
    2727#include "XPCServiceBootstrapper.Development.h"
    2828
  • trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm

    r140929 r141051  
    2929
    3030#import "EnvironmentUtilities.h"
     31#import "PluginProcess.h"
    3132#import "WKBase.h"
    32 #import "WebKit2Initialize.h"
    33 #import "PluginProcess.h"
     33#import "XPCServiceEntryPoint.h"
    3434#import <WebCore/RunLoop.h>
    35 #import <xpc/xpc.h>
     35
     36namespace WebKit {
     37
     38class PluginServiceInitializerDelegate : public XPCServiceInitializerDelegate {
     39public:
     40    PluginServiceInitializerDelegate(xpc_connection_t connection, xpc_object_t initializerMessage)
     41        : XPCServiceInitializerDelegate(connection, initializerMessage)
     42    {
     43    }
     44
     45    virtual bool getExtraInitializationData(HashMap<String, String>& extraInitializationData)
     46    {
     47        xpc_object_t extraDataInitializationDataObject = xpc_dictionary_get_value(m_initializerMessage, "extra-initialization-data");
     48
     49        String pluginPath = xpc_dictionary_get_string(extraDataInitializationDataObject, "plugin-path");
     50        if (pluginPath.isEmpty())
     51            return false;
     52        extraInitializationData.add("plugin-path", pluginPath);
     53
     54        // FIXME: We should stop passing this and have it in a hard coded place. For now
     55        // though, let the absence of a sandboxProfileDirectoryPath indicate no plugin
     56        // sandboxing should take place.
     57        String sandboxProfileDirectoryPath = xpc_dictionary_get_string(extraDataInitializationDataObject, "sandbox-profile-directory-path");
     58        extraInitializationData.add("sandbox-profile-directory-path", sandboxProfileDirectoryPath);
     59
     60        return true;
     61    }
     62};
     63
     64} // namespace WebKit
    3665
    3766using namespace WebCore;
    3867using namespace WebKit;
    3968
    40 extern "C" WK_EXPORT void initializePluginService(const char* clientIdentifier, xpc_connection_t connection, mach_port_t serverPort, const char* uiProcessName);
     69extern "C" WK_EXPORT void PluginServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage);
    4170
    42 void initializePluginService(const char* clientIdentifier, xpc_connection_t connection, mach_port_t serverPort, const char* uiProcessName)
     71void PluginServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage)
    4372{
     73    // FIXME: Add support for teardown from PluginProcessMain.mm
     74
    4475    // Remove the PluginProcess shim from the DYLD_INSERT_LIBRARIES environment variable so any processes
    4576    // spawned by the PluginProcess don't try to insert the shim and crash.
    4677    EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/PluginProcessShim.dylib");
     78    RunLoop::setUseApplicationRunLoopOnMainRunLoop();
    4779
    48     RunLoop::setUseApplicationRunLoopOnMainRunLoop();
    49     InitializeWebKit2();
    50 
    51     ChildProcessInitializationParameters parameters;
    52     parameters.uiProcessName = uiProcessName;
    53     parameters.clientIdentifier = clientIdentifier;
    54     parameters.connectionIdentifier = CoreIPC::Connection::Identifier(serverPort, connection);
    55 
    56     PluginProcess::shared().initialize(parameters);
    57 
    58     // FIXME: Add support for teardown from PluginProcessMain.mm
     80    XPCServiceInitializer<PluginProcess, PluginServiceInitializerDelegate>(connection, initializerMessage);
    5981}
    6082
  • trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp

    r140926 r141051  
    8888void PluginProcess::initializeProcess(const ChildProcessInitializationParameters& parameters)
    8989{
     90    m_pluginPath = parameters.extraInitializationData.get("plugin-path");
    9091    platformInitializeProcess(parameters);
    9192}
    92 
    93 #if !PLATFORM(MAC)
    94 void PluginProcess::enterSandbox(const String&)
    95 {
    96 }
    97 #endif
    9893
    9994void PluginProcess::removeWebProcessConnection(WebProcessConnection* webProcessConnection)
     
    156151    ASSERT(!m_pluginModule);
    157152
    158     m_pluginPath = parameters.pluginPath;
    159153    m_supportsAsynchronousPluginInitialization = parameters.supportsAsynchronousPluginInitialization;
    160154    setMinimumLifetime(parameters.minimumLifetime);
     
    265259}
    266260
     261#if !PLATFORM(MAC)
     262void PluginProcess::initializeProcessName(const ChildProcessInitializationParameters&)
     263{
     264}
     265
     266void PluginProcess::initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&)
     267{
     268}
     269#endif
     270
    267271} // namespace WebKit
    268272
  • trunk/Source/WebKit2/PluginProcess/PluginProcess.h

    r140926 r141051  
    3232#include <wtf/Forward.h>
    3333#include <wtf/text/WTFString.h>
    34 
    35 namespace WebCore {
    36 class RunLoop;
    37 }
    3834
    3935namespace WebKit {
     
    7369    ~PluginProcess();
    7470
    75     void enterSandbox(const String& sandboxProfileDirectoryPath);
    76 
    7771    // ChildProcess
    7872    virtual void initializeProcess(const ChildProcessInitializationParameters&) OVERRIDE;
     73    virtual void initializeProcessName(const ChildProcessInitializationParameters&) OVERRIDE;
     74    virtual void initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&) OVERRIDE;
    7975    virtual bool shouldTerminate() OVERRIDE;
    80 
    81     // Prevent entering the sandbox during first stage of process initialization. We can't do enter the sandbox before receiving
    82     // sandbox profile directory in initialization message.
    83     virtual void initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&) OVERRIDE { }
    84 
    8576    void platformInitializeProcess(const ChildProcessInitializationParameters&);
    8677
     
    10192    void setMinimumLifetime(double);
    10293    void minimumLifetimeTimerFired();
    103 
    104     // Stored for delayed sandbox initialization.
    105     ChildProcessInitializationParameters m_childProcessInitializationParameters;
    106 
    10794    // Our web process connections.
    10895    Vector<RefPtr<WebProcessConnection> > m_webProcessConnections;
  • trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm

    r140926 r141051  
    271271}
    272272
     273void PluginProcess::setModalWindowIsShowing(bool modalWindowIsShowing)
     274{
     275    parentProcessConnection()->send(Messages::PluginProcessProxy::SetModalWindowIsShowing(modalWindowIsShowing), 0);
     276}
     277
     278void PluginProcess::setFullscreenWindowIsShowing(bool fullscreenWindowIsShowing)
     279{
     280    parentProcessConnection()->send(Messages::PluginProcessProxy::SetFullscreenWindowIsShowing(fullscreenWindowIsShowing), 0);
     281}
     282
     283static String loadSandboxProfile(const String& pluginPath, const String& sandboxProfileDirectoryPath)
     284{
     285    if (sandboxProfileDirectoryPath.isEmpty())
     286        return String();
     287
     288    RetainPtr<CFURLRef> pluginURL = adoptCF(CFURLCreateWithFileSystemPath(0, pluginPath.createCFString().get(), kCFURLPOSIXPathStyle, false));
     289    if (!pluginURL)
     290        return String();
     291
     292    RetainPtr<CFBundleRef> pluginBundle = adoptCF(CFBundleCreate(kCFAllocatorDefault, pluginURL.get()));
     293    if (!pluginBundle)
     294        return String();
     295   
     296    CFStringRef bundleIdentifier = CFBundleGetIdentifier(pluginBundle.get());
     297    if (!bundleIdentifier)
     298        return String();
     299
     300    RetainPtr<CFURLRef> sandboxProfileDirectory = adoptCF(CFURLCreateWithFileSystemPath(0, sandboxProfileDirectoryPath.createCFString().get(), kCFURLPOSIXPathStyle, TRUE));
     301
     302    RetainPtr<CFStringRef> sandboxFileName = CFStringCreateWithFormat(0, 0, CFSTR("%@.sb"), bundleIdentifier);
     303    RetainPtr<CFURLRef> sandboxURL = adoptCF(CFURLCreateWithFileSystemPathRelativeToBase(0, sandboxFileName.get(), kCFURLPOSIXPathStyle, FALSE, sandboxProfileDirectory.get()));
     304
     305    RetainPtr<NSString> profileString = adoptNS([[NSString alloc] initWithContentsOfURL:(NSURL *)sandboxURL.get() encoding:NSUTF8StringEncoding error:NULL]);
     306    if (!profileString)
     307        return String();
     308
     309    sandboxURL = adoptCF(CFURLCreateWithFileSystemPathRelativeToBase(0, CFSTR("com.apple.WebKit.plugin-common.sb"), kCFURLPOSIXPathStyle, FALSE, sandboxProfileDirectory.get()));
     310
     311    RetainPtr<NSString> commonProfileString = adoptNS([[NSString alloc] initWithContentsOfURL:(NSURL *)sandboxURL.get() encoding:NSUTF8StringEncoding error:NULL]);
     312    if (!commonProfileString)
     313        return String();
     314
     315    return [commonProfileString.get() stringByAppendingString:profileString.get()];
     316}
     317
     318static void muteAudio(void)
     319{
     320    AudioObjectPropertyAddress propertyAddress = { kAudioHardwarePropertyProcessIsAudible, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
     321    UInt32 propertyData = 0;
     322    OSStatus result = AudioObjectSetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, 0, sizeof(UInt32), &propertyData);
     323    ASSERT_UNUSED(result, result == noErr);
     324}
     325
     326void PluginProcess::platformInitializePluginProcess(const PluginProcessCreationParameters& parameters)
     327{
     328    m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port();
     329    if (parameters.processType == TypeSnapshotProcess)
     330        muteAudio();
     331}
     332
    273333void PluginProcess::platformInitializeProcess(const ChildProcessInitializationParameters& parameters)
    274334{
    275     m_childProcessInitializationParameters = parameters;
    276 
    277     RunLoop::setUseApplicationRunLoopOnMainRunLoop();
    278 
    279335#if defined(__i386__)
    280336    // Initialize the shim.
     
    296352}
    297353
    298 void PluginProcess::setModalWindowIsShowing(bool modalWindowIsShowing)
    299 {
    300     parentProcessConnection()->send(Messages::PluginProcessProxy::SetModalWindowIsShowing(modalWindowIsShowing), 0);
    301 }
    302 
    303 void PluginProcess::setFullscreenWindowIsShowing(bool fullscreenWindowIsShowing)
    304 {
    305     parentProcessConnection()->send(Messages::PluginProcessProxy::SetFullscreenWindowIsShowing(fullscreenWindowIsShowing), 0);
    306 }
    307 
    308 static String loadSandboxProfile(const String& pluginPath, const String& sandboxProfileDirectoryPath)
    309 {
    310     if (sandboxProfileDirectoryPath.isEmpty())
    311         return String();
    312 
    313     RetainPtr<CFURLRef> pluginURL = adoptCF(CFURLCreateWithFileSystemPath(0, pluginPath.createCFString().get(), kCFURLPOSIXPathStyle, false));
    314     if (!pluginURL)
    315         return String();
    316 
    317     RetainPtr<CFBundleRef> pluginBundle = adoptCF(CFBundleCreate(kCFAllocatorDefault, pluginURL.get()));
    318     if (!pluginBundle)
    319         return String();
    320    
    321     CFStringRef bundleIdentifier = CFBundleGetIdentifier(pluginBundle.get());
    322     if (!bundleIdentifier)
    323         return String();
    324 
    325     RetainPtr<CFURLRef> sandboxProfileDirectory = adoptCF(CFURLCreateWithFileSystemPath(0, sandboxProfileDirectoryPath.createCFString().get(), kCFURLPOSIXPathStyle, TRUE));
    326 
    327     RetainPtr<CFStringRef> sandboxFileName = CFStringCreateWithFormat(0, 0, CFSTR("%@.sb"), bundleIdentifier);
    328     RetainPtr<CFURLRef> sandboxURL = adoptCF(CFURLCreateWithFileSystemPathRelativeToBase(0, sandboxFileName.get(), kCFURLPOSIXPathStyle, FALSE, sandboxProfileDirectory.get()));
    329 
    330     RetainPtr<NSString> profileString = adoptNS([[NSString alloc] initWithContentsOfURL:(NSURL *)sandboxURL.get() encoding:NSUTF8StringEncoding error:NULL]);
    331     if (!profileString)
    332         return String();
    333 
    334     sandboxURL = adoptCF(CFURLCreateWithFileSystemPathRelativeToBase(0, CFSTR("com.apple.WebKit.plugin-common.sb"), kCFURLPOSIXPathStyle, FALSE, sandboxProfileDirectory.get()));
    335 
    336     RetainPtr<NSString> commonProfileString = adoptNS([[NSString alloc] initWithContentsOfURL:(NSURL *)sandboxURL.get() encoding:NSUTF8StringEncoding error:NULL]);
    337     if (!commonProfileString)
    338         return String();
    339 
    340     return [commonProfileString.get() stringByAppendingString:profileString.get()];
    341 }
    342 
    343 static void muteAudio(void)
    344 {
    345     AudioObjectPropertyAddress propertyAddress = { kAudioHardwarePropertyProcessIsAudible, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
    346     UInt32 propertyData = 0;
    347     OSStatus result = AudioObjectSetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, 0, sizeof(UInt32), &propertyData);
    348     ASSERT_UNUSED(result, result == noErr);
    349 }
    350 
    351 void PluginProcess::platformInitializePluginProcess(const PluginProcessCreationParameters& parameters)
    352 {
    353     m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port();
    354 
    355     NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ (%@ Internet plug-in)",
    356                                                                      "visible name of the plug-in host process. The first argument is the plug-in name "
    357                                                                      "and the second argument is the application name."),
    358                                  [[(NSString *)parameters.pluginPath lastPathComponent] stringByDeletingPathExtension],
    359                                  (NSString *)parameters.parentProcessName];
    360    
     354void PluginProcess::initializeProcessName(const ChildProcessInitializationParameters& parameters)
     355{
     356    NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ (%@ Internet plug-in)", "visible name of the plug-in host process. The first argument is the plug-in name and the second argument is the application name."), [[(NSString *)m_pluginPath lastPathComponent] stringByDeletingPathExtension], (NSString *)parameters.uiProcessName];
    361357    WKSetVisibleApplicationName((CFStringRef)applicationName);
    362 
    363     // FIXME: PluginProcess initializes sandbox later than normal for ChildProcesses, because it needs
    364     // to know profile directory path. Switch to normal initialization scheme once the path can be determined earlier.
    365     enterSandbox(parameters.sandboxProfileDirectoryPath);
    366 
    367     if (parameters.processType == TypeSnapshotProcess)
    368         muteAudio();
    369 }
    370 
    371 void PluginProcess::enterSandbox(const String& sandboxProfileDirectoryPath)
    372 {
    373     SandboxInitializationParameters sandboxParameters;
    374 
    375     String sandboxProfile = loadSandboxProfile(m_pluginPath, sandboxProfileDirectoryPath);
     358}
     359
     360void PluginProcess::initializeSandbox(const ChildProcessInitializationParameters& parameters, SandboxInitializationParameters& sandboxParameters)
     361{
     362    String sandboxProfile = loadSandboxProfile(m_pluginPath, parameters.extraInitializationData.get("sandbox-profile-directory-path"));
    376363    if (sandboxProfile.isEmpty())
    377364        return;
     
    404391    [[NSUserDefaults standardUserDefaults] registerDefaults:defaults.get()];
    405392
    406     ChildProcess::initializeSandbox(m_childProcessInitializationParameters, sandboxParameters);
     393    ChildProcess::initializeSandbox(parameters, sandboxParameters);
    407394}
    408395
  • trunk/Source/WebKit2/Shared/ChildProcess.h

    r140730 r141051  
    3131#include "MessageSender.h"
    3232#include <WebCore/RunLoop.h>
     33#include <wtf/HashMap.h>
    3334#include <wtf/RetainPtr.h>
     35#include <wtf/text/StringHash.h>
    3436#include <wtf/text/WTFString.h>
    3537
     
    4244    String clientIdentifier;
    4345    CoreIPC::Connection::Identifier connectionIdentifier;
     46    HashMap<String, String> extraInitializationData;
    4447};
    4548
  • trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.h

    r140915 r141051  
    5151    virtual bool getClientIdentifier(String& clientIdentifier);
    5252    virtual bool getClientProcessName(String& clientProcessName);
     53    virtual bool getExtraInitializationData(HashMap<String, String>& extraInitializationData);
    5354
    5455    virtual void doPostRunWork();
     
    8384            return EXIT_FAILURE;
    8485
     86        if (!delegate.getExtraInitializationData(parameters.extraInitializationData))
     87            return EXIT_FAILURE;
     88
    8589        // FIXME: This should be moved to ChildProcessMac if it is still necessary.
    8690        String localization = commandLine["localization"];
  • trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.mm

    r140914 r141051  
    8989}
    9090
     91bool ChildProcessMainDelegate::getExtraInitializationData(HashMap<String, String>&)
     92{
     93    return true;
     94}
     95
    9196void ChildProcessMainDelegate::doPostRunWork()
    9297{
  • trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.Development.h

    r140922 r141051  
    3131#endif
    3232
    33 #import <AvailabilityMacros.h>
    3433#import <crt_externs.h>
    3534#import <dlfcn.h>
     
    3938#import <stdlib.h>
    4039#import <xpc/xpc.h>
    41 
    42 extern "C" mach_port_t xpc_dictionary_copy_mach_send(xpc_object_t, const char*);
    4340
    4441#define STRINGIZE(exp) #exp
     
    118115                }
    119116
    120                 typedef void (*InitializerFunction)(const char* clientIdentifer, xpc_connection_t connection, mach_port_t serverPort, const char* uiProcessName);
     117                typedef void (*InitializerFunction)(xpc_connection_t, xpc_object_t);
    121118                InitializerFunction initializerFunctionPtr = reinterpret_cast<InitializerFunction>(dlsym(frameworkLibrary, STRINGIZE_VALUE_OF(WEBKIT_XPC_SERVICE_INITIALIZER)));
    122119                if (!initializerFunctionPtr) {
     
    133130                dup2(xpc_dictionary_dup_fd(event, "stderr"), STDERR_FILENO);
    134131
    135                 initializerFunctionPtr(
    136                     xpc_dictionary_get_string(event, "client-identifier"),
    137                     peer,
    138                     xpc_dictionary_copy_mach_send(event, "server-port"),
    139                     xpc_dictionary_get_string(event, "ui-process-name")
    140                 );
     132                initializerFunctionPtr(peer, event);
    141133            }
    142134        }
  • trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.h

    r140919 r141051  
    3232
    3333#import <xpc/xpc.h>
    34 extern "C" mach_port_t xpc_dictionary_copy_mach_send(xpc_object_t, const char*);
    3534
    3635// Forward declare the specified initializer.
    37 extern "C" void WEBKIT_XPC_SERVICE_INITIALIZER(const char* clientIdentifier, xpc_connection_t, mach_port_t serverPort, const char* uiProcessName);
     36extern "C" void WEBKIT_XPC_SERVICE_INITIALIZER(xpc_connection_t, xpc_object_t);
    3837
    3938namespace WebKit {
     
    5857                xpc_release(reply);
    5958
    60                 WEBKIT_XPC_SERVICE_INITIALIZER(
    61                     xpc_dictionary_get_string(event, "client-identifier"),
    62                     peer,
    63                     xpc_dictionary_copy_mach_send(event, "server-port"),
    64                     xpc_dictionary_get_string(event, "ui-process-name")
    65                 );
     59                WEBKIT_XPC_SERVICE_INITIALIZER(peer, event);
    6660            }
    6761        }
  • trunk/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp

    r136193 r141051  
    4040void PluginProcessCreationParameters::encode(CoreIPC::ArgumentEncoder& encoder) const
    4141{
    42     encoder << pluginPath;
    4342    encoder.encodeEnum(processType);
    4443    encoder << supportsAsynchronousPluginInitialization;
    4544    encoder << minimumLifetime;
    4645    encoder << terminationTimeout;
    47 
    4846#if PLATFORM(MAC)
    49     encoder << parentProcessName;
    5047    encoder << acceleratedCompositingPort;
    51     encoder << sandboxProfileDirectoryPath;
    5248#endif
    5349}
     
    5551bool PluginProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, PluginProcessCreationParameters& result)
    5652{
    57     if (!decoder->decode(result.pluginPath))
    58         return false;
    5953    if (!decoder->decodeEnum(result.processType))
    6054        return false;
     
    6660        return false;
    6761#if PLATFORM(MAC)
    68     if (!decoder->decode(result.parentProcessName))
    69         return false;
    7062    if (!decoder->decode(result.acceleratedCompositingPort))
    71         return false;
    72     if (!decoder->decode(result.sandboxProfileDirectoryPath))
    7363        return false;
    7464#endif
  • trunk/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h

    r136193 r141051  
    3030
    3131#include "PluginProcess.h"
    32 #include <wtf/text/WTFString.h>
    3332
    3433#if PLATFORM(MAC)
     
    4948    static bool decode(CoreIPC::ArgumentDecoder*, PluginProcessCreationParameters&);
    5049
    51     String pluginPath;
    5250    PluginProcess::Type processType;
    5351    bool supportsAsynchronousPluginInitialization;
     
    5755
    5856#if PLATFORM(MAC)
    59     String parentProcessName;
    6057    CoreIPC::MachPort acceleratedCompositingPort;
    61     String sandboxProfileDirectoryPath;
    6258#endif
    6359};
  • trunk/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.h

    r132974 r141051  
    2929#include "Connection.h"
    3030#include "PlatformProcessIdentifier.h"
     31#include <wtf/HashMap.h>
    3132#include <wtf/RefPtr.h>
    3233#include <wtf/Threading.h>
    33 
    34 #ifndef NDEBUG
     34#include <wtf/text/StringHash.h>
    3535#include <wtf/text/WTFString.h>
    36 #endif
    3736
    3837namespace WebKit {
     
    6261    struct LaunchOptions {
    6362        ProcessType processType;
     63        HashMap<String, String> extraInitializationData;
    6464#if PLATFORM(MAC)
    6565        static const cpu_type_t MatchCurrentArchitecture = 0;
  • trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm

    r140929 r141051  
    179179}
    180180
    181 static void connectToServiceForDevelopment(const ProcessLauncher::LaunchOptions& launchOptions, ProcessLauncher* that, DidFinishLaunchingProcessFunction didFinishLaunchingProcessFunction, UUIDHolder* instanceUUID)
     181static void connectToService(const ProcessLauncher::LaunchOptions& launchOptions, bool forDevelopment, ProcessLauncher* that, DidFinishLaunchingProcessFunction didFinishLaunchingProcessFunction, UUIDHolder* instanceUUID)
    182182{
    183183    // Create a connection to the WebKit2 XPC service.
    184     xpc_connection_t connection = xpc_connection_create(serviceName(launchOptions, true), 0);
     184    xpc_connection_t connection = xpc_connection_create(serviceName(launchOptions, forDevelopment), 0);
    185185    xpc_connection_set_instance(connection, instanceUUID->uuid);
    186186
     
    205205    xpc_dictionary_set_string(bootstrapMessage, "client-identifier", clientIdentifier.data());
    206206    xpc_dictionary_set_string(bootstrapMessage, "ui-process-name", [[[NSProcessInfo processInfo] processName] UTF8String]);
    207     xpc_dictionary_set_fd(bootstrapMessage, "stdout", STDOUT_FILENO);
    208     xpc_dictionary_set_fd(bootstrapMessage, "stderr", STDERR_FILENO);
     207
     208    if (forDevelopment) {
     209        xpc_dictionary_set_fd(bootstrapMessage, "stdout", STDOUT_FILENO);
     210        xpc_dictionary_set_fd(bootstrapMessage, "stderr", STDERR_FILENO);
     211    }
     212
     213    xpc_object_t extraInitializationData = xpc_dictionary_create(0, 0, 0);
     214    HashMap<String, String>::const_iterator it = launchOptions.extraInitializationData.begin();
     215    HashMap<String, String>::const_iterator end = launchOptions.extraInitializationData.end();
     216    for (; it != end; ++it)
     217        xpc_dictionary_set_string(extraInitializationData, it->key.utf8().data(), it->value.utf8().data());
     218    xpc_dictionary_set_value(bootstrapMessage, "extra-initialization-data", extraInitializationData);
     219    xpc_release(extraInitializationData);
    209220
    210221    that->ref();
     
    236247}
    237248
    238 static void createServiceForDevelopment(const ProcessLauncher::LaunchOptions& launchOptions, ProcessLauncher* that, DidFinishLaunchingProcessFunction didFinishLaunchingProcessFunction)
     249static void connectToReExecService(const ProcessLauncher::LaunchOptions& launchOptions, ProcessLauncher* that, DidFinishLaunchingProcessFunction didFinishLaunchingProcessFunction)
    239250{
    240251    EnvironmentVariables environmentVariables;
     
    257268        ASSERT(xpc_get_type(event) == XPC_TYPE_ERROR);
    258269
    259         connectToServiceForDevelopment(launchOptions, that, didFinishLaunchingProcessFunction, instanceUUID.get());
     270        connectToService(launchOptions, true, that, didFinishLaunchingProcessFunction, instanceUUID.get());
    260271
    261272        // Release the connection.
     
    291302}
    292303
    293 static void createService(const ProcessLauncher::LaunchOptions& launchOptions, ProcessLauncher* that, DidFinishLaunchingProcessFunction didFinishLaunchingProcessFunction)
    294 {
     304static void createService(const ProcessLauncher::LaunchOptions& launchOptions, bool forDevelopment, ProcessLauncher* that, DidFinishLaunchingProcessFunction didFinishLaunchingProcessFunction)
     305{
     306    if (forDevelopment) {
     307        connectToReExecService(launchOptions, that, didFinishLaunchingProcessFunction);
     308        return;
     309    }
     310
    295311    // Generate the uuid for the service instance we are about to create.
    296312    // FIXME: This UUID should be stored on the ChildProcessProxy.
    297313    RefPtr<UUIDHolder> instanceUUID = UUIDHolder::create();
    298 
    299     // Create a connection to the WebKit2 XPC service.
    300     xpc_connection_t connection = xpc_connection_create(serviceName(launchOptions, false), 0);
    301     xpc_connection_set_instance(connection, instanceUUID->uuid);
    302 
    303     // XPC requires having an event handler, even if it is not used.
    304     xpc_connection_set_event_handler(connection, ^(xpc_object_t event) { });
    305     xpc_connection_resume(connection);
    306 
    307     // Create the listening port.
    308     mach_port_t listeningPort;
    309     mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
    310    
    311     // Insert a send right so we can send to it.
    312     mach_port_insert_right(mach_task_self(), listeningPort, listeningPort, MACH_MSG_TYPE_MAKE_SEND);
    313 
    314     NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
    315     CString clientIdentifier = bundleIdentifier ? String([[NSBundle mainBundle] bundleIdentifier]).utf8() : *_NSGetProgname();
    316 
    317     xpc_object_t bootstrapMessage = xpc_dictionary_create(0, 0, 0);
    318     xpc_dictionary_set_string(bootstrapMessage, "message-name", "bootstrap");
    319     xpc_dictionary_set_mach_send(bootstrapMessage, "server-port", listeningPort);
    320     xpc_dictionary_set_string(bootstrapMessage, "client-identifier", clientIdentifier.data());
    321     xpc_dictionary_set_string(bootstrapMessage, "ui-process-name", [[[NSProcessInfo processInfo] processName] UTF8String]);
    322 
    323     that->ref();
    324 
    325     xpc_connection_send_message_with_reply(connection, bootstrapMessage, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(xpc_object_t reply) {
    326         xpc_type_t type = xpc_get_type(reply);
    327         if (type == XPC_TYPE_ERROR) {
    328             // We failed to launch. Release the send right.
    329             mach_port_deallocate(mach_task_self(), listeningPort);
    330 
    331             // And the receive right.
    332             mach_port_mod_refs(mach_task_self(), listeningPort, MACH_PORT_RIGHT_RECEIVE, -1);
    333 
    334             RunLoop::main()->dispatch(bind(didFinishLaunchingProcessFunction, that, 0, CoreIPC::Connection::Identifier()));
    335         } else {
    336             ASSERT(type == XPC_TYPE_DICTIONARY);
    337             ASSERT(!strcmp(xpc_dictionary_get_string(reply, "message-name"), "process-finished-launching"));
    338 
    339             // The process has finished launching, grab the pid from the connection.
    340             pid_t processIdentifier = xpc_connection_get_pid(connection);
    341 
    342             // We've finished launching the process, message back to the main run loop.
    343             RunLoop::main()->dispatch(bind(didFinishLaunchingProcessFunction, that, processIdentifier, CoreIPC::Connection::Identifier(listeningPort, connection)));
    344         }
    345 
    346         that->deref();
    347     });
    348     xpc_release(bootstrapMessage);
    349 }
     314    connectToService(launchOptions, false, that, didFinishLaunchingProcessFunction, instanceUUID.get());
     315}
     316
    350317#endif
    351318
     
    444411    CString serviceName = String::format("com.apple.WebKit.WebProcess-%d-%p", getpid(), that).utf8();
    445412
    446     const char* args[] = { [processAppExecutablePath fileSystemRepresentation], [frameworkExecutablePath fileSystemRepresentation], "-type", ProcessLauncher::processTypeAsString(launchOptions.processType), "-servicename", serviceName.data(), "-localization", localization.data(), "-client-identifier", clientIdentifier.data(),
    447         "-ui-process-name", [[[NSProcessInfo processInfo] processName] UTF8String], 0 };
     413    Vector<const char*> args;
     414    args.append([processAppExecutablePath fileSystemRepresentation]);
     415    args.append([frameworkExecutablePath fileSystemRepresentation]);
     416    args.append("-type");
     417    args.append(ProcessLauncher::processTypeAsString(launchOptions.processType));
     418    args.append("-servicename");
     419    args.append(serviceName.data());
     420    args.append("-localization");
     421    args.append(localization.data());
     422    args.append("-client-identifier");
     423    args.append(clientIdentifier.data());
     424    args.append("-ui-process-name");
     425    args.append([[[NSProcessInfo processInfo] processName] UTF8String]);
     426
     427    HashMap<String, String>::const_iterator it = launchOptions.extraInitializationData.begin();
     428    HashMap<String, String>::const_iterator end = launchOptions.extraInitializationData.end();
     429    Vector<CString> temps;
     430    for (; it != end; ++it) {
     431        String keyPlusDash = "-" + it->key;
     432        CString key(keyPlusDash.utf8().data());
     433        temps.append(key);
     434        args.append(key.data());
     435
     436        CString value(it->value.utf8().data());
     437        temps.append(value);
     438        args.append(value.data());
     439    }
     440
     441    args.append(nullptr);
    448442
    449443    // Register ourselves.
     
    482476
    483477    pid_t processIdentifier = 0;
    484     int result = posix_spawn(&processIdentifier, args[0], 0, &attr, const_cast<char**>(args), environmentVariables.environmentPointer());
     478    int result = posix_spawn(&processIdentifier, args[0], 0, &attr, const_cast<char**>(args.data()), environmentVariables.environmentPointer());
    485479
    486480    posix_spawnattr_destroy(&attr);
     
    514508#if HAVE(XPC)
    515509    if (m_launchOptions.useXPC) {
    516         if (isWebKitDevelopmentBuild)
    517             createServiceForDevelopment(m_launchOptions, this, &ProcessLauncher::didFinishLaunchingProcess);
    518         else
    519             createService(m_launchOptions, this, &ProcessLauncher::didFinishLaunchingProcess);
     510        createService(m_launchOptions, isWebKitDevelopmentBuild, this, &ProcessLauncher::didFinishLaunchingProcess);
    520511        return;
    521512    }
  • trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp

    r139888 r141051  
    204204   
    205205    PluginProcessCreationParameters parameters;
    206 
    207     parameters.pluginPath = m_pluginInfo.path;
    208206    parameters.processType = m_processType;
    209 
    210207    parameters.minimumLifetime = minimumLifetime;
    211208    parameters.terminationTimeout = shutdownTimeout;
    212 
    213209    platformInitializePluginProcess(parameters);
    214210
  • trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm

    r140929 r141051  
    137137    launchOptions.executableHeap = PluginProcessProxy::pluginNeedsExecutableHeap(pluginInfo);
    138138
    139 #if HAVE(XPC)
    140     launchOptions.useXPC = shouldUseXPC();
    141 #endif
    142 }
    143 
    144 void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationParameters& parameters)
    145 {
    146     // For know only Flash is known to behave with asynchronous plug-in initialization.
    147     parameters.supportsAsynchronousPluginInitialization = m_pluginInfo.bundleIdentifier == "com.macromedia.Flash Player.plugin";
    148 
    149 #if USE(ACCELERATED_COMPOSITING) && HAVE(HOSTED_CORE_ANIMATION)
    150     parameters.parentProcessName = [[NSProcessInfo processInfo] processName];
    151     mach_port_t renderServerPort = [[CARemoteLayerServer sharedServer] serverPort];
    152 
    153     if (renderServerPort != MACH_PORT_NULL)
    154         parameters.acceleratedCompositingPort = CoreIPC::MachPort(renderServerPort, MACH_MSG_TYPE_COPY_SEND);
    155 #endif
     139    launchOptions.extraInitializationData.add("plugin-path", pluginInfo.path);
    156140
    157141    // FIXME: We should rip this out once we have a good place to install plug-in
     
    159143    NSString* sandboxProfileDirectoryPath = [[NSUserDefaults standardUserDefaults] stringForKey:WebKit2PlugInSandboxProfileDirectoryPathKey];
    160144    if (sandboxProfileDirectoryPath)
    161         parameters.sandboxProfileDirectoryPath = String(sandboxProfileDirectoryPath);
     145        launchOptions.extraInitializationData.add("sandbox-profile-directory-path", String(sandboxProfileDirectoryPath));
     146
     147#if HAVE(XPC)
     148    launchOptions.useXPC = shouldUseXPC();
     149#endif
     150}
     151
     152void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationParameters& parameters)
     153{
     154    // For now only Flash is known to behave with asynchronous plug-in initialization.
     155    parameters.supportsAsynchronousPluginInitialization = m_pluginInfo.bundleIdentifier == "com.macromedia.Flash Player.plugin";
     156
     157#if USE(ACCELERATED_COMPOSITING) && HAVE(HOSTED_CORE_ANIMATION)
     158    mach_port_t renderServerPort = [[CARemoteLayerServer sharedServer] serverPort];
     159    if (renderServerPort != MACH_PORT_NULL)
     160        parameters.acceleratedCompositingPort = CoreIPC::MachPort(renderServerPort, MACH_MSG_TYPE_COPY_SEND);
     161#endif
    162162}
    163163
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r141024 r141051  
    915915                BCBD3C3B125BFA7A00D2C29F /* StringPairVector.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBD3C3A125BFA7A00D2C29F /* StringPairVector.h */; };
    916916                BCBECDC316B5CEB100047A1A /* PluginService.Development.Main.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCBECDC116B5CE0D00047A1A /* PluginService.Development.Main.mm */; };
     917                BCBECDE716B6416800047A1A /* XPCServiceEntryPoint.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCBECDE516B6416700047A1A /* XPCServiceEntryPoint.mm */; };
     918                BCBECDE816B6416800047A1A /* XPCServiceEntryPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBECDE616B6416700047A1A /* XPCServiceEntryPoint.h */; };
    917919                BCC43ABA127B95DC00317F16 /* PlatformPopupMenuData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCC43AB8127B95DC00317F16 /* PlatformPopupMenuData.cpp */; };
    918920                BCC43ABB127B95DC00317F16 /* PlatformPopupMenuData.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC43AB9127B95DC00317F16 /* PlatformPopupMenuData.h */; };
     
    22642266                BCBECDC116B5CE0D00047A1A /* PluginService.Development.Main.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginService.Development.Main.mm; sourceTree = "<group>"; };
    22652267                BCBECDC216B5CE2A00047A1A /* PluginService.Development.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = PluginService.Development.xcconfig; sourceTree = "<group>"; };
     2268                BCBECDE516B6416700047A1A /* XPCServiceEntryPoint.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = XPCServiceEntryPoint.mm; sourceTree = "<group>"; };
     2269                BCBECDE616B6416700047A1A /* XPCServiceEntryPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPCServiceEntryPoint.h; sourceTree = "<group>"; };
    22662270                BCC43AB8127B95DC00317F16 /* PlatformPopupMenuData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformPopupMenuData.cpp; sourceTree = "<group>"; };
    22672271                BCC43AB9127B95DC00317F16 /* PlatformPopupMenuData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformPopupMenuData.h; sourceTree = "<group>"; };
     
    41784182                        isa = PBXGroup;
    41794183                        children = (
     4184                                BC82839716B480F600A278FE /* XPCServiceBootstrapper.Development.h */,
    41804185                                BC82839616B47EC400A278FE /* XPCServiceBootstrapper.h */,
    4181                                 BC82839716B480F600A278FE /* XPCServiceBootstrapper.Development.h */,
     4186                                BCBECDE616B6416700047A1A /* XPCServiceEntryPoint.h */,
     4187                                BCBECDE516B6416700047A1A /* XPCServiceEntryPoint.mm */,
    41824188                        );
    41834189                        name = XPCService;
     
    53215327                                518E8F0C16B2093700E91429 /* DownloadManager.h in Headers */,
    53225328                                BC82837A16B36A4F00A278FE /* ChildProcessMain.h in Headers */,
     5329                                BCBECDE816B6416800047A1A /* XPCServiceEntryPoint.h in Headers */,
    53235330                                A5EFD38C16B0E88C00B2F0E8 /* WKPageVisibilityTypes.h in Headers */,
    53245331                        );
     
    64376444                                BC8283AC16B4BF3F00A278FE /* NetworkServiceEntryPoint.mm in Sources */,
    64386445                                BC82844D16B5081C00A278FE /* PluginServiceEntryPoint.mm in Sources */,
     6446                                BCBECDE716B6416800047A1A /* XPCServiceEntryPoint.mm in Sources */,
    64396447                        );
    64406448                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService.Development/WebContentServiceMain.Development.mm

    r140919 r141051  
    2424 */
    2525
    26 #define WEBKIT_XPC_SERVICE_INITIALIZER initializeWebContentService
     26#define WEBKIT_XPC_SERVICE_INITIALIZER WebContentServiceInitializer
    2727#include "XPCServiceBootstrapper.Development.h"
    2828
  • trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentService/WebContentServiceMain.mm

    r140919 r141051  
    2424 */
    2525
    26 #define WEBKIT_XPC_SERVICE_INITIALIZER initializeWebContentService
     26#define WEBKIT_XPC_SERVICE_INITIALIZER WebContentServiceInitializer
    2727#include "XPCServiceBootstrapper.h"
    2828
  • trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm

    r140924 r141051  
    3030#import "EnvironmentUtilities.h"
    3131#import "WKBase.h"
    32 #import "WebKit2Initialize.h"
    3332#import "WebProcess.h"
     33#import "XPCServiceEntryPoint.h"
    3434#import <WebCore/RunLoop.h>
    35 #import <stdio.h>
    36 #import <stdlib.h>
    37 #import <xpc/xpc.h>
    3835
    3936using namespace WebCore;
    4037using namespace WebKit;
    4138
    42 extern "C" WK_EXPORT void initializeWebContentService(const char* clientIdentifier, xpc_connection_t connection, mach_port_t serverPort, const char* uiProcessName);
     39extern "C" WK_EXPORT void WebContentServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage);
    4340
    44 void initializeWebContentService(const char* clientIdentifier, xpc_connection_t connection, mach_port_t serverPort, const char* uiProcessName)
     41void WebContentServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage)
    4542{
    46     // Remove the SecItemShim shim from the DYLD_INSERT_LIBRARIES environment variable so any processes spawned by
     43    // Remove the SecItemShim from the DYLD_INSERT_LIBRARIES environment variable so any processes spawned by
    4744    // the this process don't try to insert the shim and crash.
    4845    EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/SecItemShim.dylib");
    4946
    5047    RunLoop::setUseApplicationRunLoopOnMainRunLoop();
    51     InitializeWebKit2();
    5248
    53     ChildProcessInitializationParameters parameters;
    54     parameters.uiProcessName = uiProcessName;
    55     parameters.clientIdentifier = clientIdentifier;
    56     parameters.connectionIdentifier = CoreIPC::Connection::Identifier(serverPort, connection);
    57 
    58     WebProcess::shared().initialize(parameters);
     49    XPCServiceInitializer<WebProcess, XPCServiceInitializerDelegate>(connection, initializerMessage);
    5950}
    6051
Note: See TracChangeset for help on using the changeset viewer.