398b5a910040960c7a23129471de2ff4a99879ee
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / public / ewk_cookie_manager.h
1 /*
2  * Copyright (C) 2009-2013 Samsung Electronics. All rights reserved.
3  *
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.
8  *
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.
13  *
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.
18  *
19  */
20
21 /**
22  * @file    ewk_cookie_manager.h
23  * @brief   Describes the Ewk Cookie Manager API.
24  */
25
26 #ifndef ewk_cookie_manager_h
27 #define ewk_cookie_manager_h
28
29 #include <Eina.h>
30 #include "ewk_error.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /** Creates a type name for Ewk_Cookie_Manager */
37 typedef struct Ewk_Cookie_Manager Ewk_Cookie_Manager;
38
39 /**
40  * \enum    Ewk_Cookie_Accept_Policy
41  *
42  * @brief   Contains accept policies for the cookies.
43  */
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
51 };
52
53 /// Creates a type name for the Ewk_Cookie_Accept_Policy.
54 typedef enum Ewk_Cookie_Accept_Policy Ewk_Cookie_Accept_Policy;
55
56 /**
57  * \enum    Ewk_Cookie_Persistent_Storage
58  *
59  * @brief   Enum values to denote cookies persistent storage type.
60  */
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
66 };
67
68 /// Creates a type name for the Ewk_Cookie_Persistent_Storage.
69 typedef enum Ewk_Cookie_Persistent_Storage Ewk_Cookie_Persistent_Storage;
70
71 /**
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
74  */
75 typedef void (*Ewk_Cookie_Manager_Policy_Async_Get_Cb)(Ewk_Cookie_Accept_Policy policy, void *event_info);
76
77 /**
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
80  *
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()
83  * or strdup().
84  */
85 typedef void (*Ewk_Cookie_Manager_Async_Hostnames_Get_Cb)(Eina_List *hostnames, Ewk_Error *error, void *event_info);
86
87
88 /**
89  * Set the @a filename where non-session cookies are stored persistently using @a storage as the format to read/write the cookies.
90  *
91  * Cookies are initially read from @filename to create an initial set of cookies.
92  * Then, non-session cookies will be written to @filename.
93  *
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.
96  *
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.
100  */
101 EXPORT_API void ewk_cookie_manager_persistent_storage_set(Ewk_Cookie_Manager *manager, const char *filename, Ewk_Cookie_Persistent_Storage storage);
102
103 /**
104  * Set @a policy as the cookie acceptance policy for @a manager.
105  *
106  * By default, only cookies set by the main document loaded are accepted.
107  *
108  * @param manager The cookie manager to update.
109  * @param policy a #Ewk_Cookie_Accept_Policy
110  */
111
112 EXPORT_API void ewk_cookie_manager_accept_policy_set(Ewk_Cookie_Manager *manager, Ewk_Cookie_Accept_Policy policy);
113
114 /**
115  * Asynchronously get the cookie acceptance policy of @a manager.
116  *
117  * By default, only cookies set by the main document loaded are accepted.
118  *
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).
122  */
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);
124
125 /**
126  * Asynchronously get the list of host names for which @a manager contains cookies.
127  *
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).
131  */
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);
133
134 /**
135  * Remove all cookies of @a manager for the given @a hostname.
136  *
137  * @param manager The cookie manager to update.
138  * @param hostname A host name.
139  */
140 EXPORT_API void ewk_cookie_manager_hostname_cookies_clear(Ewk_Cookie_Manager *manager, const char *hostname);
141
142 /**
143  * Delete all cookies of @a manager.
144  *
145  * @param manager The cookie manager to update.
146  */
147 EXPORT_API void ewk_cookie_manager_cookies_clear(Ewk_Cookie_Manager *manager);
148
149 #ifdef __cplusplus
150 }
151 #endif
152
153 #endif // ewk_cookie_manager_h