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

Changeset 176512 in webkit


Ignore:
Timestamp:
Nov 23, 2014, 11:24:01 PM (12 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Add API to override the default local storage directory
https://bugs.webkit.org/show_bug.cgi?id=138828

Reviewed by Gustavo Noronha Silva.

Source/WebKit2:

Add WebKitWebContext:local-storage-directory construct-only
property. If not provided the default will be used.

  • UIProcess/API/gtk/WebKitWebContext.cpp:

(webkitWebContextGetProperty):
(webkitWebContextSetProperty):
(webkitWebContextConstructed):
(webkit_web_context_class_init):

Tools:

Add test to check that the local storage directory is created at
the path given on construction.

  • TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp:

(testWebContextConfiguration):
(beforeAll):

  • TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h:

(Test::Test):
(Test::~Test): Deleted.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r176511 r176512  
     12014-11-23  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Add API to override the default local storage directory
     4        https://bugs.webkit.org/show_bug.cgi?id=138828
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        Add WebKitWebContext:local-storage-directory construct-only
     9        property. If not provided the default will be used.
     10
     11        * UIProcess/API/gtk/WebKitWebContext.cpp:
     12        (webkitWebContextGetProperty):
     13        (webkitWebContextSetProperty):
     14        (webkitWebContextConstructed):
     15        (webkit_web_context_class_init):
     16
    1172014-11-23  Conrad Shultz  <conrad_shultz@apple.com>
    218
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp

    r176256 r176512  
    4949#include <WebCore/IconDatabase.h>
    5050#include <WebCore/Language.h>
     51#include <glib/gi18n-lib.h>
    5152#include <libintl.h>
    5253#include <memory>
     
    9495 *
    9596 */
     97
     98enum {
     99    PROP_0,
     100
     101    PROP_LOCAL_STORAGE_DIRECTORY
     102};
    96103
    97104enum {
     
    170177    CString webExtensionsDirectory;
    171178    GRefPtr<GVariant> webExtensionsInitializationUserData;
     179
     180    CString localStorageDirectory;
    172181};
    173182
     
    213222}
    214223
     224static void webkitWebContextGetProperty(GObject* object, guint propID, GValue* value, GParamSpec* paramSpec)
     225{
     226    WebKitWebContext* context = WEBKIT_WEB_CONTEXT(object);
     227
     228    switch (propID) {
     229    case PROP_LOCAL_STORAGE_DIRECTORY:
     230        g_value_set_string(value, context->priv->localStorageDirectory.data());
     231        break;
     232    default:
     233        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propID, paramSpec);
     234    }
     235}
     236
     237static void webkitWebContextSetProperty(GObject* object, guint propID, const GValue* value, GParamSpec* paramSpec)
     238{
     239    WebKitWebContext* context = WEBKIT_WEB_CONTEXT(object);
     240
     241    switch (propID) {
     242    case PROP_LOCAL_STORAGE_DIRECTORY:
     243        context->priv->localStorageDirectory = g_value_get_string(value);
     244        break;
     245    default:
     246        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propID, paramSpec);
     247    }
     248}
     249
    215250static void webkitWebContextConstructed(GObject* object)
    216251{
     
    221256    webContextConfiguration.injectedBundlePath = WebCore::filenameToString(bundleFilename.get());
    222257    WebContext::applyPlatformSpecificConfigurationDefaults(webContextConfiguration);
    223 
    224258    WebKitWebContext* webContext = WEBKIT_WEB_CONTEXT(object);
    225259    WebKitWebContextPrivate* priv = webContext->priv;
     260    if (!priv->localStorageDirectory.isNull())
     261        webContextConfiguration.localStorageDirectory = WebCore::filenameToString(priv->localStorageDirectory.data());
     262
    226263    priv->context = WebContext::create(WTF::move(webContextConfiguration));
    227264
     
    266303    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
    267304
     305    gObjectClass->get_property = webkitWebContextGetProperty;
     306    gObjectClass->set_property = webkitWebContextSetProperty;
    268307    gObjectClass->constructed = webkitWebContextConstructed;
    269308    gObjectClass->dispose = webkitWebContextDispose;
     309
     310    /**
     311     * WebKitWebContext:local-storage-directory:
     312     *
     313     * The directory where local storage data will be saved.
     314     *
     315     * Since: 2.8
     316     */
     317    g_object_class_install_property(
     318        gObjectClass,
     319        PROP_LOCAL_STORAGE_DIRECTORY,
     320        g_param_spec_string(
     321            "local-storage-directory",
     322            _("Local Storage Directory"),
     323            _("The directory where local storage data will be saved"),
     324            nullptr,
     325            static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
    270326
    271327    /**
  • trunk/Tools/ChangeLog

    r176488 r176512  
     12014-11-23  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Add API to override the default local storage directory
     4        https://bugs.webkit.org/show_bug.cgi?id=138828
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        Add test to check that the local storage directory is created at
     9        the path given on construction.
     10
     11        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp:
     12        (testWebContextConfiguration):
     13        (beforeAll):
     14        * TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h:
     15        (Test::Test):
     16        (Test::~Test): Deleted.
     17
    1182014-11-21  Zalan Bujtas  <zalan@apple.com>
    219
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp

    r176256 r176512  
    3838}
    3939
     40static void testWebContextConfiguration(WebViewTest* test, gconstpointer)
     41{
     42    GUniquePtr<char> localStorageDirectory(g_build_filename(Test::dataDirectory(), "local-storage", nullptr));
     43    g_assert(g_file_test(localStorageDirectory.get(), G_FILE_TEST_IS_DIR));
     44}
     45
    4046class PluginsTest: public Test {
    4147public:
     
    412418
    413419    Test::add("WebKitWebContext", "default-context", testWebContextDefault);
     420    WebViewTest::add("WebKitWebContext", "configuration", testWebContextConfiguration);
    414421    PluginsTest::add("WebKitWebContext", "get-plugins", testWebContextGetPlugins);
    415422    URISchemeTest::add("WebKitWebContext", "uri-scheme", testWebContextURIScheme);
  • trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h

    r176256 r176512  
    6767
    6868    Test()
    69         : m_webContext(adoptGRef(webkit_web_context_new()))
    7069    {
     70        GUniquePtr<char> localStorageDirectory(g_build_filename(dataDirectory(), "local-storage", nullptr));
     71        m_webContext = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, "local-storage-directory", localStorageDirectory.get(), nullptr)));
     72
    7173        g_signal_connect(m_webContext.get(), "initialize-web-extensions", G_CALLBACK(initializeWebExtensionsCallback), this);
    7274        GUniquePtr<char> diskCacheDirectory(g_build_filename(dataDirectory(), "disk-cache", nullptr));
Note: See TracChangeset for help on using the changeset viewer.