2 * Copyright (C) 2012 Intel Corporation. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 * @file ewk_cookie_manager.h
28 * @brief Describes the Ewk Cookie Manager API.
31 #ifndef ewk_cookie_manager_h
32 #define ewk_cookie_manager_h
34 #include "ewk_error.h"
41 /** Creates a type name for Ewk_Cookie_Manager */
42 typedef struct Ewk_Cookie_Manager Ewk_Cookie_Manager;
45 * \enum Ewk_Cookie_Accept_Policy
47 * @brief Contains accept policies for the cookies.
49 enum Ewk_Cookie_Accept_Policy {
50 /// Accepts every cookie sent from any page.
51 EWK_COOKIE_ACCEPT_POLICY_ALWAYS,
52 /// Rejects all cookies.
53 EWK_COOKIE_ACCEPT_POLICY_NEVER,
54 /// Accepts only cookies set by the main document loaded.
55 EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY
58 /// Creates a type name for the Ewk_Cookie_Accept_Policy.
59 typedef enum Ewk_Cookie_Accept_Policy Ewk_Cookie_Accept_Policy;
62 * \enum Ewk_Cookie_Persistent_Storage
64 * @brief Enum values to denote cookies persistent storage type.
66 enum Ewk_Cookie_Persistent_Storage {
67 /// Cookies are stored in a text file in the Mozilla "cookies.txt" format.
68 EWK_COOKIE_PERSISTENT_STORAGE_TEXT,
69 /// Cookies are stored in a SQLite file in the current Mozilla format.
70 EWK_COOKIE_PERSISTENT_STORAGE_SQLITE
73 /// Creates a type name for the Ewk_Cookie_Persistent_Storage.
74 typedef enum Ewk_Cookie_Persistent_Storage Ewk_Cookie_Persistent_Storage;
77 * @typedef Ewk_Cookie_Manager_Async_Policy_Get_Cb Ewk_Cookie_Manager_Async_Policy_Get_Cb
78 * @brief Callback type for use with ewk_cookie_manager_async_accept_policy_get
80 typedef void (*Ewk_Cookie_Manager_Async_Policy_Get_Cb)(Ewk_Cookie_Accept_Policy policy, Ewk_Error *error, void *event_info);
83 * @typedef Ewk_Cookie_Manager_Async_Hostnames_Get_Cb Ewk_Cookie_Manager_Async_Hostnames_Get_Cb
84 * @brief Callback type for use with ewk_cookie_manager_async_hostnames_with_cookies_get
86 * @note The @a hostnames list items are guaranteed to be eina_stringshare. Whenever possible
87 * save yourself some cpu cycles and use eina_stringshare_ref() instead of eina_stringshare_add()
90 typedef void (*Ewk_Cookie_Manager_Async_Hostnames_Get_Cb)(Eina_List *hostnames, Ewk_Error *error, void *event_info);
93 * @typedef Ewk_Cookie_Manager_Changes_Watch_Cb Ewk_Cookie_Manager_Changes_Watch_Cb
94 * @brief Callback type for use with ewk_cookie_manager_changes_watch()
96 typedef void (*Ewk_Cookie_Manager_Changes_Watch_Cb)(void *event_info);
99 * Set the @a filename where non-session cookies are stored persistently using @a storage as the format to read/write the cookies.
101 * Cookies are initially read from @filename to create an initial set of cookies.
102 * Then, non-session cookies will be written to @filename.
104 * By default, @a manager doesn't store the cookies persistenly, so you need to call this
105 * method to keep cookies saved across sessions.
107 * @param cookie_manager The cookie manager to update.
108 * @param filename the filename to read to/write from.
109 * @param storage the type of storage.
111 EAPI void ewk_cookie_manager_persistent_storage_set(Ewk_Cookie_Manager *manager, const char *filename, Ewk_Cookie_Persistent_Storage storage);
114 * Set @a policy as the cookie acceptance policy for @a manager.
116 * By default, only cookies set by the main document loaded are accepted.
118 * @param manager The cookie manager to update.
119 * @param policy a #Ewk_Cookie_Accept_Policy
122 EAPI void ewk_cookie_manager_accept_policy_set(Ewk_Cookie_Manager *manager, Ewk_Cookie_Accept_Policy policy);
125 * Asynchronously get the cookie acceptance policy of @a manager.
127 * By default, only cookies set by the main document loaded are accepted.
129 * @param manager The cookie manager to query.
130 * @param callback The function to call when the policy is received or an error occured.
131 * @param data User data (may be @c NULL).
133 EAPI void ewk_cookie_manager_async_accept_policy_get(const Ewk_Cookie_Manager *manager, Ewk_Cookie_Manager_Async_Policy_Get_Cb callback, void *data);
136 * Asynchronously get the list of host names for which @a manager contains cookies.
138 * @param manager The cookie manager to query.
139 * @param callback The function to call when the host names have been received.
140 * @param data User data (may be @c NULL).
142 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);
145 * Remove all cookies of @a manager for the given @a hostname.
147 * @param manager The cookie manager to update.
148 * @param hostname A host name.
150 EAPI void ewk_cookie_manager_hostname_cookies_clear(Ewk_Cookie_Manager *manager, const char *hostname);
153 * Watch for cookies changes in @a manager.
155 * Pass @c NULL as value for @a callback to stop watching for changes.
157 * @param manager The cookie manager to watch.
158 * @param callback function that will be called every time cookies are added, removed or modified.
159 * @param data User data (may be @c NULL).
161 EAPI void ewk_cookie_manager_changes_watch(Ewk_Cookie_Manager *manager, Ewk_Cookie_Manager_Changes_Watch_Cb callback, void *data);
164 * Delete all cookies of @a manager.
166 * @param manager The cookie manager to update.
168 EAPI void ewk_cookie_manager_cookies_clear(Ewk_Cookie_Manager *manager);
174 #endif // ewk_cookie_manager_h