- Revision
- 211147
- Author
- [email protected]
- Date
- 2017-01-25 09:02:58 -0800 (Wed, 25 Jan 2017)
Log Message
[GTK] Icon Database should be in private browsing mode for ephemeral web views
https://bugs.webkit.org/show_bug.cgi?id=167414
Reviewed by Michael Catanzaro.
Source/WebKit2:
This is already done by WebProcessPool for the legacy private session setting, but only checking the setting and not
whether there are ephemeral web pages or not.
* UIProcess/API/gtk/WebKitWebContext.cpp:
(webkitWebContextEnableIconDatabasePrivateBrowsingIfNeeded): Enable icon database private browsing if there's
any ephemeral web view.
(webkitWebContextDisableIconDatabasePrivateBrowsingIfNeeded): Disable icon database private browsing if there
aren't ephemeral web views anymore.
(webkit_web_context_set_favicon_database_directory): Enable icon database private browsing if the web context is ephemeral.
(webkitWebContextCreatePageForWebView): Call webkitWebContextEnableIconDatabasePrivateBrowsingIfNeeded().
(webkitWebContextWebViewDestroyed): Call webkitWebContextDisableIconDatabasePrivateBrowsingIfNeeded().
* UIProcess/API/gtk/WebKitWebView.cpp:
(webkitWebViewDispose): Ensure webkitWebContextWebViewDestroyed is called only once.
Tools:
Add a test case to check ephemeral web views don't write favicons to the database.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp:
(ephemeralViewLoadChanged):
(testPrivateBrowsing):
(testFaviconDatabase):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (211146 => 211147)
--- trunk/Source/WebKit2/ChangeLog 2017-01-25 16:56:00 UTC (rev 211146)
+++ trunk/Source/WebKit2/ChangeLog 2017-01-25 17:02:58 UTC (rev 211147)
@@ -1,5 +1,26 @@
2017-01-25 Carlos Garcia Campos <[email protected]>
+ [GTK] Icon Database should be in private browsing mode for ephemeral web views
+ https://bugs.webkit.org/show_bug.cgi?id=167414
+
+ Reviewed by Michael Catanzaro.
+
+ This is already done by WebProcessPool for the legacy private session setting, but only checking the setting and not
+ whether there are ephemeral web pages or not.
+
+ * UIProcess/API/gtk/WebKitWebContext.cpp:
+ (webkitWebContextEnableIconDatabasePrivateBrowsingIfNeeded): Enable icon database private browsing if there's
+ any ephemeral web view.
+ (webkitWebContextDisableIconDatabasePrivateBrowsingIfNeeded): Disable icon database private browsing if there
+ aren't ephemeral web views anymore.
+ (webkit_web_context_set_favicon_database_directory): Enable icon database private browsing if the web context is ephemeral.
+ (webkitWebContextCreatePageForWebView): Call webkitWebContextEnableIconDatabasePrivateBrowsingIfNeeded().
+ (webkitWebContextWebViewDestroyed): Call webkitWebContextDisableIconDatabasePrivateBrowsingIfNeeded().
+ * UIProcess/API/gtk/WebKitWebView.cpp:
+ (webkitWebViewDispose): Ensure webkitWebContextWebViewDestroyed is called only once.
+
+2017-01-25 Carlos Garcia Campos <[email protected]>
+
[GTK] UIProcess from WebKitGtk+ 2.15.x SIGSEGVs because of X Error BadDamage in WebKit::AcceleratedBackingStoreX11::update(WebKit::LayerTreeContext const&) () at Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.cpp:145
https://bugs.webkit.org/show_bug.cgi?id=165656
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (211146 => 211147)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp 2017-01-25 16:56:00 UTC (rev 211146)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp 2017-01-25 17:02:58 UTC (rev 211147)
@@ -176,6 +176,7 @@
unsigned processCountLimit;
HashMap<uint64_t, WebKitWebView*> webViews;
+ unsigned ephemeralPageCount;
CString webExtensionsDirectory;
GRefPtr<GVariant> webExtensionsInitializationUserData;
@@ -712,6 +713,31 @@
priv->faviconDatabase = adoptGRef(webkitFaviconDatabaseCreate(priv->processPool->iconDatabase()));
}
+static void webkitWebContextEnableIconDatabasePrivateBrowsingIfNeeded(WebKitWebContext* context, WebKitWebView* webView)
+{
+ if (webkit_web_context_is_ephemeral(context))
+ return;
+ if (!webkit_web_view_is_ephemeral(webView))
+ return;
+
+ if (!context->priv->ephemeralPageCount)
+ context->priv->processPool->iconDatabase()->setPrivateBrowsingEnabled(true);
+ context->priv->ephemeralPageCount++;
+}
+
+static void webkitWebContextDisableIconDatabasePrivateBrowsingIfNeeded(WebKitWebContext* context, WebKitWebView* webView)
+{
+ if (webkit_web_context_is_ephemeral(context))
+ return;
+ if (!webkit_web_view_is_ephemeral(webView))
+ return;
+
+ ASSERT(context->priv->ephemeralPageCount);
+ context->priv->ephemeralPageCount--;
+ if (!context->priv->ephemeralPageCount)
+ context->priv->processPool->iconDatabase()->setPrivateBrowsingEnabled(false);
+}
+
/**
* webkit_web_context_set_favicon_database_directory:
* @context: a #WebKitWebContext
@@ -750,6 +776,9 @@
// Setting the path will cause the icon database to be opened.
priv->processPool->setIconDatabasePath(WebCore::stringFromFileSystemRepresentation(faviconDatabasePath.get()));
+
+ if (webkit_web_context_is_ephemeral(context))
+ priv->processPool->iconDatabase()->setPrivateBrowsingEnabled(true);
}
/**
@@ -1458,6 +1487,10 @@
{
WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(webView);
+ // FIXME: icon database private mode is global, not per page, so while there are
+ // pages in private mode we need to enable the private mode in the icon database.
+ webkitWebContextEnableIconDatabasePrivateBrowsingIfNeeded(context, webView);
+
auto pageConfiguration = API::PageConfiguration::create();
pageConfiguration->setProcessPool(context->priv->processPool.get());
pageConfiguration->setPreferences(webkitSettingsGetPreferences(webkit_web_view_get_settings(webView)));
@@ -1477,6 +1510,7 @@
void webkitWebContextWebViewDestroyed(WebKitWebContext* context, WebKitWebView* webView)
{
+ webkitWebContextDisableIconDatabasePrivateBrowsingIfNeeded(context, webView);
WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
context->priv->webViews.remove(page->pageID());
}
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (211146 => 211147)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2017-01-25 16:56:00 UTC (rev 211146)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2017-01-25 17:02:58 UTC (rev 211147)
@@ -778,10 +778,13 @@
if (webView->priv->loadObserver) {
getPage(webView)->pageLoadState().removeObserver(*webView->priv->loadObserver);
webView->priv->loadObserver.reset();
+
+ // We notify the context here to ensure it's called only once. Ideally we should
+ // call this in finalize, not dispose, but finalize is used internally and we don't
+ // have access to the instance pointer from the private struct destructor.
+ webkitWebContextWebViewDestroyed(webView->priv->context.get(), webView);
}
- webkitWebContextWebViewDestroyed(webView->priv->context.get(), webView);
-
G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
}
Modified: trunk/Tools/ChangeLog (211146 => 211147)
--- trunk/Tools/ChangeLog 2017-01-25 16:56:00 UTC (rev 211146)
+++ trunk/Tools/ChangeLog 2017-01-25 17:02:58 UTC (rev 211147)
@@ -1,5 +1,19 @@
2017-01-25 Carlos Garcia Campos <[email protected]>
+ [GTK] Icon Database should be in private browsing mode for ephemeral web views
+ https://bugs.webkit.org/show_bug.cgi?id=167414
+
+ Reviewed by Michael Catanzaro.
+
+ Add a test case to check ephemeral web views don't write favicons to the database.
+
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp:
+ (ephemeralViewLoadChanged):
+ (testPrivateBrowsing):
+ (testFaviconDatabase):
+
+2017-01-25 Carlos Garcia Campos <[email protected]>
+
[GTK] Add a private browsing mode to MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=167413
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp (211146 => 211147)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp 2017-01-25 16:56:00 UTC (rev 211146)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp 2017-01-25 17:02:58 UTC (rev 211147)
@@ -152,6 +152,30 @@
g_assert(!iconURI);
}
+static void ephemeralViewLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent, WebViewTest* test)
+{
+ if (loadEvent != WEBKIT_LOAD_FINISHED)
+ return;
+ g_signal_handlers_disconnect_by_func(webView, reinterpret_cast<void*>(ephemeralViewLoadChanged), test);
+ test->quitMainLoop();
+}
+
+static void testPrivateBrowsing(FaviconDatabaseTest* test)
+{
+ GRefPtr<WebKitWebView> webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW,
+ "web-context", test->m_webContext.get(),
+ "is-ephemeral", TRUE,
+ nullptr));
+ g_signal_connect(webView.get(), "load-changed", G_CALLBACK(ephemeralViewLoadChanged), test);
+ webkit_web_view_load_uri(webView.get(), kServer->getURIForPath("/foo").data());
+ g_main_loop_run(test->m_mainLoop);
+
+ // An ephemeral web view should not write to the database.
+ test->getFaviconForPageURIAndWaitUntilReady(kServer->getURIForPath("/foo").data());
+ g_assert(!test->m_favicon);
+ g_assert(test->m_error);
+}
+
static void testGetFavicon(FaviconDatabaseTest* test)
{
// We need to load the page first to ensure the icon data will be
@@ -228,6 +252,7 @@
// See https://bugs.webkit.org/show_bug.cgi?id=111434.
testNotInitialized(test);
testSetDirectory(test);
+ testPrivateBrowsing(test);
testGetFavicon(test);
testGetFaviconURI(test);
testWebViewFavicon(test);