ewebkit2  1.11.0
Web engine based on WebKit2 for EFL
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Typedefs | Enumerations | Functions
ewk_context.h File Reference

Describes the context API. More...

#include "ewk_application_cache_manager.h"
#include "ewk_cookie_manager.h"
#include "ewk_database_manager.h"
#include "ewk_favicon_database.h"
#include "ewk_navigation_data.h"
#include "ewk_storage_manager.h"
#include "ewk_url_scheme_request.h"
#include <Evas.h>

Go to the source code of this file.

Typedefs

typedef struct EwkObject Ewk_Context
 
typedef enum Ewk_Cache_Model Ewk_Cache_Model
 Creates a type name for the Ewk_Cache_Model.
 
typedef enum Ewk_Process_Model Ewk_Process_Model
 Creates a type name for the Ewk_Process_Model.
 
typedef enum Ewk_TLS_Error_Policy Ewk_TLS_Error_Policy
 
typedef void(* Ewk_Url_Scheme_Request_Cb )(Ewk_Url_Scheme_Request *request, void *user_data)
 Callback type for use with ewk_context_url_scheme_register().
 
typedef void(* Ewk_History_Navigation_Cb )(const Evas_Object *view, Ewk_Navigation_Data *navigation_data, void *user_data)
 Type definition for a function that will be called back when view did navigation (loaded new URL).
 
typedef void(* Ewk_History_Client_Redirection_Cb )(const Evas_Object *view, const char *source_url, const char *destination_url, void *user_data)
 Type definition for a function that will be called back when view performed a client redirect.
 
typedef void(* Ewk_History_Server_Redirection_Cb )(const Evas_Object *view, const char *source_url, const char *destination_url, void *user_data)
 Type definition for a function that will be called back when view performed a server redirect.
 
typedef void(* Ewk_History_Title_Update_Cb )(const Evas_Object *view, const char *title, const char *url, void *user_data)
 Type definition for a function that will be called back when history title is updated.
 
typedef void(* Ewk_History_Populate_Visited_Links_Cb )(void *user_data)
 
typedef void(* Ewk_Context_Message_From_Injected_Bundle_Cb )(const char *name, const char *body, char **return_data, void *user_data)
 

Enumerations

enum  Ewk_Cache_Model { EWK_CACHE_MODEL_DOCUMENT_VIEWER, EWK_CACHE_MODEL_DOCUMENT_BROWSER, EWK_CACHE_MODEL_PRIMARY_WEBBROWSER }
 Contains option for cache model. More...
 
enum  Ewk_Process_Model { EWK_PROCESS_MODEL_SHARED_SECONDARY, EWK_PROCESS_MODEL_MULTIPLE_SECONDARY }
 Contains option for process model.
 
enum  Ewk_TLS_Error_Policy { EWK_TLS_ERROR_POLICY_FAIL, EWK_TLS_ERROR_POLICY_IGNORE }
 Contains option for TLS error policy.
 

Functions

EAPI Ewk_Contextewk_context_default_get (void)
 
EAPI Ewk_Contextewk_context_new (void)
 
EINA_DEPRECATED EAPI Ewk_Contextewk_context_new_with_injected_bundle_path (const char *path)
 
EAPI
Ewk_Application_Cache_Manager
ewk_context_application_cache_manager_get (const Ewk_Context *context)
 
EAPI Ewk_Cookie_Managerewk_context_cookie_manager_get (const Ewk_Context *context)
 
EAPI Ewk_Database_Managerewk_context_database_manager_get (const Ewk_Context *context)
 
EAPI Eina_Bool ewk_context_favicon_database_directory_set (Ewk_Context *context, const char *directory_path)
 
EAPI Ewk_Favicon_Databaseewk_context_favicon_database_get (const Ewk_Context *context)
 
EAPI Ewk_Storage_Managerewk_context_storage_manager_get (const Ewk_Context *context)
 
EAPI Eina_Bool ewk_context_url_scheme_register (Ewk_Context *context, const char *scheme, Ewk_Url_Scheme_Request_Cb callback, void *user_data)
 
EAPI void ewk_context_history_callbacks_set (Ewk_Context *context, Ewk_History_Navigation_Cb navigate_func, Ewk_History_Client_Redirection_Cb client_redirect_func, Ewk_History_Server_Redirection_Cb server_redirect_func, Ewk_History_Title_Update_Cb title_update_func, Ewk_History_Populate_Visited_Links_Cb populate_visited_links_func, void *data)
 
