Exemplo n.º 1
0
Arquivo: cef.go Projeto: regiontog/cef
func extractCefMultiMap(cefMapPointer C.cef_string_multimap_t) map[string][]string {
	numKeys := C.cef_string_multimap_size(cefMapPointer)
	goMap := make(map[string][]string)
	for i := 0; i < int(numKeys); i++ {
		var key *C.cef_string_utf16_t = C.cef_string_userfree_utf16_alloc()
		C.cef_string_multimap_key(cefMapPointer, C.int(i), C.cefString16CastToCefString(key))
		charKeyUtf8 := C.cefStringToUtf8(C.cefString16CastToCefString(key))
		goKey := C.GoString(charKeyUtf8.str)
		if _, ok := goMap[goKey]; ok {
			continue
		}
		numValsForKey := C.cef_string_multimap_find_count(cefMapPointer, C.cefString16CastToCefString(key))

		if numValsForKey >= 0 {
			goVals := make([]string, numValsForKey)
			for k := 0; k < int(numValsForKey); k++ {
				var val *C.cef_string_utf16_t = C.cef_string_userfree_utf16_alloc()
				C.cef_string_multimap_enumerate(cefMapPointer,
					C.cefString16CastToCefString(key), C.int(k), C.cefString16CastToCefString(val))
				charValUtf8 := C.cefStringToUtf8(C.cefString16CastToCefString(val))
				goVals[k] = C.GoString(charValUtf8.str)
				C.cef_string_userfree_utf8_free(charValUtf8)
				C.cef_string_userfree_utf16_free(val)
			}
			goMap[goKey] = goVals
		}
		C.cef_string_userfree_utf8_free(charKeyUtf8)
		C.cef_string_userfree_utf16_free(key)
	}
	return goMap
}
Exemplo n.º 2
0
func (r CefResponseT) GetHeader(name string) string {
	nameCs := C.CString(name)
	defer C.free(unsafe.Pointer(nameCs))
	valCef := C.cef_response_t_get_header(r.CStruct, nameCs)
	defer C.cef_string_userfree_utf8_free(valCef)
	return C.GoString(valCef.str)
}
Exemplo n.º 3
0
func (b CefBrowserT) GetFrameNames() []string {
	nameList := C.cef_string_list_alloc()
	C.cef_browser_t_get_frame_names(b.CStruct, nameList)
	length := int(C.cef_string_list_size(nameList))
	goList := make([]string, length)
	for i := range goList {
		var cefName *C.cef_string_utf16_t = C.cef_string_userfree_utf16_alloc()
		didRet := C.cef_string_list_value(nameList, C.int(i), C.cefString16CastToCefString(cefName))
		if didRet == C.int(1) {
			nameUtf8 := C.cefStringToUtf8(C.cefString16CastToCefString(cefName))
			goList[i] = C.GoString(nameUtf8.str)
			C.cef_string_userfree_utf8_free(nameUtf8)
		}
		C.cef_string_userfree_utf16_free(cefName)
	}
	return goList
}
Exemplo n.º 4
0
//export go_CreateSchemeHandler
func go_CreateSchemeHandler(
	self *C.struct__cef_scheme_handler_factory_t,
	browser *C.struct__cef_browser_t,
	frame *C.struct__cef_frame_t,
	scheme_name *C.cef_string_utf8_t,
	request *C.struct__cef_request_t) *C.struct__cef_resource_handler_t {

	schemeName := C.GoString(scheme_name.str)
	defer C.cef_string_userfree_utf8_free(scheme_name)

	if handler, ok := schemeHandlerMap[unsafe.Pointer(self)]; ok {
		return handler.Factory.CreateSchemeHandler(
			CefBrowserT{browser},
			CefFrameT{frame},
			schemeName,
			CefRequestT{request},
		).CStruct
	}
	return nil
}
Exemplo n.º 5
0
func (f CefFrameT) GetUrl() string {
	cefString := C.cef_frame_t_get_url(f.CStruct)
	defer C.cef_string_userfree_utf8_free(cefString)
	return C.GoString(cefString.str)
}
Exemplo n.º 6
0
func (r CefResponseT) GetMimeType() string {
	cefString := C.cef_response_t_get_mime_type(r.CStruct)
	defer C.cef_string_userfree_utf8_free(cefString)
	return C.GoString(cefString.str)
}
Exemplo n.º 7
0
func (r CefResponseT) GetStatusText() string {
	cefString := C.cef_response_t_get_status_text(r.CStruct)
	defer C.cef_string_userfree_utf8_free(cefString)
	return C.GoString(cefString.str)
}
Exemplo n.º 8
0
Arquivo: cef.go Projeto: mmatey/cef2go
func CEFToGoString(source *C.cef_string_t) string {
	utf8string := C.cefSourceToString(source)
	defer C.cef_string_userfree_utf8_free(utf8string)
	return C.GoString(utf8string.str)
}