Skip to content
This repository has been archived by the owner on Jul 20, 2021. It is now read-only.

Commit

Permalink
Add new files
Browse files Browse the repository at this point in the history
  • Loading branch information
richardwilkes committed Jul 23, 2019
1 parent d4e937f commit 218131e
Show file tree
Hide file tree
Showing 12 changed files with 574 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cef/CookieAccessFilter_gen.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Code created from "callback.c.tmpl" - don't edit by hand

#include "CookieAccessFilter_gen.h"
#include "_cgo_export.h"

void gocef_set_cookie_access_filter_proxy(cef_cookie_access_filter_t *self) {
// Casts to (void *) added to avoid warnings since Go callbacks can't have
// some modifiers, such as 'const' applied to their parameter signatures.
self->can_send_cookie = (void *)&gocef_cookie_access_filter_can_send_cookie;
self->can_save_cookie = (void *)&gocef_cookie_access_filter_can_save_cookie;
}
98 changes: 98 additions & 0 deletions cef/CookieAccessFilter_gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// Code created from "callback.go.tmpl" - don't edit by hand

package cef

import (
"unsafe"

"github.com/richardwilkes/toolbox/errs"
"github.com/richardwilkes/toolbox/log/jot"
)

import (
// #include "CookieAccessFilter_gen.h"
"C"
)

// CookieAccessFilterProxy defines methods required for using CookieAccessFilter.
type CookieAccessFilterProxy interface {
CanSendCookie(self *CookieAccessFilter, browser *Browser, frame *Frame, request *Request, cookie *Cookie) int32
CanSaveCookie(self *CookieAccessFilter, browser *Browser, frame *Frame, request *Request, response *Response, cookie *Cookie) int32
}

// CookieAccessFilter (cef_cookie_access_filter_t from include/capi/cef_resource_request_handler_capi.h)
// Implement this structure to filter cookies that may be sent or received from
// resource requests. The functions of this structure will be called on the IO
// thread unless otherwise indicated.
type CookieAccessFilter C.cef_cookie_access_filter_t

// NewCookieAccessFilter creates a new CookieAccessFilter with the specified proxy. Passing
// in nil will result in default handling, if applicable.
func NewCookieAccessFilter(proxy CookieAccessFilterProxy) *CookieAccessFilter {
result := (*CookieAccessFilter)(unsafe.Pointer(newRefCntObj(C.sizeof_struct__cef_cookie_access_filter_t, proxy)))
if proxy != nil {
C.gocef_set_cookie_access_filter_proxy(result.toNative())
}
return result
}

func (d *CookieAccessFilter) toNative() *C.cef_cookie_access_filter_t {
return (*C.cef_cookie_access_filter_t)(d)
}

func lookupCookieAccessFilterProxy(obj *BaseRefCounted) CookieAccessFilterProxy {
proxy, exists := lookupProxy(obj)
if !exists {
jot.Fatal(1, errs.New("Proxy not found for ID"))
}
actual, ok := proxy.(CookieAccessFilterProxy)
if !ok {
jot.Fatal(1, errs.New("Proxy was not of type CookieAccessFilterProxy"))
}
return actual
}

// Base (base)
// Base structure.
func (d *CookieAccessFilter) Base() *BaseRefCounted {
return (*BaseRefCounted)(&d.base)
}

// CanSendCookie (can_send_cookie)
// Called on the IO thread before a resource request is sent. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers or cef_urlrequest_t. |request|
// cannot be modified in this callback. Return true (1) if the specified
// cookie can be sent with the request or false (0) otherwise.
func (d *CookieAccessFilter) CanSendCookie(browser *Browser, frame *Frame, request *Request, cookie *Cookie) int32 {
return lookupCookieAccessFilterProxy(d.Base()).CanSendCookie(d, browser, frame, request, cookie)
}

//nolint:gocritic
//export gocef_cookie_access_filter_can_send_cookie
func gocef_cookie_access_filter_can_send_cookie(self *C.cef_cookie_access_filter_t, browser *C.cef_browser_t, frame *C.cef_frame_t, request *C.cef_request_t, cookie *C.cef_cookie_t) C.int {
me__ := (*CookieAccessFilter)(self)
proxy__ := lookupCookieAccessFilterProxy(me__.Base())
cookie_ := cookie.toGo()
return C.int(proxy__.CanSendCookie(me__, (*Browser)(browser), (*Frame)(frame), (*Request)(request), cookie_))
}

// CanSaveCookie (can_save_cookie)
// Called on the IO thread after a resource response is received. The
// |browser| and |frame| values represent the source of the request, and may
// be NULL for requests originating from service workers or cef_urlrequest_t.
// |request| cannot be modified in this callback. Return true (1) if the
// specified cookie returned with the response can be saved or false (0)
// otherwise.
func (d *CookieAccessFilter) CanSaveCookie(browser *Browser, frame *Frame, request *Request, response *Response, cookie *Cookie) int32 {
return lookupCookieAccessFilterProxy(d.Base()).CanSaveCookie(d, browser, frame, request, response, cookie)
}

//nolint:gocritic
//export gocef_cookie_access_filter_can_save_cookie
func gocef_cookie_access_filter_can_save_cookie(self *C.cef_cookie_access_filter_t, browser *C.cef_browser_t, frame *C.cef_frame_t, request *C.cef_request_t, response *C.cef_response_t, cookie *C.cef_cookie_t) C.int {
me__ := (*CookieAccessFilter)(self)
proxy__ := lookupCookieAccessFilterProxy(me__.Base())
cookie_ := cookie.toGo()
return C.int(proxy__.CanSaveCookie(me__, (*Browser)(browser), (*Frame)(frame), (*Request)(request), (*Response)(response), cookie_))
}
11 changes: 11 additions & 0 deletions cef/CookieAccessFilter_gen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Code created from "callback.h.tmpl" - don't edit by hand