EAPI void ewk_context_visited_link_add (Ewk_Context *context, const char *visited_url)
 
EAPI Eina_Bool ewk_context_cache_model_set (Ewk_Context *context, Ewk_Cache_Model cache_model)
 
EAPI Ewk_Cache_Model ewk_context_cache_model_get (const Ewk_Context *context)
 
EAPI Eina_Bool ewk_context_additional_plugin_path_set (Ewk_Context *context, const char *path)
 
EAPI void ewk_context_resource_cache_clear (Ewk_Context *context)
 
EINA_DEPRECATED EAPI void ewk_context_message_post_to_injected_bundle (Ewk_Context *context, const char *name, const char *body)
 
EINA_DEPRECATED EAPI void ewk_context_message_from_injected_bundle_callback_set (Ewk_Context *context, Ewk_Context_Message_From_Injected_Bundle_Cb callback, void *user_data)
 
EAPI Eina_Bool ewk_context_process_model_set (Ewk_Context *context, Ewk_Process_Model process_model)
 
EAPI Ewk_Process_Model ewk_context_process_model_get (const Ewk_Context *context)
 
EAPI Ewk_TLS_Error_Policy ewk_context_tls_error_policy_get (const Ewk_Context *context)
 
EAPI void ewk_context_tls_error_policy_set (Ewk_Context *context, Ewk_TLS_Error_Policy tls_error_policy)
 
EAPI void ewk_context_preferred_languages_set (Eina_List *languages)
 

Detailed Description

Describes the context API.

Note
ewk_context encapsulates all pages related to specific use of WebKit.

Applications have the option of creating a context different than the default one and use it for a group of pages. All pages in the same context share the same preferences, visited link set, local storage, etc.

A process model can be specified per context. The default one is the shared model where the web-engine process is shared among the pages in the context. The second model allows each page to use a separate web-engine process. This latter model is currently not supported by WebKit2/EFL.

Typedef Documentation

typedef struct EwkObject Ewk_Context

Declare Ewk_Context as Ewk_Object.

See Also
Ewk_Object
typedef void(* Ewk_Context_Message_From_Injected_Bundle_Cb)(const char *name, const char *body, char **return_data, void *user_data)

Callback for didReceiveMessageFromInjectedBundle and didReceiveSynchronousMessageFromInjectedBundle

User should allocate new string for return_data before setting it. The return_data string will be freed on WebKit side.

Parameters
namename of message from injected bundle
bodybody of message from injected bundle
return_datareturn_data string from application
user_datauser_data will be passsed when receiving message from injected bundle

Enumeration Type Documentation

Contains option for cache model.

Enumerator
EWK_CACHE_MODEL_DOCUMENT_VIEWER 

Use the smallest cache capacity.

EWK_CACHE_MODEL_DOCUMENT_BROWSER 

Use bigger cache capacity than EWK_CACHE_MODEL_DOCUMENT_VIEWER.

EWK_CACHE_MODEL_PRIMARY_WEBBROWSER 

Use the biggest cache capacity.

Function Documentation

EAPI Eina_Bool ewk_context_additional_plugin_path_set ( Ewk_Context context,
const char *  path 
)

Sets additional plugin path for context.

Parameters
contextcontext object to set additional plugin path
paththe path to be used for plugins
Returns
EINA_TRUE on success or EINA_FALSE on failure
EAPI Ewk_Application_Cache_Manager* ewk_context_application_cache_manager_get ( const Ewk_Context context)

Gets the application cache manager instance for this context.

Parameters
contextcontext object to query.
Returns
Ewk_Cookie_Manager object instance or NULL in case of failure.
EAPI Ewk_Cache_Model ewk_context_cache_model_get ( const Ewk_Context context)

Gets the cache model for context.

Parameters
contextcontext object to query.
Returns
the cache model for the context.
EAPI Eina_Bool ewk_context_cache_model_set ( Ewk_Context context,
Ewk_Cache_Model  cache_model 
)

Set cache_model as the cache model for context.

By default, it is EWK_CACHE_MODEL_DOCUMENT_VIEWER.

