Skip to content

Commit

Permalink
Fix permissions build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
leaanthony committed Oct 25, 2023
1 parent 1650e26 commit 1ce8391
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
22 changes: 21 additions & 1 deletion v3/pkg/application/options_webview_window_win.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ const (
Tabbed BackdropType = 4
)

type CoreWebView2PermissionKind uint32

const (
CoreWebView2PermissionKindUnknownPermission CoreWebView2PermissionKind = iota
CoreWebView2PermissionKindMicrophone
CoreWebView2PermissionKindCamera
CoreWebView2PermissionKindGeolocation
CoreWebView2PermissionKindNotifications
CoreWebView2PermissionKindOtherSensors
CoreWebView2PermissionKindClipboardRead
)

type CoreWebView2PermissionState uint32

const (
CoreWebView2PermissionStateDefault CoreWebView2PermissionState = iota
CoreWebView2PermissionStateAllow
CoreWebView2PermissionStateDeny
)

type WindowsWindow struct {
// Select the type of translucent backdrop. Requires Windows 11 22621 or later.
// Only used when window's `BackgroundType` is set to `BackgroundTypeTranslucent`.
Expand Down Expand Up @@ -96,7 +116,7 @@ type WindowsWindow struct {
OnOverEffect DragEffect

// Permissions map for WebView2. If empty, default permissions will be granted.
Permissions map[uint32]uint32
Permissions map[CoreWebView2PermissionKind]CoreWebView2PermissionState
}

type Theme int
Expand Down
10 changes: 5 additions & 5 deletions v3/pkg/application/webview_window_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -1309,12 +1309,12 @@ func (w *windowsWebviewWindow) setupChromium() {
chromium.AdditionalBrowserArgs = append(chromium.AdditionalBrowserArgs, arg)
}

//if opts.Permissions != nil {
// for permission, state := range opts.Permissions {
// chromium.SetPermission(edge.CoreWebView2PermissionKind(permission),
if opts.Permissions != nil {
for permission, state := range opts.Permissions {
chromium.SetPermission(edge.CoreWebView2PermissionKind(permission),
edge.CoreWebView2PermissionState(state))
// }
//}
}
}

chromium.MessageCallback = w.processMessage
chromium.MessageWithAdditionalObjectsCallback = w.processMessageWithAdditionalObjects
Expand Down

0 comments on commit 1ce8391

Please sign in to comment.