Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

browser(webkit): no-startup-window on linux #1117

Merged
merged 1 commit into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion browser_patches/webkit/BUILD_NUMBER
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1157
1158
157 changes: 103 additions & 54 deletions browser_patches/webkit/patches/bootstrap.diff
Original file line number Diff line number Diff line change
Expand Up @@ -8468,10 +8468,10 @@ index 8a871bf2916d5eab86becf5fde0faed79283d88c..a19a429c4d53edf81c3028c7053265e6

diff --git a/Source/WebKit/UIProcess/RemoteInspectorPipe.cpp b/Source/WebKit/UIProcess/RemoteInspectorPipe.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0b4ec2de5671723f4045e98b3e398fc11180b3b8
index 0000000000000000000000000000000000000000..45d8dc48601548951dc5c5ecd68958dbd47c89db
--- /dev/null
+++ b/Source/WebKit/UIProcess/RemoteInspectorPipe.cpp
@@ -0,0 +1,219 @@
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2019 Microsoft Corporation.
+ *
Expand Down Expand Up @@ -8624,6 +8624,7 @@ index 0000000000000000000000000000000000000000..0b4ec2de5671723f4045e98b3e398fc1
+
+bool RemoteInspectorPipe::start()
+{
+ WTF::RunLoop::initializeMainRunLoop();
+ if (m_receiverThread)
+ return true;
+
Expand Down Expand Up @@ -11921,8 +11922,42 @@ index 9e9978efd3d821c7afcd7b65e14c64e36b355802..a5eef119bddd011470319ac80a0ac443
g_signal_connect(tab->webView, "load-failed-with-tls-errors", G_CALLBACK(loadFailedWithTLSerrors), tab);
g_signal_connect(tab->webView, "permission-request", G_CALLBACK(decidePermissionRequest), tab);
g_signal_connect(tab->webView, "run-color-chooser", G_CALLBACK(runColorChooserCallback), tab);
diff --git a/Tools/MiniBrowser/gtk/BrowserWindow.c b/Tools/MiniBrowser/gtk/BrowserWindow.c
index 37f9eefbafd14b69c2bedf928ef379670cfef531..5e7e5db253cf788a079e4a0922833b0778b4640d 100644
--- a/Tools/MiniBrowser/gtk/BrowserWindow.c
+++ b/Tools/MiniBrowser/gtk/BrowserWindow.c
@@ -79,6 +79,8 @@ static const gdouble defaultZoomLevel = 1;
static const gdouble zoomStep = 1.2;
static GList *windowList;

+static gboolean no_quit = false;
+
G_DEFINE_TYPE(BrowserWindow, browser_window, GTK_TYPE_WINDOW)

static char *getExternalURI(const char *uri)
@@ -707,7 +709,7 @@ static void browserWindowFinalize(GObject *gObject)

G_OBJECT_CLASS(browser_window_parent_class)->finalize(gObject);

- if (!windowList)
+ if (!windowList && !no_quit)
gtk_main_quit();
}

@@ -1233,6 +1235,11 @@ void browser_window_set_background_color(BrowserWindow *window, GdkRGBA *rgba)
gtk_widget_set_app_paintable(GTK_WIDGET(window), TRUE);
}