Parameters
contextcontext object to update.
cache_modela Ewk_Cache_Model.
Returns
EINA_TRUE on success or EINA_FALSE on failure
EAPI Ewk_Cookie_Manager* ewk_context_cookie_manager_get ( const Ewk_Context context)

Gets the cookie manager instance for this context.

Parameters
contextcontext object to query.
Returns
Ewk_Cookie_Manager object instance or NULL in case of failure.
EAPI Ewk_Database_Manager* ewk_context_database_manager_get ( const Ewk_Context context)

Gets the database manager instance for this context.

Parameters
contextcontext object to query
Returns
Ewk_Database_Manager object instance or NULL in case of failure
EAPI Ewk_Context* ewk_context_default_get ( void  )

Gets default Ewk_Context instance.

The returned Ewk_Context object should not be unref'ed if application does not call ewk_context_ref() for that.

Returns
Ewk_Context object.
EAPI Eina_Bool ewk_context_favicon_database_directory_set ( Ewk_Context context,
const char *  directory_path 
)

Sets the favicon database directory for this context.

Sets the directory path to be used to store the favicons database for context on disk. Passing NULL as directory_path will result in using the default directory for the platform.

Calling this method also means enabling the favicons database for its use from the applications, it is therefore expected to be called only once. Further calls for the same instance of context will not have any effect.

Parameters
contextcontext object to update
directory_pathdatabase directory path to set
Returns
EINA_TRUE if successful, EINA_FALSE otherwise
EAPI Ewk_Favicon_Database* ewk_context_favicon_database_get ( const Ewk_Context context)

Gets the favicon database instance for this context.

Parameters
contextcontext object to query.
Returns
Ewk_Favicon_Database object instance or NULL in case of failure.
EAPI void ewk_context_history_callbacks_set ( Ewk_Context context,
Ewk_History_Navigation_Cb  navigate_func,
Ewk_History_Client_Redirection_Cb  client_redirect_func,
Ewk_History_Server_Redirection_Cb  server_redirect_func,
Ewk_History_Title_Update_Cb  title_update_func,
Ewk_History_Populate_Visited_Links_Cb  populate_visited_links_func,
void *  data 
)

Sets history callbacks for the given context.

To stop listening for history events, you may call this function with NULL for the callbacks.

Parameters
contextcontext object to set history callbacks
navigate_funcThe function to call when ewk_view did navigation (may be NULL).
client_redirect_funcThe function to call when ewk_view performed a client redirect (may be NULL).
server_redirect_funcThe function to call when ewk_view performed a server redirect (may be NULL).
title_update_funcThe function to call when history title is updated (may be NULL).
populate_visited_links_funcThe function is called when client is asked to provide visited links from a client-managed storage (may be NULL).
dataUser data (may be NULL).
EINA_DEPRECATED EAPI void ewk_context_message_from_injected_bundle_callback_set ( Ewk_Context context,
Ewk_Context_Message_From_Injected_Bundle_Cb  callback,
void *  user_data 
)

Sets callback for received injected bundle message.

DO NOT USE THIS. IT WILL BE DEPRECATED.

Client can pass NULL for callback to stop listening for messages.

Parameters
contextcontext object
callbackcallback for received injected bundle message or NULL
user_datauser data
EINA_DEPRECATED EAPI void ewk_context_message_post_to_injected_bundle ( Ewk_Context context,
const char *  name,
const char *  body 
)

Posts message to injected bundle.

DO NOT USE THIS. IT WILL BE DEPRECATED.

Parameters
contextcontext object to post message to injected bundle
namemessage name
bodymessage body
EAPI Ewk_Context* ewk_context_new ( void  )

Creates a new Ewk_Context.

The returned Ewk_Context object should be unref'ed after use.

Returns
Ewk_Context object on success or NULL on failure
See Also
ewk_object_unref
ewk_context_new_with_injected_bundle_path
EINA_DEPRECATED EAPI Ewk_Context* ewk_context_new_with_injected_bundle_path ( const char *  path)

Creates a new Ewk_Context.

DO NOT USE THIS. IT WILL BE DEPRECATED.

The returned Ewk_Context object should be unref'ed after use.

Parameters
pathpath of injected bundle library
Returns
Ewk_Context object on success or NULL on failure
See Also
ewk_object_unref
ewk_context_new
EAPI void ewk_context_preferred_languages_set ( Eina_List *  languages)

