| 1 | /* |
| 2 | * Copyright (C) 2012 Igalia S.L. |
| 3 | * Copyright (C) 2017 Endless Mobile, Inc. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2,1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Library General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Library General Public License |
| 16 | * along with this library; see the file COPYING.LIB. If not, write to |
| 17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | * Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) |
| 22 | #error "Only <webkit2/webkit2.h> can be included directly." |
| 23 | #endif |
| 24 | |
| 25 | #ifndef WebKitCookieManager_h |
| 26 | #define WebKitCookieManager_h |
| 27 | |
| 28 | #include <gio/gio.h> |
| 29 | #include <glib-object.h> |
| 30 | #include <libsoup/soup.h> |
| 31 | #include <webkit2/WebKitDefines.h> |
| 32 | |
| 33 | G_BEGIN_DECLS |
| 34 | |
| 35 | #define WEBKIT_TYPE_COOKIE_MANAGER (webkit_cookie_manager_get_type()) |
| 36 | #define WEBKIT_COOKIE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_COOKIE_MANAGER, WebKitCookieManager)) |
| 37 | #define WEBKIT_IS_COOKIE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_COOKIE_MANAGER)) |
| 38 | #define WEBKIT_COOKIE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_COOKIE_MANAGER, WebKitCookieManagerClass)) |
| 39 | #define WEBKIT_IS_COOKIE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_COOKIE_MANAGER)) |
| 40 | #define WEBKIT_COOKIE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_COOKIE_MANAGER, WebKitCookieManagerClass)) |
| 41 | |
| 42 | typedef struct _WebKitCookieManager WebKitCookieManager; |
| 43 | typedef struct _WebKitCookieManagerClass WebKitCookieManagerClass; |
| 44 | typedef struct _WebKitCookieManagerPrivate WebKitCookieManagerPrivate; |
| 45 | |
| 46 | /** |
| 47 | * WebKitCookiePersistentStorage: |
| 48 | * @WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT: Cookies are stored in a text |
| 49 | * file in the Mozilla "cookies.txt" format. |
| 50 | * @WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE: Cookies are stored in a SQLite |
| 51 | * file in the current Mozilla format. |
| 52 | * |
| 53 | * Enum values used to denote the cookie persistent storage types. |
| 54 | */ |
| 55 | typedef enum { |
| 56 | WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT, |
| 57 | WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE |
| 58 | } WebKitCookiePersistentStorage; |
| 59 | |
| 60 | /** |
| 61 | * WebKitCookieAcceptPolicy: |
| 62 | * @WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS: Accept all cookies unconditionally. |
| 63 | * @WEBKIT_COOKIE_POLICY_ACCEPT_NEVER: Reject all cookies unconditionally. |
| 64 | * @WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY: Accept only cookies set by the main document loaded. |
| 65 | * |
| 66 | * Enum values used to denote the cookie acceptance policies. |
| 67 | */ |
| 68 | typedef enum { |
| 69 | WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS, |
| 70 | WEBKIT_COOKIE_POLICY_ACCEPT_NEVER, |
| 71 | WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY |
| 72 | } WebKitCookieAcceptPolicy; |
| 73 | |
| 74 | struct _WebKitCookieManager { |
| 75 | GObject parent; |
| 76 | |
| 77 | WebKitCookieManagerPrivate *priv; |
| 78 | }; |
| 79 | |
| 80 | struct _WebKitCookieManagerClass { |
| 81 | GObjectClass parent_class; |
| 82 | |
| 83 | void (*_webkit_reserved0) (void); |
| 84 | void (*_webkit_reserved1) (void); |
| 85 | void (*_webkit_reserved2) (void); |
| 86 | void (*_webkit_reserved3) (void); |
| 87 | }; |
| 88 | |
| 89 | WEBKIT_API GType |
| 90 | webkit_cookie_manager_get_type (void); |
| 91 | |
| 92 | WEBKIT_API void |
| 93 | webkit_cookie_manager_set_persistent_storage (WebKitCookieManager *cookie_manager, |
| 94 | const gchar *filename, |
| 95 | WebKitCookiePersistentStorage storage); |
| 96 | |
| 97 | WEBKIT_API void |
| 98 | webkit_cookie_manager_set_accept_policy (WebKitCookieManager *cookie_manager, |
| 99 | WebKitCookieAcceptPolicy policy); |
| 100 | |
| 101 | WEBKIT_API void |
| 102 | webkit_cookie_manager_get_accept_policy (WebKitCookieManager *cookie_manager, |
| 103 | GCancellable *cancellable, |
| 104 | GAsyncReadyCallback callback, |
| 105 | gpointer user_data); |
| 106 | |
| 107 | WEBKIT_API WebKitCookieAcceptPolicy |
| 108 | webkit_cookie_manager_get_accept_policy_finish (WebKitCookieManager *cookie_manager, |
| 109 | GAsyncResult *result, |
| 110 | GError **error); |
| 111 | |
| 112 | WEBKIT_API void |
| 113 | webkit_cookie_manager_add_cookie (WebKitCookieManager *cookie_manager, |
| 114 | SoupCookie *cookie, |
| 115 | GCancellable *cancellable, |
| 116 | GAsyncReadyCallback callback, |
| 117 | gpointer user_data); |
| 118 | |
| 119 | WEBKIT_API gboolean |
| 120 | webkit_cookie_manager_add_cookie_finish (WebKitCookieManager *cookie_manager, |
| 121 | GAsyncResult *result, |
| 122 | GError **error); |
| 123 | |
| 124 | WEBKIT_API void |
| 125 | webkit_cookie_manager_get_cookies (WebKitCookieManager *cookie_manager, |
| 126 | const gchar *uri, |
| 127 | GCancellable *cancellable, |
| 128 | GAsyncReadyCallback callback, |
| 129 | gpointer user_data); |
| 130 | |
| 131 | WEBKIT_API GList * |
| 132 | webkit_cookie_manager_get_cookies_finish (WebKitCookieManager *cookie_manager, |
| 133 | GAsyncResult *result, |
| 134 | GError **error); |
| 135 | |
| 136 | WEBKIT_API void |
| 137 | webkit_cookie_manager_delete_cookie (WebKitCookieManager *cookie_manager, |
| 138 | SoupCookie *cookie, |
| 139 | GCancellable *cancellable, |
| 140 | GAsyncReadyCallback callback, |
| 141 | gpointer user_data); |
| 142 | |
| 143 | WEBKIT_API gboolean |
| 144 | webkit_cookie_manager_delete_cookie_finish (WebKitCookieManager *cookie_manager, |
| 145 | GAsyncResult *result, |
| 146 | GError **error); |
| 147 | |
| 148 | WEBKIT_DEPRECATED_FOR(webkit_website_data_manager_fetch) void |
| 149 | webkit_cookie_manager_get_domains_with_cookies (WebKitCookieManager *cookie_manager, |
| 150 | GCancellable *cancellable, |
| 151 | GAsyncReadyCallback callback, |
| 152 | gpointer user_data); |
| 153 | |
| 154 | WEBKIT_DEPRECATED_FOR(webkit_website_data_manager_fetch_finish) gchar ** |
| 155 | webkit_cookie_manager_get_domains_with_cookies_finish (WebKitCookieManager *cookie_manager, |
| 156 | GAsyncResult *result, |
| 157 | GError **error); |
| 158 | |
| 159 | WEBKIT_DEPRECATED_FOR(webkit_website_data_manager_remove) void |
| 160 | webkit_cookie_manager_delete_cookies_for_domain (WebKitCookieManager *cookie_manager, |
| 161 | const gchar *domain); |
| 162 | |
| 163 | WEBKIT_DEPRECATED_FOR(webkit_website_data_manager_clear) void |
| 164 | webkit_cookie_manager_delete_all_cookies (WebKitCookieManager *cookie_manager); |
| 165 | |
| 166 | G_END_DECLS |
| 167 | |
| 168 | #endif |
| 169 | |