+void browser_window_no_quit(void)
+{
+ no_quit = true;
+}
+
static BrowserWindow *findActiveWindow(void)
{
GList *l;
diff --git a/Tools/MiniBrowser/gtk/BrowserWindow.h b/Tools/MiniBrowser/gtk/BrowserWindow.h
index 1570d65effb5d601ee3c44a2a7461436f4691c2c..456f96cf589320efa70a76f76e230b6795886b5a 100644
index 1570d65effb5d601ee3c44a2a7461436f4691c2c..65e62adad0c3684e5cec2f6bc8e7f5281e1f77eb 100644
--- a/Tools/MiniBrowser/gtk/BrowserWindow.h
+++ b/Tools/MiniBrowser/gtk/BrowserWindow.h
@@ -37,7 +37,7 @@ G_BEGIN_DECLS
Expand All @@ -11934,31 +11969,42 @@ index 1570d65effb5d601ee3c44a2a7461436f4691c2c..456f96cf589320efa70a76f76e230b67
#define BROWSER_ABOUT_SCHEME "minibrowser-about"

typedef struct _BrowserWindow BrowserWindow;
@@ -53,7 +53,7 @@ void browser_window_load_session(BrowserWindow *, const char *sessionFile);
void browser_window_set_background_color(BrowserWindow*, GdkRGBA*);
WebKitWebView* browser_window_get_or_create_web_view_for_automation(void);
WebKitWebView *browser_window_create_web_view_in_new_tab_for_automation(void);
-
+void browser_window_no_quit(void);
G_END_DECLS

#endif
diff --git a/Tools/MiniBrowser/gtk/main.c b/Tools/MiniBrowser/gtk/main.c
index 4c5147dcd38a53e2feaeaae0fce38f92dc60eba6..4b1cab0c187352688740c7cca79483fa256aa7fe 100644
index 4c5147dcd38a53e2feaeaae0fce38f92dc60eba6..77d031add801b2f45c9d90e74afab8802aa08e20 100644
--- a/Tools/MiniBrowser/gtk/main.c
+++ b/Tools/MiniBrowser/gtk/main.c
@@ -53,6 +53,9 @@ static const char *cookiesFile;
@@ -53,6 +53,10 @@ static const char *cookiesFile;
static const char *cookiesPolicy;
static const char *proxy;
static gboolean darkMode;
+static gboolean inspectorPipe;
+static gboolean headless;
+static gboolean noStartupWindow;
+static const char *userDataDir;
static gboolean printVersion;

typedef enum {
@@ -121,6 +124,9 @@ static const GOptionEntry commandLineOptions[] =
@@ -121,6 +125,10 @@ static const GOptionEntry commandLineOptions[] =
{ "ignore-tls-errors", 0, 0, G_OPTION_ARG_NONE, &ignoreTLSErrors, "Ignore TLS errors", NULL },
{ "content-filter", 0, 0, G_OPTION_ARG_FILENAME, &contentFilter, "JSON with content filtering rules", "FILE" },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &printVersion, "Print the WebKitGTK version", NULL },
+ { "inspector-pipe", 0, 0, G_OPTION_ARG_NONE, &inspectorPipe, "Open pipe connection to the remote inspector", NULL },
+ { "user-data-dir", 0, 0, G_OPTION_ARG_STRING, &userDataDir, "Default profile persistence folder location", NULL },
+ { "headless", 0, 0, G_OPTION_ARG_NONE, &headless, "Noop headless operation", NULL },
+ { "no-startup-window", 0, 0, G_OPTION_ARG_NONE, &noStartupWindow, "Do not open default page", NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uriArguments, 0, "[URL…]" },
{ 0, 0, 0, 0, 0, 0, 0 }
};
@@ -498,6 +504,36 @@ static void filterSavedCallback(WebKitUserContentFilterStore *store, GAsyncResul
@@ -498,6 +506,34 @@ static void filterSavedCallback(WebKitUserContentFilterStore *store, GAsyncResul
g_main_loop_quit(data->mainLoop);
}

Expand All @@ -11982,10 +12028,8 @@ index 4c5147dcd38a53e2feaeaae0fce38f92dc60eba6..4b1cab0c187352688740c7cca79483fa
+ return newWebView;
+}
+
+static void configureBrowserInspectorPipe(WebKitWebContext *webContext)
+static void configureBrowserInspectorPipe()
+{
+ persistentWebContext = webContext;
+
+ WebKitBrowserInspector* browserInspector = webkit_browser_inspector_get_default();
+ g_signal_connect(browserInspector, "create-new-page", G_CALLBACK(createNewPage), NULL);
+
Expand All @@ -11995,11 +12039,21 @@ index 4c5147dcd38a53e2feaeaae0fce38f92dc60eba6..4b1cab0c187352688740c7cca79483fa
int main(int argc, char *argv[])
{
#if ENABLE_DEVELOPER_MODE
@@ -541,10 +577,22 @@ int main(int argc, char *argv[])
@@ -541,8 +577,28 @@ int main(int argc, char *argv[])
return 0;
}

- WebKitWebsiteDataManager *manager = (privateMode || automationMode) ? webkit_website_data_manager_new_ephemeral() : webkit_website_data_manager_new(NULL);
+ if (inspectorPipe)
+ configureBrowserInspectorPipe();
+
+ if (noStartupWindow) {
+ browser_window_no_quit();
+ gtk_main();
+ g_clear_object(&webkitSettings);
+ return 0;
+ }
+
+ WebKitWebsiteDataManager *manager;
+ if (userDataDir) {
+ manager = webkit_website_data_manager_new("base-data-directory", userDataDir, "base-cache-directory", userDataDir, NULL);
Expand All @@ -12011,15 +12065,11 @@ index 4c5147dcd38a53e2feaeaae0fce38f92dc60eba6..4b1cab0c187352688740c7cca79483fa
+ }
+
WebKitWebContext *webContext = g_object_new(WEBKIT_TYPE_WEB_CONTEXT, "website-data-manager", manager, "process-swap-on-cross-site-navigation-enabled", TRUE, NULL);
+ persistentWebContext = webContext;
g_object_unref(manager);

+ if (inspectorPipe)
+ configureBrowserInspectorPipe(webContext);
+
if (cookiesPolicy) {
WebKitCookieManager *cookieManager = webkit_web_context_get_cookie_manager(webContext);
GEnumClass *enumClass = g_type_class_ref(WEBKIT_TYPE_COOKIE_ACCEPT_POLICY);
@@ -648,8 +696,7 @@ int main(int argc, char *argv[])
@@ -648,8 +704,7 @@ int main(int argc, char *argv[])

gtk_main();

Expand Down Expand Up @@ -12591,10 +12641,10 @@ index 373d0de77e852c673a6615e0acedd5195e3c021b..cfeb4f806f79d1a213fdb13346e2b383
+ WKPageRunBeforeUnloadConfirmPanelResultListenerRef m_beforeUnloadDialog = { };
};
diff --git a/Tools/MiniBrowser/win/WinMain.cpp b/Tools/MiniBrowser/win/WinMain.cpp
index 6008ca19e26a938cf962c0c336299fff7d13f9a3..a5f7daaf5c2dc860296b5d9379d5637d611ca707 100644
index 6008ca19e26a938cf962c0c336299fff7d13f9a3..8005d72f8c0d9ef82efda8aec1ff0e7d96501ae8 100644
--- a/Tools/MiniBrowser/win/WinMain.cpp
+++ b/Tools/MiniBrowser/win/WinMain.cpp
@@ -31,7 +31,12 @@
@@ -31,6 +31,10 @@
#include "stdafx.h"
#include "Common.h"
#include "MiniBrowserLibResource.h"
Expand All @@ -12603,11 +12653,9 @@ index 6008ca19e26a938cf962c0c336299fff7d13f9a3..a5f7daaf5c2dc860296b5d9379d5637d
+#include <WebKit/WKWebsiteDataStoreConfigurationRef.h>
+#include <WebKit/WKWebsiteDataStoreRef.h>
#include <wtf/win/SoftLinking.h>
+#include <wtf/RunLoop.h>

#if USE(CF)
#include <CoreFoundation/CoreFoundation.h>
@@ -46,11 +51,30 @@
@@ -46,9 +50,25 @@
#include <WebKitLegacy/WebKitCOMAPI.h>
#endif

Expand All @@ -12632,13 +12680,8 @@ index 6008ca19e26a938cf962c0c336299fff7d13f9a3..a5f7daaf5c2dc860296b5d9379d5637d
+
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpstrCmdLine, _In_ int nCmdShow)
{
+#if ENABLE(WEBKIT)
+ WTF::RunLoop::initializeMainRunLoop();
+#endif
#ifdef _CRTDBG_MAP_ALLOC
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
@@ -66,6 +90,11 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
@@ -66,6 +86,11 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
InitCommonControlsEx(&InitCtrlEx);

auto options = parseCommandLine();
Expand All @@ -12650,17 +12693,17 @@ index 6008ca19e26a938cf962c0c336299fff7d13f9a3..a5f7daaf5c2dc860296b5d9379d5637d

if (options.useFullDesktop)
computeFullDesktopFrame();
@@ -74,32 +103,50 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
@@ -74,32 +99,50 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
OleInitialize(nullptr);

if (SetProcessDpiAwarenessContextPtr())
- SetProcessDpiAwarenessContextPtr()(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
- else
- ::SetProcessDPIAware();
+ SetProcessDpiAwarenessContextPtr()(DPI_AWARENESS_CONTEXT_UNAWARE);

+ MainWindow::configure(options.headless, options.noStartupWindow);
+
+ MainWindow::configure(options.headless, options.noStartupWindow);

+ if (!options.noStartupWindow) {
#if !ENABLE(WEBKIT_LEGACY)
- auto factory = WebKitBrowserWindow::create;
Expand Down Expand Up @@ -12730,7 +12773,7 @@ index 04d3630dc2b0f5e937af173046268001da003753..ba0a60b832cd353776bb50b8198df2d8
)

diff --git a/Tools/MiniBrowser/wpe/main.cpp b/Tools/MiniBrowser/wpe/main.cpp
index a0ca94ac2dcc005b403180aa11407ff7b33dcbc6..ad155edd606477ecfc4a72c524df1fa5af33bab8 100644
index a0ca94ac2dcc005b403180aa11407ff7b33dcbc6..a10ce93a58f138eb475273444bba33f9a6b69081 100644
--- a/Tools/MiniBrowser/wpe/main.cpp
+++ b/Tools/MiniBrowser/wpe/main.cpp
@@ -25,7 +25,7 @@
Expand All @@ -12742,25 +12785,27 @@ index a0ca94ac2dcc005b403180aa11407ff7b33dcbc6..ad155edd606477ecfc4a72c524df1fa5
#include "WindowViewBackend.h"
#if ENABLE_WEB_AUDIO || ENABLE_VIDEO
#include <gst/gst.h>
@@ -43,6 +43,8 @@ static gboolean headlessMode;
@@ -43,6 +43,9 @@ static gboolean headlessMode;
static gboolean privateMode;
static gboolean automationMode;
static gboolean ignoreTLSErrors;
+static gboolean inspectorPipe;
+static gboolean noStartupWindow;
+static const char* userDataDir;
static const char* contentFilter;
static const char* cookiesFile;
static const char* cookiesPolicy;
@@ -63,6 +65,8 @@ static const GOptionEntry commandLineOptions[] =
@@ -63,6 +66,9 @@ static const GOptionEntry commandLineOptions[] =
{ "content-filter", 0, 0, G_OPTION_ARG_FILENAME, &contentFilter, "JSON with content filtering rules", "FILE" },
{ "bg-color", 0, 0, G_OPTION_ARG_STRING, &bgColor, "Window background color. Default: white", "COLOR" },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &printVersion, "Print the WPE version", nullptr },
+ { "inspector-pipe", 'v', 0, G_OPTION_ARG_NONE, &inspectorPipe, "Expose remote debugging protocol over pipe", nullptr },
+ { "user-data-dir", 0, 0, G_OPTION_ARG_STRING, &userDataDir, "Default profile persistence folder location", "FILE" },
+ { "no-startup-window", 0, 0, G_OPTION_ARG_NONE, &noStartupWindow, "Do not open default page", nullptr },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uriArguments, nullptr, "[URL]" },
{ nullptr, 0, 0, G_OPTION_ARG_NONE, nullptr, nullptr, nullptr }
};
@@ -131,7 +135,7 @@ static gboolean decidePermissionRequest(WebKitWebView *, WebKitPermissionRequest
@@ -131,7 +137,7 @@ static gboolean decidePermissionRequest(WebKitWebView *, WebKitPermissionRequest
static std::unique_ptr<WPEToolingBackends::ViewBackend> createViewBackend(uint32_t width, uint32_t height)
{
if (headlessMode)
Expand All @@ -12769,7 +12814,7 @@ index a0ca94ac2dcc005b403180aa11407ff7b33dcbc6..ad155edd606477ecfc4a72c524df1fa5
return std::make_unique<WPEToolingBackends::WindowViewBackend>(width, height);
}

@@ -147,12 +151,33 @@ static void filterSavedCallback(WebKitUserContentFilterStore *store, GAsyncResul
@@ -147,12 +153,33 @@ static void filterSavedCallback(WebKitUserContentFilterStore *store, GAsyncResul
g_main_loop_quit(data->mainLoop);
}

Expand Down Expand Up @@ -12804,7 +12849,7 @@ index a0ca94ac2dcc005b403180aa11407ff7b33dcbc6..ad155edd606477ecfc4a72c524df1fa5
{
auto backend = createViewBackend(1280, 720);
struct wpe_view_backend* wpeBackend = backend->backend();
@@ -164,14 +189,56 @@ static WebKitWebView* createWebView(WebKitWebView* webView, WebKitNavigationActi
@@ -164,14 +191,54 @@ static WebKitWebView* createWebView(WebKitWebView* webView, WebKitNavigationActi
delete static_cast<WPEToolingBackends::ViewBackend*>(data);
}, backend.release());

Expand Down Expand Up @@ -12852,10 +12897,8 @@ index a0ca94ac2dcc005b403180aa11407ff7b33dcbc6..ad155edd606477ecfc4a72c524df1fa5
+ return webView;
+}
+
+static void configureBrowserInspector(GMainLoop* mainLoop, WebKitWebContext *webContext)
+static void configureBrowserInspector(GMainLoop* mainLoop)
+{
+ persistentWebContext = webContext;
+
+ WebKitBrowserInspector* browserInspector = webkit_browser_inspector_get_default();
+ g_signal_connect(browserInspector, "create-new-page", G_CALLBACK(createNewPage), NULL);
+ webkit_browser_inspector_initialize_pipe(mainLoop);
Expand All @@ -12864,7 +12907,22 @@ index a0ca94ac2dcc005b403180aa11407ff7b33dcbc6..ad155edd606477ecfc4a72c524df1fa5
int main(int argc, char *argv[])
{
#if ENABLE_DEVELOPER_MODE
@@ -215,7 +282,18 @@ int main(int argc, char *argv[])
@@ -206,6 +273,14 @@ int main(int argc, char *argv[])
}

auto* loop = g_main_loop_new(nullptr, FALSE);
+ if (inspectorPipe)
+ configureBrowserInspector(loop);
+
+ if (noStartupWindow) {
+ g_main_loop_run(loop);
+ g_main_loop_unref(loop);
+ return 0;
+ }

auto backend = createViewBackend(1280, 720);
struct wpe_view_backend* wpeBackend = backend->backend();
@@ -215,7 +290,19 @@ int main(int argc, char *argv[])
return 1;
}

Expand All @@ -12880,21 +12938,12 @@ index a0ca94ac2dcc005b403180aa11407ff7b33dcbc6..ad155edd606477ecfc4a72c524df1fa5
+ }
+
+ WebKitWebContext *webContext = WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, "website-data-manager", manager, "process-swap-on-cross-site-navigation-enabled", TRUE, NULL));
+ persistentWebContext = webContext;
+ g_object_unref(manager);

