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.
21 * @file ewk_context_internal.h
22 * @brief Describes the context API.
24 * @note ewk_context encapsulates all pages related to specific use of
27 * Applications have the option of creating a context different than the default
28 * one and use it for a group of pages. All pages in the same context share the
29 * same preferences, visited link set, local storage, etc.
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.
37 #ifndef ewk_context_internal_h
38 #define ewk_context_internal_h
40 #include "ewk_application_cache_manager_internal.h"
41 #include "ewk_context.h"
42 #include "ewk_favicon_database_internal.h"
43 #include "ewk_notification_internal.h"
44 #include "ewk_security_origin_internal.h"
45 #include "ewk_storage_manager_internal.h"
51 /// Extensible API enum is not supported in chromium.
52 typedef void* Ewk_Extensible_API;
54 typedef struct Ewk_Context_Exceeded_Quota Ewk_Context_Exceeded_Quota;
56 typedef void (*Ewk_Context_Notification_Show_Callback)(
61 typedef void (*Ewk_Context_Notification_Cancel_Callback)(
67 * Deletes Ewk_Context.
69 * @param context Ewk_Context to delete
71 EXPORT_API void ewk_context_delete(Ewk_Context* context);
74 * Notify low memory to free unused memory.
76 * @param o context object to notify low memory.
78 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise.
80 EXPORT_API Eina_Bool ewk_context_notify_low_memory(Ewk_Context* ewkContext);
83 * @typedef Ewk_Local_File_System_Origins_Get_Callback Ewk_Local_File_System_Origins_Get_Callback
84 * @brief Type definition for use with ewk_context_local_file_system_origins_get()
86 typedef void (*Ewk_Local_File_System_Origins_Get_Callback)(Eina_List *origins, void *user_data);
89 * Callback for ewk_context_application_cache_origins_get
91 * @param origins web application cache origins
92 * @param user_data user_data will be passsed when ewk_context_application_cache_origins_get is called
94 typedef void (*Ewk_Web_Application_Cache_Origins_Get_Callback)(Eina_List* origins, void* user_data);
97 * Callback for ewk_context_application_cache_quota_get.
99 * @param quota web application cache quota
100 * @param user_data user_data will be passsed when ewk_context_application_cache_quota_get is called
102 typedef void (*Ewk_Web_Application_Cache_Quota_Get_Callback)(int64_t quota, void* user_data);
105 * Callback for ewk_context_application_cache_usage_for_origin_get.
107 * @param usage web application cache usage for origin
108 * @param user_data user_data will be passsed when ewk_context_application_cache_usage_for_origin_get is called
110 typedef void (*Ewk_Web_Application_Cache_Usage_For_Origin_Get_Callback)(int64_t usage, void* user_data);
113 * Callback for ewk_context_application_cache_path_get.
115 * @param path web application cache directory
116 * @param user_data user_data will be passsed when ewk_context_application_cache_path_get is called
118 //typedef void (*Ewk_Web_Application_Cache_Path_Get_Callback)(const char* path, void* user_data);
121 * Callback for ewk_context_web_database_origins_get.
123 * @param origins web database origins
124 * @param user_data user_data will be passsed when ewk_context_web_database_origins_get is called
126 typedef void (*Ewk_Web_Database_Origins_Get_Callback)(Eina_List* origins, void* user_data);
129 * Callback for ewk_context_web_database_quota_for_origin_get.
131 * @param quota web database quota
132 * @param user_data user_data will be passsed when ewk_context_web_database_quota_for_origin_get is called
134 typedef void (*Ewk_Web_Database_Quota_Get_Callback)(uint64_t quota, void* user_data);
137 * Callback for ewk_context_web_database_path_get.
139 * @param path web database directory
140 * @param user_data user_data will be passsed when ewk_context_web_database_path_get is called
142 //typedef void (*Ewk_Web_Database_Path_Get_Callback)(const char* path, void* user_data);
145 * Callback for ewk_context_web_storage_origins_get.
147 * @param origins web storage origins
148 * @param user_data user_data will be passsed when ewk_context_web_storage_origins_get is called
150 typedef void (*Ewk_Web_Storage_Origins_Get_Callback)(Eina_List* origins, void* user_data);
153 * Callback for ewk_context_web_storage_usage_for_origin_get.
155 * @param usage usage of web storage
156 * @param user_data user_data will be passsed when ewk_context_web_storage_usage_for_origin_get is called
158 typedef void (*Ewk_Web_Storage_Usage_Get_Callback)(uint64_t usage, void* user_data);
161 * Callback for didStartDownload
163 * @param download_url url to download
164 * @param user_data user_data will be passsed when download is started
166 typedef void (*Ewk_Context_Did_Start_Download_Callback)(const char* download_url, void* user_data);
169 * Callback for overriding default mime type
171 * @param url url for which the mime type can be overridden
172 * @param mime current mime type assumed by the web engine
173 * @param new_mime string with a new mime type for content pointer by url. Should be allocated
174 * dynamically by malloc or calloc. If callback returns EINA_TRUE, the browser will take ownership
175 * of the allocated memory and free it when it's no longer needed using the free() function
176 * @return true in case mime should be overridden by the contents of new_mime, false otherwise.
177 * If false will be returned, the browser won't free the new_mime
178 * @param user_data user_data will be passsed when ewk_context_mime_override_callback_set is called
180 typedef Eina_Bool (*Ewk_Context_Override_Mime_For_Url_Callback)(const char* url, const char *mime, char **new_mime, void* user_data);
183 * Callback for changed profiles.
185 * @param user_data user_data will be passsed when download is started
187 typedef void (*Ewk_Context_Form_Autofill_Profile_Changed_Callback)(void *data);
190 * Requests for freeing origins.
192 * @param origins list of origins
194 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure
196 EXPORT_API Eina_Bool ewk_context_origins_free(Eina_List* origins);
199 * Requests for deleting web application cache for origin.
201 * @param context context object
202 * @param origin application cache origin
204 * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
206 EXPORT_API Eina_Bool ewk_context_application_cache_delete(Ewk_Context* context, Ewk_Security_Origin* origin);
209 * Requests for getting application cache usage for origin.
211 * @param context context object
212 * @param origin security origin
213 * @param result_callback callback to get web database usage
214 * @param user_data user_data will be passed when result_callback is called
215 * -I.e., user data will be kept until callback is called
217 * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
219 EXPORT_API Eina_Bool ewk_context_application_cache_usage_for_origin_get(Ewk_Context* context, const Ewk_Security_Origin* origin, Ewk_Web_Application_Cache_Usage_For_Origin_Get_Callback callback, void* user_data);
222 * Requests for deleting web databases for origin.
224 * @param context context object
225 * @param origin database origin
227 * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
229 EXPORT_API Eina_Bool ewk_context_web_database_delete(Ewk_Context* context, Ewk_Security_Origin* origin);
232 * Requests for getting web database origins.
234 * @param context context object
235 * @param result_callback callback to get web database origins
236 * @param user_data user_data will be passed when result_callback is called
237 * -I.e., user data will be kept until callback is called
239 * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
241 * @see ewk_context_origins_free
243 EXPORT_API Eina_Bool ewk_context_web_database_origins_get( Ewk_Context* context, Ewk_Web_Database_Origins_Get_Callback callback, void* user_data);
246 * Requests for setting soup data path(soup data include cookie and cache).
248 * @param context context object
249 * @param path soup data path to set
251 * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
253 EXPORT_API Eina_Bool ewk_context_soup_data_directory_set(Ewk_Context* context, const char* path);
256 * Toggles the cache enable and disable
258 * @param context context object
259 * @param enable or disable cache
261 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
263 EXPORT_API Eina_Bool ewk_context_cache_disabled_set(Ewk_Context* ewkContext, Eina_Bool cacheDisabled);
266 * Adds CA certificates to persistent NSS certificate database
268 * Function accepts a path to a CA certificate file, a path to a directory
269 * containing CA certificate files, or a colon-seprarated list of those.
271 * Certificate files should have *.crt extension.
273 * Directories are traversed recursively.
275 * @param context context object
276 * @param certificate_file path to a CA certificate file(s), see above for details
278 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
280 EXPORT_API Eina_Bool ewk_context_certificate_file_set(Ewk_Context *context, const char *certificate_path);
283 * Gets CA certifcate file path
285 * It returns an internal string and should not be modified.
287 * @param context context object
289 * @return @c certificate_file is path which is set during ewk_context_certificate_file_set or @c NULL otherwise
291 EXPORT_API const char* ewk_context_certificate_file_get(const Ewk_Context *context);
294 * Requests to clear cache
296 * @param context context object
298 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
300 EXPORT_API Eina_Bool ewk_context_cache_clear(Ewk_Context* ewkContext);
303 * Sets callback for started download.
305 * @param context context object
306 * @param callback callback for started download
307 * @param user_data user data
309 EXPORT_API void ewk_context_did_start_download_callback_set(Ewk_Context* context, Ewk_Context_Did_Start_Download_Callback callback, void* user_data);
312 * Sets callback for overriding mime type
314 * @param context context object
315 * @param callback callback to be invoked whenver the mime type can be overridden
316 * @param user_data user data
318 EXPORT_API void ewk_context_mime_override_callback_set(Ewk_Context* context, Ewk_Context_Override_Mime_For_Url_Callback callback, void* user_data);
321 * @typedef Ewk_Vibration_Client_Vibrate_Cb Ewk_Vibration_Client_Vibrate_Cb
322 * @brief Type definition for a function that will be called back when vibrate
323 * request receiveed from the vibration controller.
325 typedef void (*Ewk_Vibration_Client_Vibrate_Cb)(uint64_t vibration_time, void *user_data);
328 * @typedef Ewk_Vibration_Client_Vibration_Cancel_Cb Ewk_Vibration_Client_Vibration_Cancel_Cb
329 * @brief Type definition for a function that will be called back when cancel
330 * vibration request receiveed from the vibration controller.
332 typedef void (*Ewk_Vibration_Client_Vibration_Cancel_Cb)(void *user_data);
335 * Increases the reference count of the given object.
337 * @param context context object to increase the reference count
339 * @return Ewk_Context object on success or @c NULL on failure
341 EXPORT_API Ewk_Context *ewk_context_ref(Ewk_Context *context);
344 * Decreases the reference count of the given object, possibly freeing it.
346 * When the reference count it's reached 0, the Ewk_Context is freed.
348 * @param context context object to decrease the reference count
350 EXPORT_API void ewk_context_unref(Ewk_Context *context);
352 * Gets default Ewk_Context instance.
354 * The returned Ewk_Context object @b should not be unref'ed if application
355 * does not call ewk_context_ref() for that.
357 * @return Ewk_Context object.
359 EXPORT_API Ewk_Context *ewk_context_default_get(void);
362 * Creates a new Ewk_Context.
364 * The returned Ewk_Context object @b should be unref'ed after use.
366 * @return Ewk_Context object on success or @c NULL on failure
368 * @see ewk_context_unref
369 * @see ewk_context_new_with_injected_bundle_path
371 EXPORT_API Ewk_Context *ewk_context_new(void);
374 * Creates a new Ewk_Context.
376 * The returned Ewk_Context object @b should be unref'ed after use.
378 * Ewk view based on chromium engine does not support this API
379 * Avoid using this API
381 * @param path path of injected bundle library
383 * @return Ewk_Context object on success or @c NULL on failure
385 * @see ewk_context_unref
386 * @see ewk_context_new
388 EXPORT_API Ewk_Context *ewk_context_new_with_injected_bundle_path(const char *path);
391 * Sets additional plugin directory.
393 * @param context context object
394 * @param path the directory to be set
396 * @return @c EINA_TRUE if the directory was set, @c EINA_FALSE otherwise
398 EXPORT_API Eina_Bool ewk_context_additional_plugin_path_set(Ewk_Context *context, const char *path);
401 * Sets vibration client callbacks to handle the tactile feedback in the form of
402 * vibration in the client application when the content asks for vibration.
404 * To stop listening for vibration events, you may call this function with @c
405 * NULL for the callbacks.
407 * @param context context object to set vibration client callbacks.
408 * @param vibrate The function to call when the vibrate request received from the
409 * controller (may be @c NULL).
410 * @param cancel The function to call when the cancel vibration request received
411 * from the controller (may be @c NULL).
412 * @param data User data (may be @c NULL).
414 EXPORT_API void ewk_context_vibration_client_callbacks_set(Ewk_Context *context, Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancel, void *data);
416 struct Ewk_Password_Data {
418 Eina_Bool useFingerprint;
422 * Sets callback for profiles change notification.
424 * @param callback pointer to callback function
425 * @param user_data user data returned on callback
428 EXPORT_API void ewk_context_form_autofill_profile_changed_callback_set(
429 Ewk_Context_Form_Autofill_Profile_Changed_Callback callback,
433 * Gets the existing profile for given index
435 * The obtained profile must be deleted by ewk_autofill_profile_delete.
437 * @param context context object
440 * @return @c Ewk_Autofill_Profile if profile exists, @c NULL otherwise
441 * @see ewk_autofill_profile_delete
443 EXPORT_API Ewk_Autofill_Profile* ewk_context_form_autofill_profile_get(Ewk_Context* context, unsigned id);
446 * Get tizen extensible api enable state
448 * @param context context object
449 * @param extensible_api extensible API name of every kind
451 * @return @c EINA_TRUE if the extensibleAPI set as true or @c EINA_FALSE otherwise
453 EXPORT_API Eina_Bool ewk_context_tizen_extensible_api_string_get(Ewk_Context* context, const char* extensible_api);
456 * Toggles tizen extensible api enable and disable
458 * @param context context object
459 * @param extensible_api extensible API name of every kind
460 * @param enable enable or disable tizen extensible api
462 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
464 EXPORT_API Eina_Bool ewk_context_tizen_extensible_api_string_set(Ewk_Context *context, const char *extensible_api, Eina_Bool enable);
467 * Toggles tizen extensible api enable and disable
469 * @param context context object
470 * @param extensibleAPI extensible API of every kind
471 * @param enable enable or disable tizen extensible api
473 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
475 EINA_DEPRECATED EXPORT_API Eina_Bool ewk_context_tizen_extensible_api_set(Ewk_Context *context, Ewk_Extensible_API extensible_api, Eina_Bool enable);
478 * Get tizen extensible api enable state
480 * @param context context object
481 * @param extensibleAPI extensible API of every kind
483 * @return @c EINA_TRUE if the extensibleAPI set as true or @c EINA_FALSE otherwise
485 EINA_DEPRECATED EXPORT_API Eina_Bool ewk_context_tizen_extensible_api_get(Ewk_Context *ewkContext, Ewk_Extensible_API extensibleAPI);
488 * Reset storage path such as web storage, web database, application cache and so on
490 * @param context context object
493 EXPORT_API void ewk_context_storage_path_reset(Ewk_Context* ewkContext);
496 * Sets the given id for the pixmap
498 * @param context context object
501 * @return @c EINA_TRUE if the pixmap set successfully, @c EINA_FALSE otherwise
503 EXPORT_API Eina_Bool ewk_context_pixmap_set(Ewk_Context* context, int pixmap);
506 * Start the inspector server
508 * @param context context object
511 * @return @c return the port number
513 EXPORT_API unsigned int ewk_context_inspector_server_start(Ewk_Context* context, unsigned int port);
516 * Stop the inspector server
518 * @param context context object
520 * @return @c EINA_TRUE if the inspector server stop set successfully, @c EINA_FALSE otherwise
522 EXPORT_API Eina_Bool ewk_context_inspector_server_stop(Ewk_Context* context);
525 ///------- belows are extension of chromium-ewk ---------------------------
528 * Gets the id for the pixmap
530 * @param context context object
532 * @return @c id for the pixmap. On error default return is 0.
534 EXPORT_API int ewk_context_pixmap_get(Ewk_Context *context);
536 EINA_DEPRECATED EXPORT_API void ewk_send_widget_info(Ewk_Context *context, const char *tizen_id, double scale, const char *theme, const char *encodedBundle);
539 * Sets tizen application id for @a context.
541 * Must be called before loading content in order to call
542 * DynamicPluginStartSession of injected bundle.
544 * @param context context object
545 * @param tizen_app_id tizen application id
547 EXPORT_API void ewk_context_tizen_app_id_set(Ewk_Context *context, const char *tizen_app_id);
550 * Gets the application cache manager instance for this @a context.
552 * @param context context object to query.
554 * @return Ewk_Cookie_Manager object instance or @c NULL in case of failure.
556 EXPORT_API Ewk_Application_Cache_Manager *ewk_context_application_cache_manager_get(const Ewk_Context *context);
559 * Gets the favicon database instance for this @a context.
561 * @param context context object to query.
563 * @return Ewk_Favicon_Database object instance or @c NULL in case of failure.
565 EXPORT_API Ewk_Favicon_Database *ewk_context_favicon_database_get(const Ewk_Context *context);
568 * Sets the favicon database directory for this @a context.
570 * Sets the directory path to be used to store the favicons database
571 * for @a context on disk. Passing @c NULL as @a directory_path will
572 * result in using the default directory for the platform.
574 * Calling this method also means enabling the favicons database for
575 * its use from the applications, it is therefore expected to be
576 * called only once. Further calls for the same instance of
577 * @a context will not have any effect.
579 * @param context context object to update
580 * @param directory_path database directory path to set
582 * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise
584 EXPORT_API Eina_Bool ewk_context_favicon_database_directory_set(Ewk_Context *context, const char *directory_path);
587 * Gets the storage manager instance for this @a context.
589 * @param context context object to query.
591 * @return Ewk_Storage_Manager object instance or @c NULL in case of failure.
593 EXPORT_API Ewk_Storage_Manager *ewk_context_storage_manager_get(const Ewk_Context *context);
596 * Requests for deleting all web databases.
598 * @param context context object
600 * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
602 EXPORT_API Eina_Bool ewk_context_web_database_delete_all(Ewk_Context* context);
604 EXPORT_API Eina_Bool ewk_context_notification_callbacks_set(Ewk_Context* context,
605 Ewk_Context_Notification_Show_Callback show_callback,
606 Ewk_Context_Notification_Cancel_Callback cancel_callback, void* user_data);
608 EXPORT_API Eina_Bool ewk_context_notification_callbacks_reset(Ewk_Context* context);
613 * @param context context object
614 * @param timeOffset The value will be added to system time as offset, it will
615 * be used for adjusting JS Date, certificate, cookie, animation etc.
618 EXPORT_API void ewk_context_time_offset_set(Ewk_Context* context,
622 * Set timezone offset
624 * @param context context object
625 * @param timezoneOffset The value will be used to set tz ENV.
626 * @param daylightSavingTime The value is for daylight saving time use, and will
627 * be used to set tz ENV.
630 EXPORT_API void ewk_context_timezone_offset_set(Ewk_Context* context,
631 double time_zone_offset,
632 double daylight_saving_time);
638 #endif // ewk_context_internal_h