| 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 ICoreWebView2Settings5Vtbl 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 | } |
| 42 | |
| 43 | type ICoreWebView2Settings5 struct { |
| 44 | Vtbl *ICoreWebView2Settings5Vtbl |
| 45 | } |
| 46 | |
| 47 | func (i *ICoreWebView2Settings5) AddRef() uintptr { |
| 48 | refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) |
| 49 | return refCounter |
| 50 | } |
| 51 | |
| 52 | func (i *ICoreWebViewSettings) GetICoreWebView2Settings5() *ICoreWebView2Settings5 { |
| 53 | var result *ICoreWebView2Settings5 |
| 54 | |
| 55 | iidICoreWebView2Settings5 := NewGUID("{183e7052-1d03-43a0-ab99-98e043b66b39}") |
| 56 | _, _, _ = i.vtbl.QueryInterface.Call( |
| 57 | uintptr(unsafe.Pointer(i)), |
| 58 | uintptr(unsafe.Pointer(iidICoreWebView2Settings5)), |
| 59 | uintptr(unsafe.Pointer(&result))) |
| 60 | |
| 61 | return result |
| 62 | } |
| 63 | |
| 64 | func (i *ICoreWebView2Settings5) GetIsPinchZoomEnabled() (bool, error) { |
| 65 | // Create int32 to hold bool result |
| 66 | var _enabled int32 |
| 67 | |
| 68 | hr, _, _ := i.Vtbl.GetIsPinchZoomEnabled.Call( |
| 69 | uintptr(unsafe.Pointer(i)), |
| 70 | uintptr(unsafe.Pointer(&_enabled)), |
| 71 | ) |
| 72 | if windows.Handle(hr) != windows.S_OK { |
| 73 | return false, syscall.Errno(hr) |
| 74 | } |
| 75 | // Get result and cleanup |
| 76 | enabled := _enabled != 0 |
| 77 | return enabled, nil |
| 78 | } |
| 79 | |
| 80 | func (i *ICoreWebView2Settings5) PutIsPinchZoomEnabled(enabled bool) error { |
| 81 | |
| 82 | hr, _, _ := i.Vtbl.PutIsPinchZoomEnabled.Call( |
| 83 | uintptr(unsafe.Pointer(i)), |
| 84 | uintptr(unsafe.Pointer(&enabled)), |
| 85 | ) |
| 86 | if windows.Handle(hr) != windows.S_OK { |
| 87 | return syscall.Errno(hr) |
| 88 | } |
| 89 | return nil |
| 90 | } |
| 91 |