Title: [122969] trunk/Source/WebKit2
Revision
122969
Author
[email protected]
Date
2012-07-18 07:41:22 -0700 (Wed, 18 Jul 2012)

Log Message

[EFL][WK2] Add Ewk class for cookie manager
https://bugs.webkit.org/show_bug.cgi?id=91053

Patch by Christophe Dumez <[email protected]> on 2012-07-18
Reviewed by Gustavo Noronha Silva.

Add new Ewk_Cookie_Manager class to allow the client
to set/get the cookie acceptance policy, support
persistent cookie storage and clear cookies.

The Ewk_Cookie_Manager instance can be retrieved
from the Ewk_Context API.

* PlatformEfl.cmake:
* UIProcess/API/efl/EWebKit2.h:
* UIProcess/API/efl/ewk_context.cpp:
(_Ewk_Context):
(_Ewk_Context::_Ewk_Context):
(_Ewk_Context::~_Ewk_Context):
(ewk_context_cookie_manager_get):
* UIProcess/API/efl/ewk_context.h:
* UIProcess/API/efl/ewk_cookie_manager.cpp: Added.
(_Ewk_Cookie_Manager):
(_Ewk_Cookie_Manager::_Ewk_Cookie_Manager):
(ewk_cookie_manager_persistent_storage_set):
(ewk_cookie_manager_accept_policy_set):
(Get_Policy_Async_Data):
(getAcceptPolicyCallback):
(ewk_cookie_manager_async_accept_policy_get):
(Get_Hostnames_Async_Data):
(getHostnamesWithCookiesCallback):
(ewk_cookie_manager_async_hostnames_with_cookies_get):
(ewk_cookie_manager_hostname_cookies_clear):
(ewk_cookie_manager_cookies_clear):
(ewk_cookie_manager_free):
(ewk_cookie_manager_new):
* UIProcess/API/efl/ewk_cookie_manager.h: Added.
* UIProcess/API/efl/ewk_cookie_manager_private.h: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (122968 => 122969)


--- trunk/Source/WebKit2/ChangeLog	2012-07-18 14:38:32 UTC (rev 122968)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-18 14:41:22 UTC (rev 122969)
@@ -1,3 +1,43 @@
+2012-07-18  Christophe Dumez  <[email protected]>
+
+        [EFL][WK2] Add Ewk class for cookie manager
+        https://bugs.webkit.org/show_bug.cgi?id=91053
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Add new Ewk_Cookie_Manager class to allow the client
+        to set/get the cookie acceptance policy, support
+        persistent cookie storage and clear cookies.
+
+        The Ewk_Cookie_Manager instance can be retrieved
+        from the Ewk_Context API.
+
+        * PlatformEfl.cmake:
+        * UIProcess/API/efl/EWebKit2.h:
+        * UIProcess/API/efl/ewk_context.cpp:
+        (_Ewk_Context):
+        (_Ewk_Context::_Ewk_Context):
+        (_Ewk_Context::~_Ewk_Context):
+        (ewk_context_cookie_manager_get):
+        * UIProcess/API/efl/ewk_context.h:
+        * UIProcess/API/efl/ewk_cookie_manager.cpp: Added.
+        (_Ewk_Cookie_Manager):
+        (_Ewk_Cookie_Manager::_Ewk_Cookie_Manager):
+        (ewk_cookie_manager_persistent_storage_set):
+        (ewk_cookie_manager_accept_policy_set):
+        (Get_Policy_Async_Data):
+        (getAcceptPolicyCallback):
+        (ewk_cookie_manager_async_accept_policy_get):
+        (Get_Hostnames_Async_Data):
+        (getHostnamesWithCookiesCallback):
+        (ewk_cookie_manager_async_hostnames_with_cookies_get):
+        (ewk_cookie_manager_hostname_cookies_clear):
+        (ewk_cookie_manager_cookies_clear):
+        (ewk_cookie_manager_free):
+        (ewk_cookie_manager_new):
+        * UIProcess/API/efl/ewk_cookie_manager.h: Added.
+        * UIProcess/API/efl/ewk_cookie_manager_private.h: Added.
+
 2012-07-18  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Add WebKitWebView::submit-form signal to WebKit2 GTK+ API

Modified: trunk/Source/WebKit2/PlatformEfl.cmake (122968 => 122969)


