| 1 | //go:build windows |
| 2 | |
| 3 | package edge |
| 4 | |
| 5 | import ( |
| 6 | "unsafe" |
| 7 | |
| 8 | "golang.org/x/sys/windows" |
| 9 | ) |
| 10 | |
| 11 | // ICoreWebviewSettings is the merged settings class |
| 12 | |
| 13 | type _ICoreWebViewSettingsVtbl struct { |
| 14 | _IUnknownVtbl |
| 15 | GetIsScriptEnabled ComProc |
| 16 | PutIsScriptEnabled ComProc |
| 17 | GetIsWebMessageEnabled ComProc |
| 18 | PutIsWebMessageEnabled ComProc |
| 19 | GetAreDefaultScriptDialogsEnabled ComProc |
| 20 | PutAreDefaultScriptDialogsEnabled ComProc |
| 21 | GetIsStatusBarEnabled ComProc |
| 22 | PutIsStatusBarEnabled ComProc |
| 23 | GetAreDevToolsEnabled ComProc |
| 24 | PutAreDevToolsEnabled ComProc |
| 25 | GetAreDefaultContextMenusEnabled ComProc |
| 26 | PutAreDefaultContextMenusEnabled ComProc |
| 27 | GetAreHostObjectsAllowed ComProc |
| 28 | PutAreHostObjectsAllowed ComProc |
| 29 | GetIsZoomControlEnabled ComProc |
| 30 | PutIsZoomControlEnabled ComProc |
| 31 | GetIsBuiltInErrorPageEnabled ComProc |
| 32 | PutIsBuiltInErrorPageEnabled ComProc |
| 33 | GetUserAgent ComProc // ICoreWebView2Settings2: SDK 1.0.864.35 |
| 34 | PutUserAgent ComProc |
| 35 | GetAreBrowserAcceleratorKeysEnabled ComProc // ICoreWebView2Settings3: SDK 1.0.864.35 |
| 36 | PutAreBrowserAcceleratorKeysEnabled ComProc |
| 37 | GetIsPasswordAutosaveEnabled ComProc // ICoreWebView2Settings4: SDK 1.0.902.49 |
| 38 | PutIsPasswordAutosaveEnabled ComProc |
| 39 | GetIsGeneralAutofillEnabled ComProc |
| 40 | PutIsGeneralAutofillEnabled ComProc |
| 41 | GetIsPinchZoomEnabled ComProc // ICoreWebView2Settings5: SDK 1.0.902.49 |
| 42 | PutIsPinchZoomEnabled ComProc |
| 43 | GetIsSwipeNavigationEnabled ComProc // ICoreWebView2Settings6: SDK 1.0.992.28 |
| 44 | PutIsSwipeNavigationEnabled ComProc |
| 45 | } |
| 46 | |
| 47 | type ICoreWebViewSettings struct { |
| 48 | vtbl *_ICoreWebViewSettingsVtbl |
| 49 | } |
| 50 | |
| 51 | func (i *ICoreWebViewSettings) AddRef() uint32 { |
| 52 | ret, _, _ := i.vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) |
| 53 | |
| 54 | return uint32(ret) |
| 55 | } |
| 56 | |
| 57 | func (i *ICoreWebViewSettings) Release() uint32 { |
| 58 | ret, _, _ := i.vtbl.Release.Call(uintptr(unsafe.Pointer(i))) |
| 59 | |
| 60 | return uint32(ret) |
| 61 | } |
| 62 | |
| 63 | func (i *ICoreWebViewSettings) GetIsScriptEnabled() (bool, error) { |
| 64 | var isScriptEnabled bool |
| 65 | hr, _, _ := i.vtbl.GetIsScriptEnabled.Call( |
| 66 | uintptr(unsafe.Pointer(i)), |
| 67 | uintptr(unsafe.Pointer(&isScriptEnabled)), |
| 68 | ) |
| 69 | if windows.Handle(hr) != windows.S_OK { |
| 70 | return false, windows.Errno(hr) |
| 71 | } |
| 72 | return isScriptEnabled, nil |
| 73 | } |
| 74 | |
| 75 | func (i *ICoreWebViewSettings) PutIsScriptEnabled(isScriptEnabled bool) error { |
| 76 | hr, _, _ := i.vtbl.PutIsScriptEnabled.Call( |
| 77 | uintptr(unsafe.Pointer(i)), |
| 78 | uintptr(boolToInt(isScriptEnabled)), |
| 79 | ) |
| 80 | if windows.Handle(hr) != windows.S_OK { |
| 81 | return windows.Errno(hr) |
| 82 | } |
| 83 | return nil |
| 84 | } |
| 85 | |
| 86 | func (i *ICoreWebViewSettings) GetIsWebMessageEnabled() (bool, error) { |
| 87 | var isWebMessageEnabled bool |
| 88 | hr, _, _ := i.vtbl.GetIsWebMessageEnabled.Call( |
| 89 | uintptr(unsafe.Pointer(i)), |
| 90 | uintptr(unsafe.Pointer(&isWebMessageEnabled)), |
| 91 | ) |
| 92 | if windows.Handle(hr) != windows.S_OK { |
| 93 | return false, windows.Errno(hr) |
| 94 | } |
| 95 | return isWebMessageEnabled, nil |
| 96 | } |
| 97 | |
| 98 | func (i *ICoreWebViewSettings) PutIsWebMessageEnabled(isWebMessageEnabled bool) error { |
| 99 | hr, _, _ := i.vtbl.PutIsWebMessageEnabled.Call( |
| 100 | uintptr(unsafe.Pointer(i)), |
| 101 | uintptr(boolToInt(isWebMessageEnabled)), |
| 102 | ) |
| 103 | if windows.Handle(hr) != windows.S_OK { |
| 104 | return windows.Errno(hr) |
| 105 | } |
| 106 | return nil |
| 107 | } |
| 108 | |
| 109 | func (i *ICoreWebViewSettings) GetAreDefaultScriptDialogsEnabled() (bool, error) { |
| 110 | var areDefaultScriptDialogsEnabled bool |
| 111 | hr, _, _ := i.vtbl.GetAreDefaultScriptDialogsEnabled.Call( |
| 112 | uintptr(unsafe.Pointer(i)), |
| 113 | uintptr(unsafe.Pointer(&areDefaultScriptDialogsEnabled)), |
| 114 | ) |
| 115 | if windows.Handle(hr) != windows.S_OK { |
| 116 | return false, windows.Errno(hr) |
| 117 | } |
| 118 | return areDefaultScriptDialogsEnabled, nil |
| 119 | } |
| 120 | |
| 121 | func (i *ICoreWebViewSettings) PutAreDefaultScriptDialogsEnabled(areDefaultScriptDialogsEnabled bool) error { |
| 122 | hr, _, _ := i.vtbl.PutAreDefaultScriptDialogsEnabled.Call( |
| 123 | uintptr(unsafe.Pointer(i)), |
| 124 | uintptr(boolToInt(areDefaultScriptDialogsEnabled)), |
| 125 | ) |
| 126 | if windows.Handle(hr) != windows.S_OK { |
| 127 | return windows.Errno(hr) |
| 128 | } |
| 129 | return nil |
| 130 | } |
| 131 | |
| 132 | func (i *ICoreWebViewSettings) GetIsStatusBarEnabled() (bool, error) { |
| 133 | var isStatusBarEnabled bool |
| 134 | hr, _, _ := i.vtbl.GetIsStatusBarEnabled.Call( |
| 135 | uintptr(unsafe.Pointer(i)), |
| 136 | uintptr(unsafe.Pointer(&isStatusBarEnabled)), |
| 137 | ) |
| 138 | if windows.Handle(hr) != windows.S_OK { |
| 139 | return false, windows.Errno(hr) |
| 140 | } |
| 141 | return isStatusBarEnabled, nil |
| 142 | } |
| 143 | |
| 144 | func (i *ICoreWebViewSettings) PutIsStatusBarEnabled(isStatusBarEnabled bool) error { |
| 145 | hr, _, _ := i.vtbl.PutIsStatusBarEnabled.Call( |
| 146 | uintptr(unsafe.Pointer(i)), |
| 147 | uintptr(boolToInt(isStatusBarEnabled)), |
| 148 | ) |
| 149 | if windows.Handle(hr) != windows.S_OK { |
| 150 | return windows.Errno(hr) |
| 151 | } |
| 152 | return nil |
| 153 | } |
| 154 | |
| 155 | func (i *ICoreWebViewSettings) GetAreDevToolsEnabled() (bool, error) { |
| 156 | var areDevToolsEnabled bool |
| 157 | hr, _, _ := i.vtbl.GetAreDevToolsEnabled.Call( |
| 158 | uintptr(unsafe.Pointer(i)), |
| 159 | uintptr(unsafe.Pointer(&areDevToolsEnabled)), |
| 160 | ) |
| 161 | if windows.Handle(hr) != windows.S_OK { |
| 162 | return false, windows.Errno(hr) |
| 163 | } |
| 164 | return areDevToolsEnabled, nil |
| 165 | } |
| 166 | |
| 167 | func (i *ICoreWebViewSettings) PutAreDevToolsEnabled(areDevToolsEnabled bool) error { |
| 168 | hr, _, _ := i.vtbl.PutAreDevToolsEnabled.Call( |
| 169 | uintptr(unsafe.Pointer(i)), |
| 170 | uintptr(boolToInt(areDevToolsEnabled)), |
| 171 | ) |
| 172 | if windows.Handle(hr) != windows.S_OK { |
| 173 | return windows.Errno(hr) |
| 174 | } |
| 175 | return nil |
| 176 | } |
| 177 | |
| 178 | func (i *ICoreWebViewSettings) GetAreDefaultContextMenusEnabled() (bool, error) { |
| 179 | var enabled bool |
| 180 | hr, _, _ := i.vtbl.GetAreDefaultContextMenusEnabled.Call( |
| 181 | uintptr(unsafe.Pointer(i)), |
| 182 | uintptr(unsafe.Pointer(&enabled)), |
| 183 | ) |
| 184 | if windows.Handle(hr) != windows.S_OK { |
| 185 | return false, windows.Errno(hr) |
| 186 | } |
| 187 | return enabled, nil |
| 188 | } |
| 189 | |
| 190 | func (i *ICoreWebViewSettings) PutAreDefaultContextMenusEnabled(enabled bool) error { |
| 191 | hr, _, _ := i.vtbl.PutAreDefaultContextMenusEnabled.Call( |
| 192 | uintptr(unsafe.Pointer(i)), |
| 193 | uintptr(boolToInt(enabled)), |
| 194 | ) |
| 195 | if windows.Handle(hr) != windows.S_OK { |
| 196 | return windows.Errno(hr) |
| 197 | } |
| 198 | return nil |
| 199 | } |
| 200 | |
| 201 | func (i *ICoreWebViewSettings) GetAreHostObjectsAllowed() (bool, error) { |
| 202 | var allowed bool |
| 203 | hr, _, _ := i.vtbl.GetAreHostObjectsAllowed.Call( |
| 204 | uintptr(unsafe.Pointer(i)), |
| 205 | uintptr(unsafe.Pointer(&allowed)), |
| 206 | ) |
| 207 | if windows.Handle(hr) != windows.S_OK { |
| 208 | return false, windows.Errno(hr) |
| 209 | } |
| 210 | return allowed, nil |
| 211 | } |
| 212 | |
| 213 | func (i *ICoreWebViewSettings) PutAreHostObjectsAllowed(allowed bool) error { |
| 214 | hr, _, _ := i.vtbl.PutAreHostObjectsAllowed.Call( |
| 215 | uintptr(unsafe.Pointer(i)), |
| 216 | uintptr(boolToInt(allowed)), |
| 217 | ) |
| 218 | if windows.Handle(hr) != windows.S_OK { |
| 219 | return windows.Errno(hr) |
| 220 | } |
| 221 | return nil |
| 222 | } |
| 223 | |
| 224 | func (i *ICoreWebViewSettings) GetIsZoomControlEnabled() (bool, error) { |
| 225 | var enabled bool |
| 226 | hr, _, _ := i.vtbl.GetIsZoomControlEnabled.Call( |
| 227 | uintptr(unsafe.Pointer(i)), |
| 228 | uintptr(unsafe.Pointer(&enabled)), |
| 229 | ) |
| 230 | if windows.Handle(hr) != windows.S_OK { |
| 231 | return false, windows.Errno(hr) |
| 232 | } |
| 233 | return enabled, nil |
| 234 | } |
| 235 | |
| 236 | func (i *ICoreWebViewSettings) PutIsZoomControlEnabled(enabled bool) error { |
| 237 | hr, _, _ := i.vtbl.PutIsZoomControlEnabled.Call( |
| 238 | uintptr(unsafe.Pointer(i)), |
| 239 | uintptr(boolToInt(enabled)), |
| 240 | ) |
| 241 | if windows.Handle(hr) != windows.S_OK { |
| 242 | return windows.Errno(hr) |
| 243 | } |
| 244 | return nil |
| 245 | } |
| 246 | |
| 247 | func (i *ICoreWebViewSettings) GetIsBuiltInErrorPageEnabled() (bool, error) { |
| 248 | var enabled bool |
| 249 | hr, _, _ := i.vtbl.GetIsBuiltInErrorPageEnabled.Call( |
| 250 | uintptr(unsafe.Pointer(i)), |
| 251 | uintptr(unsafe.Pointer(&enabled)), |
| 252 | ) |
| 253 | if windows.Handle(hr) != windows.S_OK { |
| 254 | return false, windows.Errno(hr) |
| 255 | } |
| 256 | return enabled, nil |
| 257 | } |
| 258 | |
| 259 | func (i *ICoreWebViewSettings) PutIsBuiltInErrorPageEnabled(enabled bool) error { |
| 260 | hr, _, _ := i.vtbl.PutIsBuiltInErrorPageEnabled.Call( |
| 261 | uintptr(unsafe.Pointer(i)), |
| 262 | uintptr(boolToInt(enabled)), |
| 263 | ) |
| 264 | if windows.Handle(hr) != windows.S_OK { |
| 265 | return windows.Errno(hr) |
| 266 | } |
| 267 | return nil |
| 268 | } |
| 269 | |
| 270 | func (i *ICoreWebViewSettings) GetUserAgent() (string, error) { |
| 271 | // Create *uint16 to hold result |
| 272 | var _userAgent *uint16 |
| 273 | hr, _, _ := i.vtbl.GetUserAgent.Call( |
| 274 | uintptr(unsafe.Pointer(i)), |
| 275 | uintptr(unsafe.Pointer(_userAgent)), |
| 276 | ) |
| 277 | if windows.Handle(hr) != windows.S_OK { |
| 278 | return "", windows.Errno(hr) |
| 279 | } // Get result and cleanup |
| 280 | userAgent := windows.UTF16PtrToString(_userAgent) |
| 281 | windows.CoTaskMemFree(unsafe.Pointer(_userAgent)) |
| 282 | return userAgent, nil |
| 283 | } |
| 284 | |
| 285 | func (i *ICoreWebViewSettings) PutUserAgent(userAgent string) error { |
| 286 | |
| 287 | // Convert string 'userAgent' to *uint16 |
| 288 | _userAgent, err := windows.UTF16PtrFromString(userAgent) |
| 289 | if err != nil { |
| 290 | return err |
| 291 | } |
| 292 | |
| 293 | hr, _, _ := i.vtbl.PutUserAgent.Call( |
| 294 | uintptr(unsafe.Pointer(i)), |
| 295 | uintptr(unsafe.Pointer(_userAgent)), |
| 296 | ) |
| 297 | if windows.Handle(hr) != windows.S_OK { |
| 298 | return windows.Errno(hr) |
| 299 | } |
| 300 | return nil |
| 301 | } |
| 302 | |
| 303 | func (i *ICoreWebViewSettings) GetAreBrowserAcceleratorKeysEnabled() (bool, error) { |
| 304 | var enabled bool |
| 305 | hr, _, _ := i.vtbl.GetAreBrowserAcceleratorKeysEnabled.Call( |
| 306 | uintptr(unsafe.Pointer(i)), |
| 307 | uintptr(unsafe.Pointer(&enabled)), |
| 308 | ) |
| 309 | if windows.Handle(hr) != windows.S_OK { |
| 310 | return false, windows.Errno(hr) |
| 311 | } |
| 312 | return enabled, nil |
| 313 | } |
| 314 | |
| 315 | func (i *ICoreWebViewSettings) PutAreBrowserAcceleratorKeysEnabled(enabled bool) error { |
| 316 | hr, _, _ := i.vtbl.PutAreBrowserAcceleratorKeysEnabled.Call( |
| 317 | uintptr(unsafe.Pointer(i)), |
| 318 | uintptr(boolToInt(enabled)), |
| 319 | ) |
| 320 | if windows.Handle(hr) != windows.S_OK { |
| 321 | return windows.Errno(hr) |
| 322 | } |
| 323 | return nil |
| 324 | } |
| 325 | |
| 326 | func (i *ICoreWebViewSettings) GetIsPinchZoomEnabled() (bool, error) { |
| 327 | var enabled bool |
| 328 | hr, _, _ := i.vtbl.GetIsPinchZoomEnabled.Call( |
| 329 | uintptr(unsafe.Pointer(i)), |
| 330 | uintptr(unsafe.Pointer(&enabled)), |
| 331 | ) |
| 332 | if windows.Handle(hr) != windows.S_OK { |
| 333 | return false, windows.Errno(hr) |
| 334 | } |
| 335 | return enabled, nil |
| 336 | } |
| 337 | |
| 338 | func (i *ICoreWebViewSettings) PutIsPinchZoomEnabled(enabled bool) error { |
| 339 | hr, _, _ := i.vtbl.PutIsPinchZoomEnabled.Call( |
| 340 | uintptr(unsafe.Pointer(i)), |
| 341 | uintptr(boolToInt(enabled)), |
| 342 | ) |
| 343 | if windows.Handle(hr) != windows.S_OK { |
| 344 | return windows.Errno(hr) |
| 345 | } |
| 346 | return nil |
| 347 | } |
| 348 | |
| 349 | func (i *ICoreWebViewSettings) GetIsSwipeNavigationEnabled() (bool, error) { |
| 350 | var enabled bool |
| 351 | hr, _, _ := i.vtbl.GetIsSwipeNavigationEnabled.Call( |
| 352 | uintptr(unsafe.Pointer(i)), |
| 353 | uintptr(unsafe.Pointer(&enabled)), |
| 354 | ) |
| 355 | if windows.Handle(hr) != windows.S_OK { |
| 356 | return false, windows.Errno(hr) |
| 357 | } |
| 358 | return enabled, nil |
| 359 | } |
| 360 | |
| 361 | func (i *ICoreWebViewSettings) PutIsSwipeNavigationEnabled(enabled bool) error { |
| 362 | hr, _, _ := i.vtbl.PutIsSwipeNavigationEnabled.Call( |
| 363 | uintptr(unsafe.Pointer(i)), |
| 364 | uintptr(boolToInt(enabled)), |
| 365 | ) |
| 366 | if windows.Handle(hr) != windows.S_OK { |
| 367 | return windows.Errno(hr) |
| 368 | } |
| 369 | return nil |
| 370 | } |
| 371 |