diff options
Diffstat (limited to 'Source/WebKit2/WebProcess/gtk')
5 files changed, 38 insertions, 90 deletions
diff --git a/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp b/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp index 1e2390d0c..36b9bf06f 100644 --- a/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp +++ b/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp @@ -27,14 +27,14 @@ #include "WKType.h" #include "WebKitWebExtensionPrivate.h" #include <WebCore/FileSystem.h> -#include <wtf/OwnPtr.h> +#include <memory> #include <wtf/text/CString.h> namespace WebKit { -WebGtkExtensionManager& WebGtkExtensionManager::shared() +WebGtkExtensionManager& WebGtkExtensionManager::singleton() { - DEFINE_STATIC_LOCAL(WebGtkExtensionManager, extensionManager, ()); + static NeverDestroyed<WebGtkExtensionManager> extensionManager; return extensionManager; } @@ -67,7 +67,7 @@ static void parseUserData(WKTypeRef userData, String& webExtensionsDirectory, GR GVariant* data = nullptr; g_variant_get(variant.get(), "(m&smv)", &directory, &data); - webExtensionsDirectory = WebCore::filenameToString(directory); + webExtensionsDirectory = WebCore::stringFromFileSystemRepresentation(directory); initializationUserData = adoptGRef(data); } @@ -105,11 +105,11 @@ void WebGtkExtensionManager::initialize(WKBundleRef bundle, WKTypeRef userDataSt scanModules(webExtensionsDirectory, modulePaths); for (size_t i = 0; i < modulePaths.size(); ++i) { - OwnPtr<Module> module = adoptPtr(new Module(modulePaths[i])); + auto module = std::make_unique<Module>(modulePaths[i]); if (!module->load()) continue; if (initializeWebExtension(module.get(), userData.get())) - m_extensionModules.append(module.leakPtr()); + m_extensionModules.append(module.release()); } } diff --git a/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.h b/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.h index ec0bdc5df..884ca39f4 100644 --- a/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.h +++ b/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.h @@ -22,9 +22,10 @@ #include "Module.h" #include "WKBundle.h" +#include <wtf/NeverDestroyed.h> #include <wtf/Noncopyable.h> #include <wtf/Vector.h> -#include <wtf/gobject/GRefPtr.h> +#include <wtf/glib/GRefPtr.h> typedef struct _WebKitWebExtension WebKitWebExtension; @@ -38,7 +39,7 @@ class WebGtkExtensionManager { WTF_MAKE_NONCOPYABLE(WebGtkExtensionManager); public: - WK_EXPORT static WebGtkExtensionManager& shared(); + WK_EXPORT static WebGtkExtensionManager& singleton(); WK_EXPORT void initialize(WKBundleRef, WKTypeRef); @@ -50,6 +51,8 @@ private: Vector<Module*> m_extensionModules; GRefPtr<WebKitWebExtension> m_extension; + + friend class NeverDestroyed<WebGtkExtensionManager>; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/gtk/WebGtkInjectedBundleMain.cpp b/Source/WebKit2/WebProcess/gtk/WebGtkInjectedBundleMain.cpp index 84ff809cd..0037cd476 100644 --- a/Source/WebKit2/WebProcess/gtk/WebGtkInjectedBundleMain.cpp +++ b/Source/WebKit2/WebProcess/gtk/WebGtkInjectedBundleMain.cpp @@ -20,7 +20,7 @@ #include "config.h" #include "WebGtkExtensionManager.h" -#include <WebKit2/WKBundleInitialize.h> +#include <WebKit/WKBundleInitialize.h> using namespace WebKit; @@ -31,5 +31,5 @@ extern "C" #endif void WKBundleInitialize(WKBundleRef bundle, WKTypeRef userData) { - WebGtkExtensionManager::shared().initialize(bundle, userData); + WebGtkExtensionManager::singleton().initialize(bundle, userData); } diff --git a/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp b/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp index 57d4ab3e6..3711f4a4b 100644 --- a/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp +++ b/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp @@ -25,61 +25,48 @@ */ #include "config.h" -#include "WebProcessMainGtk.h" +#include "WebProcessMainUnix.h" -#include "WKBase.h" -#include "WebKit2Initialize.h" -#include <WebCore/AuthenticationChallenge.h> -#include <WebCore/NetworkingContext.h> +#include "ChildProcessMain.h" +#include "WebProcess.h" #include <WebCore/SoupNetworkSession.h> -#include <WebKit2/WebProcess.h> #include <gtk/gtk.h> #include <libintl.h> #include <libsoup/soup.h> -#include <unistd.h> -#include <wtf/RunLoop.h> -#include <wtf/gobject/GRefPtr.h> +#include <wtf/CurrentTime.h> + +#if PLATFORM(X11) +#include <X11/Xlib.h> +#endif using namespace WebCore; namespace WebKit { -WK_EXPORT int WebProcessMainGtk(int argc, char* argv[]) -{ - ASSERT(argc == 2); - +class WebProcessMain final: public ChildProcessMainBase { +public: + bool platformInitialize() override + { #ifndef NDEBUG - if (g_getenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH")) - sleep(30); + if (g_getenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH")) + g_usleep(30 * G_USEC_PER_SEC); #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. - SoupNetworkSession::defaultSession().setSSLPolicy(SoupNetworkSession::SSLUseSystemCAFile); +#if (USE(COORDINATED_GRAPHICS_THREADED) || USE(GSTREAMER_GL)) && PLATFORM(X11) + XInitThreads(); +#endif + gtk_init(nullptr, nullptr); - RunLoop::run(); + bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); - if (SoupCache* soupCache = SoupNetworkSession::defaultSession().cache()) { - soup_cache_flush(soupCache); - soup_cache_dump(soupCache); + return true; } +}; - return 0; +int WebProcessMainUnix(int argc, char** argv) +{ + return ChildProcessMain<WebProcess, WebProcessMain>(argc, argv); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.h b/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.h deleted file mode 100644 index 828af830e..000000000 --- a/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WebProcessMainGtk_h -#define WebProcessMainGtk_h - -#include <WebKit2/WKBase.h> - -namespace WebKit { - -#ifdef __cplusplus -extern "C" { -WK_EXPORT int WebProcessMainGtk(int argc, char* argv[]); -} // extern "C" -#endif // __cplusplus - -} // namespace WebKit - -#endif // WebProcessMain_h |