Q_DECL_EXPORT int WebProcessMainQt(QGuiApplication* app)
{
#if ENABLE(SUID_SANDBOX_LINUX)
    pid_t helper = chrootMe();
    if (helper == -1) {
        fprintf(stderr, "Asking for chroot failed.\n");
        return -1;
    }
#endif
    initializeProxy();

    InitializeWebKit2();

    // Create the connection.
    if (app->arguments().size() <= 1) {
        qDebug() << "Error: wrong number of arguments.";
        return 1;
    }

#if OS(DARWIN)
    QString serviceName = app->arguments().value(1);

    // Get the server port.
    mach_port_t identifier;
    kern_return_t kr = bootstrap_look_up2(bootstrap_port, serviceName.toUtf8().data(), &identifier, 0, 0);
    if (kr) {
        printf("bootstrap_look_up2 result: %x", kr);
        return 2;
    }
#else
    bool wasNumber = false;
    qulonglong id = app->arguments().at(1).toULongLong(&wasNumber, 10);
    if (!wasNumber) {
        qDebug() << "Error: connection identifier wrong.";
        return 1;
    }
    CoreIPC::Connection::Identifier identifier;
#if OS(WINDOWS)
    // Convert to HANDLE
    identifier = reinterpret_cast<CoreIPC::Connection::Identifier>(id);
#else
    // Convert to int
    identifier = static_cast<CoreIPC::Connection::Identifier>(id);
#endif
#endif


    WebKit::ChildProcessInitializationParameters parameters;
    parameters.connectionIdentifier = identifier;

    WebKit::WebProcess::shared().initialize(parameters);

    RunLoop::run();

    // FIXME: Do more cleanup here.
    delete app;

    return 0;
}
WK_EXPORT int NetworkProcessMain(int argc, char* argv[])
{
    if (argc != 2)
        return 1;

#if PLATFORM(EFL)
    if (!ecore_init())
        return 1;

    if (!ecore_main_loop_glib_integrate())
        return 1;
#endif

    InitializeWebKit2();

#if USE(SOUP)
    SoupSession* session = ResourceHandle::defaultSession();
#if PLATFORM(EFL)
    // Only for EFL because GTK port uses the default resolver, which uses GIO's proxy resolver.
    const char* httpProxy = getenv("http_proxy");
    if (httpProxy) {
        const char* noProxy = getenv("no_proxy");
        GRefPtr<SoupProxyURIResolver> resolver = adoptGRef(soupProxyResolverWkNew(httpProxy, noProxy));
        soup_session_add_feature(session, SOUP_SESSION_FEATURE(resolver.get()));
    }
#endif
#endif

    int socket = atoi(argv[1]);

    WebKit::ChildProcessInitializationParameters parameters;
    parameters.connectionIdentifier = int(socket);

    NetworkProcess::shared().initialize(parameters);

#if USE(SOUP)
    // Despite using system CAs to validate certificates we're
    // accepting invalid certificates by default. New API will be
    // added later to let client accept/discard invalid certificates.
    g_object_set(session, SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
        SOUP_SESSION_SSL_STRICT, FALSE, NULL);
#endif

    RunLoop::run();

#if USE(SOUP)
    if (SoupSessionFeature* soupCache = soup_session_get_feature(session, SOUP_TYPE_CACHE)) {
        soup_cache_flush(SOUP_CACHE(soupCache));
        soup_cache_dump(SOUP_CACHE(soupCache));
    }
#endif

    return 0;
}
Exemple #3
0
void ChildProcess::initialize(const ChildProcessInitializationParameters& parameters)
{
    InitializeWebKit2();

    platformInitialize();

    initializeProcess(parameters);
    initializeProcessName(parameters);
    initializeSandbox(parameters);
    
    m_connection = CoreIPC::Connection::createClientConnection(parameters.connectionIdentifier, this, RunLoop::main());
    m_connection->setDidCloseOnConnectionWorkQueueCallback(didCloseOnConnectionWorkQueue);
    initializeConnection(m_connection.get());
    m_connection->open();
}
WK_EXPORT int PluginProcessMainUnix(int argc, char* argv[])
{
#if PLUGIN_ARCHITECTURE(X11)
    bool scanPlugin = !strcmp(argv[1], "-scanPlugin");
#endif
    ASSERT_UNUSED(argc, argc == 3);

#if PLATFORM(GTK)
    gtk_init(&argc, &argv);
#elif PLATFORM(EFL)
#ifdef HAVE_ECORE_X
    if (!ecore_x_init(0))
#endif
        return 1;
#endif

    InitializeWebKit2();

#if PLUGIN_ARCHITECTURE(X11)
    if (scanPlugin) {
        String pluginPath(argv[2]);
        if (!NetscapePluginModule::scanPlugin(pluginPath))
            return EXIT_FAILURE;
        return EXIT_SUCCESS;
    }
#endif

    // Plugins can produce X errors that are handled by the GDK X error handler, which
    // exits the process. Since we don't want to crash due to plugin bugs, we install a
    // custom error handler to show a warning when a X error happens without aborting.
#if defined(XP_UNIX)
    programName = basename(argv[0]);
    XSetErrorHandler(webkitXError);
#endif

    int socket = atoi(argv[1]);

    WebKit::ChildProcessInitializationParameters parameters;
    parameters.connectionIdentifier = socket;
    parameters.extraInitializationData.add("plugin-path", argv[2]);

    WebKit::PluginProcess::shared().initialize(parameters);

    RunLoop::run();

    return 0;
}
Exemple #5
0
WK_EXPORT int WebProcessMainNix(int argc, char* argv[])
{
    // WebProcess should be launched with an option.
    if (argc != 2)
        return 1;

#ifdef WTF_USE_SOUP
#if !GLIB_CHECK_VERSION(2, 35, 0)
    g_type_init();
#endif
#endif

    InitializeWebKit2();

#ifdef WTF_USE_SOUP
    SoupSession* session = WebCore::ResourceHandle::defaultSession();
    g_object_set(G_OBJECT(session), "ssl-use-system-ca-file", true, NULL);

    const char* httpProxy = getenv("http_proxy");
    if (httpProxy) {
        const char* noProxy = getenv("no_proxy");
        SoupProxyURIResolver* resolverNix = soupProxyResolverWkNew(httpProxy, noProxy);
        soup_session_add_feature(session, SOUP_SESSION_FEATURE(resolverNix));
        g_object_unref(resolverNix);
    }
#endif

    int socket = atoi(argv[1]);

    ChildProcessInitializationParameters parameters;
    parameters.connectionIdentifier = socket;

    WebProcess::shared().initialize(parameters);

    RunLoop::run();

#ifdef WTF_USE_SOUP
    if (SoupSessionFeature* soupCache = soup_session_get_feature(session, SOUP_TYPE_CACHE)) {
        soup_cache_flush(SOUP_CACHE(soupCache));
        soup_cache_dump(SOUP_CACHE(soupCache));
    }
#endif

    return 0;
}
Exemple #6
0
WK_EXPORT int WebProcessMainGtk(int argc, char* argv[])
{
    ASSERT(argc == 2);

#ifndef NDEBUG
    if (g_getenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH"))
        sleep(30);
#endif

    gtk_init(&argc, &argv);

    bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");

    InitializeWebKit2();

    int socket = atoi(argv[1]);

    ChildProcessInitializationParameters parameters;
    parameters.connectionIdentifier = socket;

    WebProcess::shared().initialize(parameters);

    // Despite using system CAs to validate certificates we're
    // accepting invalid certificates by default. New API will be
    // added later to let client accept/discard invalid certificates.
    SoupSession* session = WebCore::ResourceHandle::defaultSession();
    g_object_set(session, SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
                 SOUP_SESSION_SSL_STRICT, FALSE, NULL);

    GOwnPtr<char> soupCacheDirectory(g_build_filename(g_get_user_cache_dir(), g_get_prgname(), NULL));
    GRefPtr<SoupCache> soupCache = adoptGRef(soup_cache_new(soupCacheDirectory.get(), SOUP_CACHE_SINGLE_USER));
    soup_session_add_feature(session, SOUP_SESSION_FEATURE(soupCache.get()));
    soup_cache_load(soupCache.get());

    RunLoop::run();

    soup_cache_flush(soupCache.get());
    soup_cache_dump(soupCache.get());

    return 0;
}
Exemple #7
0
PassRefPtr<WebContext> WebContext::create(WebContextConfiguration configuration)
{
    InitializeWebKit2();
    return adoptRef(new WebContext(std::move(configuration)));
}
Exemple #8
0
Ref<WebProcessPool> WebProcessPool::create(API::ProcessPoolConfiguration& configuration)
{
    InitializeWebKit2();
    return adoptRef(*new WebProcessPool(configuration));
}
WK_EXPORT int WebProcessMainEfl(int argc, char* argv[])
{
    // WebProcess should be launched with an option.
    if (argc != 2)
        return 1;

    if (!eina_init())
        return 1;

    if (!ecore_init()) {
        // Could not init ecore.
        eina_shutdown();
        return 1;
    }

#ifdef HAVE_ECORE_X
    XSetExtensionErrorHandler(dummyExtensionErrorHandler);

    if (!ecore_x_init(0)) {
        // Could not init ecore_x.
        // PlatformScreenEfl and systemBeep() functions
        // depend on ecore_x functionality.
        ecore_shutdown();
        eina_shutdown();
        return 1;
    }
#endif

    if (!ecore_evas_init()) {
#ifdef HAVE_ECORE_X
        ecore_x_shutdown();
#endif
        ecore_shutdown();
        eina_shutdown();
        return 1;
    }

    if (!edje_init()) {
        ecore_evas_shutdown();
#ifdef HAVE_ECORE_X
        ecore_x_shutdown();
#endif
        ecore_shutdown();
        eina_shutdown();
        return 1;
    }

#if !GLIB_CHECK_VERSION(2, 35, 0)
    g_type_init();
#endif

    if (!ecore_main_loop_glib_integrate())
        return 1;

    InitializeWebKit2();

    SoupSession* session = WebCore::ResourceHandle::defaultSession();
    const char* httpProxy = getenv("http_proxy");
    if (httpProxy) {
        const char* noProxy = getenv("no_proxy");
        SoupProxyURIResolver* resolverEfl = soupProxyResolverWkNew(httpProxy, noProxy);
        soup_session_add_feature(session, SOUP_SESSION_FEATURE(resolverEfl));
        g_object_unref(resolverEfl);
    }

    int socket = atoi(argv[1]);

    ChildProcessInitializationParameters parameters;
    parameters.connectionIdentifier = socket;

    WebProcess::shared().initialize(parameters);

    RunLoop::run();

    if (SoupSessionFeature* soupCache = soup_session_get_feature(session, SOUP_TYPE_CACHE)) {
        soup_cache_flush(SOUP_CACHE(soupCache));
        soup_cache_dump(SOUP_CACHE(soupCache));
    }

    edje_shutdown();
    ecore_evas_shutdown();
#ifdef HAVE_ECORE_X
    ecore_x_shutdown();
#endif
    ecore_shutdown();
    eina_shutdown();

    return 0;

}