Sets the list of preferred languages.

Sets the list of preferred langages. This list will be used to build the "Accept-Language" header that will be included in the network requests. Client can pass NULL for languages to clear what is set before.

Parameters
languagesthe list of preferred languages (char* as data) or NULL
Note
all contexts will be affected.
EAPI Ewk_Process_Model ewk_context_process_model_get ( const Ewk_Context context)

Gets the process model for context.

Parameters
contextcontext object to query
Returns
the process model for the context
EAPI Eina_Bool ewk_context_process_model_set ( Ewk_Context context,
Ewk_Process_Model  process_model 
)

Sets a process model for context.

Sets a process model for web views, which will be used to decide how processes should be handled. Default value is EWK_PROCESS_MODEL_SHARED_SECONDARY which means that there is only one web process. When EWK_PROCESS_MODEL_MULTIPLE_SECONDARY is set a network process is introduced and every web view starts new web process. This function should be used before first web process is spawned.

Parameters
contextcontext object to set process model
process_modela Ewk_Process_Model
EAPI void ewk_context_resource_cache_clear ( Ewk_Context context)

Clears HTTP caches in local storage and all resources cached in memory such as images, CSS, JavaScript, XSL, and fonts for context.

Parameters
contextcontext object to clear all resource caches
EAPI Ewk_Storage_Manager* ewk_context_storage_manager_get ( const Ewk_Context context)

Gets the storage manager instance for this context.

Parameters
contextcontext object to query.
Returns
Ewk_Storage_Manager object instance or NULL in case of failure.
EAPI Ewk_TLS_Error_Policy ewk_context_tls_error_policy_get ( const Ewk_Context context)

Gets TLS error policy for context.

Parameters
contextcontext object to get TLS error policy
Returns
The TLS errors policy for the context
EAPI void ewk_context_tls_error_policy_set ( Ewk_Context context,
Ewk_TLS_Error_Policy  tls_error_policy 
)

Sets TLS error policy for context.

Sets how TLS certificate errors should be handled. The available policies are listed in Ewk_TLS_Error_Policy enumeration.

Parameters
contextcontext object to set TLS error policy
tls_error_policya Ewk_TLS_Error_Policy
EAPI Eina_Bool ewk_context_url_scheme_register ( Ewk_Context context,
const char *  scheme,
Ewk_Url_Scheme_Request_Cb  callback,
void *  user_data 
)

Register scheme in context.

When an URL request with scheme is made in the Ewk_Context, the callback function provided will be called with a Ewk_Url_Scheme_Request.

It is possible to handle URL scheme requests asynchronously, by calling ewk_url_scheme_ref() on the Ewk_Url_Scheme_Request and calling ewk_url_scheme_request_finish() later when the data of the request is available.

Parameters
contexta Ewk_Context object.
schemethe network scheme to register
callbackthe function to be called when an URL request with scheme is made.
user_datadata to pass to callback function
static void about_url_scheme_request_cb(Ewk_Url_Scheme_Request *request, void *user_data)
{
const char *path;
char *contents_data = NULL;
unsigned int contents_length = 0;
if (!strcmp(path, "plugins")) {
// Initialize contents_data with the contents of plugins about page, and set its length to contents_length
} else if (!strcmp(path, "memory")) {
// Initialize contents_data with the contents of memory about page, and set its length to contents_length
} else if (!strcmp(path, "applications")) {
// Initialize contents_data with the contents of application about page, and set its length to contents_length
} else {
Eina_Strbuf *buf = eina_strbuf_new();
eina_strbuf_append_printf(buf, "&lt;html&gt;&lt;body&gt;&lt;p&gt;Invalid about:%s page&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;", path);
contents_data = eina_strbuf_string_steal(buf);
contents_length = strlen(contents);
eina_strbuf_free(buf);
}
ewk_url_scheme_request_finish(request, contents_data, contents_length, "text/html");
free(contents_data);
}
EAPI void ewk_context_visited_link_add ( Ewk_Context context,
const char *  visited_url 
)

Registers the given visited_url as visited link in context visited link cache.

This function shall be invoked as a response to populateVisitedLinks callback of the history cient.

Parameters
contextcontext object to add visited link data
visited_urlvisited url
See Also
Ewk_Context_History_Client