| 1 | //go:build windows |
| 2 | |
| 3 | package edge |
| 4 | |
| 5 | import ( |
| 6 | "golang.org/x/sys/windows" |
| 7 | "syscall" |
| 8 | "unsafe" |
| 9 | ) |
| 10 | |
| 11 | type ICoreWebView2Settings3Vtbl struct { |
| 12 | _IUnknownVtbl |
| 13 | GetIsScriptEnabled ComProc |
| 14 | PutIsScriptEnabled ComProc |
| 15 | GetIsWebMessageEnabled ComProc |
| 16 | PutIsWebMessageEnabled ComProc |
| 17 | GetAreDefaultScriptDialogsEnabled ComProc |
| 18 | PutAreDefaultScriptDialogsEnabled ComProc |
| 19 | GetIsStatusBarEnabled ComProc |
| 20 | PutIsStatusBarEnabled ComProc |
| 21 | GetAreDevToolsEnabled ComProc |
| 22 | PutAreDevToolsEnabled ComProc |
| 23 | GetAreDefaultContextMenusEnabled ComProc |
| 24 | PutAreDefaultContextMenusEnabled ComProc |
| 25 | GetAreHostObjectsAllowed ComProc |
| 26 | PutAreHostObjectsAllowed ComProc |
| 27 | GetIsZoomControlEnabled ComProc |
| 28 | PutIsZoomControlEnabled ComProc |
| 29 | GetIsBuiltInErrorPageEnabled ComProc |
| 30 | PutIsBuiltInErrorPageEnabled ComProc |
| 31 | GetUserAgent ComProc |
| 32 | PutUserAgent ComProc |
| 33 | GetAreBrowserAcceleratorKeysEnabled ComProc |
| 34 | PutAreBrowserAcceleratorKeysEnabled ComProc |
| 35 | } |
| 36 | |
| 37 | type ICoreWebView2Settings3 struct { |
| 38 | Vtbl *ICoreWebView2Settings3Vtbl |
| 39 | } |
| 40 | |
| 41 | func (i *ICoreWebView2Settings3) AddRef() uintptr { |
| 42 | refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) |
| 43 | return refCounter |
| 44 | } |
| 45 | |
| 46 | func (i *ICoreWebViewSettings) GetICoreWebView2Settings3() *ICoreWebView2Settings3 { |
| 47 | var result *ICoreWebView2Settings3 |
| 48 | |
| 49 | iidICoreWebView2Settings3 := NewGUID("{fdb5ab74-af33-4854-84f0-0a631deb5eba}") |
| 50 | _, _, _ = i.vtbl.QueryInterface.Call( |
| 51 | uintptr(unsafe.Pointer(i)), |
| 52 | uintptr(unsafe.Pointer(iidICoreWebView2Settings3)), |
| 53 | uintptr(unsafe.Pointer(&result))) |
| 54 | |
| 55 | return result |
| 56 | } |
| 57 | |
| 58 | func (i *ICoreWebView2Settings3) GetAreBrowserAcceleratorKeysEnabled() (bool, error) { |
| 59 | // Create int32 to hold bool result |
| 60 | var _areBrowserAcceleratorKeysEnabled int32 |
| 61 | |
| 62 | hr, _, _ := i.Vtbl.GetAreBrowserAcceleratorKeysEnabled.Call( |
| 63 | uintptr(unsafe.Pointer(i)), |
| 64 | uintptr(unsafe.Pointer(&_areBrowserAcceleratorKeysEnabled)), |
| 65 | ) |
| 66 | if windows.Handle(hr) != windows.S_OK { |
| 67 | return false, syscall.Errno(hr) |
| 68 | } |
| 69 | // Get result and cleanup |
| 70 | areBrowserAcceleratorKeysEnabled := _areBrowserAcceleratorKeysEnabled != 0 |
| 71 | return areBrowserAcceleratorKeysEnabled, nil |
| 72 | } |
| 73 | |
| 74 | func (i *ICoreWebView2Settings3) PutAreBrowserAcceleratorKeysEnabled(areBrowserAcceleratorKeysEnabled bool) error { |
| 75 | |
| 76 | hr, _, _ := i.Vtbl.PutAreBrowserAcceleratorKeysEnabled.Call( |
| 77 | uintptr(unsafe.Pointer(i)), |
| 78 | uintptr(unsafe.Pointer(&areBrowserAcceleratorKeysEnabled)), |
| 79 | ) |
| 80 | if windows.Handle(hr) != windows.S_OK { |
| 81 | return syscall.Errno(hr) |
| 82 | } |
| 83 | return nil |
| 84 | } |
| 85 |