[M67 Dev][EWK] Classify EWK APIs by public, internal, or product
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / public / ewk_context_internal.h
1 /*
2  * Copyright (C) 2016 Samsung Electronics
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 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.
13  *
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.
18  */
19
20 /**
21  * @file    ewk_context_internal.h
22  * @brief   Describes the context API.
23  *
24  * @note ewk_context encapsulates all pages related to specific use of
25  *       Chromium-efl
26  *
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.
30  *
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.
35  */
36
37 #ifndef ewk_context_internal_h
38 #define ewk_context_internal_h
39
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"
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 /// Extensible API enum is not supported in chromium.
52 typedef void* Ewk_Extensible_API;
53
54 typedef struct Ewk_Context_Exceeded_Quota Ewk_Context_Exceeded_Quota;
55
56 typedef void (*Ewk_Context_Notification_Show_Callback)(
57     Ewk_Context*,
58     Ewk_Notification*,
59     void*);
60
61 typedef void (*Ewk_Context_Notification_Cancel_Callback)(
62     Ewk_Context*,
63     uint64_t,
64     void*);
65
66 /**
67  * Deletes Ewk_Context.
68  *
69  * @param context Ewk_Context to delete
70  */
71 EXPORT_API void ewk_context_delete(Ewk_Context* context);
72
73 /**
74  * Notify low memory to free unused memory.
75  *
76  * @param o context object to notify low memory.
77  *
78  * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise.
79  */
80 EXPORT_API Eina_Bool ewk_context_notify_low_memory(Ewk_Context* ewkContext);
81
82 /**
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()
85  */
86 typedef void (*Ewk_Local_File_System_Origins_Get_Callback)(Eina_List *origins, void *user_data);
87
88 /**
89  * Callback for ewk_context_application_cache_origins_get
90  *
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
93  */
94 typedef void (*Ewk_Web_Application_Cache_Origins_Get_Callback)(Eina_List* origins, void* user_data);
95
96 /**
97  * Callback for ewk_context_application_cache_quota_get.
98  *
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
101  */
102 typedef void (*Ewk_Web_Application_Cache_Quota_Get_Callback)(int64_t quota, void* user_data);
103
104 /**
105  * Callback for ewk_context_application_cache_usage_for_origin_get.
106  *
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
109  */
110 typedef void (*Ewk_Web_Application_Cache_Usage_For_Origin_Get_Callback)(int64_t usage, void* user_data);
111
112 /**
113  * Callback for ewk_context_application_cache_path_get.
114  *
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
117  */
118 //typedef void (*Ewk_Web_Application_Cache_Path_Get_Callback)(const char* path, void* user_data);
119
120 /**
121  * Callback for ewk_context_web_database_origins_get.
122  *
123  * @param origins web database origins
124  * @param user_data user_data will be passsed when ewk_context_web_database_origins_get is called
125  */
126 typedef void (*Ewk_Web_Database_Origins_Get_Callback)(Eina_List* origins, void* user_data);
127
128 /**
129  * Callback for ewk_context_web_database_quota_for_origin_get.
130  *
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
133  */
134 typedef void (*Ewk_Web_Database_Quota_Get_Callback)(uint64_t quota, void* user_data);
135
136 /**
137  * Callback for ewk_context_web_database_path_get.
138  *
139  * @param path web database directory
140  * @param user_data user_data will be passsed when ewk_context_web_database_path_get is called
141  */
142 //typedef void (*Ewk_Web_Database_Path_Get_Callback)(const char* path, void* user_data);
143
144 /**
145  * Callback for ewk_context_web_storage_origins_get.
146  *
147  * @param origins web storage origins
148  * @param user_data user_data will be passsed when ewk_context_web_storage_origins_get is called
149  */
150 typedef void (*Ewk_Web_Storage_Origins_Get_Callback)(Eina_List* origins, void* user_data);
151
152 /**
153  * Callback for ewk_context_web_storage_usage_for_origin_get.
154  *
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
157  */
158 typedef void (*Ewk_Web_Storage_Usage_Get_Callback)(uint64_t usage, void* user_data);
159
160 /**
161  * Callback for didStartDownload
162  *
163  * @param download_url url to download
164  * @param user_data user_data will be passsed when download is started
165  */
166 typedef void (*Ewk_Context_Did_Start_Download_Callback)(const char* download_url, void* user_data);
167
168 /**
169  * Callback for overriding default mime type
170  *
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
179  */
180 typedef Eina_Bool (*Ewk_Context_Override_Mime_For_Url_Callback)(const char* url, const char *mime, char **new_mime, void* user_data);
181
182 /*
183  * Callback for changed profiles.
184  *
185  * @param user_data user_data will be passsed when download is started
186  */
187 typedef void (*Ewk_Context_Form_Autofill_Profile_Changed_Callback)(void *data);
188
189 /**
190  * Requests for freeing origins.
191  *
192  * @param origins list of origins
193  *
194  * @return @c EINA_TRUE on success, @c EINA_FALSE on failure
195  */
196 EXPORT_API Eina_Bool ewk_context_origins_free(Eina_List* origins);
197
198 /**
199  * Requests for deleting web application cache for origin.
200  *
201  * @param context context object
202  * @param origin application cache origin
203  *
204  * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
205  */
206 EXPORT_API Eina_Bool ewk_context_application_cache_delete(Ewk_Context* context, Ewk_Security_Origin* origin);
207
208 /**
209  * Requests for getting application cache usage for origin.
210  *
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
216  *
217  * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
218  */
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);
220
221 /**
222  * Requests for deleting web databases for origin.
223  *
224  * @param context context object
225  * @param origin database origin
226  *
227  * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
228  */
229 EXPORT_API Eina_Bool ewk_context_web_database_delete(Ewk_Context* context, Ewk_Security_Origin* origin);
230
231 /**
232  * Requests for getting web database origins.
233  *
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
238  *
239  * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
240  *
241  * @see ewk_context_origins_free
242  */
243 EXPORT_API Eina_Bool ewk_context_web_database_origins_get( Ewk_Context* context, Ewk_Web_Database_Origins_Get_Callback callback, void* user_data);
244
245 /**
246  * Requests for setting soup data path(soup data include cookie and cache).
247  *
248  * @param context context object
249  * @param path soup data path to set
250  *
251  * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
252  */
253 EXPORT_API Eina_Bool ewk_context_soup_data_directory_set(Ewk_Context* context, const char* path);
254
255 /**
256 * Toggles the cache enable and disable
257 *
258 * @param context context object
259 * @param enable or disable cache
260 *
261 * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
262 */
263 EXPORT_API Eina_Bool ewk_context_cache_disabled_set(Ewk_Context* ewkContext, Eina_Bool cacheDisabled);
264
265 /**
266  * Adds CA certificates to persistent NSS certificate database
267  *
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.
270  *
271  * Certificate files should have *.crt extension.
272  *
273  * Directories are traversed recursively.
274  *
275  * @param context context object
276  * @param certificate_file path to a CA certificate file(s), see above for details
277  *
278  * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
279  */
280 EXPORT_API Eina_Bool ewk_context_certificate_file_set(Ewk_Context *context, const char *certificate_path);
281
282 /**
283 * Gets CA certifcate file path
284 *
285 * It returns an internal string and should not be modified.
286 *
287 * @param context context object
288 *
289 * @return @c certificate_file is path which is set during ewk_context_certificate_file_set or @c NULL otherwise
290 */
291 EXPORT_API const char* ewk_context_certificate_file_get(const Ewk_Context *context);
292
293 /**
294  * Requests to clear cache
295  *
296  * @param context context object
297  *
298  * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
299  */
300 EXPORT_API Eina_Bool ewk_context_cache_clear(Ewk_Context* ewkContext);
301
302 /**
303  * Sets callback for started download.
304  *
305  * @param context context object
306  * @param callback callback for started download
307  * @param user_data user data
308  */
309 EXPORT_API void ewk_context_did_start_download_callback_set(Ewk_Context* context, Ewk_Context_Did_Start_Download_Callback callback, void* user_data);
310
311 /**
312  * Sets callback for overriding mime type
313  *
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
317  */
318 EXPORT_API void ewk_context_mime_override_callback_set(Ewk_Context* context, Ewk_Context_Override_Mime_For_Url_Callback callback, void* user_data);
319
320 /**
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.
324  */
325 typedef void (*Ewk_Vibration_Client_Vibrate_Cb)(uint64_t vibration_time, void *user_data);
326
327 /**
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.
331  */
332 typedef void (*Ewk_Vibration_Client_Vibration_Cancel_Cb)(void *user_data);
333
334 /**
335  * Increases the reference count of the given object.
336  *
337  * @param context context object to increase the reference count
338  *
339  * @return Ewk_Context object on success or @c NULL on failure
340  */
341 EXPORT_API Ewk_Context *ewk_context_ref(Ewk_Context *context);
342
343 /**
344  * Decreases the reference count of the given object, possibly freeing it.
345  *
346  * When the reference count it's reached 0, the Ewk_Context is freed.
347  *
348  * @param context context object to decrease the reference count
349  */
350 EXPORT_API void ewk_context_unref(Ewk_Context *context);
351 /**
352  * Gets default Ewk_Context instance.
353  *
354  * The returned Ewk_Context object @b should not be unref'ed if application
355  * does not call ewk_context_ref() for that.
356  *
357  * @return Ewk_Context object.
358  */
359 EXPORT_API Ewk_Context *ewk_context_default_get(void);
360
361 /**
362  * Creates a new Ewk_Context.
363  *
364  * The returned Ewk_Context object @b should be unref'ed after use.
365  *
366  * @return Ewk_Context object on success or @c NULL on failure
367  *
368  * @see ewk_context_unref
369  * @see ewk_context_new_with_injected_bundle_path
370  */
371 EXPORT_API Ewk_Context *ewk_context_new(void);
372
373 /**
374  * Creates a new Ewk_Context.
375  *
376  * The returned Ewk_Context object @b should be unref'ed after use.
377  *
378  * Ewk view based on chromium engine does not support this API
379  * Avoid using this API
380  *
381  * @param path path of injected bundle library
382  *
383  * @return Ewk_Context object on success or @c NULL on failure
384  *
385  * @see ewk_context_unref
386  * @see ewk_context_new
387  */
388 EXPORT_API Ewk_Context *ewk_context_new_with_injected_bundle_path(const char *path);
389
390 /**
391  * Sets additional plugin directory.
392  *
393  * @param context context object
394  * @param path the directory to be set
395  *
396  * @return @c EINA_TRUE if the directory was set, @c EINA_FALSE otherwise
397  */
398 EXPORT_API Eina_Bool ewk_context_additional_plugin_path_set(Ewk_Context *context, const char *path);
399
400 /**
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.
403  *
404  * To stop listening for vibration events, you may call this function with @c
405  * NULL for the callbacks.
406  *
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).
413  */
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);
415
416 struct Ewk_Password_Data {
417     char* url;
418     Eina_Bool useFingerprint;
419 };
420
421 /**
422  * Sets callback for profiles change notification.
423  *
424  * @param callback pointer to callback function
425  * @param user_data user data returned on callback
426  *
427  */
428 EXPORT_API void ewk_context_form_autofill_profile_changed_callback_set(
429     Ewk_Context_Form_Autofill_Profile_Changed_Callback callback,
430     void* user_data);
431
432 /**
433  * Gets the existing profile for given index
434  *
435  * The obtained profile must be deleted by ewk_autofill_profile_delete.
436  *
437  * @param context context object
438  * @param profile id
439  *
440  * @return @c Ewk_Autofill_Profile if profile exists, @c NULL otherwise
441  * @see ewk_autofill_profile_delete
442  */
443 EXPORT_API Ewk_Autofill_Profile* ewk_context_form_autofill_profile_get(Ewk_Context* context, unsigned id);
444
445 /**
446  * Get tizen extensible api enable state
447  *
448  * @param context context object
449  * @param extensible_api extensible API name of every kind
450  *
451  * @return @c EINA_TRUE if the extensibleAPI set as true or @c EINA_FALSE otherwise
452  */
453 EXPORT_API Eina_Bool ewk_context_tizen_extensible_api_string_get(Ewk_Context* context,  const char* extensible_api);
454
455 /**
456  * Toggles tizen extensible api enable and disable
457  *
458  * @param context context object
459  * @param extensible_api extensible API name of every kind
460  * @param enable enable or disable tizen extensible api
461  *
462  * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
463  */
464 EXPORT_API Eina_Bool ewk_context_tizen_extensible_api_string_set(Ewk_Context *context,  const char *extensible_api, Eina_Bool enable);
465
466 /**
467  * Toggles tizen extensible api enable and disable
468  *
469  * @param context context object
470  * @param extensibleAPI extensible API of every kind
471  * @param enable enable or disable tizen extensible api
472  *
473  * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
474  */
475 EINA_DEPRECATED EXPORT_API Eina_Bool ewk_context_tizen_extensible_api_set(Ewk_Context *context, Ewk_Extensible_API extensible_api, Eina_Bool enable);
476
477 /**
478  * Get tizen extensible api enable state
479  *
480  * @param context context object
481  * @param extensibleAPI extensible API of every kind
482  *  *
483  * @return @c EINA_TRUE if the extensibleAPI set as true or @c EINA_FALSE otherwise
484  */
485 EINA_DEPRECATED EXPORT_API Eina_Bool ewk_context_tizen_extensible_api_get(Ewk_Context *ewkContext, Ewk_Extensible_API extensibleAPI);
486
487 /**
488  * Reset storage path such as web storage, web database, application cache and so on
489  *
490  * @param context context object
491  *
492  */
493 EXPORT_API void ewk_context_storage_path_reset(Ewk_Context* ewkContext);
494
495 /**
496  * Sets the given id for the pixmap
497  *
498  * @param context context object
499  * @param pixmap id
500  *
501  * @return @c EINA_TRUE if the pixmap set successfully, @c EINA_FALSE otherwise
502  */
503 EXPORT_API Eina_Bool ewk_context_pixmap_set(Ewk_Context* context, int pixmap);
504
505 /**
506  * Start the inspector server
507  *
508  * @param context context object
509  * @param port number
510  *
511  * @return @c return the port number
512  */
513 EXPORT_API unsigned int ewk_context_inspector_server_start(Ewk_Context* context, unsigned int port);
514
515 /**
516  * Stop the inspector server
517  *
518  * @param context context object
519   *
520  * @return @c EINA_TRUE if the inspector server stop set successfully, @c EINA_FALSE otherwise
521  */
522 EXPORT_API Eina_Bool ewk_context_inspector_server_stop(Ewk_Context* context);
523
524
525 ///------- belows are extension of chromium-ewk ---------------------------
526
527 /**
528  * Gets the id for the pixmap
529  *
530  * @param context context object
531  *
532  * @return @c id for the pixmap. On error default return is 0.
533  */
534 EXPORT_API int ewk_context_pixmap_get(Ewk_Context *context);
535
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);
537
538 /**
539  * Sets tizen application id for @a context.
540  *
541  * Must be called before loading content in order to call
542  * DynamicPluginStartSession of injected bundle.
543  *
544  * @param context context object
545  * @param tizen_app_id tizen application id
546  */
547 EXPORT_API void ewk_context_tizen_app_id_set(Ewk_Context *context, const char *tizen_app_id);
548
549 /**
550  * Gets the application cache manager instance for this @a context.
551  *
552  * @param context context object to query.
553  *
554  * @return Ewk_Cookie_Manager object instance or @c NULL in case of failure.
555  */
556 EXPORT_API Ewk_Application_Cache_Manager *ewk_context_application_cache_manager_get(const Ewk_Context *context);
557
558 /**
559  * Gets the favicon database instance for this @a context.
560  *
561  * @param context context object to query.
562  *
563  * @return Ewk_Favicon_Database object instance or @c NULL in case of failure.
564  */
565 EXPORT_API Ewk_Favicon_Database *ewk_context_favicon_database_get(const Ewk_Context *context);
566
567 /**
568  * Sets the favicon database directory for this @a context.
569  *
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.
573  *
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.
578  *
579  * @param context context object to update
580  * @param directory_path database directory path to set
581  *
582  * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise
583  */
584 EXPORT_API Eina_Bool ewk_context_favicon_database_directory_set(Ewk_Context *context, const char *directory_path);
585
586 /**
587  * Gets the storage manager instance for this @a context.
588  *
589  * @param context context object to query.
590  *
591  * @return Ewk_Storage_Manager object instance or @c NULL in case of failure.
592  */
593 EXPORT_API Ewk_Storage_Manager *ewk_context_storage_manager_get(const Ewk_Context *context);
594
595 /**
596  * Requests for deleting all web databases.
597  *
598  * @param context context object
599  *
600  * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
601  */
602 EXPORT_API Eina_Bool ewk_context_web_database_delete_all(Ewk_Context* context);
603
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);
607
608 EXPORT_API Eina_Bool ewk_context_notification_callbacks_reset(Ewk_Context* context);
609
610 /**
611  * Set time offset
612  *
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.
616  *
617  */
618 EXPORT_API void ewk_context_time_offset_set(Ewk_Context* context,
619                                             double time_offset);
620
621 /**
622  * Set timezone offset
623  *
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.
628  *
629  */
630 EXPORT_API void ewk_context_timezone_offset_set(Ewk_Context* context,
631                                                 double time_zone_offset,
632                                                 double daylight_saving_time);
633
634 #ifdef __cplusplus
635 }
636 #endif
637
638 #endif // ewk_context_internal_h