⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 231637 in webkit


Ignore:
Timestamp:
May 10, 2018, 1:37:37 AM (8 years ago)
Author:
Carlos Garcia Campos
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):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r231625 r231637  
     12018-05-10  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Add support for settings cookies policy and storage type in MiniBrowser
     4        https://bugs.webkit.org/show_bug.cgi?id=185506
     5
     6        Reviewed by Philippe Normand.
     7
     8        Useful for testing and debugging.
     9
     10        * MiniBrowser/gtk/main.c:
     11        (main):
     12
    1132018-05-09  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Tools/MiniBrowser/gtk/main.c

    r229799 r231637  
    4747static gboolean fullScreen;
    4848static gboolean enableIntelligentTrackingPrevention;
     49static const char *cookiesFile;
     50static const char *cookiesPolicy;
    4951static const char *proxy;
    5052
    … …  
    105107    { "automation", 0, 0, G_OPTION_ARG_NONE, &automationMode, "Run in automation mode", NULL },
    106108    { "enable-itp", 0, 0, G_OPTION_ARG_NONE, &enableIntelligentTrackingPrevention, "Enable intelligent tracking prevention", NULL },
     109    { "cookies-file", 'c', 0, G_OPTION_ARG_FILENAME, &cookiesFile, "Persistent cookie storage database file", "FILE" },
     110    { "cookies-policy", 0, 0, G_OPTION_ARG_STRING, &cookiesPolicy, "Cookies accept policy (always, never, no-third-party). Default: no-third-party", "POLICY" },
    107111    { "proxy", 0, 0, G_OPTION_ARG_STRING, &proxy, "Set proxy", "PROXY" },
    108112    { "ignore-host", 0, 0, G_OPTION_ARG_STRING_ARRAY, &ignoreHosts, "Set proxy ignore hosts", "HOSTS" },
    … …  
    497501    WebKitWebContext *webContext = (privateMode || automationMode) ? webkit_web_context_new_ephemeral() : webkit_web_context_get_default();
    498502
     503    if (cookiesPolicy) {
     504        WebKitCookieManager *cookieManager = webkit_web_context_get_cookie_manager(webContext);
     505        GEnumClass *enumClass = g_type_class_ref(WEBKIT_TYPE_COOKIE_ACCEPT_POLICY);
     506        GEnumValue *enumValue = g_enum_get_value_by_nick(enumClass, cookiesPolicy);
     507        if (enumValue)
     508            webkit_cookie_manager_set_accept_policy(cookieManager, enumValue->value);
     509        g_type_class_unref(enumClass);
     510    }
     511
     512    if (cookiesFile && !webkit_web_context_is_ephemeral(webContext)) {
     513        WebKitCookieManager *cookieManager = webkit_web_context_get_cookie_manager(webContext);
     514        WebKitCookiePersistentStorage storageType = g_str_has_suffix(cookiesFile, ".txt") ? WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT : WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE;
     515        webkit_cookie_manager_set_persistent_storage(cookieManager, cookiesFile, storageType);
     516    }
     517
    499518    if (proxy) {
    500519        WebKitNetworkProxySettings *webkitProxySettings = webkit_network_proxy_settings_new(proxy, ignoreHosts);
Note: See TracChangeset for help on using the changeset viewer.