| 1 | //go:build windows |
| 2 | |
| 3 | package edge |
| 4 | |
| 5 | import ( |
| 6 | "unsafe" |
| 7 | |
| 8 | "golang.org/x/sys/windows" |
| 9 | ) |
| 10 | |
| 11 | type iCoreWebView2_3Vtbl struct { |
| 12 | iCoreWebView2_2Vtbl |
| 13 | TrySuspend ComProc |
| 14 | Resume ComProc |
| 15 | GetIsSuspended ComProc |
| 16 | SetVirtualHostNameToFolderMapping ComProc |
| 17 | ClearVirtualHostNameToFolderMapping ComProc |
| 18 | } |
| 19 | |
| 20 | type ICoreWebView2_3 struct { |
| 21 | vtbl *iCoreWebView2_3Vtbl |
| 22 | } |
| 23 | |
| 24 | func (i *ICoreWebView2_3) AddRef() uint32 { |
| 25 | ret, _, _ := i.vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) |
| 26 | |
| 27 | return uint32(ret) |
| 28 | } |
| 29 | |
| 30 | func (i *ICoreWebView2_3) Release() uint32 { |
| 31 | ret, _, _ := i.vtbl.Release.Call(uintptr(unsafe.Pointer(i))) |
| 32 | |
| 33 | return uint32(ret) |
| 34 | } |
| 35 | |
| 36 | func (i *ICoreWebView2_3) SetVirtualHostNameToFolderMapping(hostName, folderPath string, accessKind COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND) error { |
| 37 | _hostName, err := windows.UTF16PtrFromString(hostName) |
| 38 | if err != nil { |
| 39 | return err |
| 40 | } |
| 41 | |
| 42 | _folderPath, err := windows.UTF16PtrFromString(folderPath) |
| 43 | if err != nil { |
| 44 | return err |
| 45 | } |
| 46 | |
| 47 | hr, _, _ := i.vtbl.SetVirtualHostNameToFolderMapping.Call( |
| 48 | uintptr(unsafe.Pointer(i)), |
| 49 | uintptr(unsafe.Pointer(_hostName)), |
| 50 | uintptr(unsafe.Pointer(_folderPath)), |
| 51 | uintptr(accessKind), |
| 52 | ) |
| 53 | if windows.Handle(hr) != windows.S_OK { |
| 54 | return windows.Errno(hr) |
| 55 | } |
| 56 | |
| 57 | return nil |
| 58 | } |
| 59 | |
| 60 | func (i *ICoreWebView2) GetICoreWebView2_3() *ICoreWebView2_3 { |
| 61 | var result *ICoreWebView2_3 |
| 62 | |
| 63 | iidICoreWebView2_3 := NewGUID("{A0D6DF20-3B92-416D-AA0C-437A9C727857}") |
| 64 | _, _, _ = i.vtbl.QueryInterface.Call( |
| 65 | uintptr(unsafe.Pointer(i)), |
| 66 | uintptr(unsafe.Pointer(iidICoreWebView2_3)), |
| 67 | uintptr(unsafe.Pointer(&result))) |
| 68 | |
| 69 | return result |
| 70 | } |
| 71 | |
| 72 | func (e *Chromium) GetICoreWebView2_3() *ICoreWebView2_3 { |
| 73 | return e.webview.GetICoreWebView2_3() |
| 74 | } |
| 75 |