2 * Copyright (C) 2016 Samsung Electronics
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 program 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 License
15 * along with this program; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
22 * @brief This file describes the Ewk Context API.
24 * @remarks ewk_context encapsulates all pages related to the specific use of
27 * Applications have the option of creating a context different from the default
28 * one and using it for a group of pages. All pages in the same context share
29 * the same preferences, visited link set, local storage, and so on.
31 * A process model can be specified per context. The default one is the shared
32 * model where the web-engine process is shared among the pages in the context.
33 * The second model allows each page to use a separate web-engine process.
34 * This latter model is currently not supported by Chromium-efl.
44 #include "ewk_autofill_profile.h"
45 #include "ewk_cookie_manager.h"
46 #include "ewk_intercept_request.h"
58 * @brief The structure type that creates a type name for #Ewk_Context.
59 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
61 typedef struct Ewk_Context Ewk_Context;
64 * \enum Ewk_Cache_Model
65 * @brief Contains option for cache model
69 enum _Ewk_Cache_Model {
70 EWK_CACHE_MODEL_DOCUMENT_VIEWER, /* Use the smallest cache capacity. */
71 EWK_CACHE_MODEL_DOCUMENT_BROWSER, /* Use bigger cache capacity than EWK_CACHE_MODEL_DOCUMENT_VIEWER. */
72 EWK_CACHE_MODEL_PRIMARY_WEBBROWSER /* Use the biggest cache capacity. */
76 * @brief The structure type that creates a type name for Ewk_Cache_Model.
77 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
79 typedef enum _Ewk_Cache_Model Ewk_Cache_Model;
82 * @brief Gets the cookie manager instance for this @a context.
84 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
86 * @param[in] context The context object to query
88 * @return The Ewk_Cookie_Manager object instance,\n
89 * otherwise @c NULL in case of failure
91 EXPORT_API Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* context);
95 * @brief Requests for deleting all web application caches.
99 * @param[in] context Context object
101 * @return @c EINA_TRUE on success, otherwise @c EINA FALSE
104 EXPORT_API Eina_Bool ewk_context_application_cache_delete_all(Ewk_Context* context);
107 * @brief Requests to set the cache model.
109 * The default cache option is EWK_CACHE_MODEL_DOCUMENT_VIEWER.
111 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
113 * @param[in] context The context object
114 * @param[in] model The cache model
116 * @return @c EINA_TRUE on success,\n
117 * otherwise @c EINA_FALSE
119 EXPORT_API Eina_Bool ewk_context_cache_model_set(Ewk_Context* context, Ewk_Cache_Model model);
122 * @brief Returns the cache model type.
124 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
126 * @param[in] context The context object
128 * @return #Ewk_Cache_Model
130 EXPORT_API Ewk_Cache_Model ewk_context_cache_model_get(Ewk_Context* context);
134 * @brief Saves the created profile into permenant storage
136 * The profile used to save must be created by ewk_autofill_profile_new.
137 * Data can be added to the created profile by ewk_autofill_profile_data_set.
141 * @param[in] context Context object
142 * @param[in] profile Ewk_Autofill_Profile
144 * @return @c EINA_TRUE if the profile data is saved successfully, otherwise
147 * @see ewk_autofill_profile_new
150 EXPORT_API Eina_Bool ewk_context_form_autofill_profile_add(Ewk_Context* context, Ewk_Autofill_Profile* profile);
154 * @brief Gets the existing profile for given index
158 * @param[in] context Context object
159 * @param[in] id Profile
161 * @return @c Ewk_Autofill_Profile if profile exists, otherwise @c NULL
163 * @see ewk_autofill_profile_delete
166 EXPORT_API Ewk_Autofill_Profile* ewk_context_form_autofill_profile_get(Ewk_Context* context, unsigned id);
170 * @brief Gets a list of all existing profiles
172 * The obtained profile must be deleted by ewk_autofill_profile_delete.
176 * @param[in] context Context object
178 * @return @c Eina_List of Ewk_Autofill_Profile, otherwise @c NULL
180 * @see ewk_autofill_profile_delete
183 EXPORT_API Eina_List* ewk_context_form_autofill_profile_get_all(Ewk_Context* context);
187 * @brief Sets the given profile for the given id
189 * Data can be added to the created profile by ewk_autofill_profile_data_set.
193 * @param[in] context Context object
194 * @param[in] id Profile
195 * @param[in] profile Ewk_Autofill_Profile
197 * @return @c EINA_TRUE if the profile data is set successfully, otherwise
200 * @see ewk_autofill_profile_new
201 * @see ewk_context_form_autofill_profile_add
204 EXPORT_API Eina_Bool ewk_context_form_autofill_profile_set(Ewk_Context* context, unsigned id, Ewk_Autofill_Profile* profile);
208 * @brief Removes Autofill Form profile completely
212 * @param[in] context Context object
213 * @param[in] id Profile
215 * @return @c EINA_TRUE if the profile data is removed successfully, otherwise
218 * @see ewk_context_form_autofill_profile_get_all
221 EXPORT_API Eina_Bool ewk_context_form_autofill_profile_remove(Ewk_Context* context, unsigned id);
225 * @brief Deletes all candidate form data from DB
229 * @param[in] context Context object
232 EXPORT_API void ewk_context_form_candidate_data_delete_all(Ewk_Context* context);
236 * @brief Deletes whole password data from DB
240 * @param context Context object
243 EXPORT_API void ewk_context_form_password_data_delete_all(Ewk_Context* context);
246 * @brief Clears HTTP caches in the local storage and
247 * all resources cached in memory\n
248 * such as images, CSS, JavaScript, XSL, and fonts for @a context.
250 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
252 * @param[in] context The context object to clear all resource caches
254 EXPORT_API void ewk_context_resource_cache_clear(Ewk_Context* context);
258 * @brief Requests to get image representing the given URL.
262 * @param[in] context Context object
263 * @param[in] uri Which url to query icon, must not be @c 0
264 * @param[in] canvas Evas instance where to add resulting object,
267 * @return @c Evas_Object instance, otherwise @c 0
270 EXPORT_API Evas_Object* ewk_context_icon_database_icon_object_add(Ewk_Context* context, const char* uri, Evas* canvas);
274 * @deprecated Deprecated 2.4
276 * @brief Sets the list of preferred languages.
278 * @details This function sets the list of preferred langages.\n
279 * This list will be used to build the "Accept-Language" header that
280 * will be included in the network requests.\n
281 * The client can pass @c NULL for languages to clear what is set
286 * @remarks All contexts will be affected.
288 * @param[in] languages The list of preferred languages (char* as data),\n
292 EXPORT_API void ewk_context_preferred_languages_set(Eina_List* languages);
296 * @brief Requests for deleting all web indexed databases.
300 * @param[in] context Context object
302 * @return @c EINA_TRUE on success, otherwise @c EINA_FALSE
305 EXPORT_API Eina_Bool ewk_context_web_indexed_database_delete_all(Ewk_Context* context);
309 * @brief Deletes web storage.
311 * @details This function does not ensure that all data will be removed.
312 * Should be used to extend free physical memory.
316 * @param[in] context Context object
318 * @return @c EINA_TRUE on success, otherwise @c EINA_FALSE
321 EXPORT_API Eina_Bool ewk_context_web_storage_delete_all(Ewk_Context* context);
324 * @brief Callback for intercept request feature.
326 * @details Ewk_Context_Intercept_Request_Callback callback allows host
327 * application to intercept a resource request and write custom
330 * @warning Callback is not called on UI thread, so user should be cautious
331 * when accessing their data also used on UI thread. No ewk api other
332 * than ewk_intercept_request_* api should be used in the callback.
334 * @remarks Inside the callback user can use the following EWK API calls on
335 * a given Ewk_Intercept_Request instance to decide if request should
336 * be intercepted or handled normally:
337 * - ewk_intercept_request_url_get
338 * - ewk_intercept_request_http_method_get
339 * - ewk_intercept_request_headers_get
341 * To let engine handle the request normally, use
342 * ewk_intercept_request_ignore *inside* the callback. Using it later
343 * results in undefined behavior.
345 * To respond to a request with a custom response, use
346 * ewk_intercept_request_response_set or
347 * ewk_intercept_request_response_body_set inside or outside the
348 * callback. Using it outside of the callback is advised for better
349 * responsiveness. If your responses take too much time to prepare, it
350 * would block handling other requests. You can also use
351 * ewk_intercept_request_response_write outside the callback to write
352 * response in chunks.
354 * Handling a request is done after using either
355 * ewk_intercept_request_ignore, ewk_intercept_request_response_set,
356 * ewk_intercept_request_response_body_set, and in some cases after
357 * ewk_intercept_request_response_write_chunk.
359 * Further EWK API calls on this Ewk_Intercept_Request instance result
360 * in undefined behavior.
362 * Failing to call one of these functions results in leaking
363 * Ewk_Intercept_Request object.
367 * @param[in] ewk_context Ewk_Context for which callback was set
368 * @param[in] intercept_request Intercept request object for reading request
369 * info and writing response data
370 * @param[in] user_data User data passed to
371 * ewk_context_intercept_request_callback_set
373 typedef void (*Ewk_Context_Intercept_Request_Callback)(Ewk_Context* ewk_context, Ewk_Intercept_Request* intercept_request, void* user_data);
376 * @brief Sets Ewk_Context_Intercept_Request_Callback
378 * @details Sets Ewk_Context_Intercept_Request_Callback to give a chance to
379 * intercept resource request before sending it and return a custom
382 * @remarks Pass NULL pointer as @a callback to reset current callback.
386 * @param[in] ewk_context Ewk_Context object to intercept requests
387 * @param[in] callback New callback, NULL resets current callback
388 * @param[in] user_data User data passed to @a callback
390 * @see Ewk_Context_Intercept_Request_Callback
392 EXPORT_API void ewk_context_intercept_request_callback_set(Ewk_Context* ewk_context, Ewk_Context_Intercept_Request_Callback callback, void* user_data);
402 #endif // ewk_context_h