2 * Copyright (C) 2009-2013 Samsung Electronics. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
22 * @file ewk_cookie_manager.h
23 * @brief Describes the Ewk Cookie Manager API.
26 #ifndef ewk_cookie_manager_h
27 #define ewk_cookie_manager_h
30 #include "ewk_error.h"
36 /** Creates a type name for Ewk_Cookie_Manager */
37 typedef struct Ewk_Cookie_Manager Ewk_Cookie_Manager;
40 * \enum Ewk_Cookie_Accept_Policy
42 * @brief Contains accept policies for the cookies.
44 enum Ewk_Cookie_Accept_Policy {
45 /// Accepts every cookie sent from any page.
46 EWK_COOKIE_ACCEPT_POLICY_ALWAYS,
47 /// Rejects all cookies.
48 EWK_COOKIE_ACCEPT_POLICY_NEVER,
49 /// Accepts only cookies set by the main document loaded.
50 EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY
53 /// Creates a type name for the Ewk_Cookie_Accept_Policy.
54 typedef enum Ewk_Cookie_Accept_Policy Ewk_Cookie_Accept_Policy;
57 * \enum Ewk_Cookie_Persistent_Storage
59 * @brief Enum values to denote cookies persistent storage type.
61 enum Ewk_Cookie_Persistent_Storage {
62 /// Cookies are stored in a text file in the Mozilla "cookies.txt" format.
63 EWK_COOKIE_PERSISTENT_STORAGE_TEXT,
64 /// Cookies are stored in a SQLite file in the current Mozilla format.
65 EWK_COOKIE_PERSISTENT_STORAGE_SQLITE
68 /// Creates a type name for the Ewk_Cookie_Persistent_Storage.
69 typedef enum Ewk_Cookie_Persistent_Storage Ewk_Cookie_Persistent_Storage;
72 * @typedef Ewk_Cookie_Manager_Policy_Async_Get_Cb Ewk_Cookie_Manager_Policy_Async_Get_Cb
73 * @brief Callback type for use with ewk_cookie_manager_accept_policy_async_get
75 typedef void (*Ewk_Cookie_Manager_Policy_Async_Get_Cb)(Ewk_Cookie_Accept_Policy policy, void *event_info);
78 * @typedef Ewk_Cookie_Manager_Async_Hostnames_Get_Cb Ewk_Cookie_Manager_Async_Hostnames_Get_Cb
79 * @brief Callback type for use with ewk_cookie_manager_async_hostnames_with_cookies_get
81 * @note The @a hostnames list items are guaranteed to be eina_stringshare. Whenever possible
82 * save yourself some cpu cycles and use eina_stringshare_ref() instead of eina_stringshare_add()
85 typedef void (*Ewk_Cookie_Manager_Async_Hostnames_Get_Cb)(Eina_List *hostnames, Ewk_Error *error, void *event_info);
89 * Set the @a filename where non-session cookies are stored persistently using @a storage as the format to read/write the cookies.
91 * Cookies are initially read from @filename to create an initial set of cookies.
92 * Then, non-session cookies will be written to @filename.
94 * By default, @a manager doesn't store the cookies persistenly, so you need to call this
95 * method to keep cookies saved across sessions.
97 * @param cookie_manager The cookie manager to update.
98 * @param filename the filename to read to/write from.
99 * @param storage the type of storage.
101 EXPORT_API void ewk_cookie_manager_persistent_storage_set(Ewk_Cookie_Manager *manager, const char *filename, Ewk_Cookie_Persistent_Storage storage);
104 * Set @a policy as the cookie acceptance policy for @a manager.
106 * By default, only cookies set by the main document loaded are accepted.
108 * @param manager The cookie manager to update.
109 * @param policy a #Ewk_Cookie_Accept_Policy
112 EXPORT_API void ewk_cookie_manager_accept_policy_set(Ewk_Cookie_Manager *manager, Ewk_Cookie_Accept_Policy policy);
115 * Asynchronously get the cookie acceptance policy of @a manager.
117 * By default, only cookies set by the main document loaded are accepted.
119 * @param manager The cookie manager to query.
120 * @param callback The function to call when the policy is received or an error occured.
121 * @param data User data (may be @c NULL).
123 EXPORT_API void ewk_cookie_manager_accept_policy_async_get(const Ewk_Cookie_Manager *manager, Ewk_Cookie_Manager_Policy_Async_Get_Cb callback, void *data);
126 * Asynchronously get the list of host names for which @a manager contains cookies.
128 * @param manager The cookie manager to query.
129 * @param callback The function to call when the host names have been received.
130 * @param data User data (may be @c NULL).
132 EXPORT_API void ewk_cookie_manager_async_hostnames_with_cookies_get(const Ewk_Cookie_Manager *manager, Ewk_Cookie_Manager_Async_Hostnames_Get_Cb callback, void *data);
135 * Remove all cookies of @a manager for the given @a hostname.
137 * @param manager The cookie manager to update.
138 * @param hostname A host name.
140 EXPORT_API void ewk_cookie_manager_hostname_cookies_clear(Ewk_Cookie_Manager *manager, const char *hostname);
143 * Delete all cookies of @a manager.
145 * @param manager The cookie manager to update.
147 EXPORT_API void ewk_cookie_manager_cookies_clear(Ewk_Cookie_Manager *manager);
153 #endif // ewk_cookie_manager_h