Here is the only documentation I have seen for the getters https://github.com/chromiumembedded/cef ... ent_capi.h
Below is my code if the getter is expected to only be called once, or if the struct that the getter creates is freed before being called again.
Request Handler Getter
- Code: Select all
static cef_request_handler_t* get_request_handler(cef_client_t* self) {
http_cef_request_handler_t* request_handler = http_cef_request_handler_init();
return &request_handler->base;
Initialize the client and set the request handler getter
- Code: Select all
http_cef_client_t* http_cef_client_init() {
http_cef_client_t* custom_client = (http_cef_client_t *)base_calloc(1,
sizeof(http_cef_client_t));
/* Initialize base structure */
cef_client_t* client = &custom_client->base;
client->base.size = sizeof(cef_client_t);
client->base.add_ref = add_ref_generic;
client->base.release = release_generic;
client->get_request_handler = get_request_handler;
return custom_client;
}
Request Handler Initializer
- Code: Select all
http_cef_request_handler_t* http_cef_request_handler_init() {
/* Allocate memory for the custom request handler */
http_cef_request_handler_t* handler =
(http_cef_request_handler_t *)base_calloc(1, sizeof(http_cef_request_handler_t));
/* Initialize base structure with its size and define callbacks */
handler->base.base.size = sizeof(cef_request_handler_t);
handler->base.base.add_ref = add_ref_generic;
handler->base.base.release = release_generic;
/* Return the new request handler instance */
return handler;
}