This repository has been archived by the owner on Feb 28, 2023. It is now read-only.
forked from jchv/go-webview2
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from mattpodraza/v2
- Loading branch information
Showing
26 changed files
with
2,311 additions
and
1,054 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
# IDE settings | ||
.vscode/ | ||
|
||
# Compiled binaries | ||
*.exe | ||
|
||
# Generated code | ||
*_string.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/mattpodraza/webview2/v2/pkg/webview2" | ||
) | ||
|
||
func main() { | ||
wv, err := webview2.New( | ||
webview2.WithTitle("The Go Programming Language"), | ||
webview2.WithMinSize(640, 480), | ||
webview2.WithSize(800, 600), | ||
webview2.WithMaxSize(1280, 720), | ||
webview2.WithDevtools(false), | ||
webview2.WithURL("https://golang.org"), | ||
) | ||
|
||
if err != nil { | ||
log.Fatalf("Failed to create webview2: %v", err) | ||
} | ||
|
||
if err := wv.Run(); err != nil { | ||
log.Fatalf("Failed while running webview: %v", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
module github.com/mattpodraza/webview2 | ||
module github.com/mattpodraza/webview2/v2 | ||
|
||
go 1.16 | ||
|
||
require ( | ||
github.com/jchv/go-winloader v0.0.0-20200815041850-dec1ee9a7fd5 | ||
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed | ||
github.com/jchv/go-winloader v0.0.0-20210323001710-152514a7f070 | ||
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 | ||
golang.org/x/tools v0.1.1 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,31 @@ | ||
github.com/jchv/go-winloader v0.0.0-20200815041850-dec1ee9a7fd5 h1:pdFFlHXY9tZXmJz+tRSm1DzYEH4ebha7cffmm607bMU= | ||
github.com/jchv/go-winloader v0.0.0-20200815041850-dec1ee9a7fd5/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs= | ||
github.com/jchv/go-winloader v0.0.0-20210323001710-152514a7f070 h1:PpoLyL/i1My03oF/Q91qTmoMohheoZuIqOyC4zUrBEE= | ||
github.com/jchv/go-winloader v0.0.0-20210323001710-152514a7f070/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs= | ||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= | ||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | ||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= | ||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed h1:J22ig1FUekjjkmZUM7pTKixYm8DvrYsvrBZdunYeIuQ= | ||
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E= | ||
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||
golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs= | ||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= | ||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= | ||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
// Forked from https://github.com/Inkeliz/gowebview/tree/master/internal/wincom. | ||
// Expanded upon by Matt Podraza, 2021. | ||
// Copyright (c) 2020 Inkeliz | ||
// Copyright (c) 2017 Serge Zaitsev | ||
|
||
// Package com exposes some wrappers around webview2 procedures. | ||
package com | ||
|
||
import ( | ||
"golang.org/x/sys/windows" | ||
) | ||
|
||
type ( | ||
// Basic is the basic struct that any other must include, which implements basic COM functions and implements NewHandler | ||
Basic struct{} | ||
|
||
// BasicVTBL is the basic VTBL, which implements basic COM functions, which implements VTBL | ||
BasicVTBL struct { | ||
QueryInterface uintptr | ||
AddRef uintptr | ||
Release uintptr | ||
} | ||
) | ||
|
||
func NewBasicVTBL(h *Basic) BasicVTBL { | ||
return BasicVTBL{ | ||
QueryInterface: windows.NewCallback(h.QueryInterface), | ||
AddRef: windows.NewCallback(h.AddRef), | ||
Release: windows.NewCallback(h.Release), | ||
} | ||
} | ||
|
||
// QueryInterface is the QueryInterface from COM | ||
func (obj *Basic) QueryInterface(_ *ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler, _, _ uintptr) uintptr { | ||
return 0 | ||
} | ||
|
||
// AddRef is the AddRef from COM | ||
func (obj *Basic) AddRef(_ *ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler) uintptr { | ||
return 1 | ||
} | ||
|
||
// Release is the Release from COM | ||
func (obj *Basic) Release(_ *ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler) uintptr { | ||
return 1 | ||
} | ||
|
||
type ( | ||
// ICoreWebView2 implements https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.622.22 | ||
ICoreWebView2 struct { | ||
Basic | ||
VTBL *ICoreWebView2VTBL | ||
} | ||
|
||
// ICoreWebView2VTBL implements https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.622.22 | ||
ICoreWebView2VTBL struct { | ||
BasicVTBL | ||
GetSettings uintptr | ||
GetSource uintptr | ||
Navigate uintptr | ||
NavigateToString uintptr | ||
AddNavigationStarting uintptr | ||
RemoveNavigationStarting uintptr | ||
AddContentLoading uintptr | ||
RemoveContentLoading uintptr | ||
AddSourceChanged uintptr | ||
RemoveSourceChanged uintptr | ||
AddHistoryChanged uintptr | ||
RemoveHistoryChanged uintptr | ||
AddNavigationCompleted uintptr | ||
RemoveNavigationCompleted uintptr | ||
AddFrameNavigationStarting uintptr | ||
RemoveFrameNavigationStarting uintptr | ||
AddFrameNavigationCompleted uintptr | ||
RemoveFrameNavigationCompleted uintptr | ||
AddScriptDialogOpening uintptr | ||
RemoveScriptDialogOpening uintptr | ||
AddPermissionRequested uintptr | ||
RemovePermissionRequested uintptr | ||
AddProcessFailed uintptr | ||
RemoveProcessFailed uintptr | ||
AddScriptToExecuteOnDocumentCreated uintptr | ||
RemoveScriptToExecuteOnDocumentCreated uintptr | ||
ExecuteScript uintptr | ||
CapturePreview uintptr | ||
Reload uintptr | ||
PostWebMessageAsJSON uintptr | ||
PostWebMessageAsString uintptr | ||
AddWebMessageReceived uintptr | ||
RemoveWebMessageReceived uintptr | ||
CallDevToolsProtocolMethod uintptr | ||
GetBrowserProcessID uintptr | ||
GetCanGoBack uintptr | ||
GetCanGoForward uintptr | ||
GoBack uintptr | ||
GoForward uintptr | ||
GetDevToolsProtocolEventReceiver uintptr | ||
Stop uintptr | ||
AddNewWindowRequested uintptr | ||
RemoveNewWindowRequested uintptr | ||
AddDocumentTitleChanged uintptr | ||
RemoveDocumentTitleChanged uintptr | ||
GetDocumentTitle uintptr | ||
AddHostObjectToScript uintptr | ||
RemoveHostObjectFromScript uintptr | ||
OpenDevToolsWindow uintptr | ||
AddContainsFullScreenElementChanged uintptr | ||
RemoveContainsFullScreenElementChanged uintptr | ||
GetContainsFullScreenElement uintptr | ||
AddWebResourceRequested uintptr | ||
RemoveWebResourceRequested uintptr | ||
AddWebResourceRequestedFilter uintptr | ||
RemoveWebResourceRequestedFilter uintptr | ||
AddWindowCloseRequested uintptr | ||
RemoveWindowCloseRequested uintptr | ||
} | ||
) | ||
|
||
type ( | ||
// ICoreWebView2Environment is the implementation of https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment | ||
ICoreWebView2Environment struct { | ||
Basic | ||
VTBL *ICoreWebView2EnvironmentVTBL | ||
} | ||
|
||
// ICoreWebView2EnvironmentVTBL is the implementation of https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment | ||
ICoreWebView2EnvironmentVTBL struct { | ||
BasicVTBL | ||
CreateCoreWebView2Controller uintptr | ||
CreateWebResourceResponse uintptr | ||
GetBrowserVersionString uintptr | ||
AddNewBrowserVersionAvailable uintptr | ||
RemoveNewBrowserVersionAvailable uintptr | ||
} | ||
) | ||
|
||
type ( | ||
// ICoreWebView2Controller implements https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.622.22 | ||
ICoreWebView2Controller struct { | ||
VTBL *ICoreWebView2ControllerVTBL | ||
} | ||
|
||
// ICoreWebView2ControllerVTBL implements https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.622.22 | ||
ICoreWebView2ControllerVTBL struct { | ||
BasicVTBL | ||
GetIsVisible uintptr | ||
PutIsVisible uintptr | ||
GetBounds uintptr | ||
PutBounds uintptr | ||
GetZoomFactor uintptr | ||
PutZoomFactor uintptr | ||
AddZoomFactorChanged uintptr | ||
RemoveZoomFactorChanged uintptr | ||
SetBoundsAndZoomFactor uintptr | ||
MoveFocus uintptr | ||
AddMoveFocusRequested uintptr | ||
RemoveMoveFocusRequested uintptr | ||
AddGotFocus uintptr | ||
RemoveGotFocus uintptr | ||
AddLostFocus uintptr | ||
RemoveLostFocus uintptr | ||
AddAcceleratorKeyPressed uintptr | ||
RemoveAcceleratorKeyPressed uintptr | ||
GetParentWindow uintptr | ||
PutParentWindow uintptr | ||
NotifyParentWindowPositionChanged uintptr | ||
Close uintptr | ||
GetCoreWebView2 uintptr | ||
} | ||
) | ||
|
||
type ( | ||
// ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler is the implementation of https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2createcorewebview2environmentcompletedhandler. | ||
ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler struct { | ||
Basic | ||
VTBL *ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerVTBL | ||
} | ||
|
||
// ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerVTBL is the implementation of https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2createcorewebview2environmentcompletedhandler. | ||
ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerVTBL struct { | ||
BasicVTBL | ||
// Invoke is ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerInvoke | ||
Invoke uintptr | ||
} | ||
|
||
// ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerInvoke: public HRESULT Invoke(HRESULT errorCode, ICoreWebView2Environment * createdEnvironment) | ||
ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerInvoke func(i *ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler, p uintptr, createdEnvironment *ICoreWebView2Environment) uintptr | ||
) | ||
|
||
type ( | ||
// ICoreWebView2CreateCoreWebView2ControllerCompletedHandler implements https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2createcorewebview2controllercompletedhandler | ||
ICoreWebView2CreateCoreWebView2ControllerCompletedHandler struct { | ||
Basic | ||
VTBL *ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerVTBL | ||
} | ||
|
||
// ICoreWebView2CreateCoreWebView2ControllerCompletedVTBL implements https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2createcorewebview2controllercompletedhandler | ||
ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerVTBL struct { | ||
BasicVTBL | ||
Invoke uintptr | ||
} | ||
|
||
// ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerInvoke: public HRESULT Invoke(HRESULT errorCode, ICoreWebView2Controller * createdController) | ||
ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerInvoke func(i *ICoreWebView2CreateCoreWebView2ControllerCompletedHandler, p uintptr, createdController *ICoreWebView2Controller) uintptr | ||
) | ||
|
||
type ( | ||
ICoreWebView2SettingsVTBL struct { | ||
BasicVTBL | ||
GetAreDefaultContextMenusEnabled uintptr | ||
GetAreDefaultScriptDialogsEnabled uintptr | ||
GetAreDevToolsEnabled uintptr | ||
GetAreHostObjectsAllowed uintptr | ||
GetIsBuiltInErrorPageEnabled uintptr | ||
GetIsScriptEnabled uintptr | ||
GetIsStatusBarEnabled uintptr | ||
GetIsWebMessageEnabled uintptr | ||
GetIsZoomControlEnabled uintptr | ||
PutAreDefaultContextMenusEnabled uintptr | ||
PutAreDefaultScriptDialogsEnabled uintptr | ||
PutAreDevToolsEnabled uintptr | ||
PutAreHostObjectsAllowed uintptr | ||
PutIsBuiltInErrorPageEnabled uintptr | ||
PutIsScriptEnabled uintptr | ||
PutIsStatusBarEnabled uintptr | ||
PutIsWebMessageEnabled uintptr | ||
PutIsZoomControlEnabled uintptr | ||
} | ||
|
||
ICoreWebView2Settings struct { | ||
Basic | ||
VTBL *ICoreWebView2SettingsVTBL | ||
} | ||
) |
Oops, something went wrong.