#ifndef GOCEF_CookieAccessFilter_H_
#define GOCEF_CookieAccessFilter_H_
#pragma once

#include "capi_gen.h"

void gocef_set_cookie_access_filter_proxy(cef_cookie_access_filter_t *self);

#endif // GOCEF_CookieAccessFilter_H_
10 changes: 10 additions & 0 deletions cef/ResourceReadCallback_gen.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Code created from "callback.c.tmpl" - don't edit by hand

#include "ResourceReadCallback_gen.h"
#include "_cgo_export.h"

void gocef_set_resource_read_callback_proxy(cef_resource_read_callback_t *self) {
// Casts to (void *) added to avoid warnings since Go callbacks can't have
// some modifiers, such as 'const' applied to their parameter signatures.
self->cont = (void *)&gocef_resource_read_callback_cont;
}
74 changes: 74 additions & 0 deletions cef/ResourceReadCallback_gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Code created from "callback.go.tmpl" - don't edit by hand

package cef

import (
"unsafe"

"github.com/richardwilkes/toolbox/errs"
"github.com/richardwilkes/toolbox/log/jot"
)

import (
// #include "ResourceReadCallback_gen.h"
"C"
)

// ResourceReadCallbackProxy defines methods required for using ResourceReadCallback.
type ResourceReadCallbackProxy interface {
Cont(self *ResourceReadCallback, bytes_read int32)
}

// ResourceReadCallback (cef_resource_read_callback_t from include/capi/cef_resource_handler_capi.h)
// Callback for asynchronous continuation of cef_resource_handler_t::read().
type ResourceReadCallback C.cef_resource_read_callback_t

// NewResourceReadCallback creates a new ResourceReadCallback with the specified proxy. Passing
// in nil will result in default handling, if applicable.
func NewResourceReadCallback(proxy ResourceReadCallbackProxy) *ResourceReadCallback {
result := (*ResourceReadCallback)(unsafe.Pointer(newRefCntObj(C.sizeof_struct__cef_resource_read_callback_t, proxy)))
if proxy != nil {
C.gocef_set_resource_read_callback_proxy(result.toNative())
}
return result
}

func (d *ResourceReadCallback) toNative() *C.cef_resource_read_callback_t {
return (*C.cef_resource_read_callback_t)(d)
}

func lookupResourceReadCallbackProxy(obj *BaseRefCounted) ResourceReadCallbackProxy {
proxy, exists := lookupProxy(obj)
if !exists {
jot.Fatal(1, errs.New("Proxy not found for ID"))
}
actual, ok := proxy.(ResourceReadCallbackProxy)
if !ok {
jot.Fatal(1, errs.New("Proxy was not of type ResourceReadCallbackProxy"))
}
return actual
}

// Base (base)
// Base structure.
func (d *ResourceReadCallback) Base() *BaseRefCounted {
return (*BaseRefCounted)(&d.base)
}

// Cont (cont)
// Callback for asynchronous continuation of read(). If |bytes_read| == 0 the
// response will be considered complete. If |bytes_read| > 0 then read() will
// be called again until the request is complete (based on either the result
// or the expected content length). If |bytes_read| < 0 then the request will
// fail and the |bytes_read| value will be treated as the error code.
func (d *ResourceReadCallback) Cont(bytes_read int32) {
lookupResourceReadCallbackProxy(d.Base()).Cont(d, bytes_read)
}

//nolint:gocritic
//export gocef_resource_read_callback_cont
func gocef_resource_read_callback_cont(self *C.cef_resource_read_callback_t, bytes_read C.int) {
me__ := (*ResourceReadCallback)(self)
proxy__ := lookupResourceReadCallbackProxy(me__.Base())
proxy__.Cont(me__, int32(bytes_read))
}
11 changes: 11 additions & 0 deletions cef/ResourceReadCallback_gen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Code created from "callback.h.tmpl" - don't edit by hand

#ifndef GOCEF_ResourceReadCallback_H_
#define GOCEF_ResourceReadCallback_H_
#pragma once

#include "capi_gen.h"

void gocef_set_resource_read_callback_proxy(cef_resource_read_callback_t *self);

#endif // GOCEF_ResourceReadCallback_H_
17 changes: 17 additions & 0 deletions cef/ResourceRequestHandler_gen.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Code created from "callback.c.tmpl" - don't edit by hand

#include "ResourceRequestHandler_gen.h"
#include "_cgo_export.h"

void gocef_set_resource_request_handler_proxy(cef_resource_request_handler_t *self) {
// Casts to (void *) added to avoid warnings since Go callbacks can't have
// some modifiers, such as 'const' applied to their parameter signatures.
self->get_cookie_access_filter = (void *)&gocef_resource_request_handler_get_cookie_access_filter;
self->on_before_resource_load = (void *)&gocef_resource_request_handler_on_before_resource_load;
self->get_resource_handler = (void *)&gocef_resource_request_handler_get_resource_handler;
self->on_resource_redirect = (void *)&gocef_resource_request_handler_on_resource_redirect;
self->on_resource_response = (void *)&gocef_resource_request_handler_on_resource_response;
self->get_resource_response_filter = (void *)&gocef_resource_request_handler_get_resource_response_filter;
self->on_resource_load_complete = (void *)&gocef_resource_request_handler_on_resource_load_complete;
self->on_protocol_execution = (void *)&gocef_resource_request_handler_on_protocol_execution;
}
Loading

0 comments on commit 218131e

Please sign in to comment.