--- trunk/Source/WebKit2/PlatformEfl.cmake	2012-07-18 14:38:32 UTC (rev 122968)
+++ trunk/Source/WebKit2/PlatformEfl.cmake	2012-07-18 14:41:22 UTC (rev 122969)
@@ -37,6 +37,7 @@
     UIProcess/API/efl/BatteryProvider.cpp
     UIProcess/API/efl/PageClientImpl.cpp
     UIProcess/API/efl/ewk_context.cpp
+    UIProcess/API/efl/ewk_cookie_manager.cpp
     UIProcess/API/efl/ewk_intent.cpp
     UIProcess/API/efl/ewk_intent_service.cpp
     UIProcess/API/efl/ewk_navigation_policy_decision.cpp
@@ -172,6 +173,7 @@
 SET (EWebKit2_HEADERS
     "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/EWebKit2.h"
     "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_context.h"
+    "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_cookie_manager.h"
     "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_intent.h"
     "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_intent_service.h"
     "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_navigation_policy_decision.h"

Modified: trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h (122968 => 122969)


--- trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h	2012-07-18 14:38:32 UTC (rev 122968)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h	2012-07-18 14:41:22 UTC (rev 122969)
@@ -28,6 +28,7 @@
 #define EWebKit2_h
 
 #include "ewk_context.h"
+#include "ewk_cookie_manager.h"
 #include "ewk_intent.h"
 #include "ewk_intent_service.h"
 #include "ewk_navigation_policy_decision.h"

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp (122968 => 122969)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp	2012-07-18 14:38:32 UTC (rev 122968)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp	2012-07-18 14:41:22 UTC (rev 122969)
@@ -25,20 +25,40 @@
 #include "WKAPICast.h"
 #include "WKRetainPtr.h"
 #include "ewk_context_private.h"
+#include "ewk_cookie_manager_private.h"
 
 using namespace WebKit;
 
 struct _Ewk_Context {
     WKRetainPtr<WKContextRef> context;
+
+    Ewk_Cookie_Manager* cookieManager;
 #if ENABLE(BATTERY_STATUS)
     RefPtr<BatteryProvider> batteryProvider;
 #endif
 
     _Ewk_Context(WKContextRef contextRef)
         : context(contextRef)
+        , cookieManager(0)
     { }
+
+    ~_Ewk_Context()
+    {
+        if (cookieManager)
+            ewk_cookie_manager_free(cookieManager);
+    }
 };
 
+Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* ewkContext)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
+
+    if (!ewkContext->cookieManager)
+        const_cast<Ewk_Context*>(ewkContext)->cookieManager = ewk_cookie_manager_new(WKContextGetCookieManager(ewkContext->context.get()));
+
+    return ewkContext->cookieManager;
+}
+
 WKContextRef ewk_context_WKContext_get(const Ewk_Context* ewkContext)
 {
     return ewkContext->context.get();

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.h (122968 => 122969)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.h	2012-07-18 14:38:32 UTC (rev 122968)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.h	2012-07-18 14:41:22 UTC (rev 122969)
@@ -29,6 +29,7 @@
 #ifndef ewk_context_h
 #define ewk_context_h
 
+#include "ewk_cookie_manager.h"
 #include <Evas.h>
 
 #ifdef __cplusplus
@@ -45,6 +46,15 @@
  */
 EAPI Ewk_Context *ewk_context_default_get();
 
+/**
+ * Gets the cookie manager instance for this @a context.
+ *
+ * @param context context object to query.
+ *
+ * @return Ewk_Cookie_Manager object instance or @c NULL in case of failure.
+ */
+EAPI Ewk_Cookie_Manager *ewk_context_cookie_manager_get(const Ewk_Context *context);
+
 #ifdef __cplusplus
 }
 #endif

Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp (0 => 122969)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp	2012-07-18 14:41:22 UTC (rev 122969)
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ewk_cookie_manager.h"
+
+#include "SoupCookiePersistentStorageType.h"
+#include "WKAPICast.h"
+#include "WKArray.h"
+#include "WKCookieManager.h"
+#include "WKRetainPtr.h"
+#include "WKString.h"
+#include "WebCookieManagerProxy.h"
+#include "ewk_private.h"
+#include "ewk_web_error_private.h"
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebKit;
+
+/**
+ * \struct  _Ewk_Cookie_Manager
+ * @brief   Contains the cookie manager data.
+ */
+struct _Ewk_Cookie_Manager {
+    WKRetainPtr<WKCookieManagerRef> wkCookieManager;
+
+    _Ewk_Cookie_Manager(WKCookieManagerRef cookieManagerRef)
+        : wkCookieManager(cookieManagerRef)
+    { }
+};
+
+#define EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager_, ...)    \
+    if (!(manager)) {                                                    \
+        EINA_LOG_CRIT("manager is NULL.");                               \
+        return __VA_ARGS__;                                              \
+    }                                                                    \
+    if (!(manager)->wkCookieManager) {                                   \
+        EINA_LOG_CRIT("manager->wkCookieManager is NULL.");              \
+        return __VA_ARGS__;                                              \
+    }                                                                    \
+    WKCookieManagerRef wkManager_ = (manager)->wkCookieManager.get()
+
+// Ewk_Cookie_Accept_Policy enum validation
+COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_ACCEPT_POLICY_ALWAYS, kWKHTTPCookieAcceptPolicyAlways);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_ACCEPT_POLICY_NEVER, kWKHTTPCookieAcceptPolicyNever);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY, kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain);
+
+// Ewk_Cookie_Persistent_Storage enum validation
+COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_PERSISTENT_STORAGE_TEXT, SoupCookiePersistentStorageText);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_COOKIE_PERSISTENT_STORAGE_SQLITE, SoupCookiePersistentStorageSQLite);
+
+void ewk_cookie_manager_persistent_storage_set(Ewk_Cookie_Manager* manager, const char* filename, Ewk_Cookie_Persistent_Storage storage)
+{
+    EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager);
+    EINA_SAFETY_ON_NULL_RETURN(filename);
+
+    toImpl(wkManager)->setCookiePersistentStorage(String::fromUTF8(filename), storage);
+}
+
+void ewk_cookie_manager_accept_policy_set(Ewk_Cookie_Manager* manager, Ewk_Cookie_Accept_Policy policy)
+{
+    EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager);
+
+    WKCookieManagerSetHTTPCookieAcceptPolicy(wkManager, static_cast<WKHTTPCookieAcceptPolicy>(policy));
+}
+
+struct Get_Policy_Async_Data {
+    Ewk_Cookie_Manager_Async_Policy_Get_Cb callback;
+    void* userData;
+};
+
+static void getAcceptPolicyCallback(WKHTTPCookieAcceptPolicy policy, WKErrorRef wkError, void* data)
+{
+    Get_Policy_Async_Data* callbackData = static_cast<Get_Policy_Async_Data*>(data);
+    Ewk_Web_Error* ewkError = wkError ? ewk_web_error_new(wkError) : 0;
+
+    callbackData->callback(static_cast<Ewk_Cookie_Accept_Policy>(policy), ewkError, callbackData->userData);
+
+    if (ewkError)
+        ewk_web_error_free(ewkError);
+    delete callbackData;
+}
+
+void ewk_cookie_manager_async_accept_policy_get(const Ewk_Cookie_Manager* manager, Ewk_Cookie_Manager_Async_Policy_Get_Cb callback, void* data)
+{
+    EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager);
+    EINA_SAFETY_ON_NULL_RETURN(callback);
+
+    Get_Policy_Async_Data* callbackData = new Get_Policy_Async_Data;
+    callbackData->callback = callback;
+    callbackData->userData = data;
+
+    WKCookieManagerGetHTTPCookieAcceptPolicy(wkManager, callbackData, getAcceptPolicyCallback);
+}
+
+struct Get_Hostnames_Async_Data {
+    Ewk_Cookie_Manager_Async_Hostnames_Get_Cb callback;
+    void* userData;
+};
+
+static void getHostnamesWithCookiesCallback(WKArrayRef wkHostnames, WKErrorRef wkError, void* context)
+{
+    Eina_List* hostnames = 0;
+    Get_Hostnames_Async_Data* callbackData = static_cast<Get_Hostnames_Async_Data*>(context);
+    Ewk_Web_Error* ewkError = wkError ? ewk_web_error_new(wkError) : 0;
+
+    const size_t hostnameCount = WKArrayGetSize(wkHostnames);
+    for (size_t i = 0; i < hostnameCount; ++i) {
+        WKStringRef wkHostname = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkHostnames, i));
+        String hostname = toImpl(wkHostname)->string();
+        if (hostname.isEmpty())
+            continue;
+        hostnames = eina_list_append(hostnames, eina_stringshare_add(hostname.utf8().data()));
+    }
+
+    callbackData->callback(hostnames, ewkError, callbackData->userData);
+
+    void* item;
+    EINA_LIST_FREE(hostnames, item)
+      eina_stringshare_del(static_cast<Eina_Stringshare*>(item));
+    if (ewkError)
+        ewk_web_error_free(ewkError);
+    delete callbackData;
+}
+
+void ewk_cookie_manager_async_hostnames_with_cookies_get(const Ewk_Cookie_Manager* manager, Ewk_Cookie_Manager_Async_Hostnames_Get_Cb callback, void* data)
+{
+    EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager);
+    EINA_SAFETY_ON_NULL_RETURN(callback);
+
+    Get_Hostnames_Async_Data* callbackData = new Get_Hostnames_Async_Data;
+    callbackData->callback = callback;
+    callbackData->userData = data;
+
+    WKCookieManagerGetHostnamesWithCookies(wkManager, callbackData, getHostnamesWithCookiesCallback);
+}
+
+void ewk_cookie_manager_hostname_cookies_clear(Ewk_Cookie_Manager* manager, const char* hostName)
+{
+    EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager);
+    EINA_SAFETY_ON_NULL_RETURN(hostName);
+
+    WKRetainPtr<WKStringRef> wkHostName(AdoptWK, WKStringCreateWithUTF8CString(hostName));
+    WKCookieManagerDeleteCookiesForHostname(wkManager, wkHostName.get());
+}
+
+void ewk_cookie_manager_cookies_clear(Ewk_Cookie_Manager* manager)
+{
+    EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager);
+
+    WKCookieManagerDeleteAllCookies(wkManager);
+}
+
+/**
+ * @internal
+ * Frees a Ewk_Cookie_Manager object.
+ */
+void ewk_cookie_manager_free(Ewk_Cookie_Manager* manager)
+{
+    EINA_SAFETY_ON_NULL_RETURN(manager);
+
+    delete manager;
+}
+
+/**
+ * @internal
+ * Constructs a Ewk_Cookie_Manager from a WKCookieManagerRef.
+ */
+Ewk_Cookie_Manager* ewk_cookie_manager_new(WKCookieManagerRef wkCookieManager)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(wkCookieManager, 0);
+
+    return new Ewk_Cookie_Manager(wkCookieManager);
+}

Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h (0 => 122969)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h	2012-07-18 14:41:22 UTC (rev 122969)
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file    ewk_cookie_manager.h
+ * @brief   Describes the Ewk Cookie Manager API.
+ */
+
+#ifndef ewk_cookie_manager_h
+#define ewk_cookie_manager_h
+
+#include "ewk_web_error.h"
+#include <Eina.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Creates a type name for _Ewk_Cookie_Manager */
+typedef struct _Ewk_Cookie_Manager Ewk_Cookie_Manager;
+
+/**
+ * \enum    _Ewk_Cookie_Accept_Policy
+ *
+ * @brief   Contains accept policies for the cookies.
+ */
+enum _Ewk_Cookie_Accept_Policy {
+    /// Accepts every cookie sent from any page.
+    EWK_COOKIE_ACCEPT_POLICY_ALWAYS,
+    /// Rejects all cookies.
+    EWK_COOKIE_ACCEPT_POLICY_NEVER,
+    /// Accepts cookies only from the main page.
+    EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY
+};
+
+/// Creates a type name for the _Ewk_Cookie_Accept_Policy.
+typedef enum _Ewk_Cookie_Accept_Policy Ewk_Cookie_Accept_Policy;
+
+/**
+ * \enum    _Ewk_Cookie_Persistent_Storage
+ *
+ * @brief   Enum values to denote cookies persistent storage type.
+ */
+enum _Ewk_Cookie_Persistent_Storage {
+    /// Cookies are stored in a text file in the Mozilla "cookies.txt" format.
+    EWK_COOKIE_PERSISTENT_STORAGE_TEXT,
+    /// Cookies are stored in a SQLite file in the current Mozilla format.
+    EWK_COOKIE_PERSISTENT_STORAGE_SQLITE
+};
+
+/// Creates a type name for the _Ewk_Cookie_Persistent_Storage.
+typedef enum _Ewk_Cookie_Persistent_Storage Ewk_Cookie_Persistent_Storage;
+
+/**
+ * @typedef Ewk_Cookie_Manager_Async_Policy_Get_Cb Ewk_Cookie_Manager_Async_Policy_Get_Cb
+ * @brief Callback type for use with ewk_cookie_manager_async_accept_policy_get
+ */
+typedef void (*Ewk_Cookie_Manager_Async_Policy_Get_Cb)(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *error, void *event_info);
+
+/**
+ * @typedef Ewk_Cookie_Manager_Async_Hostnames_Get_Cb Ewk_Cookie_Manager_Async_Hostnames_Get_Cb
+ * @brief Callback type for use with ewk_cookie_manager_async_hostnames_with_cookies_get
+ *
+ * @note The @a hostnames list items are guaranteed to be eina_stringshare. Whenever possible
+ * save yourself some cpu cycles and use eina_stringshare_ref() instead of eina_stringshare_add()
+ * or strdup().
+ */
+typedef void (*Ewk_Cookie_Manager_Async_Hostnames_Get_Cb)(Eina_List* hostnames, Ewk_Web_Error *error, void *event_info);
+
+/**
+ * Set the @a filename where non-session cookies are stored persistently using @a storage as the format to read/write the cookies.
+ *
+ * Cookies are initially read from @filename to create an initial set of cookies.
+ * Then, non-session cookies will be written to @filename.
+ *
+ * By default, @a manager doesn't store the cookies persistenly, so you need to call this
+ * method to keep cookies saved across sessions.
+ *
+ * @param cookie_manager The cookie manager to update.
+ * @param filename the filename to read to/write from.
+ * @param storage the type of storage.
+ */
+void ewk_cookie_manager_persistent_storage_set(Ewk_Cookie_Manager *manager, const char *filename, Ewk_Cookie_Persistent_Storage storage);
+
+/**
+ * Set @a policy as the cookie acceptance policy for @a manager.
+ *
+ * By default, cookies are always accepted.
+ *
+ * @param manager The cookie manager to update.
+ * @param policy a #Ewk_Cookie_Accept_Policy
+ */
+
+EAPI void ewk_cookie_manager_accept_policy_set(Ewk_Cookie_Manager *manager, Ewk_Cookie_Accept_Policy policy);
+
+/**
+ * Asynchronously get the cookie acceptance policy of @a manager.
+ *
+ * By default, cookies are always accepted.
+ *
+ * @param manager The cookie manager to query.
+ * @param callback The function to call when the policy is received or an error occured.
+ * @param data User data (may be @c NULL).
+ */
+EAPI void ewk_cookie_manager_async_accept_policy_get(const Ewk_Cookie_Manager *manager, Ewk_Cookie_Manager_Async_Policy_Get_Cb callback, void *data);
+
+/**
+ * Asynchronously get the list of host names for which @a manager contains cookies.
+ *
+ * @param manager The cookie manager to query.
+ * @param callback The function to call when the host names have been received.
+ * @param data User data (may be @c NULL).
+ */
+EAPI void ewk_cookie_manager_async_hostnames_with_cookies_get(const Ewk_Cookie_Manager *manager, Ewk_Cookie_Manager_Async_Hostnames_Get_Cb callback, void *data);
+
+/**
+ * Remove all cookies of @a manager for the given @a hostname.
+ *
+ * @param manager The cookie manager to update.
+ * @param hostname A host name.
+ */
+EAPI void ewk_cookie_manager_hostname_cookies_clear(Ewk_Cookie_Manager *manager, const char *hostname);
+
+/**
+ * Delete all cookies of @a manager.
+ *
+ * @param manager The cookie manager to update.
+ */
+EAPI void ewk_cookie_manager_cookies_clear(Ewk_Cookie_Manager *manager);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ewk_cookie_manager_h

Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h (0 => 122969)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h	2012-07-18 14:41:22 UTC (rev 122969)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ewk_cookie_manager_private_h
+#define ewk_cookie_manager_private_h
+
+#include <WebKit2/WKBase.h>
+
+typedef struct _Ewk_Cookie_Manager Ewk_Cookie_Manager;
+
+Ewk_Cookie_Manager* ewk_cookie_manager_new(WKCookieManagerRef wkCookieManager);
+void ewk_cookie_manager_free(Ewk_Cookie_Manager* manager);
+
+#endif // ewk_cookie_manager_private_h
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to