| 1 | //go:build windows |
| 2 | |
| 3 | package edge |
| 4 | |
| 5 | import ( |
| 6 | "syscall" |
| 7 | "unsafe" |
| 8 | |
| 9 | "golang.org/x/sys/windows" |
| 10 | ) |
| 11 | |
| 12 | type iCoreWebView2_2Vtbl struct { |
| 13 | QueryInterface ComProc |
| 14 | AddRef ComProc |
| 15 | Release ComProc |
| 16 | // ICoreWebView2 methods |
| 17 | GetSettings ComProc |
| 18 | GetSource ComProc |
| 19 | Navigate ComProc |
| 20 | NavigateToString ComProc |
| 21 | AddNavigationStarting ComProc |
| 22 | RemoveNavigationStarting ComProc |
| 23 | AddContentLoading ComProc |
| 24 | RemoveContentLoading ComProc |
| 25 | AddSourceChanged ComProc |
| 26 | RemoveSourceChanged ComProc |
| 27 | AddHistoryChanged ComProc |
| 28 | RemoveHistoryChanged ComProc |
| 29 | AddNavigationCompleted ComProc |
| 30 | RemoveNavigationCompleted ComProc |
| 31 | AddFrameNavigationStarting ComProc |
| 32 | RemoveFrameNavigationStarting ComProc |
| 33 | AddFrameNavigationCompleted ComProc |
| 34 | RemoveFrameNavigationCompleted ComProc |
| 35 | AddScriptDialogOpening ComProc |
| 36 | RemoveScriptDialogOpening ComProc |
| 37 | AddPermissionRequested ComProc |
| 38 | RemovePermissionRequested ComProc |
| 39 | AddProcessFailed ComProc |
| 40 | RemoveProcessFailed ComProc |
| 41 | AddScriptToExecuteOnDocumentCreated ComProc |
| 42 | RemoveScriptToExecuteOnDocumentCreated ComProc |
| 43 | ExecuteScript ComProc |
| 44 | CapturePreview ComProc |
| 45 | Reload ComProc |
| 46 | PostWebMessageAsJSON ComProc |
| 47 | PostWebMessageAsString ComProc |
| 48 | AddWebMessageReceived ComProc |
| 49 | RemoveWebMessageReceived ComProc |
| 50 | CallDevToolsProtocolMethod ComProc |
| 51 | GetBrowserProcessID ComProc |
| 52 | GetCanGoBack ComProc |
| 53 | GetCanGoForward ComProc |
| 54 | GoBack ComProc |
| 55 | GoForward ComProc |
| 56 | GetDevToolsProtocolEventReceiver ComProc |
| 57 | Stop ComProc |
| 58 | AddNewWindowRequested ComProc |
| 59 | RemoveNewWindowRequested ComProc |
| 60 | AddDocumentTitleChanged ComProc |
| 61 | RemoveDocumentTitleChanged ComProc |
| 62 | GetDocumentTitle ComProc |
| 63 | AddHostObjectToScript ComProc |
| 64 | RemoveHostObjectFromScript ComProc |
| 65 | OpenDevToolsWindow ComProc |
| 66 | AddContainsFullScreenElementChanged ComProc |
| 67 | RemoveContainsFullScreenElementChanged ComProc |
| 68 | GetContainsFullScreenElement ComProc |
| 69 | AddWebResourceRequested ComProc |
| 70 | RemoveWebResourceRequested ComProc |
| 71 | AddWebResourceRequestedFilter ComProc |
| 72 | RemoveWebResourceRequestedFilter ComProc |
| 73 | AddWindowCloseRequested ComProc |
| 74 | RemoveWindowCloseRequested ComProc |
| 75 | // ICoreWebView2_2 methods |
| 76 | AddWebResourceResponseReceived ComProc |
| 77 | RemoveWebResourceResponseReceived ComProc |
| 78 | NavigateWithWebResourceRequest ComProc |
| 79 | AddDomContentLoaded ComProc |
| 80 | RemoveDomContentLoaded ComProc |
| 81 | GetCookieManager ComProc |
| 82 | GetEnvironment ComProc |
| 83 | } |
| 84 | |
| 85 | type ICoreWebView2_2 struct { |
| 86 | vtbl *iCoreWebView2_2Vtbl |
| 87 | } |
| 88 | |
| 89 | // AddRef increments the reference count of the ICoreWebView2_2 interface |
| 90 | func (i *ICoreWebView2_2) AddRef() uint32 { |
| 91 | ret, _, _ := i.vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) |
| 92 | |
| 93 | return uint32(ret) |
| 94 | } |
| 95 | |
| 96 | // Release decrements the reference count of the ICoreWebView2_2 interface |
| 97 | func (i *ICoreWebView2_2) Release() uint32 { |
| 98 | ret, _, _ := i.vtbl.Release.Call(uintptr(unsafe.Pointer(i))) |
| 99 | |
| 100 | return uint32(ret) |
| 101 | } |
| 102 | |
| 103 | func (i *ICoreWebView2_2) GetCookieManager() (*ICoreWebView2CookieManager, error) { |
| 104 | var cookieManager *ICoreWebView2CookieManager |
| 105 | hr, _, _ := i.vtbl.GetCookieManager.Call( |
| 106 | uintptr(unsafe.Pointer(i)), |
| 107 | uintptr(unsafe.Pointer(&cookieManager)), |
| 108 | ) |
| 109 | if windows.Handle(hr) != windows.S_OK { |
| 110 | return nil, syscall.Errno(hr) |
| 111 | } |
| 112 | return cookieManager, nil |
| 113 | } |
| 114 |