1 // Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
13 // * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 // ---------------------------------------------------------------------------
32 // This file was generated by the CEF translator tool and should not edited
33 // by hand. See the translator.README.txt file in the tools directory for
37 #ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
38 #define CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
41 #include "include/capi/cef_base_capi.h"
42 #include "include/capi/cef_callback_capi.h"
48 struct _cef_cookie_visitor_t;
49 struct _cef_delete_cookies_callback_t;
50 struct _cef_set_cookie_callback_t;
53 // Structure used for managing cookies. The functions of this structure may be
54 // called on any thread unless otherwise indicated.
56 typedef struct _cef_cookie_manager_t {
63 // Set the schemes supported by this manager. By default only "http" and
64 // "https" schemes are supported. If |callback| is non-NULL it will be
65 // executed asnychronously on the IO thread after the change has been applied.
66 // Must be called before any cookies are accessed.
68 void (CEF_CALLBACK *set_supported_schemes)(struct _cef_cookie_manager_t* self,
69 cef_string_list_t schemes, struct _cef_completion_callback_t* callback);
72 // Visit all cookies on the IO thread. The returned cookies are ordered by
73 // longest path, then by earliest creation date. Returns false (0) if cookies
74 // cannot be accessed.
76 int (CEF_CALLBACK *visit_all_cookies)(struct _cef_cookie_manager_t* self,
77 struct _cef_cookie_visitor_t* visitor);
80 // Visit a subset of cookies on the IO thread. The results are filtered by the
81 // given url scheme, host, domain and path. If |includeHttpOnly| is true (1)
82 // HTTP-only cookies will also be included in the results. The returned
83 // cookies are ordered by longest path, then by earliest creation date.
84 // Returns false (0) if cookies cannot be accessed.
86 int (CEF_CALLBACK *visit_url_cookies)(struct _cef_cookie_manager_t* self,
87 const cef_string_t* url, int includeHttpOnly,
88 struct _cef_cookie_visitor_t* visitor);
91 // Sets a cookie given a valid URL and explicit user-provided cookie
92 // attributes. This function expects each attribute to be well-formed. It will
93 // check for disallowed characters (e.g. the ';' character is disallowed
94 // within the cookie value attribute) and fail without setting the cookie if
95 // such characters are found. If |callback| is non-NULL it will be executed
96 // asnychronously on the IO thread after the cookie has been set. Returns
97 // false (0) if an invalid URL is specified or if cookies cannot be accessed.
99 int (CEF_CALLBACK *set_cookie)(struct _cef_cookie_manager_t* self,
100 const cef_string_t* url, const struct _cef_cookie_t* cookie,
101 struct _cef_set_cookie_callback_t* callback);
104 // Delete all cookies that match the specified parameters. If both |url| and
105 // |cookie_name| values are specified all host and domain cookies matching
106 // both will be deleted. If only |url| is specified all host cookies (but not
107 // domain cookies) irrespective of path will be deleted. If |url| is NULL all
108 // cookies for all hosts and domains will be deleted. If |callback| is non-
109 // NULL it will be executed asnychronously on the IO thread after the cookies
110 // have been deleted. Returns false (0) if a non-NULL invalid URL is specified
111 // or if cookies cannot be accessed. Cookies can alternately be deleted using
112 // the Visit*Cookies() functions.
114 int (CEF_CALLBACK *delete_cookies)(struct _cef_cookie_manager_t* self,
115 const cef_string_t* url, const cef_string_t* cookie_name,
116 struct _cef_delete_cookies_callback_t* callback);
119 // Sets the directory path that will be used for storing cookie data. If
120 // |path| is NULL data will be stored in memory only. Otherwise, data will be
121 // stored at the specified |path|. To persist session cookies (cookies without
122 // an expiry date or validity interval) set |persist_session_cookies| to true
123 // (1). Session cookies are generally intended to be transient and most Web
124 // browsers do not persist them. If |callback| is non-NULL it will be executed
125 // asnychronously on the IO thread after the manager's storage has been
126 // initialized. Returns false (0) if cookies cannot be accessed.
128 int (CEF_CALLBACK *set_storage_path)(struct _cef_cookie_manager_t* self,
129 const cef_string_t* path, int persist_session_cookies,
130 struct _cef_completion_callback_t* callback);
133 // Flush the backing store (if any) to disk. If |callback| is non-NULL it will
134 // be executed asnychronously on the IO thread after the flush is complete.
135 // Returns false (0) if cookies cannot be accessed.
137 int (CEF_CALLBACK *flush_store)(struct _cef_cookie_manager_t* self,
138 struct _cef_completion_callback_t* callback);
139 } cef_cookie_manager_t;
143 // Returns the global cookie manager. By default data will be stored at
144 // CefSettings.cache_path if specified or in memory otherwise. If |callback| is
145 // non-NULL it will be executed asnychronously on the IO thread after the
146 // manager's storage has been initialized. Using this function is equivalent to
147 // calling cef_request_tContext::cef_request_context_get_global_context()->get_d
148 // efault_cookie_manager().
150 CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(
151 struct _cef_completion_callback_t* callback);
154 // Creates a new cookie manager. If |path| is NULL data will be stored in memory
155 // only. Otherwise, data will be stored at the specified |path|. To persist
156 // session cookies (cookies without an expiry date or validity interval) set
157 // |persist_session_cookies| to true (1). Session cookies are generally intended
158 // to be transient and most Web browsers do not persist them. If |callback| is
159 // non-NULL it will be executed asnychronously on the IO thread after the
160 // manager's storage has been initialized.
162 CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_create_manager(
163 const cef_string_t* path, int persist_session_cookies,
164 struct _cef_completion_callback_t* callback);
168 // Structure to implement for visiting cookie values. The functions of this
169 // structure will always be called on the IO thread.
171 typedef struct _cef_cookie_visitor_t {
178 // Method that will be called once for each cookie. |count| is the 0-based
179 // index for the current cookie. |total| is the total number of cookies. Set
180 // |deleteCookie| to true (1) to delete the cookie currently being visited.
181 // Return false (0) to stop visiting cookies. This function may never be
182 // called if no cookies are found.
184 int (CEF_CALLBACK *visit)(struct _cef_cookie_visitor_t* self,
185 const struct _cef_cookie_t* cookie, int count, int total,
187 } cef_cookie_visitor_t;
191 // Structure to implement to be notified of asynchronous completion via
192 // cef_cookie_manager_t::set_cookie().
194 typedef struct _cef_set_cookie_callback_t {
201 // Method that will be called upon completion. |success| will be true (1) if
202 // the cookie was set successfully.
204 void (CEF_CALLBACK *on_complete)(struct _cef_set_cookie_callback_t* self,
206 } cef_set_cookie_callback_t;
210 // Structure to implement to be notified of asynchronous completion via
211 // cef_cookie_manager_t::delete_cookies().
213 typedef struct _cef_delete_cookies_callback_t {
220 // Method that will be called upon completion. |num_deleted| will be the
221 // number of cookies that were deleted or -1 if unknown.
223 void (CEF_CALLBACK *on_complete)(struct _cef_delete_cookies_callback_t* self,
225 } cef_delete_cookies_callback_t;
232 #endif // CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_