| 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 ICoreWebView2Settings6Vtbl 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 | GetIsPasswordAutosaveEnabled ComProc |
| 36 | PutIsPasswordAutosaveEnabled ComProc |
| 37 | GetIsGeneralAutofillEnabled ComProc |
| 38 | PutIsGeneralAutofillEnabled ComProc |
| 39 | GetIsPinchZoomEnabled ComProc |
| 40 | PutIsPinchZoomEnabled ComProc |
| 41 | GetIsSwipeNavigationEnabled ComProc |
| 42 | PutIsSwipeNavigationEnabled ComProc |
| 43 | } |
| 44 | |
| 45 | type ICoreWebView2Settings6 struct { |
| 46 | Vtbl *ICoreWebView2Settings6Vtbl |
| 47 | } |
| 48 | |
| 49 | func (i *ICoreWebView2Settings6) AddRef() uintptr { |
| 50 | refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) |
| 51 | return refCounter |
| 52 | } |
| 53 | |
| 54 | func (i *ICoreWebViewSettings) GetICoreWebView2Settings6() *ICoreWebView2Settings6 { |
| 55 | var result *ICoreWebView2Settings6 |
| 56 | |
| 57 | iidICoreWebView2Settings6 := NewGUID("{11cb3acd-9bc8-43b8-83bf-f40753714f87}") |
| 58 | i.vtbl.QueryInterface.Call( |
| 59 | uintptr(unsafe.Pointer(i)), |
| 60 | uintptr(unsafe.Pointer(iidICoreWebView2Settings6)), |
| 61 | uintptr(unsafe.Pointer(&result))) |
| 62 | |
| 63 | return result |
| 64 | } |
| 65 | |
| 66 | func (i *ICoreWebView2Settings6) GetIsSwipeNavigationEnabled() (bool, error) { |
| 67 | // Create int32 to hold bool result |
| 68 | var _enabled int32 |
| 69 | |
| 70 | hr, _, _ := i.Vtbl.GetIsSwipeNavigationEnabled.Call( |
| 71 | uintptr(unsafe.Pointer(i)), |
| 72 | uintptr(unsafe.Pointer(&_enabled)), |
| 73 | ) |
| 74 | if windows.Handle(hr) != windows.S_OK { |
| 75 | return false, syscall.Errno(hr) |
| 76 | } |
| 77 | // Get result and cleanup |
| 78 | enabled := _enabled != 0 |
| 79 | return enabled, nil |
| 80 | } |
| 81 | |
| 82 | func (i *ICoreWebView2Settings6) PutIsSwipeNavigationEnabled(enabled bool) error { |
| 83 | |
| 84 | hr, _, _ := i.Vtbl.PutIsSwipeNavigationEnabled.Call( |
| 85 | uintptr(unsafe.Pointer(i)), |
| 86 | uintptr(boolToInt(enabled)), |
| 87 | ) |
| 88 | if windows.Handle(hr) != windows.S_OK { |
| 89 | return syscall.Errno(hr) |
| 90 | } |
| 91 | return nil |
| 92 | } |
| 93 |