| 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 ICoreWebView2Settings4Vtbl 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 | } |
| 40 | |
| 41 | type ICoreWebView2Settings4 struct { |
| 42 | Vtbl *ICoreWebView2Settings4Vtbl |
| 43 | } |
| 44 | |
| 45 | func (i *ICoreWebView2Settings4) AddRef() uintptr { |
| 46 | refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) |
| 47 | return refCounter |
| 48 | } |
| 49 | |
| 50 | func (i *ICoreWebViewSettings) GetICoreWebView2Settings4() *ICoreWebView2Settings4 { |
| 51 | var result *ICoreWebView2Settings4 |
| 52 | |
| 53 | iidICoreWebView2Settings4 := NewGUID("{cb56846c-4168-4d53-b04f-03b6d6796ff2}") |
| 54 | _, _, _ = i.vtbl.QueryInterface.Call( |
| 55 | uintptr(unsafe.Pointer(i)), |
| 56 | uintptr(unsafe.Pointer(iidICoreWebView2Settings4)), |
| 57 | uintptr(unsafe.Pointer(&result))) |
| 58 | |
| 59 | return result |
| 60 | } |
| 61 | |
| 62 | func (i *ICoreWebView2Settings4) GetIsPasswordAutosaveEnabled() (bool, error) { |
| 63 | // Create int32 to hold bool result |
| 64 | var _value int32 |
| 65 | |
| 66 | hr, _, _ := i.Vtbl.GetIsPasswordAutosaveEnabled.Call( |
| 67 | uintptr(unsafe.Pointer(i)), |
| 68 | uintptr(unsafe.Pointer(&_value)), |
| 69 | ) |
| 70 | if windows.Handle(hr) != windows.S_OK { |
| 71 | return false, syscall.Errno(hr) |
| 72 | } |
| 73 | // Get result and cleanup |
| 74 | value := _value != 0 |
| 75 | return value, nil |
| 76 | } |
| 77 | |
| 78 | // PutIsPasswordAutosaveEnabled sets the IsPasswordAutosaveEnabled property. |
| 79 | // The default value is `FALSE`. |
| 80 | func (i *ICoreWebView2Settings4) PutIsPasswordAutosaveEnabled(value bool) error { |
| 81 | |
| 82 | hr, _, _ := i.Vtbl.PutIsPasswordAutosaveEnabled.Call( |
| 83 | uintptr(unsafe.Pointer(i)), |
| 84 | uintptr(boolToInt(value)), |
| 85 | ) |
| 86 | if windows.Handle(hr) != windows.S_OK { |
| 87 | return syscall.Errno(hr) |
| 88 | } |
| 89 | |
| 90 | return nil |
| 91 | } |
| 92 | |
| 93 | func (i *ICoreWebView2Settings4) GetIsGeneralAutofillEnabled() (bool, error) { |
| 94 | // Create int32 to hold bool result |
| 95 | var _value int32 |
| 96 | |
| 97 | hr, _, _ := i.Vtbl.GetIsGeneralAutofillEnabled.Call( |
| 98 | uintptr(unsafe.Pointer(i)), |
| 99 | uintptr(unsafe.Pointer(&_value)), |
| 100 | ) |
| 101 | if windows.Handle(hr) != windows.S_OK { |
| 102 | return false, syscall.Errno(hr) |
| 103 | } |
| 104 | // Get result and cleanup |
| 105 | value := _value != 0 |
| 106 | return value, nil |
| 107 | } |
| 108 | |
| 109 | func (i *ICoreWebView2Settings4) PutIsGeneralAutofillEnabled(value bool) error { |
| 110 | |
| 111 | hr, _, _ := i.Vtbl.PutIsGeneralAutofillEnabled.Call( |
| 112 | uintptr(unsafe.Pointer(i)), |
| 113 | uintptr(boolToInt(value)), |
| 114 | ) |
| 115 | |
| 116 | if windows.Handle(hr) != windows.S_OK { |
| 117 | return syscall.Errno(hr) |
| 118 | } |
| 119 | |
| 120 | return nil |
| 121 | } |
| 122 |