Exemplo n.º 1
0
static
void
run_node_command(Command *self, Context *context)
{
	fprintf(stderr, "Started Node\n");
	cef_string_t name = {};
	cef_string_set(u"CapybaraInvocation", 18, &name, 0);
	cef_process_message_t *message = cef_process_message_create(&name);

	cef_list_value_t *args = message->get_argument_list(message);

	cef_string_t value = {};
	cef_string_utf8_to_utf16(self->arguments[0], strlen(self->arguments[0]), &value);
	args->set_string(args, 0, &value);

	args->set_bool(args, 1, strcmp(self->arguments[1], "true") == 0);

	for (int i = 2; i < self->argument_count; i++) {
		cef_string_utf8_to_utf16(self->arguments[i], strlen(self->arguments[i]), &value);
		args->set_string(args, i, &value);
		cef_string_clear(&value);
	}

	context->browser->send_process_message(context->browser, PID_RENDERER, message);
}
void CEF_CALLBACK cfx_resource_handler_get_response_headers(cef_resource_handler_t* self, cef_response_t* response, int64* response_length, cef_string_t* redirectUrl) {
    char16* redirectUrl_tmp_str = redirectUrl->str; int redirectUrl_tmp_length = (int)redirectUrl->length;
    cfx_resource_handler_get_response_headers_callback(((cfx_resource_handler_t*)self)->gc_handle, response, response_length, &(redirectUrl_tmp_str), &(redirectUrl_tmp_length));
    if(redirectUrl_tmp_str != redirectUrl->str) {
        if(redirectUrl->dtor) redirectUrl->dtor(redirectUrl->str);
        cef_string_set(redirectUrl_tmp_str, redirectUrl_tmp_length, redirectUrl, 1);
        cfx_gc_handle_free((gc_handle_t)redirectUrl_tmp_str);
    }
}
Exemplo n.º 3
0
void CEF_CALLBACK cfx_request_handler_on_resource_redirect(cef_request_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_request_t* request, cef_string_t* new_url) {
    char16* new_url_tmp_str = new_url->str; int new_url_tmp_length = (int)new_url->length;
    cfx_request_handler_on_resource_redirect_callback(((cfx_request_handler_t*)self)->gc_handle, browser, frame, request, &(new_url_tmp_str), &(new_url_tmp_length));
    if(new_url_tmp_str != new_url->str) {
        if(new_url->dtor) new_url->dtor(new_url->str);
        cef_string_set(new_url_tmp_str, new_url_tmp_length, new_url, 1);
        cfx_gc_handle_free((gc_handle_t)new_url_tmp_str);
    }
}
int CEF_CALLBACK cfx_resource_bundle_handler_get_localized_string(cef_resource_bundle_handler_t* self, int string_id, cef_string_t* string) {
    int __retval;
    char16* string_tmp_str = 0; int string_tmp_length = 0; gc_handle_t string_gc_handle = 0;
    ((cfx_resource_bundle_handler_t*)self)->get_localized_string(((cfx_resource_bundle_handler_t*)self)->gc_handle, &__retval, string_id, &string_tmp_str, &string_tmp_length, &string_gc_handle);
    if(string_tmp_length > 0) {
        cef_string_set(string_tmp_str, string_tmp_length, string, 1);
        cfx_gc_handle_switch(&string_gc_handle, GC_HANDLE_FREE);
    }
    return __retval;
}
Exemplo n.º 5
0
static
void
run_find_css_command(Command *self, Context *context)
{
	fprintf(stderr, "Started FindCss\n");
	cef_string_t name = {};
	cef_string_set(u"CapybaraInvocation", 18, &name, 0);
	cef_process_message_t *message = cef_process_message_create(&name);

	cef_list_value_t *args = message->get_argument_list(message);

	cef_string_t value = {};
	cef_string_set(u"findCss", 7, &value, 0);
	args->set_string(args, 0, &value);

	args->set_bool(args, 1, 1);

	cef_string_utf8_to_utf16(self->arguments[0], strlen(self->arguments[0]), &value);
	args->set_string(args, 2, &value);
	cef_string_clear(&value);

	context->browser->send_process_message(context->browser, PID_RENDERER, message);
}
Exemplo n.º 6
0
int CEF_CALLBACK cfx_v8handler_execute(cef_v8handler_t* self, const cef_string_t* name, cef_v8value_t* object, size_t argumentsCount, cef_v8value_t* const* arguments, cef_v8value_t** retval, cef_string_t* exception) {
    int __retval;
    int object_release;
    int arguments_release;
    char16* exception_tmp_str = 0; int exception_tmp_length = 0; gc_handle_t exception_gc_handle = 0;
    ((cfx_v8handler_t*)self)->execute(((cfx_v8handler_t*)self)->gc_handle, &__retval, name ? name->str : 0, name ? (int)name->length : 0, object, &object_release, argumentsCount, arguments, &arguments_release, retval, &exception_tmp_str, &exception_tmp_length, &exception_gc_handle);
    if(object_release && object) object->base.release((cef_base_ref_counted_t*)object);
    if(arguments_release) {
        for(size_t i = 0; i < argumentsCount; ++i) {
            arguments[i]->base.release((cef_base_ref_counted_t*)arguments[i]);
        }
    }
    if(*retval)((cef_base_ref_counted_t*)*retval)->add_ref((cef_base_ref_counted_t*)*retval);
    if(exception_tmp_length > 0) {
        cef_string_set(exception_tmp_str, exception_tmp_length, exception, 1);
        cfx_gc_handle_switch(&exception_gc_handle, GC_HANDLE_FREE);
    }
    return __retval;
}
static int CEF_CALLBACK
execute(struct _cef_v8handler_t* self,
    const cef_string_t* name, struct _cef_v8value_t* object,
    size_t argumentsCount, struct _cef_v8value_t* const* arguments,
    struct _cef_v8value_t** retval, cef_string_t* exception)
{
	int success;
	cef_string_utf8_t out = {};
	cef_string_utf16_to_utf8(name->str, name->length, &out);
	if (strcmp(out.str, "clickTest") == 0) {
		cef_v8value_t *result = cef_v8value_create_bool(1);
		*retval = result;
		success = 1;
	} else if (strcmp(out.str, "leftClick") == 0) {
		cef_v8context_t *context = cef_v8context_get_current_context();
		cef_browser_t *browser = context->get_browser(context);

		cef_string_t message_name = {};
		cef_string_set(u"SendMouseClickEvent", 19, &message_name, 0);
		cef_process_message_t *cef_message = cef_process_message_create(&message_name);

		cef_list_value_t *args = cef_message->get_argument_list(cef_message);

		int x = arguments[0]->get_int_value(arguments[0]);
		args->set_int(args, 0, x);
		int y = arguments[0]->get_int_value(arguments[1]);
		args->set_int(args, 1, y);

		browser->send_process_message(browser, PID_BROWSER, cef_message);
		browser->base.release((cef_base_t *)browser);

		success = 1;
	} else if (strcmp(out.str, "done") == 0) {
		cef_string_t name = {};
		cef_string_set(u"RequestInvocationResult", 23, &name, 0);
		cef_process_message_t *message = cef_process_message_create(&name);

		cef_v8context_t *context = cef_v8context_get_current_context();
		cef_browser_t *browser = context->get_browser(context);
		browser->base.add_ref((cef_base_t *)browser);

		BrowserMessageTask *t = calloc(1, sizeof(BrowserMessageTask));
		t->browser = browser;
		t->message = message;
		((cef_task_t *)t)->base.size = sizeof(BrowserMessageTask);
		((cef_task_t *)t)->execute = execute_done_task;
		cef_post_task(TID_RENDERER, (cef_task_t *)t);

		success = 1;
	} else if (strcmp(out.str, "keypress") == 0) {
		cef_v8context_t *context = cef_v8context_get_current_context();
		cef_browser_t *browser = context->get_browser(context);

		cef_string_t message_name = {};
		cef_string_set(u"SendKeyEvent", 12, &message_name, 0);
		cef_process_message_t *cef_message = cef_process_message_create(&message_name);

		cef_list_value_t *args = cef_message->get_argument_list(cef_message);

		int c = arguments[0]->get_int_value(arguments[0]);
		args->set_int(args, 0, c);

		browser->send_process_message(browser, PID_BROWSER, cef_message);
		browser->base.release((cef_base_t *)browser);

		success = 1;
	} else {
		success = 0;
	}
	cef_string_utf8_clear(&out);

	return success;
}