Skip to content

Commit

Permalink
Fix cookies and crashes on webview (#60)
Browse files Browse the repository at this point in the history
* fix: [webviewer] update demo version

* fix: [webviewer] use secure cookies when specified

* fix: [webviewer] remove winloader to prevent crashes

Fixes #59
  • Loading branch information
inkeliz authored Mar 23, 2024
1 parent 8f18aae commit 3331d8c
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 51 deletions.
9 changes: 8 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
* text eol=lf
* text eol=lf
*.dll binary
*.jar binary
*.aar binary
*.so binary
*.zip binary
*.gz binary
*.class binary
17 changes: 6 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,22 @@ module github.com/gioui-plugins/gio-plugins
go 1.19

require (
gioui.org v0.0.0-20220924144830-24eb1a4fc5fd
gioui.org v0.1.1-0.20230801070910-edbf872b44af
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0
github.com/go-ole/go-ole v1.2.6
github.com/inkeliz/giosvg v0.0.0-20230419135231-464df5851c6a
github.com/inkeliz/go_inkwasm v0.0.0-20220912074516-049d3472c98a
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
golang.org/x/exp/shiny v0.0.0-20220921164117-439092de6870
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8
)

require (
gioui.org/cmd v0.0.0-20230128024137-5c14d1ba6479 // indirect
gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7 // indirect
gioui.org/shader v1.0.6 // indirect
github.com/akavel/rsrc v0.10.1 // indirect
github.com/benoitkugler/textlayout v0.3.0 // indirect
github.com/go-text/typesetting v0.0.0-20221214153724-0399769901d5 // indirect
github.com/go-text/typesetting v0.0.0-20230720191532-efc36025df80 // indirect
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/exp/shiny v0.0.0-20220921164117-439092de6870 // indirect
golang.org/x/image v0.5.0 // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/tools v0.1.12 // indirect
)
50 changes: 25 additions & 25 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
eliasnaur.com/font v0.0.0-20220124212145-832bb8fc08c3 h1:djFprmHZgrSepsHAIRMp5UJn3PzsoTg9drI+BDmif5Q=
gioui.org/cmd v0.0.0-20230128024137-5c14d1ba6479 h1:55KIi9Kx8rf8R9EnO9VGBQO2B6BoPgFbEn38uJO8aA4=
gioui.org/cmd v0.0.0-20230128024137-5c14d1ba6479/go.mod h1:sOPHaz5lc8CQuJqPyX/YTFdcs5+XKNXXa03qxFIln6w=
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d h1:ARo7NCVvN2NdhLlJE9xAbKweuI9L6UgfTbYb0YwPacY=
gioui.org v0.1.1-0.20230801070910-edbf872b44af h1:JyZldA0MGu2FjO8vCnLOhnFeL1HicOm3HVkbvoB4lJg=
gioui.org v0.1.1-0.20230801070910-edbf872b44af/go.mod h1:klzDun/4xN9Z9DyIRVyNHU8b6lqbHIcJpnIhKOArpyY=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7 h1:tNJdnP5CgM39PRc+KWmBRRYX/zJ+rd5XaYxY5d5veqA=
gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/shader v1.0.6 h1:cvZmU+eODFR2545X+/8XucgZdTtEjR3QWW6W65b0q5Y=
gioui.org/shader v1.0.6/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0 h1:bGG/g4ypjrCJoSvFrP5hafr9PPB5aw8SjcOWWila7ZI=
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0/go.mod h1:+axXBRUTIDlCeE73IKeD/os7LoEnTKdkp8/gQOFjqyo=
github.com/akavel/rsrc v0.10.1 h1:hCCPImjmFKVNGpeLZyTDRHEFC283DzyTXTo0cO0Rq9o=
github.com/akavel/rsrc v0.10.1/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/benoitkugler/pstokenizer v1.0.0/go.mod h1:l1G2Voirz0q/jj0TQfabNxVsa8HZXh/VMxFSRALWTiE=
github.com/benoitkugler/textlayout v0.3.0 h1:2ehWXEkgb6RUokTjXh1LzdGwG4dRP6X3dqhYYDYhUVk=
github.com/benoitkugler/textlayout v0.3.0/go.mod h1:o+1hFV+JSHBC9qNLIuwVoLedERU7sBPgEFcuSgfvi/w=
github.com/benoitkugler/textlayout-testdata v0.1.1 h1:AvFxBxpfrQd8v55qH59mZOJOQjtD6K2SFe9/HvnIbJk=
github.com/benoitkugler/textlayout-testdata v0.1.1/go.mod h1:i/qZl09BbUOtd7Bu/W1CAubRwTWrEXWq6JwMkw8wYxo=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-text/typesetting v0.0.0-20221214153724-0399769901d5 h1:iOA0HmtpANn48hX2nlDNMu0VVaNza35HJG0WeetBVzQ=
github.com/go-text/typesetting v0.0.0-20221214153724-0399769901d5/go.mod h1:/cmOXaoTiO+lbCwkTZBgCvevJpbFsZ5reXIpEJVh5MI=
github.com/go-text/typesetting v0.0.0-20230720191532-efc36025df80 h1:hyqXubLnpwyvrg5vRGTvxtJLmxyXLtcNtZRfm1XlPfM=
github.com/go-text/typesetting v0.0.0-20230720191532-efc36025df80/go.mod h1:evDBbvNR/KaVFZ2ZlDSOWWXIUKq0wCOEtzLxRM8SG3k=
github.com/go-text/typesetting-utils v0.0.0-20230616150549-2a7df14b6a22 h1:LBQTFxP2MfsyEDqSKmUBZaDuDHN1vpqDyOZjcqS7MYI=
github.com/inkeliz/giosvg v0.0.0-20230419135231-464df5851c6a h1:sDqP2vCcqZrUPbEpjIenuQDXsEiT7q7djhd9qDI+nT4=
github.com/inkeliz/giosvg v0.0.0-20230419135231-464df5851c6a/go.mod h1:9cMSIlqFpG0OLzPNsUf/l+j7Icbs5nbxln/Ez0q6S94=
github.com/inkeliz/go_inkwasm v0.0.0-20220912074516-049d3472c98a h1:uZklbtdSPrDL/d1EUKd9s8a0Byla2TT01Wg/GZ4xj0w=
github.com/inkeliz/go_inkwasm v0.0.0-20220912074516-049d3472c98a/go.mod h1:LPI3Qojj7OgTyc2R4RPB6BuMSgjoOXCObwnDzz1SOVk=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95 h1:sBdrWpxhGDdTAYNqbgBLAR+ULAPPhfgncLr1X0lyWtg=
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/exp/shiny v0.0.0-20220921164117-439092de6870 h1:GjCs9zNN8fojJskeK7QiiVecCaMk0dfGTyL6IUcmp0o=
golang.org/x/exp/shiny v0.0.0-20220921164117-439092de6870/go.mod h1:VjAR7z0ngyATZTELrBSkxOOHhhlnVUxDye4mcjx5h/8=
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69 h1:Lj6HJGCSn5AjxRAH2+r35Mir4icalbqku+CLUtjnvXY=
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI=
golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/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-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 h1:h+EGohizhe9XlX18rfpa8k8RAc5XyaeamM+0VHRd4lc=
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
2 changes: 1 addition & 1 deletion webviewer/demo/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

var (
GlobalShaper = text.NewShaper(gofont.Collection())
GlobalShaper = text.NewShaper(text.WithCollection(gofont.Collection()))
DefaultURL = "https://google.com"

IconAdd, _ = widget.NewIcon(icons.ContentAdd)
Expand Down
4 changes: 2 additions & 2 deletions webviewer/demo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
replace github.com/gioui-plugins/gio-plugins => ../../

require (
gioui.org v0.0.0-20230425023356-bba91263b077
gioui.org v0.1.1-0.20230801070910-edbf872b44af
github.com/gioui-plugins/gio-plugins v0.0.0-00010101000000-000000000000
golang.org/x/exp/shiny v0.0.0-20230425010034-47ecfdc1ba53
)
Expand All @@ -16,7 +16,7 @@ require (
gioui.org/shader v1.0.6 // indirect
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0 // indirect
github.com/akavel/rsrc v0.10.1 // indirect
github.com/go-text/typesetting v0.0.0-20230413204129-b4f0492bf7ae // indirect
github.com/go-text/typesetting v0.0.0-20230720191532-efc36025df80 // indirect
github.com/inkeliz/go_inkwasm v0.0.0-20220912074516-049d3472c98a // indirect
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95 // indirect
Expand Down
4 changes: 4 additions & 0 deletions webviewer/demo/go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d h1:ARo7NCVvN2NdhLlJE9xAbKweuI9L6UgfTbYb0YwPacY=
gioui.org v0.0.0-20230425023356-bba91263b077 h1:BfZ3LodNX41vEUJI2dWHkFsZe+NVEHSTv8TceMyVe0M=
gioui.org v0.0.0-20230425023356-bba91263b077/go.mod h1:8CFQM/4LurRd9G3NUYdacFb9j2pK0LrAyVO2mAZo4mw=
gioui.org v0.1.1-0.20230801070910-edbf872b44af h1:JyZldA0MGu2FjO8vCnLOhnFeL1HicOm3HVkbvoB4lJg=
gioui.org v0.1.1-0.20230801070910-edbf872b44af/go.mod h1:klzDun/4xN9Z9DyIRVyNHU8b6lqbHIcJpnIhKOArpyY=
gioui.org/cmd v0.0.0-20230502182008-0a86898b4184 h1:/vJ5Q9ZpawCIr1btGykwTHsrMQIkl/Vo1lCrhF8MENE=
gioui.org/cmd v0.0.0-20230502182008-0a86898b4184/go.mod h1:Ka3v7oyXel7Kmtuqwtlp05nEQzm9t4wskHnIEWojWNU=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
Expand All @@ -14,6 +16,8 @@ github.com/akavel/rsrc v0.10.1 h1:hCCPImjmFKVNGpeLZyTDRHEFC283DzyTXTo0cO0Rq9o=
github.com/akavel/rsrc v0.10.1/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/go-text/typesetting v0.0.0-20230413204129-b4f0492bf7ae h1:LCcaQgYrnS+sx9Tc3oGUvbRBRt+5oFnKWakaxeAvNVI=
github.com/go-text/typesetting v0.0.0-20230413204129-b4f0492bf7ae/go.mod h1:KmrpWuSMFcO2yjmyhGpnBGQHSKAoEgMTSSzvLDzCuEA=
github.com/go-text/typesetting v0.0.0-20230720191532-efc36025df80 h1:hyqXubLnpwyvrg5vRGTvxtJLmxyXLtcNtZRfm1XlPfM=
github.com/go-text/typesetting v0.0.0-20230720191532-efc36025df80/go.mod h1:evDBbvNR/KaVFZ2ZlDSOWWXIUKq0wCOEtzLxRM8SG3k=
github.com/go-text/typesetting-utils v0.0.0-20230412163830-89e4bcfa3ecc h1:9Kf84pnrmmjdRzZIkomfjowmGUhHs20jkrWYw/I6CYc=
github.com/inkeliz/go_inkwasm v0.0.0-20220912074516-049d3472c98a h1:uZklbtdSPrDL/d1EUKd9s8a0Byla2TT01Wg/GZ4xj0w=
github.com/inkeliz/go_inkwasm v0.0.0-20220912074516-049d3472c98a/go.mod h1:LPI3Qojj7OgTyc2R4RPB6BuMSgjoOXCObwnDzz1SOVk=
Expand Down
11 changes: 5 additions & 6 deletions webviewer/webview/sys_darwin.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
@import WebKit;

@interface callbackHandler : NSObject<WKScriptMessageHandler>
@property (nonatomic, assign) uintptr_t handler;
@property (nonatomic, assign) uintptr_t webviewerHandler;
@end

@implementation callbackHandler
uintptr_t handler;
uintptr_t webviewerHandler;

- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message {
javascriptManagerCallback(_handler, (char *)[[message body] UTF8String]);
javascriptManagerCallback(self.webviewerHandler, (char *)[[message body] UTF8String]);
}
@end

Expand Down Expand Up @@ -114,7 +114,6 @@ void run(CFTypeRef web, CFTypeRef windowRef) {
}

void getCookies(CFTypeRef config, uintptr_t handler, uintptr_t done) {
NSISO8601DateFormatter *dateFormatting = [[NSISO8601DateFormatter alloc] init];
WKWebViewConfiguration *configuration = (__bridge WKWebViewConfiguration *)config;
[[[configuration websiteDataStore] httpCookieStore] getAllCookies: ^(NSArray<NSHTTPCookie *> * array) {
int i = 0;
Expand Down Expand Up @@ -157,7 +156,7 @@ void addCookie(CFTypeRef config, uintptr_t done, char *name, char *value, char *
NSHTTPCookieDomain: @(domain),
NSHTTPCookiePath: @(path),
NSHTTPCookieExpires: [NSDate dateWithTimeIntervalSince1970:expires],
NSHTTPCookieSecure: ((features) == 2 ? @("true") : @("false")),
NSHTTPCookieSecure: ((features & 2) == 2 ? @("true") : @("false")),
}];

[[[configuration websiteDataStore] httpCookieStore] setCookie:cookie completionHandler: ^(void) {
Expand Down Expand Up @@ -221,7 +220,7 @@ void addCallbackJavascript(CFTypeRef config, char *name, uintptr_t handler) {
WKUserContentController *controller = [configuration userContentController];

callbackHandler *scriptMessageHandler = [callbackHandler alloc];
scriptMessageHandler.handler = handler;
scriptMessageHandler.webviewerHandler = handler;

[controller addScriptMessageHandler:scriptMessageHandler name:@(name)];
}
36 changes: 32 additions & 4 deletions webviewer/webview/sys_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,49 @@
package webview

import (
"os"
"path/filepath"
"unsafe"

"github.com/jchv/go-winloader"
"golang.org/x/sys/windows"
)

var (
_CreateCoreWebView2EnvironmentWithOptions winloader.Proc
_CreateCoreWebView2EnvironmentWithOptions *windows.Proc
_Ole32 = windows.NewLazySystemDLL("ole32.dll")
_Ole32CoTaskMemAlloc = _Ole32.NewProc("CoTaskMemAlloc")
)

func init() {
dll, _ := winloader.LoadFromMemory(dllFile)
_CreateCoreWebView2EnvironmentWithOptions = dll.Proc("CreateCoreWebView2EnvironmentWithOptions")
// current app name
appName := "gio-webview2-"
if len(os.Args) > 0 {
appName = filepath.Base(os.Args[0])
}

dllPath := filepath.Join(os.TempDir(), appName+"webview2loader.dll")
dst, err := os.Create(dllPath)
if err != nil {
panic(err)
}

if _, err := dst.Write(dllFile); err != nil {
panic(err)
}

if err := dst.Close(); err != nil {
panic(err)
}

dll, err := windows.LoadDLL(dllPath)
if err != nil {
panic(err)
}

_CreateCoreWebView2EnvironmentWithOptions, err = dll.FindProc("CreateCoreWebView2EnvironmentWithOptions")
if err != nil {
panic(err)
}
}

var (
Expand Down
Binary file modified webviewer/webview/sys_windows_386.dll
Binary file not shown.
Binary file modified webviewer/webview/sys_windows_amd64.dll
Binary file not shown.
Binary file modified webviewer/webview/sys_windows_arm64.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion webviewer/webview/webview_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (r *driver) attach(w *webview) error {
pathPtr = uintptr(unsafe.Pointer(&r.dir[0]))
}

hr, _, _ := _CreateCoreWebView2EnvironmentWithOptions.Call(0, uint64(pathPtr), 0, uint64(uintptr(unsafe.Pointer(r.environmentCompletedHandler))))
hr, _, _ := _CreateCoreWebView2EnvironmentWithOptions.Call(0, pathPtr, 0, uintptr(unsafe.Pointer(r.environmentCompletedHandler)))
if hr != 0 {
cerr <- ErrInvalidOptionChange
return
Expand Down

0 comments on commit 3331d8c

Please sign in to comment.