if (cookiesPolicy) {
auto* cookieManager = webkit_web_context_get_cookie_manager(webContext);
@@ -280,6 +358,9 @@ int main(int argc, char *argv[])
delete static_cast<WPEToolingBackends::ViewBackend*>(data);
}, backend.release());

+ if (inspectorPipe)
+ configureBrowserInspector(loop, webContext);
+
auto* webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW,
"backend", viewBackend,
"web-context", webContext,
@@ -300,7 +381,9 @@ int main(int argc, char *argv[])
@@ -300,7 +387,9 @@ int main(int argc, char *argv[])
g_signal_connect(webContext, "automation-started", G_CALLBACK(automationStartedCallback), webView);
g_signal_connect(webView, "permission-request", G_CALLBACK(decidePermissionRequest), nullptr);
g_signal_connect(webView, "create", G_CALLBACK(createWebView), nullptr);
Expand All @@ -12905,7 +12954,7 @@ index a0ca94ac2dcc005b403180aa11407ff7b33dcbc6..ad155edd606477ecfc4a72c524df1fa5

if (ignoreTLSErrors)
webkit_web_context_set_tls_errors_policy(webContext, WEBKIT_TLS_ERRORS_POLICY_IGNORE);
@@ -319,7 +402,7 @@ int main(int argc, char *argv[])
@@ -319,7 +408,7 @@ int main(int argc, char *argv[])
g_object_unref(file);
webkit_web_view_load_uri(webView, url);
g_free(url);
Expand All @@ -12914,7 +12963,7 @@ index a0ca94ac2dcc005b403180aa11407ff7b33dcbc6..ad155edd606477ecfc4a72c524df1fa5
webkit_web_view_load_uri(webView, "about:blank");
else
webkit_web_view_load_uri(webView, "https://wpewebkit.org");
@@ -327,8 +410,7 @@ int main(int argc, char *argv[])
@@ -327,8 +416,7 @@ int main(int argc, char *argv[])
g_main_loop_run(loop);

g_object_unref(webView);
Expand Down