Title: [231637] trunk/Tools
Revision
231637
Author
[email protected]
Date
2018-05-10 01:37:37 -0700 (Thu, 10 May 2018)

Log Message

[GTK] Add support for settings cookies policy and storage type in MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=185506

Reviewed by Philippe Normand.

Useful for testing and debugging.

* MiniBrowser/gtk/main.c:
(main):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (231636 => 231637)


--- trunk/Tools/ChangeLog	2018-05-10 07:41:36 UTC (rev 231636)
+++ trunk/Tools/ChangeLog	2018-05-10 08:37:37 UTC (rev 231637)
@@ -1,3 +1,15 @@
+2018-05-10  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Add support for settings cookies policy and storage type in MiniBrowser
+        https://bugs.webkit.org/show_bug.cgi?id=185506
+
+        Reviewed by Philippe Normand.
+
+        Useful for testing and debugging.
+
+        * MiniBrowser/gtk/main.c:
+        (main):
+
 2018-05-09  Chris Dumez  <[email protected]>
 
         Unreviewed Windows build fix after r231622.

Modified: trunk/Tools/MiniBrowser/gtk/main.c (231636 => 231637)


--- trunk/Tools/MiniBrowser/gtk/main.c	2018-05-10 07:41:36 UTC (rev 231636)
+++ trunk/Tools/MiniBrowser/gtk/main.c	2018-05-10 08:37:37 UTC (rev 231637)
@@ -46,6 +46,8 @@
 static gboolean automationMode;
 static gboolean fullScreen;
 static gboolean enableIntelligentTrackingPrevention;
+static const char *cookiesFile;
+static const char *cookiesPolicy;
 static const char *proxy;
 
 typedef enum {
@@ -104,6 +106,8 @@
     { "private", 'p', 0, G_OPTION_ARG_NONE, &privateMode, "Run in private browsing mode", NULL },
     { "automation", 0, 0, G_OPTION_ARG_NONE, &automationMode, "Run in automation mode", NULL },
     { "enable-itp", 0, 0, G_OPTION_ARG_NONE, &enableIntelligentTrackingPrevention, "Enable intelligent tracking prevention", NULL },
+    { "cookies-file", 'c', 0, G_OPTION_ARG_FILENAME, &cookiesFile, "Persistent cookie storage database file", "FILE" },
+    { "cookies-policy", 0, 0, G_OPTION_ARG_STRING, &cookiesPolicy, "Cookies accept policy (always, never, no-third-party). Default: no-third-party", "POLICY" },
     { "proxy", 0, 0, G_OPTION_ARG_STRING, &proxy, "Set proxy", "PROXY" },
     { "ignore-host", 0, 0, G_OPTION_ARG_STRING_ARRAY, &ignoreHosts, "Set proxy ignore hosts", "HOSTS" },
     { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uriArguments, 0, "[URL…]" },
@@ -496,6 +500,21 @@
 
     WebKitWebContext *webContext = (privateMode || automationMode) ? webkit_web_context_new_ephemeral() : webkit_web_context_get_default();
 
+    if (cookiesPolicy) {
+        WebKitCookieManager *cookieManager = webkit_web_context_get_cookie_manager(webContext);
+        GEnumClass *enumClass = g_type_class_ref(WEBKIT_TYPE_COOKIE_ACCEPT_POLICY);
+        GEnumValue *enumValue = g_enum_get_value_by_nick(enumClass, cookiesPolicy);
+        if (enumValue)
+            webkit_cookie_manager_set_accept_policy(cookieManager, enumValue->value);
+        g_type_class_unref(enumClass);
+    }
+
+    if (cookiesFile && !webkit_web_context_is_ephemeral(webContext)) {
+        WebKitCookieManager *cookieManager = webkit_web_context_get_cookie_manager(webContext);
+        WebKitCookiePersistentStorage storageType = g_str_has_suffix(cookiesFile, ".txt") ? WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT : WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE;
+        webkit_cookie_manager_set_persistent_storage(cookieManager, cookiesFile, storageType);
+    }
+
     if (proxy) {
         WebKitNetworkProxySettings *webkitProxySettings = webkit_network_proxy_settings_new(proxy, ignoreHosts);
         webkit_web_context_set_network_proxy_settings(webContext, WEBKIT_NETWORK_PROXY_MODE_CUSTOM, webkitProxySettings);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to