From 11ef710e8530513e02829548e687aad20c1c2710 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Mon, 9 Sep 2024 20:58:36 +1000 Subject: [PATCH] Add PutIsGeneralAutofillEnabled & PutIsPasswordAutosaveEnabled --- .gitignore | 4 +- pkg/edge/ICoreWebView2Settings4.go | 6 +- pkg/edge/chromium.go | 29 + pkg/edge/version_map.go | 727 +- .../COREWEBVIEW2_BROWSING_DATA_KINDS.go | 32 +- .../COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND.go | 10 + ...EWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION.go | 10 + pkg/webview2/COREWEBVIEW2_MOUSE_EVENT_KIND.go | 36 +- .../COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS.go | 14 +- .../COREWEBVIEW2_PDF_TOOLBAR_ITEMS.go | 24 +- .../COREWEBVIEW2_POINTER_EVENT_KIND.go | 12 +- pkg/webview2/COREWEBVIEW2_SAVE_AS_KIND.go | 12 + .../COREWEBVIEW2_SAVE_AS_UI_RESULT.go | 13 + .../COREWEBVIEW2_TEXT_DIRECTION_KIND.go | 11 + ...VIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS.go | 11 +- ...xecuteOnDocumentCreatedCompletedHandler.go | 6 +- .../ICoreWebView2BrowserExtensionList.go | 16 +- ...reWebView2BrowserProcessExitedEventArgs.go | 6 +- ...lDevToolsProtocolMethodCompletedHandler.go | 6 +- ...CoreWebView2ClientCertificateCollection.go | 12 +- .../ICoreWebView2CompositionController2.go | 6 +- .../ICoreWebView2ContentLoadingEventArgs.go | 14 +- pkg/webview2/ICoreWebView2Controller2.go | 10 +- .../ICoreWebView2ControllerOptions2.go | 18 +- pkg/webview2/ICoreWebView2CookieList.go | 16 +- ...w2CompositionControllerCompletedHandler.go | 6 +- ...eCoreWebView2ControllerCompletedHandler.go | 6 +- ...CoreWebView2EnvironmentCompletedHandler.go | 6 +- .../ICoreWebView2DOMContentLoadedEventArgs.go | 6 +- ...2DevToolsProtocolEventReceivedEventArgs.go | 10 +- ...DevToolsProtocolEventReceivedEventArgs2.go | 12 +- ...reWebView2DevToolsProtocolEventReceiver.go | 4 +- pkg/webview2/ICoreWebView2Environment10.go | 14 +- pkg/webview2/ICoreWebView2Environment11.go | 2 +- pkg/webview2/ICoreWebView2Environment12.go | 12 +- pkg/webview2/ICoreWebView2Environment14.go | 95 + pkg/webview2/ICoreWebView2Environment2.go | 22 +- pkg/webview2/ICoreWebView2Environment3.go | 10 +- pkg/webview2/ICoreWebView2Environment4.go | 6 +- pkg/webview2/ICoreWebView2Environment6.go | 6 +- pkg/webview2/ICoreWebView2Environment7.go | 2 +- pkg/webview2/ICoreWebView2Environment8.go | 2 +- pkg/webview2/ICoreWebView2Environment9.go | 16 +- ...reWebView2ExecuteScriptCompletedHandler.go | 6 +- pkg/webview2/ICoreWebView2File.go | 10 +- pkg/webview2/ICoreWebView2FileSystemHandle.go | 70 + pkg/webview2/ICoreWebView2Frame3.go | 4 +- pkg/webview2/ICoreWebView2Frame4.go | 2 +- pkg/webview2/ICoreWebView2Frame5.go | 6 +- .../ICoreWebView2FrameCreatedEventArgs.go | 6 +- pkg/webview2/ICoreWebView2FrameInfo.go | 20 +- .../ICoreWebView2FrameInfoCollection.go | 6 +- ...CoreWebView2FrameInfoCollectionIterator.go | 22 +- ...ICoreWebView2GetCookiesCompletedHandler.go | 6 +- ...ICoreWebView2GetFaviconCompletedHandler.go | 6 +- ...faultPermissionSettingsCompletedHandler.go | 6 +- ...GetProcessExtendedInfosCompletedHandler.go | 6 +- .../ICoreWebView2HttpRequestHeaders.go | 20 +- .../ICoreWebView2HttpResponseHeaders.go | 20 +- ...reWebView2NavigationCompletedEventArgs2.go | 8 +- ...oreWebView2NavigationStartingEventArgs2.go | 2 +- ...oreWebView2NavigationStartingEventArgs3.go | 8 +- ...oreWebView2NewWindowRequestedEventArgs3.go | 6 +- pkg/webview2/ICoreWebView2Notification.go | 311 + ...2NotificationCloseRequestedEventHandler.go | 59 + ...reWebView2NotificationReceivedEventArgs.go | 100 + ...ebView2NotificationReceivedEventHandler.go | 59 + pkg/webview2/ICoreWebView2ObjectCollection.go | 61 + ...reWebView2PermissionRequestedEventArgs2.go | 12 +- .../ICoreWebView2PrintCompletedHandler.go | 6 +- ...ICoreWebView2PrintToPdfCompletedHandler.go | 6 +- ...ebView2PrintToPdfStreamCompletedHandler.go | 6 +- ...reWebView2ProcessExtendedInfoCollection.go | 14 +- .../ICoreWebView2ProcessFailedEventArgs.go | 6 +- .../ICoreWebView2ProcessInfoCollection.go | 14 +- pkg/webview2/ICoreWebView2Profile3.go | 2 +- pkg/webview2/ICoreWebView2Profile4.go | 14 +- pkg/webview2/ICoreWebView2Profile5.go | 8 +- ...fileAddBrowserExtensionCompletedHandler.go | 6 +- ...ileGetBrowserExtensionsCompletedHandler.go | 6 +- .../ICoreWebView2SaveAsUIShowingEventArgs.go | 210 + ...CoreWebView2SaveAsUIShowingEventHandler.go | 59 + pkg/webview2/ICoreWebView2Settings2.go | 18 +- pkg/webview2/ICoreWebView2Settings3.go | 12 +- pkg/webview2/ICoreWebView2Settings5.go | 12 +- pkg/webview2/ICoreWebView2Settings6.go | 12 +- pkg/webview2/ICoreWebView2Settings7.go | 10 +- pkg/webview2/ICoreWebView2Settings9.go | 14 +- ...oreWebView2ShowSaveAsUICompletedHandler.go | 59 + .../ICoreWebView2SourceChangedEventArgs.go | 8 +- pkg/webview2/ICoreWebView2StringCollection.go | 6 +- ...ICoreWebView2TrySuspendCompletedHandler.go | 6 +- ...CoreWebView2WebMessageReceivedEventArgs.go | 30 +- ...eWebView2WebResourceRequestedEventArgs2.go | 8 +- ...ew2WebResourceResponseReceivedEventArgs.go | 12 +- ...eResponseViewGetContentCompletedHandler.go | 6 +- pkg/webview2/ICoreWebView2_13.go | 2 +- pkg/webview2/ICoreWebView2_14.go | 2 +- pkg/webview2/ICoreWebView2_17.go | 2 +- pkg/webview2/ICoreWebView2_18.go | 2 +- pkg/webview2/ICoreWebView2_19.go | 12 +- pkg/webview2/ICoreWebView2_20.go | 6 +- pkg/webview2/ICoreWebView2_22.go | 10 +- pkg/webview2/ICoreWebView2_23.go | 54 + pkg/webview2/ICoreWebView2_24.go | 63 + pkg/webview2/ICoreWebView2_25.go | 76 + pkg/webview2/ICoreWebView2_7.go | 8 +- scripts/WebView2.1.0.2739.15.idl | 10680 ++++++++++++++++ scripts/latest_version.txt | 2 +- 109 files changed, 13150 insertions(+), 479 deletions(-) create mode 100644 pkg/webview2/COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND.go create mode 100644 pkg/webview2/COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION.go create mode 100644 pkg/webview2/COREWEBVIEW2_SAVE_AS_KIND.go create mode 100644 pkg/webview2/COREWEBVIEW2_SAVE_AS_UI_RESULT.go create mode 100644 pkg/webview2/COREWEBVIEW2_TEXT_DIRECTION_KIND.go create mode 100644 pkg/webview2/ICoreWebView2Environment14.go create mode 100644 pkg/webview2/ICoreWebView2FileSystemHandle.go create mode 100644 pkg/webview2/ICoreWebView2Notification.go create mode 100644 pkg/webview2/ICoreWebView2NotificationCloseRequestedEventHandler.go create mode 100644 pkg/webview2/ICoreWebView2NotificationReceivedEventArgs.go create mode 100644 pkg/webview2/ICoreWebView2NotificationReceivedEventHandler.go create mode 100644 pkg/webview2/ICoreWebView2ObjectCollection.go create mode 100644 pkg/webview2/ICoreWebView2SaveAsUIShowingEventArgs.go create mode 100644 pkg/webview2/ICoreWebView2SaveAsUIShowingEventHandler.go create mode 100644 pkg/webview2/ICoreWebView2ShowSaveAsUICompletedHandler.go create mode 100644 pkg/webview2/ICoreWebView2_23.go create mode 100644 pkg/webview2/ICoreWebView2_24.go create mode 100644 pkg/webview2/ICoreWebView2_25.go create mode 100644 scripts/WebView2.1.0.2739.15.idl diff --git a/.gitignore b/.gitignore index 222edef..64de580 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .idea -pkg/edge_generated \ No newline at end of file +pkg/edge_generated +/.aider.tags.cache.v3/ +.aider* diff --git a/pkg/edge/ICoreWebView2Settings4.go b/pkg/edge/ICoreWebView2Settings4.go index aa55674..e34cdb9 100644 --- a/pkg/edge/ICoreWebView2Settings4.go +++ b/pkg/edge/ICoreWebView2Settings4.go @@ -75,11 +75,13 @@ func (i *ICoreWebView2Settings4) GetIsPasswordAutosaveEnabled() (bool, error) { return value, err } +// PutIsPasswordAutosaveEnabled sets the IsPasswordAutosaveEnabled property. +// The default value is `FALSE`. func (i *ICoreWebView2Settings4) PutIsPasswordAutosaveEnabled(value bool) error { hr, _, err := i.Vtbl.PutIsPasswordAutosaveEnabled.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&value)), + uintptr(boolToInt(value)), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) @@ -107,7 +109,7 @@ func (i *ICoreWebView2Settings4) PutIsGeneralAutofillEnabled(value bool) error { hr, _, err := i.Vtbl.PutIsGeneralAutofillEnabled.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&value)), + uintptr(boolToInt(value)), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) diff --git a/pkg/edge/chromium.go b/pkg/edge/chromium.go index b9db2bf..a5157c4 100644 --- a/pkg/edge/chromium.go +++ b/pkg/edge/chromium.go @@ -621,6 +621,35 @@ func (e *Chromium) GetIsSwipeNavigationEnabled() (bool, error) { return result, nil } +// PutIsGeneralAutofillEnabled controls whether autofill for information +// like names, street and email addresses, phone numbers, and arbitrary input +// is enabled. This excludes password and credit card information. When +// IsGeneralAutofillEnabled is false, no suggestions appear, and no new information +// is saved. When IsGeneralAutofillEnabled is true, information is saved, suggestions +// appear and clicking on one will populate the form fields. +// It will take effect immediately after setting. +// The default value is `FALSE`. +func (e *Chromium) PutIsGeneralAutofillEnabled(value bool) error { + webview2Settings, err := e.webview.GetSettings() + if err != nil { + return err + } + webview2Settings4 := webview2Settings.GetICoreWebView2Settings4() + return webview2Settings4.PutIsGeneralAutofillEnabled(value) +} + +// PutIsPasswordAutosaveEnabled sets whether the browser should offer to save passwords and other +// identifying information entered into forms automatically. +// The default value is `FALSE`. +func (e *Chromium) PutIsPasswordAutosaveEnabled(value bool) error { + webview2Settings, err := e.webview.GetSettings() + if err != nil { + return err + } + webview2Settings4 := webview2Settings.GetICoreWebView2Settings4() + return webview2Settings4.PutIsPasswordAutosaveEnabled(value) +} + func (e *Chromium) PutIsSwipeNavigationEnabled(enabled bool) error { if !hasCapability(e.webview2RuntimeVersion, SwipeNavigation) { return UnsupportedCapabilityError diff --git a/pkg/edge/version_map.go b/pkg/edge/version_map.go index b8b70a9..ca0d636 100644 --- a/pkg/edge/version_map.go +++ b/pkg/edge/version_map.go @@ -3,18 +3,647 @@ package edge type Version struct { - SDKVersion string - ReleaseNotes string + SDKVersion string + ReleaseNotes string RuntimeVersion string Notes string } var versionMapping = map[string]Version{ + "1.0.2739.15": { + SDKVersion: "1.0.2739.15", + ReleaseNotes: "https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes?tabs=win32cpp#10273915", + RuntimeVersion: "128.0.2739.15", + Notes: ` + + +#### Promotions + +The following APIs have been promoted to Stable and are now included in this Release SDK. + + + +###### Web notification handling + +Added support for Web Notification, for non-persistent notifications. The 'NotificationReceived' event for 'CoreWebView2' controls web notification handling, allowing customization or suppression by the host app. Unhandled notifications default to WebView2's UI. + +##### [.NET/C#](#tab/dotnetcsharp) + +* 'CoreWebView2' Class: + * [CoreWebView2.NotificationReceived Event](/dotnet/api/microsoft.web.webview2.core.corewebview2.notificationreceived?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + +* [CoreWebView2Notification Class](/dotnet/api/microsoft.web.webview2.core.corewebview2notification?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.BadgeUri Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.badgeuri?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.Body Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.body?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.BodyImageUri Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.bodyimageuri?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.Direction Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.direction?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.IconUri Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.iconuri?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.IsSilent Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.issilent?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.Language Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.language?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.RequiresInteraction Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.requiresinteraction?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.ShouldRenotify Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.shouldrenotify?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.Tag Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.tag?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.Timestamp Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.timestamp?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.Title Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.title?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.VibrationPattern Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.vibrationpattern?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.ReportClicked Method](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.reportclicked?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.ReportClosed Method](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.reportclosed?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.ReportShown Method](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.reportshown?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.CloseRequested Event](/dotnet/api/microsoft.web.webview2.core.corewebview2notification.closerequested?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + +* [CoreWebView2NotificationReceivedEventArgs Class](/dotnet/api/microsoft.web.webview2.core.corewebview2notificationreceivedeventargs?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2NotificationReceivedEventArgs.Handled Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notificationreceivedeventargs.handled?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2NotificationReceivedEventArgs.Notification Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notificationreceivedeventargs.notification?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2NotificationReceivedEventArgs.SenderOrigin Property](/dotnet/api/microsoft.web.webview2.core.corewebview2notificationreceivedeventargs.senderorigin?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2NotificationReceivedEventArgs.GetDeferral Method](/dotnet/api/microsoft.web.webview2.core.corewebview2notificationreceivedeventargs.getdeferral?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + +* [CoreWebView2TextDirectionKind Enum](/dotnet/api/microsoft.web.webview2.core.corewebview2textdirectionkind?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * 'Default' + * 'LeftToRight' + * 'RightToLeft' + +##### [WinRT/C#](#tab/winrtcsharp) + +* 'CoreWebView2' Class: + * [CoreWebView2.NotificationReceived Event](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2?view=webview2-winrt-1.0.2739.15&preserve-view=true#notificationreceived) + +* [CoreWebView2Notification Class](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true) + * [CoreWebView2Notification.BadgeUri Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#badgeuri) + * [CoreWebView2Notification.Body Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#body) + * [CoreWebView2Notification.BodyImageUri Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#bodyimageuri) + * [CoreWebView2Notification.Direction Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#direction) + * [CoreWebView2Notification.IconUri Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#iconuri) + * [CoreWebView2Notification.IsSilent Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#issilent) + * [CoreWebView2Notification.Language Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#language) + * [CoreWebView2Notification.RequiresInteraction Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#requiresinteraction) + * [CoreWebView2Notification.ShouldRenotify Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#shouldrenotify) + * [CoreWebView2Notification.Tag Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#tag) + * [CoreWebView2Notification.Timestamp Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#timestamp) + * [CoreWebView2Notification.Title Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#title) + * [CoreWebView2Notification.VibrationPattern Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#vibrationpattern) + * [CoreWebView2Notification.ReportClicked Method](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#reportclicked) + * [CoreWebView2Notification.ReportClosed Method](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#reportclosed) + * [CoreWebView2Notification.ReportShown Method](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#reportshown) + * [CoreWebView2Notification.CloseRequested Event](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2739.15&preserve-view=true#closerequested) + +* [CoreWebView2NotificationReceivedEventArgs Class](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notificationreceivedeventargs?view=webview2-winrt-1.0.2739.15&preserve-view=true) + * [CoreWebView2NotificationReceivedEventArgs.Handled Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notificationreceivedeventargs?view=webview2-winrt-1.0.2739.15&preserve-view=true#handled) + * [CoreWebView2NotificationReceivedEventArgs.Notification Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notificationreceivedeventargs?view=webview2-winrt-1.0.2739.15&preserve-view=true#notification) + * [CoreWebView2NotificationReceivedEventArgs.SenderOrigin Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notificationreceivedeventargs?view=webview2-winrt-1.0.2739.15&preserve-view=true#senderorigin) + * [CoreWebView2NotificationReceivedEventArgs.GetDeferral Method](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notificationreceivedeventargs?view=webview2-winrt-1.0.2739.15&preserve-view=true#getdeferral) + +* [CoreWebView2TextDirectionKind Enum](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2textdirectionkind?view=webview2-winrt-1.0.2739.15&preserve-view=true) + * 'Default' + * 'LeftToRight' + * 'RightToLeft' + +##### [Win32/C++](#tab/win32cpp) + +* [ICoreWebView2_24](/microsoft-edge/webview2/reference/win32/icorewebview2_24?view=webview2-1.0.2739.15&preserve-view=true) + * [ICoreWebView2_24::add_NotificationReceived](/microsoft-edge/webview2/reference/win32/icorewebview2_24?view=webview2-1.0.2739.15&preserve-view=true#add_notificationreceived) + * [ICoreWebView2_24::remove_NotificationReceived](/microsoft-edge/webview2/reference/win32/icorewebview2_24?view=webview2-1.0.2739.15&preserve-view=true#remove_notificationreceived) + +* [ICoreWebView2Notification](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true) + * [ICoreWebView2Notification::add_CloseRequested](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#add_closerequested) + * [ICoreWebView2Notification::get_BadgeUri](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#get_badgeuri) + * [ICoreWebView2Notification::get_Body](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#get_body) + * [ICoreWebView2Notification::get_BodyImageUri](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#get_bodyimageuri) + * [ICoreWebView2Notification::get_Direction](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#get_direction) + * [ICoreWebView2Notification::get_IconUri](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#get_iconuri) + * [ICoreWebView2Notification::get_IsSilent](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#get_issilent) + * [ICoreWebView2Notification::get_Language](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#get_language) + * [ICoreWebView2Notification::get_RequiresInteraction](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#get_requiresinteraction) + * [ICoreWebView2Notification::get_ShouldRenotify](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#get_shouldrenotify) + * [ICoreWebView2Notification::get_Tag](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#get_tag) + * [ICoreWebView2Notification::get_Timestamp](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#get_timestamp) + * [ICoreWebView2Notification::get_Title](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#get_title) + * [ICoreWebView2Notification::GetVibrationPattern](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#getvibrationpattern) + * [ICoreWebView2Notification::remove_CloseRequested](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#remove_closerequested) + * [ICoreWebView2Notification::ReportClicked](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#reportclicked) + * [ICoreWebView2Notification::ReportClosed](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#reportclosed) + * [ICoreWebView2Notification::ReportShown](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2739.15&preserve-view=true#reportshown) + +* [ICoreWebView2NotificationCloseRequestedEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2notificationcloserequestedeventhandler?view=webview2-1.0.2739.15&preserve-view=true) + +* [ICoreWebView2NotificationReceivedEventArgs](/microsoft-edge/webview2/reference/win32/icorewebview2notificationreceivedeventargs?view=webview2-1.0.2739.15&preserve-view=true) + * [ICoreWebView2NotificationReceivedEventArgs::get_Handled](/microsoft-edge/webview2/reference/win32/icorewebview2notificationreceivedeventargs?view=webview2-1.0.2739.15&preserve-view=true#get_handled) + * [ICoreWebView2NotificationReceivedEventArgs::get_Notification](/microsoft-edge/webview2/reference/win32/icorewebview2notificationreceivedeventargs?view=webview2-1.0.2739.15&preserve-view=true#get_notification) + * [ICoreWebView2NotificationReceivedEventArgs::get_SenderOrigin](/microsoft-edge/webview2/reference/win32/icorewebview2notificationreceivedeventargs?view=webview2-1.0.2739.15&preserve-view=true#get_senderorigin) + * [ICoreWebView2NotificationReceivedEventArgs::GetDeferral](/microsoft-edge/webview2/reference/win32/icorewebview2notificationreceivedeventargs?view=webview2-1.0.2739.15&preserve-view=true#getdeferral) + * [ICoreWebView2NotificationReceivedEventArgs::put_Handled](/microsoft-edge/webview2/reference/win32/icorewebview2notificationreceivedeventargs?view=webview2-1.0.2739.15&preserve-view=true#put_handled) + +* [ICoreWebView2NotificationReceivedEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2notificationreceivedeventhandler?view=webview2-1.0.2739.15&preserve-view=true) + +* ['COREWEBVIEW2_TEXT_DIRECTION_KIND' Enum](/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2739.15&preserve-view=true#corewebview2_text_direction_kind) + * 'COREWEBVIEW2_TEXT_DIRECTION_KIND_DEFAULT' + * 'COREWEBVIEW2_TEXT_DIRECTION_KIND_LEFT_TO_RIGHT' + * 'COREWEBVIEW2_TEXT_DIRECTION_KIND_RIGHT_TO_LEFT' + +--- + + + +###### Save as + +Added 'SaveAs' APIs that allow you to programmatically perform the **Save as** operation. You can use these APIs to block the default **Save as** dialog, and then either save silently, or build your own UI for **Save as**. These APIs pertain only to the **Save as** dialog, not the **Download** dialog, which continues to use the existing Download APIs. + +##### [.NET/C#](#tab/dotnetcsharp) + +* 'CoreWebView2' Class: + * [CoreWebView2.ShowSaveAsUIAsync Method](/dotnet/api/microsoft.web.webview2.core.corewebview2.showsaveasuiasync?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2.SaveAsUIShowing Event](/dotnet/api/microsoft.web.webview2.core.corewebview2.saveasuishowing?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + +* [CoreWebView2SaveAsKind Enum](/dotnet/api/microsoft.web.webview2.core.corewebview2saveaskind?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * 'Complete' + * 'Default' + * 'HtmlOnly' + * 'SingleFile' + +* [CoreWebView2SaveAsUIResult Enum](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuiresult?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * 'Cancelled' + * 'FileAlreadyExists' + * 'InvalidPath' + * 'KindNotSupported' + * 'Success' + +* [CoreWebView2SaveAsUIShowingEventArgs Class](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.AllowReplace Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.allowreplace?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.Cancel Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.cancel?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.ContentMimeType Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.contentmimetype?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.Kind Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.kind?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.SaveAsFilePath Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.saveasfilepath?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.SuppressDefaultDialog Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.suppressdefaultdialog?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.GetDeferral Method](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.getdeferral?view=webview2-dotnet-1.0.2739.15&preserve-view=true) + +##### [WinRT/C#](#tab/winrtcsharp) + +* 'CoreWebView2' Class: + * [CoreWebView2.ShowSaveAsUIAsync Method](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2?view=webview2-winrt-1.0.2739.15&preserve-view=true#showsaveasuiasync) + * [CoreWebView2.SaveAsUIShowing Event](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2?view=webview2-winrt-1.0.2739.15&preserve-view=true#saveasuishowing) + +* [CoreWebView2SaveAsKind Enum](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveaskind?view=webview2-winrt-1.0.2739.15&preserve-view=true) + * 'Default' + * 'HtmlOnly' + * 'SingleFile' + * 'Complete' + +* [CoreWebView2SaveAsUIResult Enum](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuiresult?view=webview2-winrt-1.0.2739.15&preserve-view=true) + * 'Success' + * 'InvalidPath' + * 'FileAlreadyExists' + * 'KindNotSupported' + * 'Cancelled' + +* [CoreWebView2SaveAsUIShowingEventArgs Class](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2739.15&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.AllowReplace Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2739.15&preserve-view=true#allowreplace) + * [CoreWebView2SaveAsUIShowingEventArgs.Cancel Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2739.15&preserve-view=true#cancel) + * [CoreWebView2SaveAsUIShowingEventArgs.ContentMimeType Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2739.15&preserve-view=true#contentmimetype) + * [CoreWebView2SaveAsUIShowingEventArgs.Kind Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2739.15&preserve-view=true#kind) + * [CoreWebView2SaveAsUIShowingEventArgs.SaveAsFilePath Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2739.15&preserve-view=true#saveasfilepath) + * [CoreWebView2SaveAsUIShowingEventArgs.SuppressDefaultDialog Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2739.15&preserve-view=true#suppressdefaultdialog) + * [CoreWebView2SaveAsUIShowingEventArgs.GetDeferral Method](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2739.15&preserve-view=true#getdeferral) + +##### [Win32/C++](#tab/win32cpp) + +* [ICoreWebView2_25](/microsoft-edge/webview2/reference/win32/icorewebview2_25?view=webview2-1.0.2739.15&preserve-view=true) + * [ICoreWebView2_25::add_SaveAsUIShowing](/microsoft-edge/webview2/reference/win32/icorewebview2_25?view=webview2-1.0.2739.15&preserve-view=true#add_saveasuishowing) + * [ICoreWebView2_25::remove_SaveAsUIShowing](/microsoft-edge/webview2/reference/win32/icorewebview2_25?view=webview2-1.0.2739.15&preserve-view=true#remove_saveasuishowing) + * [ICoreWebView2_25::ShowSaveAsUI](/microsoft-edge/webview2/reference/win32/icorewebview2_25?view=webview2-1.0.2739.15&preserve-view=true#showsaveasui) + +* [ICoreWebView2SaveAsUIShowingEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventhandler?view=webview2-1.0.2739.15&preserve-view=true) + +* [ICoreWebView2SaveAsUIShowingEventArgs](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2739.15&preserve-view=true) + * [ICoreWebView2SaveAsUIShowingEventArgs::get_AllowReplace](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2739.15&preserve-view=true#get_allowreplace) + * [ICoreWebView2SaveAsUIShowingEventArgs::get_Cancel](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2739.15&preserve-view=true#get_cancel) + * [ICoreWebView2SaveAsUIShowingEventArgs::get_ContentMimeType](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2739.15&preserve-view=true#get_contentmimetype) + * [ICoreWebView2SaveAsUIShowingEventArgs::get_Kind](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2739.15&preserve-view=true#get_kind) + * [ICoreWebView2SaveAsUIShowingEventArgs::get_SaveAsFilePath](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2739.15&preserve-view=true#get_saveasfilepath) + * [ICoreWebView2SaveAsUIShowingEventArgs::get_SuppressDefaultDialog](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2739.15&preserve-view=true#get_suppressdefaultdialog) + * [ICoreWebView2SaveAsUIShowingEventArgs::GetDeferral](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2739.15&preserve-view=true#getdeferral) + * [ICoreWebView2SaveAsUIShowingEventArgs::put_AllowReplace](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2739.15&preserve-view=true#put_allowreplace) + * [ICoreWebView2SaveAsUIShowingEventArgs::put_Cancel](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2739.15&preserve-view=true#put_cancel) + * [ICoreWebView2SaveAsUIShowingEventArgs::put_Kind](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2739.15&preserve-view=true#put_kind) + * [ICoreWebView2SaveAsUIShowingEventArgs::put_SaveAsFilePath](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2739.15&preserve-view=true#put_saveasfilepath) + * [ICoreWebView2SaveAsUIShowingEventArgs::put_SuppressDefaultDialog](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2739.15&preserve-view=true#put_suppressdefaultdialog) + +* [ICoreWebView2ShowSaveAsUICompletedHandler](/microsoft-edge/webview2/reference/win32/icorewebview2showsaveasuicompletedhandler?view=webview2-1.0.2739.15&preserve-view=true) + +* ['COREWEBVIEW2_SAVE_AS_KIND' Enum](/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2739.15&preserve-view=true#corewebview2_save_as_kind) + * 'COREWEBVIEW2_SAVE_AS_KIND_DEFAULT' + * 'COREWEBVIEW2_SAVE_AS_KIND_HTML_ONLY' + * 'COREWEBVIEW2_SAVE_AS_KIND_SINGLE_FILE' + * 'COREWEBVIEW2_SAVE_AS_KIND_COMPLETE' + +* ['COREWEBVIEW2_SAVE_AS_UI_RESULT' Enum](/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2739.15&preserve-view=true#corewebview2_save_as_ui_result) + * 'COREWEBVIEW2_SAVE_AS_UI_RESULT_SUCCESS' + * 'COREWEBVIEW2_SAVE_AS_UI_RESULT_INVALID_PATH' + * 'COREWEBVIEW2_SAVE_AS_UI_RESULT_FILE_ALREADY_EXISTS' + * 'COREWEBVIEW2_SAVE_AS_UI_RESULT_KIND_NOT_SUPPORTED' + * 'COREWEBVIEW2_SAVE_AS_UI_RESULT_CANCELLED' + +--- + + + +#### Bug fixes + +There are no bug fixes in this Release SDK. + + + + + + +Release Date: August 26, 2024`, + }, + "1.0.2783-prerelease": { + SDKVersion: "1.0.2783-prerelease", + ReleaseNotes: "https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes?tabs=win32cpp#102783-prerelease", + RuntimeVersion: "129.0.2783.0", + Notes: ` + + +#### Experimental APIs + +No Experimental APIs have been added in this Prerelease SDK. + + + +#### Promotions + +No APIs have been promoted from Experimental to Stable in this Prerelease SDK. + + + +#### Bug fixes + + + +###### Runtime and SDK + +* Re-enabled the default behavior of 'SetUserAgent': by default, 'SetUserAgent' is effective for cross-origin iframes. + + + +###### Runtime-only + +* Enabled the interactive dragging feature by default. See 'edge-webview-interactive-dragging' in [WebView2 browser flags](../concepts/webview-features-flags.md). +* Disabled 'IsolateSandboxedIframes' for WebView2. +* Fixed an issue where WebView creation fails when multiple instances are launched at the same time. ([Issue #4731](https://github.com/MicrosoftEdge/WebView2Feedback/issues/4731)) +* Fixed a bug in WinRT JavaScript projection where caching existing properties in objects whose name contains 'Proxy' or 'Function' caused an error due to name collision. +* Fixed a bug where the WebView2 control became the wrong size after disconnecting and reconnecting a monitor. +* Fixed an issue where "mailto:" links leave an untitled popup window open, instead of automatically closing the popup window. + + + +###### SDK-only + +* C# WinRT projection now works on UWP. +* Fixed an issue to ensure that 'GeneratedFilesDir' no longer appears in Visual Studio for C# WinRT projection. + + + + + + + +Release Date: August 13, 2024`, + }, + "1.0.2651.64": { + SDKVersion: "1.0.2651.64", + ReleaseNotes: "https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes?tabs=win32cpp#10265164", + RuntimeVersion: "127.0.2651.64", + Notes: ` + + +#### Promotions + +The following APIs have been promoted to Stable and are now included in this Release SDK. + + + +* Updated the WebMessageObjects API to allow injecting DOM objects into WebView2 content that's constructed via the app, and via the 'CoreWebView2.PostWebMessage' API in the other direction. Added a new web object type ('CoreWebView2FileSystemHandle') to represent a file system handle that can be posted to the web content to provide it with filesystem access. + +##### [.NET/C#](#tab/dotnetcsharp) + +* 'CoreWebView2' Class: + * [CoreWebView2.PostWebMessageAsJson(webMessageAsJson, additionalObjects) Method](/dotnet/api/microsoft.web.webview2.core.corewebview2.postwebmessageasjson?view=webview2-dotnet-1.0.2651.64&preserve-view=true#microsoft-web-webview2-core-corewebview2-postwebmessageasjson(system-string-system-collections-generic-list((system-object)))) + +* 'CoreWebView2Environment' Class: + * [CoreWebView2Environment.CreateWebFileSystemDirectoryHandle Method](/dotnet/api/microsoft.web.webview2.core.corewebview2environment.createwebfilesystemdirectoryhandle?view=webview2-dotnet-1.0.2651.64&preserve-view=true) + * [CoreWebView2Environment.CreateWebFileSystemFileHandle Method](/dotnet/api/microsoft.web.webview2.core.corewebview2environment.createwebfilesystemfilehandle?view=webview2-dotnet-1.0.2651.64&preserve-view=true) + +* 'CoreWebView2FileSystemHandle' Class: + * [CoreWebView2FileSystemHandle.Kind Property](/dotnet/api/microsoft.web.webview2.core.corewebview2filesystemhandle.kind?view=webview2-dotnet-1.0.2651.64&preserve-view=true) + * [CoreWebView2FileSystemHandle.Path Property](/dotnet/api/microsoft.web.webview2.core.corewebview2filesystemhandle.path?view=webview2-dotnet-1.0.2651.64&preserve-view=true) + * [CoreWebView2FileSystemHandle.Permission Property](/dotnet/api/microsoft.web.webview2.core.corewebview2filesystemhandle.permission?view=webview2-dotnet-1.0.2651.64&preserve-view=true) + +* [CoreWebView2FileSystemHandleKind Enum](/dotnet/api/microsoft.web.webview2.core.corewebview2filesystemhandlekind?view=webview2-dotnet-1.0.2651.64&preserve-view=true) + * 'File' + * 'Directory' + +* [CoreWebView2FileSystemHandlePermission Enum](/dotnet/api/microsoft.web.webview2.core.corewebview2filesystemhandlepermission?view=webview2-dotnet-1.0.2651.64&preserve-view=true) + * 'ReadOnly' + * 'ReadWrite' + +##### [WinRT/C#](#tab/winrtcsharp) + +* 'CoreWebView2' Class: + * [CoreWebView2.PostWebMessageAsJson(webMessageAsJson, additionalObjects) Method](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2?view=webview2-winrt-1.0.2651.64&preserve-view=true#postwebmessageasjson) + +* 'CoreWebView2Environment' Class: + * [CoreWebView2Environment.CreateWebFileSystemDirectoryHandle Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2environment?view=webview2-winrt-1.0.2651.64&preserve-view=true#createwebfilesystemdirectoryhandle) + * [CoreWebView2Environment.CreateWebFileSystemFileHandle Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2environment?view=webview2-winrt-1.0.2651.64&preserve-view=true#createwebfilesystemfilehandle) + +* 'CoreWebView2FileSystemHandle' Class: + * [CoreWebView2FileSystemHandle.Kind Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2filesystemhandle?view=webview2-winrt-1.0.2651.64&preserve-view=true#kind) + * [CoreWebView2FileSystemHandle.Path Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2filesystemhandle?view=webview2-winrt-1.0.2651.64&preserve-view=true#path) + * [CoreWebView2FileSystemHandle.Permission Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2filesystemhandle?view=webview2-winrt-1.0.2651.64&preserve-view=true#permission) + +* [CoreWebView2FileSystemHandleKind Enum](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2filesystemhandlekind?view=webview2-winrt-1.0.2651.64&preserve-view=true) + * 'File' + * 'Directory' + +* [CoreWebView2FileSystemHandlePermission Enum](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2filesystemhandlepermission?view=webview2-winrt-1.0.2651.64&preserve-view=true) + * 'ReadOnly' + * 'ReadWrite' + +##### [Win32/C++](#tab/win32cpp) + +* [ICoreWebView2_23](/microsoft-edge/webview2/reference/win32/icorewebview2_23?view=webview2-1.0.2651.64&preserve-view=true) + * [ICoreWebView2_23::PostWebMessageAsJsonWithAdditionalObjects](/microsoft-edge/webview2/reference/win32/icorewebview2_23?view=webview2-1.0.2651.64&preserve-view=true#postwebmessageasjsonwithadditionalobjects) + +* [ICoreWebView2Environment14](/microsoft-edge/webview2/reference/win32/icorewebview2environment14?view=webview2-1.0.2651.64&preserve-view=true) + * [ICoreWebView2Environment14::CreateObjectCollection](/microsoft-edge/webview2/reference/win32/icorewebview2environment14?view=webview2-1.0.2651.64&preserve-view=true#createobjectcollection) + * [ICoreWebView2Environment14::CreateWebFileSystemDirectoryHandle](/microsoft-edge/webview2/reference/win32/icorewebview2environment14?view=webview2-1.0.2651.64&preserve-view=true#createwebfilesystemdirectoryhandle) + * [ICoreWebView2Environment14::CreateWebFileSystemFileHandle](/microsoft-edge/webview2/reference/win32/icorewebview2environment14?view=webview2-1.0.2651.64&preserve-view=true#createwebfilesystemfilehandle) + +* [ICoreWebView2FileSystemHandle](/microsoft-edge/webview2/reference/win32/icorewebview2filesystemhandle?view=webview2-1.0.2651.64&preserve-view=true) + * [ICoreWebView2FileSystemHandle::get_Kind](/microsoft-edge/webview2/reference/win32/icorewebview2filesystemhandle?view=webview2-1.0.2651.64&preserve-view=true#get_kind) + * [ICoreWebView2FileSystemHandle::get_Path](/microsoft-edge/webview2/reference/win32/icorewebview2filesystemhandle?view=webview2-1.0.2651.64&preserve-view=true#get_path) + * [ICoreWebView2FileSystemHandle::get_Permission](/microsoft-edge/webview2/reference/win32/icorewebview2filesystemhandle?view=webview2-1.0.2651.64&preserve-view=true#get_permission) + +* [ICoreWebView2ObjectCollection](/microsoft-edge/webview2/reference/win32/icorewebview2objectcollection?view=webview2-1.0.2651.64&preserve-view=true) + * [ICoreWebView2ObjectCollection::InsertValueAtIndex](/microsoft-edge/webview2/reference/win32/icorewebview2objectcollection?view=webview2-1.0.2651.64&preserve-view=true#insertvalueatindex) + * [ICoreWebView2ObjectCollection::RemoveValueAtIndex](/microsoft-edge/webview2/reference/win32/icorewebview2objectcollection?view=webview2-1.0.2651.64&preserve-view=true#removevalueatindex) + +* [COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND enum](/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2651.64&preserve-view=true#corewebview2_file_system_handle_kind) + * 'COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND_FILE' + * 'COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND_DIRECTORY' + +* [COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION enum](/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2651.64&preserve-view=true#corewebview2_file_system_handle_permission) + * 'COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION_READ_ONLY' + * 'COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION_READ_WRITE' + +--- + + + +#### Bug fixes + +###### Runtime-only + +* Fixed a regression where 'WebResourceRequested' events crash on certain sites. ([Issue #4602](https://github.com/MicrosoftEdge/WebView2Feedback/issues/4602)) + +###### SDK-only + +* Fixed x86 for WinRT C# projection. + + + + + + +Release Date: August 7, 2024`, + }, + "1.0.2730-prerelease": { + SDKVersion: "1.0.2730-prerelease", + ReleaseNotes: "https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes?tabs=win32cpp#102730-prerelease", + RuntimeVersion: "128.0.2730.0", + Notes: ` + + +#### Experimental APIs + +The following Experimental APIs have been added in this Prerelease SDK. + + + +* Added new Throttling Controls APIs which allows for efficient resource management by allowing you to throttle JavaScript timers. This is helpful in scenarios where a WebView2 control needs to remain visible, but needs to consume fewer resources (such as when the user isn't interacting with the content). These Throttling Controls APIs allow you to: + * Customize script timers ('setTimeout' and 'setInterval') throttling under different page states (foreground, background, and background with intensive throttling). + * Throttle script timers in select hosted iframes. + +##### [.NET/C#](#tab/dotnetcsharp) + +* 'CoreWebView2Frame' Class: + * [CoreWebView2Frame.UseOverrideTimerWakeInterval Property](/dotnet/api/microsoft.web.webview2.core.corewebview2frame.useoverridetimerwakeinterval?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + +* 'CoreWebView2Settings' Class: + * [CoreWebView2Settings.PreferredBackgroundTimerWakeInterval Property](/dotnet/api/microsoft.web.webview2.core.corewebview2settings.preferredbackgroundtimerwakeinterval?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + * [CoreWebView2Settings.PreferredForegroundTimerWakeInterval Property](/dotnet/api/microsoft.web.webview2.core.corewebview2settings.preferredforegroundtimerwakeinterval?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + * [CoreWebView2Settings.PreferredIntensiveTimerWakeInterval Property](/dotnet/api/microsoft.web.webview2.core.corewebview2settings.preferredintensivetimerwakeinterval?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + * [CoreWebView2Settings.PreferredOverrideTimerWakeInterval Property](/dotnet/api/microsoft.web.webview2.core.corewebview2settings.preferredoverridetimerwakeinterval?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + +##### [WinRT/C#](#tab/winrtcsharp) + +* 'CoreWebView2Frame' Class: + * [CoreWebView2Frame.UseOverrideTimerWakeInterval Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2frame?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#useoverridetimerwakeinterval) + +* 'CoreWebView2Settings' Class: + * [CoreWebView2Settings.PreferredBackgroundTimerWakeInterval Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2settings?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#preferredbackgroundtimerwakeinterval) + * [CoreWebView2Settings.PreferredForegroundTimerWakeInterval Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2settings?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#preferredforegroundtimerwakeinterval) + * [CoreWebView2Settings.PreferredIntensiveTimerWakeInterval Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2settings?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#preferredintensivetimerwakeinterval) + * [CoreWebView2Settings.PreferredOverrideTimerWakeInterval Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2settings?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#preferredoverridetimerwakeinterval) + +##### [Win32/C++](#tab/win32cpp) + +* [ICoreWebView2ExperimentalFrame7](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalframe7?view=webview2-1.0.2730-prerelease&preserve-view=true) + * [ICoreWebView2ExperimentalFrame7::get_UseOverrideTimerWakeInterval](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalframe7?view=webview2-1.0.2730-prerelease&preserve-view=true#get_useoverridetimerwakeinterval) + * [ICoreWebView2ExperimentalFrame7::put_UseOverrideTimerWakeInterval](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalframe7?view=webview2-1.0.2730-prerelease&preserve-view=true#put_useoverridetimerwakeinterval) + +* [ICoreWebView2ExperimentalSettings9](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsettings9?view=webview2-1.0.2730-prerelease&preserve-view=true) + * [ICoreWebView2ExperimentalSettings9::get_PreferredBackgroundTimerWakeIntervalInMilliseconds](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsettings9?view=webview2-1.0.2730-prerelease&preserve-view=true#get_preferredbackgroundtimerwakeintervalinmilliseconds) + * [ICoreWebView2ExperimentalSettings9::get_PreferredForegroundTimerWakeIntervalInMilliseconds](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsettings9?view=webview2-1.0.2730-prerelease&preserve-view=true#get_preferredforegroundtimerwakeintervalinmilliseconds) + * [ICoreWebView2ExperimentalSettings9::get_PreferredIntensiveTimerWakeIntervalInMilliseconds](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsettings9?view=webview2-1.0.2730-prerelease&preserve-view=true#get_preferredintensivetimerwakeintervalinmilliseconds) + * [ICoreWebView2ExperimentalSettings9::get_PreferredOverrideTimerWakeIntervalInMilliseconds](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsettings9?view=webview2-1.0.2730-prerelease&preserve-view=true#get_preferredoverridetimerwakeintervalinmilliseconds) + * [ICoreWebView2ExperimentalSettings9::put_PreferredBackgroundTimerWakeIntervalInMilliseconds](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsettings9?view=webview2-1.0.2730-prerelease&preserve-view=true#put_preferredbackgroundtimerwakeintervalinmilliseconds) + * [ICoreWebView2ExperimentalSettings9::put_PreferredForegroundTimerWakeIntervalInMilliseconds](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsettings9?view=webview2-1.0.2730-prerelease&preserve-view=true#put_preferredforegroundtimerwakeintervalinmilliseconds) + * [ICoreWebView2ExperimentalSettings9::put_PreferredIntensiveTimerWakeIntervalInMilliseconds](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsettings9?view=webview2-1.0.2730-prerelease&preserve-view=true#put_preferredintensivetimerwakeintervalinmilliseconds) + * [ICoreWebView2ExperimentalSettings9::put_PreferredOverrideTimerWakeIntervalInMilliseconds](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsettings9?view=webview2-1.0.2730-prerelease&preserve-view=true#put_preferredoverridetimerwakeintervalinmilliseconds) + +--- + + + +#### Promotions + +The following APIs have been promoted from Experimental to Stable in this Prerelease SDK. + + + +* Added 'SaveAs' APIs that allow you to programmatically perform the **Save as** operation. You can use these APIs to block the default **Save as** dialog, and then either save silently, or build your own UI for **Save as**. These APIs pertain only to the **Save as** dialog, not the **Download** dialog, which continues to use the existing Download APIs. + +##### [.NET/C#](#tab/dotnetcsharp) + +* 'CoreWebView2' Class: + * [CoreWebView2.SaveAsUIShowing Event](/dotnet/api/microsoft.web.webview2.core.corewebview2.saveasuishowing?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + * [CoreWebView2.ShowSaveAsUIAsync Method](/dotnet/api/microsoft.web.webview2.core.corewebview2.showsaveasuiasync?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + +* [CoreWebView2SaveAsKind Enum](/dotnet/api/microsoft.web.webview2.core.corewebview2saveaskind?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + * 'Default' + * 'HtmlOnly' + * 'SingleFile' + * 'Complete' + +* [CoreWebView2SaveAsUIResult Enum](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuiresult?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + * 'Success' + * 'InvalidPath' + * 'FileAlreadyExists' + * 'KindNotSupported' + * 'Cancelled' + +* [CoreWebView2SaveAsUIShowingEventArgs Class](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.AllowReplace Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.allowreplace?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.Cancel Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.cancel?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.ContentMimeType Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.contentmimetype?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.Kind Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.kind?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.SaveAsFilePath Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.saveasfilepath?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.SuppressDefaultDialog Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.suppressdefaultdialog?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.GetDeferral Method](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.getdeferral?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + +##### [WinRT/C#](#tab/winrtcsharp) + +* 'CoreWebView2' Class: + * [CoreWebView2.SaveAsUIShowing Event](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#saveasuishowing) + * [CoreWebView2.ShowSaveAsUIAsync Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#showsaveasuiasync) + +* [CoreWebView2SaveAsKind Enum](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveaskind?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true) + * 'Default' + * 'HtmlOnly' + * 'SingleFile' + * 'Complete' + +* [CoreWebView2SaveAsUIResult Enum](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuiresult?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true) + * 'Success' + * 'InvalidPath' + * 'FileAlreadyExists' + * 'KindNotSupported' + * 'Cancelled' + +* [CoreWebView2SaveAsUIShowingEventArgs Class](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.AllowReplace Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#allowreplace) + * [CoreWebView2SaveAsUIShowingEventArgs.Cancel Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#cancel) + * [CoreWebView2SaveAsUIShowingEventArgs.ContentMimeType Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#contentmimetype) + * [CoreWebView2SaveAsUIShowingEventArgs.Kind Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#kind) + * [CoreWebView2SaveAsUIShowingEventArgs.SaveAsFilePath Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#saveasfilepath) + * [CoreWebView2SaveAsUIShowingEventArgs.SuppressDefaultDialog Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#suppressdefaultdialog) + * [CoreWebView2SaveAsUIShowingEventArgs.GetDeferral Method](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#getdeferral) + +##### [Win32/C++](#tab/win32cpp) + +* [ICoreWebView2_25](/microsoft-edge/webview2/reference/win32/icorewebview2_25?view=webview2-1.0.2730-prerelease&preserve-view=true) + * [ICoreWebView2_25::add_SaveAsUIShowing](/microsoft-edge/webview2/reference/win32/icorewebview2_25?view=webview2-1.0.2730-prerelease&preserve-view=true#add_saveasuishowing) + * [ICoreWebView2_25::remove_SaveAsUIShowing](/microsoft-edge/webview2/reference/win32/icorewebview2_25?view=webview2-1.0.2730-prerelease&preserve-view=true#remove_saveasuishowing) + * [ICoreWebView2_25::ShowSaveAsUI](/microsoft-edge/webview2/reference/win32/icorewebview2_25?view=webview2-1.0.2730-prerelease&preserve-view=true#showsaveasui) + +* [ICoreWebView2SaveAsUIShowingEventArgs](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true) + * [ICoreWebView2SaveAsUIShowingEventArgs::get_AllowReplace](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true#get_allowreplace) + * [ICoreWebView2SaveAsUIShowingEventArgs::get_Cancel](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true#get_cancel) + * [ICoreWebView2SaveAsUIShowingEventArgs::get_ContentMimeType](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true#get_contentmimetype) + * [ICoreWebView2SaveAsUIShowingEventArgs::get_Kind](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true#get_kind) + * [ICoreWebView2SaveAsUIShowingEventArgs::get_SaveAsFilePath](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true#get_saveasfilepath) + * [ICoreWebView2SaveAsUIShowingEventArgs::get_SuppressDefaultDialog](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true#get_suppressdefaultdialog) + * [ICoreWebView2SaveAsUIShowingEventArgs::GetDeferral](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true#getdeferral) + * [ICoreWebView2SaveAsUIShowingEventArgs::put_AllowReplace](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true#put_allowreplace) + * [ICoreWebView2SaveAsUIShowingEventArgs::put_Cancel](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true#put_cancel) + * [ICoreWebView2SaveAsUIShowingEventArgs::put_Kind](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true#put_kind) + * [ICoreWebView2SaveAsUIShowingEventArgs::put_SaveAsFilePath](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true#put_saveasfilepath) + * [ICoreWebView2SaveAsUIShowingEventArgs::put_SuppressDefaultDialog](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true#put_suppressdefaultdialog) + +* [ICoreWebView2SaveAsUIShowingEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2saveasuishowingeventhandler?view=webview2-1.0.2730-prerelease&preserve-view=true) + +* [ICoreWebView2ShowSaveAsUICompletedHandler](/microsoft-edge/webview2/reference/win32/icorewebview2showsaveasuicompletedhandler?view=webview2-1.0.2730-prerelease&preserve-view=true) + +* [COREWEBVIEW2_SAVE_AS_KIND enum](/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2730-prerelease&preserve-view=true#corewebview2_save_as_kind) + * 'COREWEBVIEW2_SAVE_AS_KIND_DEFAULT' + * 'COREWEBVIEW2_SAVE_AS_KIND_HTML_ONLY' + * 'COREWEBVIEW2_SAVE_AS_KIND_SINGLE_FILE' + * 'COREWEBVIEW2_SAVE_AS_KIND_COMPLETE' + +* [COREWEBVIEW2_SAVE_AS_UI_RESULT enum](/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2730-prerelease&preserve-view=true#corewebview2_save_as_ui_result) + * 'COREWEBVIEW2_SAVE_AS_UI_RESULT_SUCCESS' + * 'COREWEBVIEW2_SAVE_AS_UI_RESULT_INVALID_PATH' + * 'COREWEBVIEW2_SAVE_AS_UI_RESULT_FILE_ALREADY_EXISTS' + * 'COREWEBVIEW2_SAVE_AS_UI_RESULT_KIND_NOT_SUPPORTED' + * 'COREWEBVIEW2_SAVE_AS_UI_RESULT_CANCELLED' + +--- + + + +* Added support for Web Notification, for non-persistent notifications. The 'NotificationReceived' event for 'CoreWebView2' controls web notification handling, allowing customization or suppression by the host app. Unhandled notifications default to WebView2's UI. + +##### [.NET/C#](#tab/dotnetcsharp) + +* 'CoreWebView2' Class: + * [CoreWebView2.NotificationReceived Event](/dotnet/api/microsoft.web.webview2.core.corewebview2.notificationreceived?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + +* [CoreWebView2Notification Class](/dotnet/api/microsoft.web.webview2.core.corewebview2notification?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + +* [CoreWebView2NotificationReceivedEventArgs Class](/dotnet/api/microsoft.web.webview2.core.corewebview2notificationreceivedeventargs?view=webview2-dotnet-1.0.2730-prerelease&preserve-view=true) + +##### [WinRT/C#](#tab/winrtcsharp) + +* 'CoreWebView2' Class: + * [CoreWebView2.NotificationReceived Event](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true#notificationreceived) + +* [CoreWebView2Notification Class](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notification?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true) + +* [CoreWebView2NotificationReceivedEventArgs Class](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2notificationreceivedeventargs?view=webview2-winrt-1.0.2730-prerelease&preserve-view=true) + +##### [Win32/C++](#tab/win32cpp) + +* [ICoreWebView2_24](/microsoft-edge/webview2/reference/win32/icorewebview2_24?view=webview2-1.0.2730-prerelease&preserve-view=true) + * [ICoreWebView2_24::add_NotificationReceived](/microsoft-edge/webview2/reference/win32/icorewebview2_24?view=webview2-1.0.2730-prerelease&preserve-view=true#add_notificationreceived) + * [ICoreWebView2_24::remove_NotificationReceived](/microsoft-edge/webview2/reference/win32/icorewebview2_24?view=webview2-1.0.2730-prerelease&preserve-view=true#remove_notificationreceived) + +* [ICoreWebView2Notification](/microsoft-edge/webview2/reference/win32/icorewebview2notification?view=webview2-1.0.2730-prerelease&preserve-view=true) + +* [ICoreWebView2NotificationCloseRequestedEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2notificationcloserequestedeventhandler?view=webview2-1.0.2730-prerelease&preserve-view=true) + +* [ICoreWebView2NotificationReceivedEventArgs](/microsoft-edge/webview2/reference/win32/icorewebview2notificationreceivedeventargs?view=webview2-1.0.2730-prerelease&preserve-view=true) + +* [ICoreWebView2NotificationReceivedEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2notificationreceivedeventhandler?view=webview2-1.0.2730-prerelease&preserve-view=true) + +--- + + + +#### Bug fixes + +###### Runtime-only + +* Fixed an issue where the app window couldn't be controlled via system commands (such as **Alt+F4** or **Alt+Spacebar**) when the focus was in WebView2 for Visual hosting mode. ([Issue #2961](https://github.com/MicrosoftEdge/WebView2Feedback/issues/2961)) +* Fixed a bug in WebView2 UWP where the Find bar couldn't be clicked into from the host app. + +###### SDK-only + +* Adding the missing WinRT 'CoreWebView2Notification.VibrationPattern' API. This WinRT API can be combined with the stable notification API promotion release notes; see "Web Notification" and 'NotificationReceived' for WinRT, immediately above. +* Fixed an issue where 'KeyDown' events from the WinForms WebView2 control didn't include the correct 'ModifierKeys' information. ([Issue #1216](https://github.com/MicrosoftEdge/WebView2Feedback/issues/1216)) +* Fixed x86 for WinRT C# projection. +* Made 'CreateCoreWebView2Environment' and 'GetAvailableCoreWebView2BrowserVersionString' more robust against potential race condition during Runtime update. + + + + + +Release Date: June 19, 2024`, + }, "1.0.2592.51": { SDKVersion: "1.0.2592.51", ReleaseNotes: "https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes?tabs=win32cpp#10259251", RuntimeVersion: "126.0.2592.51", - Notes: ` + Notes: ` #### Promotions @@ -29,7 +658,7 @@ No additional APIs have been promoted to Stable and added in this Release SDK. * Disabled 'BreakoutBoxPreferCaptureTimestampInVideoFrame' for WebView2 'TextureStream'. * Fixed a regression where the 'WindowCloseRequested' event only fires for first 'window.close()' call. -* Fixed a regression where typed arrays in WinRT JavaScript projection could not be handled as 'IDispatch' in the host. +* Fixed a regression where typed arrays in WinRT JavaScript projection could not be handled as 'IDispatch' in the host. * Fixed a bug where the autofill popup dismisses immediately and causes a focus change. * Fixed a bug where WebView2 fails to load because of 'AppPolicyGetWindowingModel'. ([Issue #4591](https://github.com/MicrosoftEdge/WebView2Feedback/issues/4591)) @@ -43,7 +672,7 @@ Release Date: June 19, 2024`, SDKVersion: "1.0.2646-prerelease", ReleaseNotes: "https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes?tabs=win32cpp#102646-prerelease", RuntimeVersion: "128.0.2646.0", - Notes: ` + Notes: ` #### General features @@ -79,13 +708,11 @@ The following Experimental APIs have been added in this Prerelease SDK. * [CoreWebView2SaveFileSecurityCheckStartingEventArgs.DocumentOriginUri Property](/dotnet/api/microsoft.web.webview2.core.corewebview2savefilesecuritycheckstartingeventargs.documentoriginuri?view=webview2-dotnet-1.0.2646-prerelease&preserve-view=true) * [CoreWebView2SaveFileSecurityCheckStartingEventArgs.FileExtension Property](/dotnet/api/microsoft.web.webview2.core.corewebview2savefilesecuritycheckstartingeventargs.fileextension?view=webview2-dotnet-1.0.2646-prerelease&preserve-view=true) * [CoreWebView2SaveFileSecurityCheckStartingEventArgs.FilePath Property](/dotnet/api/microsoft.web.webview2.core.corewebview2savefilesecuritycheckstartingeventargs.filepath?view=webview2-dotnet-1.0.2646-prerelease&preserve-view=true) - * [CoreWebView2SaveFileSecurityCheckStartingEventArgs.GetDeferral Method](/dotnet/api/microsoft.web.webview2.core.corewebview2savefilesecuritycheckstartingeventargs.getdeferral?view=webview2-dotnet-1.0.2646-prerelease&preserve-view=true) * [CoreWebView2SaveFileSecurityCheckStartingEventArgs.SuppressDefaultPolicy Property](/dotnet/api/microsoft.web.webview2.core.corewebview2savefilesecuritycheckstartingeventargs.suppressdefaultpolicy?view=webview2-dotnet-1.0.2646-prerelease&preserve-view=true) - + * [CoreWebView2SaveFileSecurityCheckStartingEventArgs.GetDeferral Method](/dotnet/api/microsoft.web.webview2.core.corewebview2savefilesecuritycheckstartingeventargs.getdeferral?view=webview2-dotnet-1.0.2646-prerelease&preserve-view=true) ##### [WinRT/C#](#tab/winrtcsharp) - * 'CoreWebView2' Class: * [CoreWebView2.SaveFileSecurityCheckStarting Event](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2?view=webview2-winrt-1.0.2646-prerelease&preserve-view=true#savefilesecuritycheckstarting) @@ -95,25 +722,27 @@ The following Experimental APIs have been added in this Prerelease SDK. * [CoreWebView2SaveFileSecurityCheckStartingEventArgs.FileExtension Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2savefilesecuritycheckstartingeventargs?view=webview2-winrt-1.0.2646-prerelease&preserve-view=true#fileextension) * [CoreWebView2SaveFileSecurityCheckStartingEventArgs.FilePath Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2savefilesecuritycheckstartingeventargs?view=webview2-winrt-1.0.2646-prerelease&preserve-view=true#filepath) * [CoreWebView2SaveFileSecurityCheckStartingEventArgs.SuppressDefaultPolicy Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2savefilesecuritycheckstartingeventargs?view=webview2-winrt-1.0.2646-prerelease&preserve-view=true#suppressdefaultpolicy) + * [CoreWebView2SaveFileSecurityCheckStartingEventArgs.GetDeferral Method](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2savefilesecuritycheckstartingeventargs?view=webview2-winrt-1.0.2646-prerelease&preserve-view=true#getdeferral) - ##### [Win32/C++](#tab/win32cpp) * [ICoreWebView2Experimental27](/microsoft-edge/webview2/reference/win32/icorewebview2experimental27?view=webview2-1.0.2646-prerelease&preserve-view=true) * [ICoreWebView2Experimental27::add_SaveFileSecurityCheckStarting](/microsoft-edge/webview2/reference/win32/icorewebview2experimental27?view=webview2-1.0.2646-prerelease&preserve-view=true#add_savefilesecuritycheckstarting) * [ICoreWebView2Experimental27::remove_SaveFileSecurityCheckStarting](/microsoft-edge/webview2/reference/win32/icorewebview2experimental27?view=webview2-1.0.2646-prerelease&preserve-view=true#remove_savefilesecuritycheckstarting) - * [ICoreWebView2ExperimentalSaveFileSecurityCheckStartingEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstartingeventhandler?view=webview2-1.0.2646-prerelease&preserve-view=true) * [ICoreWebView2ExperimentalSaveFileSecurityCheckStartingEventArgs](/microsoft- edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true) * [ICoreWebView2ExperimentalSaveFileSecurityCheckStartingEventArgs::get_CancelSave](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#get_cancelsave) - * [ICoreWebView2ExperimentalSaveFileSecurityCheckStartingEventArgs::put_CancelSave](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#put_cancelsave) * [ICoreWebView2ExperimentalSaveFileSecurityCheckStartingEventArgs::get_DocumentOriginUri](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#get_documentoriginuri) * [ICoreWebView2ExperimentalSaveFileSecurityCheckStartingEventArgs::get_FileExtension](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#get_fileextension) * [ICoreWebView2ExperimentalSaveFileSecurityCheckStartingEventArgs::get_FilePath](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#get_filepath) * [ICoreWebView2ExperimentalSaveFileSecurityCheckStartingEventArgs::get_SuppressDefaultPolicy](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#get_suppressdefaultpolicy) - * [ICoreWebView2ExperimentalSaveFileSecurityCheckStartingEventArgs::put_SuppressDefaultPolicy](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#put_suppressdefaultpolicy) * [ICoreWebView2ExperimentalSaveFileSecurityCheckStartingEventArgs::GetDeferral](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#getdeferral) + * [ICoreWebView2ExperimentalSaveFileSecurityCheckStartingEventArgs::put_CancelSave](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#put_cancelsave) + * [ICoreWebView2ExperimentalSaveFileSecurityCheckStartingEventArgs::put_SuppressDefaultPolicy](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#put_suppressdefaultpolicy) + +* [ICoreWebView2ExperimentalSaveFileSecurityCheckStartingEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstartingeventhandler?view=webview2-1.0.2646-prerelease&preserve-view=true) + --- @@ -130,9 +759,9 @@ edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstar * 'CoreWebView2ScreenCaptureStartingEventArgs' Class: * [CoreWebView2ScreenCaptureStartingEventArgs.Cancel Property](/dotnet/api/microsoft.web.webview2.core.corewebview2screencapturestartingeventargs.cancel?view=webview2-dotnet-1.0.2646-prerelease&preserve-view=true) - * [CoreWebView2ScreenCaptureStartingEventArgs.GetDeferral Method](/dotnet/api/microsoft.web.webview2.core.corewebview2screencapturestartingeventargs.getdeferral?view=webview2-dotnet-1.0.2646-prerelease&preserve-view=true) * [CoreWebView2ScreenCaptureStartingEventArgs.Handled Property](/dotnet/api/microsoft.web.webview2.core.corewebview2screencapturestartingeventargs.handled?view=webview2-dotnet-1.0.2646-prerelease&preserve-view=true) * [CoreWebView2ScreenCaptureStartingEventArgs.OriginalSourceFrameInfo Property](/dotnet/api/microsoft.web.webview2.core.corewebview2screencapturestartingeventargs.originalsourceframeinfo?view=webview2-dotnet-1.0.2646-prerelease&preserve-view=true) + * [CoreWebView2ScreenCaptureStartingEventArgs.GetDeferral Method](/dotnet/api/microsoft.web.webview2.core.corewebview2screencapturestartingeventargs.getdeferral?view=webview2-dotnet-1.0.2646-prerelease&preserve-view=true) ##### [WinRT/C#](#tab/winrtcsharp) @@ -144,32 +773,31 @@ edge/webview2/reference/win32/icorewebview2experimentalsavefilesecuritycheckstar * 'CoreWebView2ScreenCaptureStartingEventArgs' Class: * [CoreWebView2ScreenCaptureStartingEventArgs.Cancel Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2screencapturestartingeventargs?view=webview2-winrt-1.0.2646-prerelease&preserve-view=true#cancel) - * [CoreWebView2ScreenCaptureStartingEventArgs.GetDeferral Method](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2screencapturestartingeventargs?view=webview2-winrt-1.0.2646-prerelease&preserve-view=true#getdeferral) * [CoreWebView2ScreenCaptureStartingEventArgs.Handled Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2screencapturestartingeventargs?view=webview2-winrt-1.0.2646-prerelease&preserve-view=true#handled) * [CoreWebView2ScreenCaptureStartingEventArgs.OriginalSourceFrameInfo Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2screencapturestartingeventargs?view=webview2-winrt-1.0.2646-prerelease&preserve-view=true#originalsourceframeinfo) + * [CoreWebView2ScreenCaptureStartingEventArgs.GetDeferral Method](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2screencapturestartingeventargs?view=webview2-winrt-1.0.2646-prerelease&preserve-view=true#getdeferral) ##### [Win32/C++](#tab/win32cpp) * [ICoreWebView2Experimental26](/microsoft-edge/webview2/reference/win32/icorewebview2experimental26?view=webview2-1.0.2646-prerelease&preserve-view=true) * [ICoreWebView2Experimental26::add_ScreenCaptureStarting](/microsoft-edge/webview2/reference/win32/icorewebview2experimental26?view=webview2-1.0.2646-prerelease&preserve-view=true#add_screencapturestarting) * [ICoreWebView2Experimental26::remove_ScreenCaptureStarting](/microsoft-edge/webview2/reference/win32/icorewebview2experimental26?view=webview2-1.0.2646-prerelease&preserve-view=true#remove_screencapturestarting) - * [ICoreWebView2ExperimentalScreenCaptureStartingEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventhandler?view=webview2-1.0.2646-prerelease&preserve-view=true) * [ICoreWebView2ExperimentalFrame6](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalframe6?view=webview2-1.0.2646-prerelease&preserve-view=true) * [ICoreWebView2ExperimentalFrame6::add_ScreenCaptureStarting](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalframe6?view=webview2-1.0.2646-prerelease&preserve-view=true#add_screencapturestarting) * [ICoreWebView2ExperimentalFrame6::remove_ScreenCaptureStarting](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalframe6?view=webview2-1.0.2646-prerelease&preserve-view=true#remove_screencapturestarting) - * [ICoreWebView2ExperimentalFrameScreenCaptureStartingEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalframescreencapturestartingeventhandler?view=webview2-1.0.2646-prerelease&preserve-view=true) + +* [ICoreWebView2ExperimentalFrameScreenCaptureStartingEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalframescreencapturestartingeventhandler?view=webview2-1.0.2646-prerelease&preserve-view=true) * [ICoreWebView2ExperimentalScreenCaptureStartingEventArgs](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true) * [ICoreWebView2ExperimentalScreenCaptureStartingEventArgs::get_Cancel](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#get_cancel) - * [ICoreWebView2ExperimentalScreenCaptureStartingEventArgs::put_Cancel](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#put_cancel) * [ICoreWebView2ExperimentalScreenCaptureStartingEventArgs::get_Handled](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#get_handled) - * [ICoreWebView2ExperimentalScreenCaptureStartingEventArgs::put_Handled](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#put_handled) * [ICoreWebView2ExperimentalScreenCaptureStartingEventArgs::get_OriginalSourceFrameInfo](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#get_originalsourceframeinfo) * [ICoreWebView2ExperimentalScreenCaptureStartingEventArgs::GetDeferral](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#getdeferral) - * [ICoreWebView2ExperimentalScreenCaptureStartingEventArgs::Invoke](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#invoke) - * [ICoreWebView2ExperimentalScreenCaptureStartingEventArgs::Invoke](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#invoke) - * [ICoreWebView2ExperimentalScreenCaptureStartingEventArgs::Invoke](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#invoke) + * [ICoreWebView2ExperimentalScreenCaptureStartingEventArgs::put_Cancel](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#put_cancel) + * [ICoreWebView2ExperimentalScreenCaptureStartingEventArgs::put_Handled](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventargs?view=webview2-1.0.2646-prerelease&preserve-view=true#put_handled) + +* [ICoreWebView2ExperimentalScreenCaptureStartingEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalscreencapturestartingeventhandler?view=webview2-1.0.2646-prerelease&preserve-view=true) --- @@ -263,9 +891,8 @@ The following APIs have been promoted from Experimental to Stable in this Prerel * [ICoreWebView2FileSystemHandle::get_Permission](/microsoft-edge/webview2/reference/win32/icorewebview2filesystemhandle?view=webview2-1.0.2646-prerelease&preserve-view=true#get_permission) * [ICoreWebView2ObjectCollection](/microsoft-edge/webview2/reference/win32/icorewebview2objectcollection?view=webview2-1.0.2646-prerelease&preserve-view=true) - * [ICoreWebView2ObjectCollection::RemoveValueAtIndex](/microsoft-edge/webview2/reference/win32/icorewebview2objectcollection?view=webview2-1.0.2646-prerelease&preserve-view=true#removevalueatindex) * [ICoreWebView2ObjectCollection::InsertValueAtIndex](/microsoft-edge/webview2/reference/win32/icorewebview2objectcollection?view=webview2-1.0.2646-prerelease&preserve-view=true#insertvalueatindex) - * [ICoreWebView2ObjectCollection::get_Kind](/microsoft-edge/webview2/reference/win32/icorewebview2objectcollection?view=webview2-1.0.2646-prerelease&preserve-view=true#get_kind) + * [ICoreWebView2ObjectCollection::RemoveValueAtIndex](/microsoft-edge/webview2/reference/win32/icorewebview2objectcollection?view=webview2-1.0.2646-prerelease&preserve-view=true#removevalueatindex) * [COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND enum](/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2646-prerelease&preserve-view=true#corewebview2_file_system_handle_kind) * 'COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND_FILE' @@ -295,7 +922,7 @@ Release Date: May 28, 2024`, SDKVersion: "1.0.2535.41", ReleaseNotes: "https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes?tabs=win32cpp#10253541", RuntimeVersion: "125.0.2535.41", - Notes: ` + Notes: ` #### Promotions @@ -344,7 +971,7 @@ The following APIs have been promoted to Stable and are now included in this Rel ###### Runtime-only -* Fixed a bug where if the 'LaunchingExternalURIScheme' event handler is attached, and the **always remember** checkbox is enabled, and the user selects this checkbox, the dialog is incorrectly displayed again. +* Fixed a bug where if the 'LaunchingExternalURIScheme' event handler is attached, and the **always remember** checkbox is enabled, and the user selects this checkbox, the dialog is incorrectly displayed again. * Fixed an issue where text edit controls in visual hosting would duplicate IME input when losing and then regaining focus. * Fixed an issue where full-trust UWP apps couldn't display owned windows. @@ -364,7 +991,7 @@ Release Date: May 28, 2024`, SDKVersion: "1.0.2584-prerelease", ReleaseNotes: "https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes?tabs=win32cpp#102584-prerelease", RuntimeVersion: "126.0.2584.0", - Notes: ` + Notes: ` #### Experimental features @@ -413,7 +1040,7 @@ Release Date: April 22, 2024`, SDKVersion: "1.0.2478.35", ReleaseNotes: "https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes?tabs=win32cpp#10247835", RuntimeVersion: "124.0.2478.35", - Notes: ` + Notes: ` #### Promotions @@ -499,7 +1126,7 @@ Release Date: April 22, 2024`, SDKVersion: "1.0.2526-prerelease", ReleaseNotes: "https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes?tabs=win32cpp#102526-prerelease", RuntimeVersion: "125.0.2526.0", - Notes: ` + Notes: ` #### Breaking changes @@ -537,10 +1164,10 @@ The following Experimental APIs have been added in this Prerelease SDK. * [CoreWebView2SaveAsUIShowingEventArgs.AllowReplace Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.allowreplace?view=webview2-dotnet-1.0.2526-prerelease&preserve-view=true) * [CoreWebView2SaveAsUIShowingEventArgs.Cancel Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.cancel?view=webview2-dotnet-1.0.2526-prerelease&preserve-view=true) * [CoreWebView2SaveAsUIShowingEventArgs.ContentMimeType Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.contentmimetype?view=webview2-dotnet-1.0.2526-prerelease&preserve-view=true) - * [CoreWebView2SaveAsUIShowingEventArgs.GetDeferral Method](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.getdeferral?view=webview2-dotnet-1.0.2526-prerelease&preserve-view=true) * [CoreWebView2SaveAsUIShowingEventArgs.Kind Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.kind?view=webview2-dotnet-1.0.2526-prerelease&preserve-view=true) * [CoreWebView2SaveAsUIShowingEventArgs.SaveAsFilePath Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.saveasfilepath?view=webview2-dotnet-1.0.2526-prerelease&preserve-view=true) * [CoreWebView2SaveAsUIShowingEventArgs.SuppressDefaultDialog Property](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.suppressdefaultdialog?view=webview2-dotnet-1.0.2526-prerelease&preserve-view=true) + * [CoreWebView2SaveAsUIShowingEventArgs.GetDeferral Method](/dotnet/api/microsoft.web.webview2.core.corewebview2saveasuishowingeventargs.getdeferral?view=webview2-dotnet-1.0.2526-prerelease&preserve-view=true) ##### [WinRT/C#](#tab/winrtcsharp) @@ -565,10 +1192,10 @@ The following Experimental APIs have been added in this Prerelease SDK. * [CoreWebView2SaveAsUIShowingEventArgs.AllowReplace Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2526-prerelease&preserve-view=true#allowreplace) * [CoreWebView2SaveAsUIShowingEventArgs.Cancel Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2526-prerelease&preserve-view=true#cancel) * [CoreWebView2SaveAsUIShowingEventArgs.ContentMimeType Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2526-prerelease&preserve-view=true#contentmimetype) - * [CoreWebView2SaveAsUIShowingEventArgs.GetDeferral Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2526-prerelease&preserve-view=true#getdeferral) * [CoreWebView2SaveAsUIShowingEventArgs.Kind Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2526-prerelease&preserve-view=true#kind) * [CoreWebView2SaveAsUIShowingEventArgs.SaveAsFilePath Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2526-prerelease&preserve-view=true#saveasfilepath) * [CoreWebView2SaveAsUIShowingEventArgs.SuppressDefaultDialog Property](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2526-prerelease&preserve-view=true#suppressdefaultdialog) + * [CoreWebView2SaveAsUIShowingEventArgs.GetDeferral Method](/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2saveasuishowingeventargs?view=webview2-winrt-1.0.2526-prerelease&preserve-view=true#getdeferral) ##### [Win32/C++](#tab/win32cpp) @@ -577,10 +1204,24 @@ The following Experimental APIs have been added in this Prerelease SDK. * [ICoreWebView2Experimental25::remove_SaveAsUIShowing](/microsoft-edge/webview2/reference/win32/icorewebview2experimental25?view=webview2-1.0.2526-prerelease&preserve-view=true#remove_saveasuishowing) * [ICoreWebView2Experimental25::ShowSaveAsUI](/microsoft-edge/webview2/reference/win32/icorewebview2experimental25?view=webview2-1.0.2526-prerelease&preserve-view=true#showsaveasui) -* [ICoreWebView2ExperimentalShowSaveAsUICompletedHandler](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalshowsaveasuicompletedhandler?view=webview2-1.0.2526-prerelease&preserve-view=true) - * [ICoreWebView2ExperimentalShowSaveAsUICompletedHandler::Invoke](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalshowsaveasuicompletedhandler?view=webview2-1.0.2526-prerelease&preserve-view=true#invoke) +* [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true) + * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::get_AllowReplace](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#get_allowreplace) + * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::get_Cancel](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#get_cancel) + * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::get_ContentMimeType](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#get_contentmimetype) + * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::get_Kind](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#get_kind) + * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::get_SaveAsFilePath](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#get_saveasfilepath) + * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::get_SuppressDefaultDialog](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#get_suppressdefaultdialog) + * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::GetDeferral](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#getdeferral) + * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::put_AllowReplace](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#put_allowreplace) + * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::put_Cancel](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#put_cancel) + * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::put_Kind](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#put_kind) + * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::put_SaveAsFilePath](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#put_saveasfilepath) + * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::put_SuppressDefaultDialog](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#put_suppressdefaultdialog) + +* [ICoreWebView2ExperimentalSaveAsUIShowingEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventhandler?view=webview2-1.0.2526-prerelease&preserve-view=true) -* [ICoreWebView2ExperimentalSaveAsUIShowingEventHandler](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventhandler?view=webview2-1.0.2526-prerelease&preserve-view=true) +* [ICoreWebView2ExperimentalShowSaveAsUICompletedHandler](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalshowsaveasuicompletedhandler?view=webview2-1.0.2526-prerelease&preserve-view=true) + * [ICoreWebView2ExperimentalShowSaveAsUICompletedHandler::Invoke](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalshowsaveasuicompletedhandler?view=webview2-1.0.2526-prerelease&preserve-view=true#invoke) * [COREWEBVIEW2_SAVE_AS_KIND enum](/microsoft-edge/webview2/reference/win32/webview2experimental-idl?view=webview2-1.0.2526-prerelease&preserve-view=true#corewebview2_save_as_kind) * 'COREWEBVIEW2_SAVE_AS_KIND_DEFAULT' @@ -595,20 +1236,6 @@ The following Experimental APIs have been added in this Prerelease SDK. * 'COREWEBVIEW2_SAVE_AS_UI_RESULT_KIND_NOT_SUPPORTED' * 'COREWEBVIEW2_SAVE_AS_UI_RESULT_CANCELLED' -* [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true) - * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::get_AllowReplace](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#get_allowreplace) - * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::get_Cancel](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#get_cancel) - * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::get_ContentMimeType](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#get_contentmimetype) - * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::get_Kind](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#get_kind) - * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::get_SaveAsFilePath](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#get_saveasfilepath) - * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::get_SuppressDefaultDialog](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#get_suppressdefaultdialog) - * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::GetDeferral](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#getdeferral) - * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::put_AllowReplace](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#put_allowreplace) - * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::put_Cancel](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#put_cancel) - * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::put_Kind](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#put_kind) - * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::put_SaveAsFilePath](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#put_saveasfilepath) - * [ICoreWebView2ExperimentalSaveAsUIShowingEventArgs::put_SuppressDefaultDialog](/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsaveasuishowingeventargs?view=webview2-1.0.2526-prerelease&preserve-view=true#put_suppressdefaultdialog) - --- @@ -707,7 +1334,7 @@ Release Date: March 25, 2024`, SDKVersion: "1.0.2420.47", ReleaseNotes: "https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes?tabs=win32cpp#10242047", RuntimeVersion: "123.0.2420.47", - Notes: ` + Notes: ` #### Promotions @@ -820,7 +1447,7 @@ Release Date: March 25, 2024`, SDKVersion: "1.0.2470-prerelease", ReleaseNotes: "https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes?tabs=win32cpp#102470-prerelease", RuntimeVersion: "124.0.2470.0", - Notes: ` + Notes: ` @@ -1045,7 +1672,7 @@ Release Date: February 26, 2024`, SDKVersion: "1.0.2365.46", ReleaseNotes: "https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes?tabs=win32cpp#10236546", RuntimeVersion: "122.0.2365.46", - Notes: ` + Notes: ` #### Promotions diff --git a/pkg/webview2/COREWEBVIEW2_BROWSING_DATA_KINDS.go b/pkg/webview2/COREWEBVIEW2_BROWSING_DATA_KINDS.go index ffe322e..f751576 100644 --- a/pkg/webview2/COREWEBVIEW2_BROWSING_DATA_KINDS.go +++ b/pkg/webview2/COREWEBVIEW2_BROWSING_DATA_KINDS.go @@ -5,20 +5,20 @@ package webview2 type COREWEBVIEW2_BROWSING_DATA_KINDS uint32 const ( - COREWEBVIEW2_BROWSING_DATA_KINDS_FILE_SYSTEMS = 1 << 0 - COREWEBVIEW2_BROWSING_DATA_KINDS_INDEXED_DB = 1 << 1 - COREWEBVIEW2_BROWSING_DATA_KINDS_LOCAL_STORAGE = 1 << 2 - COREWEBVIEW2_BROWSING_DATA_KINDS_WEB_SQL = 1 << 3 - COREWEBVIEW2_BROWSING_DATA_KINDS_CACHE_STORAGE = 1 << 4 - COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_DOM_STORAGE = 1 << 5 - COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES = 1 << 6 - COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_SITE = 1 << 7 - COREWEBVIEW2_BROWSING_DATA_KINDS_DISK_CACHE = 1 << 8 - COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY = 1 << 9 - COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL = 1 << 10 - COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE = 1 << 11 - COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY = 1 << 12 - COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS = 1 << 13 - COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_PROFILE = 1 << 14 - COREWEBVIEW2_BROWSING_DATA_KINDS_SERVICE_WORKERS = 1 << 15 + COREWEBVIEW2_BROWSING_DATA_KINDS_FILE_SYSTEMS = 0x1 + COREWEBVIEW2_BROWSING_DATA_KINDS_INDEXED_DB = 0x2 + COREWEBVIEW2_BROWSING_DATA_KINDS_LOCAL_STORAGE = 0x4 + COREWEBVIEW2_BROWSING_DATA_KINDS_WEB_SQL = 0x8 + COREWEBVIEW2_BROWSING_DATA_KINDS_CACHE_STORAGE = 0x10 + COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_DOM_STORAGE = 0x20 + COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES = 0x40 + COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_SITE = 0x80 + COREWEBVIEW2_BROWSING_DATA_KINDS_DISK_CACHE = 0x100 + COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY = 0x200 + COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL = 0x400 + COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE = 0x800 + COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY = 0x1000 + COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS = 0x2000 + COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_PROFILE = 0x4000 + COREWEBVIEW2_BROWSING_DATA_KINDS_SERVICE_WORKERS = 0x8000 ) diff --git a/pkg/webview2/COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND.go b/pkg/webview2/COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND.go new file mode 100644 index 0000000..9ef9325 --- /dev/null +++ b/pkg/webview2/COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND.go @@ -0,0 +1,10 @@ +//go:build windows + +package webview2 + +type COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND uint32 + +const ( + COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND_FILE = 0 + COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND_DIRECTORY = 1 +) diff --git a/pkg/webview2/COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION.go b/pkg/webview2/COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION.go new file mode 100644 index 0000000..375b6c4 --- /dev/null +++ b/pkg/webview2/COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION.go @@ -0,0 +1,10 @@ +//go:build windows + +package webview2 + +type COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION uint32 + +const ( + COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION_READ_ONLY = 0 + COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION_READ_WRITE = 1 +) diff --git a/pkg/webview2/COREWEBVIEW2_MOUSE_EVENT_KIND.go b/pkg/webview2/COREWEBVIEW2_MOUSE_EVENT_KIND.go index dfc62c3..01d18a8 100644 --- a/pkg/webview2/COREWEBVIEW2_MOUSE_EVENT_KIND.go +++ b/pkg/webview2/COREWEBVIEW2_MOUSE_EVENT_KIND.go @@ -5,22 +5,22 @@ package webview2 type COREWEBVIEW2_MOUSE_EVENT_KIND uint32 const ( - COREWEBVIEW2_MOUSE_EVENT_KIND_HORIZONTAL_WHEEL = 0x020E - COREWEBVIEW2_MOUSE_EVENT_KIND_LEFT_BUTTON_DOUBLE_CLICK = 0x0203 - COREWEBVIEW2_MOUSE_EVENT_KIND_LEFT_BUTTON_DOWN = 0x0201 - COREWEBVIEW2_MOUSE_EVENT_KIND_LEFT_BUTTON_UP = 0x0202 - COREWEBVIEW2_MOUSE_EVENT_KIND_LEAVE = 0x02A3 - COREWEBVIEW2_MOUSE_EVENT_KIND_MIDDLE_BUTTON_DOUBLE_CLICK = 0x0209 - COREWEBVIEW2_MOUSE_EVENT_KIND_MIDDLE_BUTTON_DOWN = 0x0207 - COREWEBVIEW2_MOUSE_EVENT_KIND_MIDDLE_BUTTON_UP = 0x0208 - COREWEBVIEW2_MOUSE_EVENT_KIND_MOVE = 0x0200 - COREWEBVIEW2_MOUSE_EVENT_KIND_RIGHT_BUTTON_DOUBLE_CLICK = 0x0206 - COREWEBVIEW2_MOUSE_EVENT_KIND_RIGHT_BUTTON_DOWN = 0x0204 - COREWEBVIEW2_MOUSE_EVENT_KIND_RIGHT_BUTTON_UP = 0x0205 - COREWEBVIEW2_MOUSE_EVENT_KIND_WHEEL = 0x020A - COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_DOUBLE_CLICK = 0x020D - COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_DOWN = 0x020B - COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_UP = 0x020C - COREWEBVIEW2_MOUSE_EVENT_KIND_NON_CLIENT_RIGHT_BUTTON_DOWN = 0x00A4 - COREWEBVIEW2_MOUSE_EVENT_KIND_NON_CLIENT_RIGHT_BUTTON_UP = 0x00A5 + COREWEBVIEW2_MOUSE_EVENT_KIND_HORIZONTAL_WHEEL = 526 + COREWEBVIEW2_MOUSE_EVENT_KIND_LEFT_BUTTON_DOUBLE_CLICK = 515 + COREWEBVIEW2_MOUSE_EVENT_KIND_LEFT_BUTTON_DOWN = 513 + COREWEBVIEW2_MOUSE_EVENT_KIND_LEFT_BUTTON_UP = 514 + COREWEBVIEW2_MOUSE_EVENT_KIND_LEAVE = 675 + COREWEBVIEW2_MOUSE_EVENT_KIND_MIDDLE_BUTTON_DOUBLE_CLICK = 521 + COREWEBVIEW2_MOUSE_EVENT_KIND_MIDDLE_BUTTON_DOWN = 519 + COREWEBVIEW2_MOUSE_EVENT_KIND_MIDDLE_BUTTON_UP = 520 + COREWEBVIEW2_MOUSE_EVENT_KIND_MOVE = 512 + COREWEBVIEW2_MOUSE_EVENT_KIND_RIGHT_BUTTON_DOUBLE_CLICK = 518 + COREWEBVIEW2_MOUSE_EVENT_KIND_RIGHT_BUTTON_DOWN = 516 + COREWEBVIEW2_MOUSE_EVENT_KIND_RIGHT_BUTTON_UP = 517 + COREWEBVIEW2_MOUSE_EVENT_KIND_WHEEL = 522 + COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_DOUBLE_CLICK = 525 + COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_DOWN = 523 + COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_UP = 524 + COREWEBVIEW2_MOUSE_EVENT_KIND_NON_CLIENT_RIGHT_BUTTON_DOWN = 164 + COREWEBVIEW2_MOUSE_EVENT_KIND_NON_CLIENT_RIGHT_BUTTON_UP = 165 ) diff --git a/pkg/webview2/COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS.go b/pkg/webview2/COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS.go index 680188f..2d2facd 100644 --- a/pkg/webview2/COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS.go +++ b/pkg/webview2/COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS.go @@ -6,11 +6,11 @@ type COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS uint32 const ( COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_NONE = 0x0 - COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_LEFT_BUTTON = 0x0001 - COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_RIGHT_BUTTON = 0x0002 - COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_SHIFT = 0x0004 - COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_CONTROL = 0x0008 - COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_MIDDLE_BUTTON = 0x0010 - COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_X_BUTTON1 = 0x0020 - COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_X_BUTTON2 = 0x0040 + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_LEFT_BUTTON = 0x1 + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_RIGHT_BUTTON = 0x2 + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_SHIFT = 0x4 + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_CONTROL = 0x8 + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_MIDDLE_BUTTON = 0x10 + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_X_BUTTON1 = 0x20 + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_X_BUTTON2 = 0x40 ) diff --git a/pkg/webview2/COREWEBVIEW2_PDF_TOOLBAR_ITEMS.go b/pkg/webview2/COREWEBVIEW2_PDF_TOOLBAR_ITEMS.go index 0f7d885..3b4747b 100644 --- a/pkg/webview2/COREWEBVIEW2_PDF_TOOLBAR_ITEMS.go +++ b/pkg/webview2/COREWEBVIEW2_PDF_TOOLBAR_ITEMS.go @@ -6,17 +6,17 @@ type COREWEBVIEW2_PDF_TOOLBAR_ITEMS uint32 const ( COREWEBVIEW2_PDF_TOOLBAR_ITEMS_NONE = 0x0 - COREWEBVIEW2_PDF_TOOLBAR_ITEMS_SAVE = 0x0001 - COREWEBVIEW2_PDF_TOOLBAR_ITEMS_PRINT = 0x0002 - COREWEBVIEW2_PDF_TOOLBAR_ITEMS_SAVE_AS = 0x0004 - COREWEBVIEW2_PDF_TOOLBAR_ITEMS_ZOOM_IN = 0x0008 - COREWEBVIEW2_PDF_TOOLBAR_ITEMS_ZOOM_OUT = 0x0010 - COREWEBVIEW2_PDF_TOOLBAR_ITEMS_ROTATE = 0x0020 - COREWEBVIEW2_PDF_TOOLBAR_ITEMS_FIT_PAGE = 0x0040 - COREWEBVIEW2_PDF_TOOLBAR_ITEMS_PAGE_LAYOUT = 0x0080 - COREWEBVIEW2_PDF_TOOLBAR_ITEMS_BOOKMARKS = 0x0100 - COREWEBVIEW2_PDF_TOOLBAR_ITEMS_PAGE_SELECTOR = 0x0200 - COREWEBVIEW2_PDF_TOOLBAR_ITEMS_SEARCH = 0x0400 - COREWEBVIEW2_PDF_TOOLBAR_ITEMS_FULL_SCREEN = 0x0800 + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_SAVE = 0x1 + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_PRINT = 0x2 + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_SAVE_AS = 0x4 + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_ZOOM_IN = 0x8 + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_ZOOM_OUT = 0x10 + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_ROTATE = 0x20 + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_FIT_PAGE = 0x40 + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_PAGE_LAYOUT = 0x80 + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_BOOKMARKS = 0x100 + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_PAGE_SELECTOR = 0x200 + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_SEARCH = 0x400 + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_FULL_SCREEN = 0x800 COREWEBVIEW2_PDF_TOOLBAR_ITEMS_MORE_SETTINGS = 0x1000 ) diff --git a/pkg/webview2/COREWEBVIEW2_POINTER_EVENT_KIND.go b/pkg/webview2/COREWEBVIEW2_POINTER_EVENT_KIND.go index f7b9561..6c2181b 100644 --- a/pkg/webview2/COREWEBVIEW2_POINTER_EVENT_KIND.go +++ b/pkg/webview2/COREWEBVIEW2_POINTER_EVENT_KIND.go @@ -5,10 +5,10 @@ package webview2 type COREWEBVIEW2_POINTER_EVENT_KIND uint32 const ( - COREWEBVIEW2_POINTER_EVENT_KIND_ACTIVATE = 0x024B - COREWEBVIEW2_POINTER_EVENT_KIND_DOWN = 0x0246 - COREWEBVIEW2_POINTER_EVENT_KIND_ENTER = 0x0249 - COREWEBVIEW2_POINTER_EVENT_KIND_LEAVE = 0x024A - COREWEBVIEW2_POINTER_EVENT_KIND_UP = 0x0247 - COREWEBVIEW2_POINTER_EVENT_KIND_UPDATE = 0x0245 + COREWEBVIEW2_POINTER_EVENT_KIND_ACTIVATE = 587 + COREWEBVIEW2_POINTER_EVENT_KIND_DOWN = 582 + COREWEBVIEW2_POINTER_EVENT_KIND_ENTER = 585 + COREWEBVIEW2_POINTER_EVENT_KIND_LEAVE = 586 + COREWEBVIEW2_POINTER_EVENT_KIND_UP = 583 + COREWEBVIEW2_POINTER_EVENT_KIND_UPDATE = 581 ) diff --git a/pkg/webview2/COREWEBVIEW2_SAVE_AS_KIND.go b/pkg/webview2/COREWEBVIEW2_SAVE_AS_KIND.go new file mode 100644 index 0000000..9fc159b --- /dev/null +++ b/pkg/webview2/COREWEBVIEW2_SAVE_AS_KIND.go @@ -0,0 +1,12 @@ +//go:build windows + +package webview2 + +type COREWEBVIEW2_SAVE_AS_KIND uint32 + +const ( + COREWEBVIEW2_SAVE_AS_KIND_DEFAULT = 0 + COREWEBVIEW2_SAVE_AS_KIND_HTML_ONLY = 1 + COREWEBVIEW2_SAVE_AS_KIND_SINGLE_FILE = 2 + COREWEBVIEW2_SAVE_AS_KIND_COMPLETE = 3 +) diff --git a/pkg/webview2/COREWEBVIEW2_SAVE_AS_UI_RESULT.go b/pkg/webview2/COREWEBVIEW2_SAVE_AS_UI_RESULT.go new file mode 100644 index 0000000..9d86c15 --- /dev/null +++ b/pkg/webview2/COREWEBVIEW2_SAVE_AS_UI_RESULT.go @@ -0,0 +1,13 @@ +//go:build windows + +package webview2 + +type COREWEBVIEW2_SAVE_AS_UI_RESULT uint32 + +const ( + COREWEBVIEW2_SAVE_AS_UI_RESULT_SUCCESS = 0 + COREWEBVIEW2_SAVE_AS_UI_RESULT_INVALID_PATH = 1 + COREWEBVIEW2_SAVE_AS_UI_RESULT_FILE_ALREADY_EXISTS = 2 + COREWEBVIEW2_SAVE_AS_UI_RESULT_KIND_NOT_SUPPORTED = 3 + COREWEBVIEW2_SAVE_AS_UI_RESULT_CANCELLED = 4 +) diff --git a/pkg/webview2/COREWEBVIEW2_TEXT_DIRECTION_KIND.go b/pkg/webview2/COREWEBVIEW2_TEXT_DIRECTION_KIND.go new file mode 100644 index 0000000..d803344 --- /dev/null +++ b/pkg/webview2/COREWEBVIEW2_TEXT_DIRECTION_KIND.go @@ -0,0 +1,11 @@ +//go:build windows + +package webview2 + +type COREWEBVIEW2_TEXT_DIRECTION_KIND uint32 + +const ( + COREWEBVIEW2_TEXT_DIRECTION_KIND_DEFAULT = 0 + COREWEBVIEW2_TEXT_DIRECTION_KIND_LEFT_TO_RIGHT = 1 + COREWEBVIEW2_TEXT_DIRECTION_KIND_RIGHT_TO_LEFT = 2 +) diff --git a/pkg/webview2/COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS.go b/pkg/webview2/COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS.go index 0567cac..64d7f5a 100644 --- a/pkg/webview2/COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS.go +++ b/pkg/webview2/COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS.go @@ -5,10 +5,9 @@ package webview2 type COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS uint32 const ( - COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_NONE = 0 - COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_DOCUMENT = 1 - COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_SHARED_WORKER = 2 - COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_SERVICE_WORKER = 4 - COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_ALL = 0 - XFFFFFFFF = 5 + COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_NONE = 0x0 + COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_DOCUMENT = 0x1 + COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_SHARED_WORKER = 0x2 + COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_SERVICE_WORKER = 0x4 + COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_ALL = 0xFFFFFFFF ) diff --git a/pkg/webview2/ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler.go b/pkg/webview2/ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler.go index 5e5a431..1a3d86c 100644 --- a/pkg/webview2/ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandlerIUnknownRel return this.impl.Release() } -func ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandlerInvoke(this *ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler, errorCode uintptr, id string) uintptr { - return this.impl.AddScriptToExecuteOnDocumentCreatedCompleted(errorCode, id) +func ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandlerInvoke(this *ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler, errorCode uintptr, result string) uintptr { + return this.impl.AddScriptToExecuteOnDocumentCreatedCompleted(errorCode, result) } type ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandlerImpl interface { IUnknownImpl - AddScriptToExecuteOnDocumentCreatedCompleted(errorCode uintptr, id string) uintptr + AddScriptToExecuteOnDocumentCreatedCompleted(errorCode uintptr, result string) uintptr } var ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandlerFn = ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2BrowserExtensionList.go b/pkg/webview2/ICoreWebView2BrowserExtensionList.go index 8c4a061..0d3a56c 100644 --- a/pkg/webview2/ICoreWebView2BrowserExtensionList.go +++ b/pkg/webview2/ICoreWebView2BrowserExtensionList.go @@ -23,31 +23,31 @@ func (i *ICoreWebView2BrowserExtensionList) AddRef() uintptr { return refCounter } -func (i *ICoreWebView2BrowserExtensionList) GetCount() (uint, error) { +func (i *ICoreWebView2BrowserExtensionList) GetCount() (uint32, error) { - var count uint + var value uint32 hr, _, err := i.Vtbl.GetCount.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&count)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return count, err + return value, err } -func (i *ICoreWebView2BrowserExtensionList) GetValueAtIndex(index uint) (*ICoreWebView2BrowserExtension, error) { +func (i *ICoreWebView2BrowserExtensionList) GetValueAtIndex(index uint32) (*ICoreWebView2BrowserExtension, error) { - var extension *ICoreWebView2BrowserExtension + var value *ICoreWebView2BrowserExtension hr, _, err := i.Vtbl.GetValueAtIndex.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(&index)), - uintptr(unsafe.Pointer(&extension)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return extension, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2BrowserProcessExitedEventArgs.go b/pkg/webview2/ICoreWebView2BrowserProcessExitedEventArgs.go index bd17335..12772a5 100644 --- a/pkg/webview2/ICoreWebView2BrowserProcessExitedEventArgs.go +++ b/pkg/webview2/ICoreWebView2BrowserProcessExitedEventArgs.go @@ -25,16 +25,16 @@ func (i *ICoreWebView2BrowserProcessExitedEventArgs) AddRef() uintptr { func (i *ICoreWebView2BrowserProcessExitedEventArgs) GetBrowserProcessExitKind() (COREWEBVIEW2_BROWSER_PROCESS_EXIT_KIND, error) { - var browserProcessExitKind COREWEBVIEW2_BROWSER_PROCESS_EXIT_KIND + var value COREWEBVIEW2_BROWSER_PROCESS_EXIT_KIND hr, _, err := i.Vtbl.GetBrowserProcessExitKind.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&browserProcessExitKind)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return browserProcessExitKind, err + return value, err } func (i *ICoreWebView2BrowserProcessExitedEventArgs) GetBrowserProcessId() (uint32, error) { diff --git a/pkg/webview2/ICoreWebView2CallDevToolsProtocolMethodCompletedHandler.go b/pkg/webview2/ICoreWebView2CallDevToolsProtocolMethodCompletedHandler.go index 9392d3d..95e1714 100644 --- a/pkg/webview2/ICoreWebView2CallDevToolsProtocolMethodCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2CallDevToolsProtocolMethodCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2CallDevToolsProtocolMethodCompletedHandlerIUnknownRelease(this return this.impl.Release() } -func ICoreWebView2CallDevToolsProtocolMethodCompletedHandlerInvoke(this *ICoreWebView2CallDevToolsProtocolMethodCompletedHandler, errorCode uintptr, returnObjectAsJson string) uintptr { - return this.impl.CallDevToolsProtocolMethodCompleted(errorCode, returnObjectAsJson) +func ICoreWebView2CallDevToolsProtocolMethodCompletedHandlerInvoke(this *ICoreWebView2CallDevToolsProtocolMethodCompletedHandler, errorCode uintptr, result string) uintptr { + return this.impl.CallDevToolsProtocolMethodCompleted(errorCode, result) } type ICoreWebView2CallDevToolsProtocolMethodCompletedHandlerImpl interface { IUnknownImpl - CallDevToolsProtocolMethodCompleted(errorCode uintptr, returnObjectAsJson string) uintptr + CallDevToolsProtocolMethodCompleted(errorCode uintptr, result string) uintptr } var ICoreWebView2CallDevToolsProtocolMethodCompletedHandlerFn = ICoreWebView2CallDevToolsProtocolMethodCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2ClientCertificateCollection.go b/pkg/webview2/ICoreWebView2ClientCertificateCollection.go index 54641dc..98d355f 100644 --- a/pkg/webview2/ICoreWebView2ClientCertificateCollection.go +++ b/pkg/webview2/ICoreWebView2ClientCertificateCollection.go @@ -23,9 +23,9 @@ func (i *ICoreWebView2ClientCertificateCollection) AddRef() uintptr { return refCounter } -func (i *ICoreWebView2ClientCertificateCollection) GetCount() (uint, error) { +func (i *ICoreWebView2ClientCertificateCollection) GetCount() (uint32, error) { - var value uint + var value uint32 hr, _, err := i.Vtbl.GetCount.Call( uintptr(unsafe.Pointer(i)), @@ -37,17 +37,17 @@ func (i *ICoreWebView2ClientCertificateCollection) GetCount() (uint, error) { return value, err } -func (i *ICoreWebView2ClientCertificateCollection) GetValueAtIndex(index uint) (*ICoreWebView2ClientCertificate, error) { +func (i *ICoreWebView2ClientCertificateCollection) GetValueAtIndex(index uint32) (*ICoreWebView2ClientCertificate, error) { - var certificate *ICoreWebView2ClientCertificate + var value *ICoreWebView2ClientCertificate hr, _, err := i.Vtbl.GetValueAtIndex.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(&index)), - uintptr(unsafe.Pointer(&certificate)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return certificate, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2CompositionController2.go b/pkg/webview2/ICoreWebView2CompositionController2.go index 2946665..51c8380 100644 --- a/pkg/webview2/ICoreWebView2CompositionController2.go +++ b/pkg/webview2/ICoreWebView2CompositionController2.go @@ -36,14 +36,14 @@ func (i *ICoreWebView2) GetICoreWebView2CompositionController2() *ICoreWebView2C func (i *ICoreWebView2CompositionController2) GetAutomationProvider() (*IUnknown, error) { - var provider *IUnknown + var value *IUnknown hr, _, err := i.Vtbl.GetAutomationProvider.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&provider)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return provider, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2ContentLoadingEventArgs.go b/pkg/webview2/ICoreWebView2ContentLoadingEventArgs.go index 03b3104..cb6b8ca 100644 --- a/pkg/webview2/ICoreWebView2ContentLoadingEventArgs.go +++ b/pkg/webview2/ICoreWebView2ContentLoadingEventArgs.go @@ -25,30 +25,30 @@ func (i *ICoreWebView2ContentLoadingEventArgs) AddRef() uintptr { func (i *ICoreWebView2ContentLoadingEventArgs) GetIsErrorPage() (bool, error) { // Create int32 to hold bool result - var _isErrorPage int32 + var _value int32 hr, _, err := i.Vtbl.GetIsErrorPage.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&_isErrorPage)), + uintptr(unsafe.Pointer(&_value)), ) if windows.Handle(hr) != windows.S_OK { return false, syscall.Errno(hr) } // Get result and cleanup - isErrorPage := _isErrorPage != 0 - return isErrorPage, err + value := _value != 0 + return value, err } func (i *ICoreWebView2ContentLoadingEventArgs) GetNavigationId() (uint64, error) { - var navigationId uint64 + var value uint64 hr, _, err := i.Vtbl.GetNavigationId.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&navigationId)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return navigationId, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2Controller2.go b/pkg/webview2/ICoreWebView2Controller2.go index 8bfc381..5a60926 100644 --- a/pkg/webview2/ICoreWebView2Controller2.go +++ b/pkg/webview2/ICoreWebView2Controller2.go @@ -37,23 +37,23 @@ func (i *ICoreWebView2) GetICoreWebView2Controller2() *ICoreWebView2Controller2 func (i *ICoreWebView2Controller2) GetDefaultBackgroundColor() (COREWEBVIEW2_COLOR, error) { - var backgroundColor COREWEBVIEW2_COLOR + var value COREWEBVIEW2_COLOR hr, _, err := i.Vtbl.GetDefaultBackgroundColor.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&backgroundColor)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return COREWEBVIEW2_COLOR{}, syscall.Errno(hr) } - return backgroundColor, err + return value, err } -func (i *ICoreWebView2Controller2) PutDefaultBackgroundColor(backgroundColor COREWEBVIEW2_COLOR) error { +func (i *ICoreWebView2Controller2) PutDefaultBackgroundColor(value COREWEBVIEW2_COLOR) error { hr, _, err := i.Vtbl.PutDefaultBackgroundColor.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&backgroundColor)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) diff --git a/pkg/webview2/ICoreWebView2ControllerOptions2.go b/pkg/webview2/ICoreWebView2ControllerOptions2.go index 810578d..46a3356 100644 --- a/pkg/webview2/ICoreWebView2ControllerOptions2.go +++ b/pkg/webview2/ICoreWebView2ControllerOptions2.go @@ -37,32 +37,32 @@ func (i *ICoreWebView2) GetICoreWebView2ControllerOptions2() *ICoreWebView2Contr func (i *ICoreWebView2ControllerOptions2) GetScriptLocale() (string, error) { // Create *uint16 to hold result - var _locale *uint16 + var _value *uint16 hr, _, err := i.Vtbl.GetScriptLocale.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_locale)), + uintptr(unsafe.Pointer(_value)), ) if windows.Handle(hr) != windows.S_OK { return "", syscall.Errno(hr) } // Get result and cleanup - locale := UTF16PtrToString(_locale) - CoTaskMemFree(unsafe.Pointer(_locale)) - return locale, err + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err } -func (i *ICoreWebView2ControllerOptions2) PutScriptLocale(locale string) error { +func (i *ICoreWebView2ControllerOptions2) PutScriptLocale(value string) error { - // Convert string 'locale' to *uint16 - _locale, err := UTF16PtrFromString(locale) + // Convert string 'value' to *uint16 + _value, err := UTF16PtrFromString(value) if err != nil { return err } hr, _, err := i.Vtbl.PutScriptLocale.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_locale)), + uintptr(unsafe.Pointer(_value)), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) diff --git a/pkg/webview2/ICoreWebView2CookieList.go b/pkg/webview2/ICoreWebView2CookieList.go index 2132a96..448e731 100644 --- a/pkg/webview2/ICoreWebView2CookieList.go +++ b/pkg/webview2/ICoreWebView2CookieList.go @@ -23,31 +23,31 @@ func (i *ICoreWebView2CookieList) AddRef() uintptr { return refCounter } -func (i *ICoreWebView2CookieList) GetCount() (uint, error) { +func (i *ICoreWebView2CookieList) GetCount() (uint32, error) { - var count uint + var value uint32 hr, _, err := i.Vtbl.GetCount.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&count)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return count, err + return value, err } -func (i *ICoreWebView2CookieList) GetValueAtIndex(index uint) (*ICoreWebView2Cookie, error) { +func (i *ICoreWebView2CookieList) GetValueAtIndex(index uint32) (*ICoreWebView2Cookie, error) { - var cookie *ICoreWebView2Cookie + var value *ICoreWebView2Cookie hr, _, err := i.Vtbl.GetValueAtIndex.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(&index)), - uintptr(unsafe.Pointer(&cookie)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return cookie, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler.go b/pkg/webview2/ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler.go index 6f50300..930ba52 100644 --- a/pkg/webview2/ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandlerIUnknow return this.impl.Release() } -func ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandlerInvoke(this *ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler, errorCode uintptr, webView *ICoreWebView2CompositionController) uintptr { - return this.impl.CreateCoreWebView2CompositionControllerCompleted(errorCode, webView) +func ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandlerInvoke(this *ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler, errorCode uintptr, result *ICoreWebView2CompositionController) uintptr { + return this.impl.CreateCoreWebView2CompositionControllerCompleted(errorCode, result) } type ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandlerImpl interface { IUnknownImpl - CreateCoreWebView2CompositionControllerCompleted(errorCode uintptr, webView *ICoreWebView2CompositionController) uintptr + CreateCoreWebView2CompositionControllerCompleted(errorCode uintptr, result *ICoreWebView2CompositionController) uintptr } var ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandlerFn = ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2CreateCoreWebView2ControllerCompletedHandler.go b/pkg/webview2/ICoreWebView2CreateCoreWebView2ControllerCompletedHandler.go index 8e79885..49602c8 100644 --- a/pkg/webview2/ICoreWebView2CreateCoreWebView2ControllerCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2CreateCoreWebView2ControllerCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerIUnknownRelease(th return this.impl.Release() } -func ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerInvoke(this *ICoreWebView2CreateCoreWebView2ControllerCompletedHandler, errorCode uintptr, createdController *ICoreWebView2Controller) uintptr { - return this.impl.CreateCoreWebView2ControllerCompleted(errorCode, createdController) +func ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerInvoke(this *ICoreWebView2CreateCoreWebView2ControllerCompletedHandler, errorCode uintptr, result *ICoreWebView2Controller) uintptr { + return this.impl.CreateCoreWebView2ControllerCompleted(errorCode, result) } type ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerImpl interface { IUnknownImpl - CreateCoreWebView2ControllerCompleted(errorCode uintptr, createdController *ICoreWebView2Controller) uintptr + CreateCoreWebView2ControllerCompleted(errorCode uintptr, result *ICoreWebView2Controller) uintptr } var ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerFn = ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler.go b/pkg/webview2/ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler.go index 182aefb..4ad6137 100644 --- a/pkg/webview2/ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerIUnknownRelease(t return this.impl.Release() } -func ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerInvoke(this *ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler, errorCode uintptr, createdEnvironment *ICoreWebView2Environment) uintptr { - return this.impl.CreateCoreWebView2EnvironmentCompleted(errorCode, createdEnvironment) +func ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerInvoke(this *ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler, errorCode uintptr, result *ICoreWebView2Environment) uintptr { + return this.impl.CreateCoreWebView2EnvironmentCompleted(errorCode, result) } type ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerImpl interface { IUnknownImpl - CreateCoreWebView2EnvironmentCompleted(errorCode uintptr, createdEnvironment *ICoreWebView2Environment) uintptr + CreateCoreWebView2EnvironmentCompleted(errorCode uintptr, result *ICoreWebView2Environment) uintptr } var ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerFn = ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2DOMContentLoadedEventArgs.go b/pkg/webview2/ICoreWebView2DOMContentLoadedEventArgs.go index d197742..b3f508a 100644 --- a/pkg/webview2/ICoreWebView2DOMContentLoadedEventArgs.go +++ b/pkg/webview2/ICoreWebView2DOMContentLoadedEventArgs.go @@ -24,14 +24,14 @@ func (i *ICoreWebView2DOMContentLoadedEventArgs) AddRef() uintptr { func (i *ICoreWebView2DOMContentLoadedEventArgs) GetNavigationId() (uint64, error) { - var navigationId uint64 + var value uint64 hr, _, err := i.Vtbl.GetNavigationId.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&navigationId)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return navigationId, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2DevToolsProtocolEventReceivedEventArgs.go b/pkg/webview2/ICoreWebView2DevToolsProtocolEventReceivedEventArgs.go index 9956fb7..18458bd 100644 --- a/pkg/webview2/ICoreWebView2DevToolsProtocolEventReceivedEventArgs.go +++ b/pkg/webview2/ICoreWebView2DevToolsProtocolEventReceivedEventArgs.go @@ -24,17 +24,17 @@ func (i *ICoreWebView2DevToolsProtocolEventReceivedEventArgs) AddRef() uintptr { func (i *ICoreWebView2DevToolsProtocolEventReceivedEventArgs) GetParameterObjectAsJson() (string, error) { // Create *uint16 to hold result - var _parameterObjectAsJson *uint16 + var _value *uint16 hr, _, err := i.Vtbl.GetParameterObjectAsJson.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_parameterObjectAsJson)), + uintptr(unsafe.Pointer(_value)), ) if windows.Handle(hr) != windows.S_OK { return "", syscall.Errno(hr) } // Get result and cleanup - parameterObjectAsJson := UTF16PtrToString(_parameterObjectAsJson) - CoTaskMemFree(unsafe.Pointer(_parameterObjectAsJson)) - return parameterObjectAsJson, err + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err } diff --git a/pkg/webview2/ICoreWebView2DevToolsProtocolEventReceivedEventArgs2.go b/pkg/webview2/ICoreWebView2DevToolsProtocolEventReceivedEventArgs2.go index 7743e70..f8f20b4 100644 --- a/pkg/webview2/ICoreWebView2DevToolsProtocolEventReceivedEventArgs2.go +++ b/pkg/webview2/ICoreWebView2DevToolsProtocolEventReceivedEventArgs2.go @@ -25,7 +25,7 @@ func (i *ICoreWebView2DevToolsProtocolEventReceivedEventArgs2) AddRef() uintptr func (i *ICoreWebView2) GetICoreWebView2DevToolsProtocolEventReceivedEventArgs2() *ICoreWebView2DevToolsProtocolEventReceivedEventArgs2 { var result *ICoreWebView2DevToolsProtocolEventReceivedEventArgs2 - iidICoreWebView2DevToolsProtocolEventReceivedEventArgs2 := NewGUID("{2DC4959D-1494-4393-95BA-BEA4CB9EBD1B}") + iidICoreWebView2DevToolsProtocolEventReceivedEventArgs2 := NewGUID("{2dc4959d-1494-4393-95ba-bea4cb9ebd1b}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2DevToolsProtocolEventReceivedEventArgs2)), @@ -36,17 +36,17 @@ func (i *ICoreWebView2) GetICoreWebView2DevToolsProtocolEventReceivedEventArgs2( func (i *ICoreWebView2DevToolsProtocolEventReceivedEventArgs2) GetSessionId() (string, error) { // Create *uint16 to hold result - var _sessionId *uint16 + var _value *uint16 hr, _, err := i.Vtbl.GetSessionId.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_sessionId)), + uintptr(unsafe.Pointer(_value)), ) if windows.Handle(hr) != windows.S_OK { return "", syscall.Errno(hr) } // Get result and cleanup - sessionId := UTF16PtrToString(_sessionId) - CoTaskMemFree(unsafe.Pointer(_sessionId)) - return sessionId, err + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err } diff --git a/pkg/webview2/ICoreWebView2DevToolsProtocolEventReceiver.go b/pkg/webview2/ICoreWebView2DevToolsProtocolEventReceiver.go index d621e93..e65d45b 100644 --- a/pkg/webview2/ICoreWebView2DevToolsProtocolEventReceiver.go +++ b/pkg/webview2/ICoreWebView2DevToolsProtocolEventReceiver.go @@ -23,13 +23,13 @@ func (i *ICoreWebView2DevToolsProtocolEventReceiver) AddRef() uintptr { return refCounter } -func (i *ICoreWebView2DevToolsProtocolEventReceiver) AddDevToolsProtocolEventReceived(handler *ICoreWebView2DevToolsProtocolEventReceivedEventHandler) (EventRegistrationToken, error) { +func (i *ICoreWebView2DevToolsProtocolEventReceiver) AddDevToolsProtocolEventReceived(eventHandler *ICoreWebView2DevToolsProtocolEventReceivedEventHandler) (EventRegistrationToken, error) { var token EventRegistrationToken hr, _, err := i.Vtbl.AddDevToolsProtocolEventReceived.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(handler)), + uintptr(unsafe.Pointer(eventHandler)), uintptr(unsafe.Pointer(&token)), ) if windows.Handle(hr) != windows.S_OK { diff --git a/pkg/webview2/ICoreWebView2Environment10.go b/pkg/webview2/ICoreWebView2Environment10.go index fb81e2f..a6a0f5b 100644 --- a/pkg/webview2/ICoreWebView2Environment10.go +++ b/pkg/webview2/ICoreWebView2Environment10.go @@ -38,23 +38,23 @@ func (i *ICoreWebView2) GetICoreWebView2Environment10() *ICoreWebView2Environmen func (i *ICoreWebView2Environment10) CreateCoreWebView2ControllerOptions() (*ICoreWebView2ControllerOptions, error) { - var options *ICoreWebView2ControllerOptions + var value *ICoreWebView2ControllerOptions hr, _, err := i.Vtbl.CreateCoreWebView2ControllerOptions.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&options)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return options, err + return value, err } -func (i *ICoreWebView2Environment10) CreateCoreWebView2ControllerWithOptions(parentWindow HWND, options *ICoreWebView2ControllerOptions, handler *ICoreWebView2CreateCoreWebView2ControllerCompletedHandler) error { +func (i *ICoreWebView2Environment10) CreateCoreWebView2ControllerWithOptions(ParentWindow HWND, options *ICoreWebView2ControllerOptions, handler *ICoreWebView2CreateCoreWebView2ControllerCompletedHandler) error { hr, _, err := i.Vtbl.CreateCoreWebView2ControllerWithOptions.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&parentWindow)), + uintptr(unsafe.Pointer(&ParentWindow)), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(handler)), ) @@ -64,11 +64,11 @@ func (i *ICoreWebView2Environment10) CreateCoreWebView2ControllerWithOptions(par return err } -func (i *ICoreWebView2Environment10) CreateCoreWebView2CompositionControllerWithOptions(parentWindow HWND, options *ICoreWebView2ControllerOptions, handler *ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler) error { +func (i *ICoreWebView2Environment10) CreateCoreWebView2CompositionControllerWithOptions(ParentWindow HWND, options *ICoreWebView2ControllerOptions, handler *ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler) error { hr, _, err := i.Vtbl.CreateCoreWebView2CompositionControllerWithOptions.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&parentWindow)), + uintptr(unsafe.Pointer(&ParentWindow)), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(handler)), ) diff --git a/pkg/webview2/ICoreWebView2Environment11.go b/pkg/webview2/ICoreWebView2Environment11.go index 899317b..6f0f5b8 100644 --- a/pkg/webview2/ICoreWebView2Environment11.go +++ b/pkg/webview2/ICoreWebView2Environment11.go @@ -25,7 +25,7 @@ func (i *ICoreWebView2Environment11) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2Environment11() *ICoreWebView2Environment11 { var result *ICoreWebView2Environment11 - iidICoreWebView2Environment11 := NewGUID("{F0913DC6-A0EC-42EF-9805-91DFF3A2966A}") + iidICoreWebView2Environment11 := NewGUID("{f0913dc6-a0ec-42ef-9805-91dff3a2966a}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2Environment11)), diff --git a/pkg/webview2/ICoreWebView2Environment12.go b/pkg/webview2/ICoreWebView2Environment12.go index 42a44e1..ce1df4e 100644 --- a/pkg/webview2/ICoreWebView2Environment12.go +++ b/pkg/webview2/ICoreWebView2Environment12.go @@ -25,7 +25,7 @@ func (i *ICoreWebView2Environment12) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2Environment12() *ICoreWebView2Environment12 { var result *ICoreWebView2Environment12 - iidICoreWebView2Environment12 := NewGUID("{F503DB9B-739F-48DD-B151-FDFCF253F54E}") + iidICoreWebView2Environment12 := NewGUID("{f503db9b-739f-48dd-b151-fdfcf253f54e}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2Environment12)), @@ -34,17 +34,17 @@ func (i *ICoreWebView2) GetICoreWebView2Environment12() *ICoreWebView2Environmen return result } -func (i *ICoreWebView2Environment12) CreateSharedBuffer(size uint64) (*ICoreWebView2SharedBuffer, error) { +func (i *ICoreWebView2Environment12) CreateSharedBuffer(Size uint64) (*ICoreWebView2SharedBuffer, error) { - var shared_buffer *ICoreWebView2SharedBuffer + var value *ICoreWebView2SharedBuffer hr, _, err := i.Vtbl.CreateSharedBuffer.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&size)), - uintptr(unsafe.Pointer(&shared_buffer)), + uintptr(unsafe.Pointer(&Size)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return shared_buffer, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2Environment14.go b/pkg/webview2/ICoreWebView2Environment14.go new file mode 100644 index 0000000..af12990 --- /dev/null +++ b/pkg/webview2/ICoreWebView2Environment14.go @@ -0,0 +1,95 @@ +//go:build windows + +package webview2 + +import ( + "golang.org/x/sys/windows" + "syscall" + "unsafe" +) + +type ICoreWebView2Environment14Vtbl struct { + IUnknownVtbl + CreateWebFileSystemFileHandle ComProc + CreateWebFileSystemDirectoryHandle ComProc + CreateObjectCollection ComProc +} + +type ICoreWebView2Environment14 struct { + Vtbl *ICoreWebView2Environment14Vtbl +} + +func (i *ICoreWebView2Environment14) AddRef() uintptr { + refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) + return refCounter +} + +func (i *ICoreWebView2) GetICoreWebView2Environment14() *ICoreWebView2Environment14 { + var result *ICoreWebView2Environment14 + + iidICoreWebView2Environment14 := NewGUID("{a5e9fad9-c875-59da-9bd7-473aa5ca1cef}") + _, _, _ = i.Vtbl.QueryInterface.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(iidICoreWebView2Environment14)), + uintptr(unsafe.Pointer(&result))) + + return result +} + +func (i *ICoreWebView2Environment14) CreateWebFileSystemFileHandle(path string, permission COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION) (*ICoreWebView2FileSystemHandle, error) { + + // Convert string 'path' to *uint16 + _path, err := UTF16PtrFromString(path) + if err != nil { + return nil, err + } + var value *ICoreWebView2FileSystemHandle + + hr, _, err := i.Vtbl.CreateWebFileSystemFileHandle.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_path)), + uintptr(permission), + uintptr(unsafe.Pointer(&value)), + ) + if windows.Handle(hr) != windows.S_OK { + return nil, syscall.Errno(hr) + } + return value, err +} + +func (i *ICoreWebView2Environment14) CreateWebFileSystemDirectoryHandle(path string, permission COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION) (*ICoreWebView2FileSystemHandle, error) { + + // Convert string 'path' to *uint16 + _path, err := UTF16PtrFromString(path) + if err != nil { + return nil, err + } + var value *ICoreWebView2FileSystemHandle + + hr, _, err := i.Vtbl.CreateWebFileSystemDirectoryHandle.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_path)), + uintptr(permission), + uintptr(unsafe.Pointer(&value)), + ) + if windows.Handle(hr) != windows.S_OK { + return nil, syscall.Errno(hr) + } + return value, err +} + +func (i *ICoreWebView2Environment14) CreateObjectCollection(length uint32, items **IUnknown) (*ICoreWebView2ObjectCollection, error) { + + var objectCollection *ICoreWebView2ObjectCollection + + hr, _, err := i.Vtbl.CreateObjectCollection.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&length)), + uintptr(unsafe.Pointer(&items)), + uintptr(unsafe.Pointer(&objectCollection)), + ) + if windows.Handle(hr) != windows.S_OK { + return nil, syscall.Errno(hr) + } + return objectCollection, err +} diff --git a/pkg/webview2/ICoreWebView2Environment2.go b/pkg/webview2/ICoreWebView2Environment2.go index 7d154b0..0b90301 100644 --- a/pkg/webview2/ICoreWebView2Environment2.go +++ b/pkg/webview2/ICoreWebView2Environment2.go @@ -25,7 +25,7 @@ func (i *ICoreWebView2Environment2) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2Environment2() *ICoreWebView2Environment2 { var result *ICoreWebView2Environment2 - iidICoreWebView2Environment2 := NewGUID("{41F3632B-5EF4-404F-AD82-2D606C5A9A21}") + iidICoreWebView2Environment2 := NewGUID("{41f3632b-5ef4-404f-ad82-2d606c5a9a21}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2Environment2)), @@ -34,35 +34,35 @@ func (i *ICoreWebView2) GetICoreWebView2Environment2() *ICoreWebView2Environment return result } -func (i *ICoreWebView2Environment2) CreateWebResourceRequest(uri string, method string, postData *IStream, headers string) (*ICoreWebView2WebResourceRequest, error) { +func (i *ICoreWebView2Environment2) CreateWebResourceRequest(uri string, Method string, postData *IStream, Headers string) (*ICoreWebView2WebResourceRequest, error) { // Convert string 'uri' to *uint16 _uri, err := UTF16PtrFromString(uri) if err != nil { return nil, err } - // Convert string 'method' to *uint16 - _method, err := UTF16PtrFromString(method) + // Convert string 'Method' to *uint16 + _Method, err := UTF16PtrFromString(Method) if err != nil { return nil, err } - // Convert string 'headers' to *uint16 - _headers, err := UTF16PtrFromString(headers) + // Convert string 'Headers' to *uint16 + _Headers, err := UTF16PtrFromString(Headers) if err != nil { return nil, err } - var request *ICoreWebView2WebResourceRequest + var value *ICoreWebView2WebResourceRequest hr, _, err := i.Vtbl.CreateWebResourceRequest.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(_uri)), - uintptr(unsafe.Pointer(_method)), + uintptr(unsafe.Pointer(_Method)), uintptr(unsafe.Pointer(postData)), - uintptr(unsafe.Pointer(_headers)), - uintptr(unsafe.Pointer(&request)), + uintptr(unsafe.Pointer(_Headers)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return request, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2Environment3.go b/pkg/webview2/ICoreWebView2Environment3.go index 8a70b07..1ec3216 100644 --- a/pkg/webview2/ICoreWebView2Environment3.go +++ b/pkg/webview2/ICoreWebView2Environment3.go @@ -35,11 +35,11 @@ func (i *ICoreWebView2) GetICoreWebView2Environment3() *ICoreWebView2Environment return result } -func (i *ICoreWebView2Environment3) CreateCoreWebView2CompositionController(parentWindow HWND, handler *ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler) error { +func (i *ICoreWebView2Environment3) CreateCoreWebView2CompositionController(ParentWindow HWND, handler *ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler) error { hr, _, err := i.Vtbl.CreateCoreWebView2CompositionController.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&parentWindow)), + uintptr(unsafe.Pointer(&ParentWindow)), uintptr(unsafe.Pointer(handler)), ) if windows.Handle(hr) != windows.S_OK { @@ -50,14 +50,14 @@ func (i *ICoreWebView2Environment3) CreateCoreWebView2CompositionController(pare func (i *ICoreWebView2Environment3) CreateCoreWebView2PointerInfo() (*ICoreWebView2PointerInfo, error) { - var pointerInfo *ICoreWebView2PointerInfo + var value *ICoreWebView2PointerInfo hr, _, err := i.Vtbl.CreateCoreWebView2PointerInfo.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&pointerInfo)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return pointerInfo, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2Environment4.go b/pkg/webview2/ICoreWebView2Environment4.go index c48aa31..7bbfac4 100644 --- a/pkg/webview2/ICoreWebView2Environment4.go +++ b/pkg/webview2/ICoreWebView2Environment4.go @@ -36,15 +36,15 @@ func (i *ICoreWebView2) GetICoreWebView2Environment4() *ICoreWebView2Environment func (i *ICoreWebView2Environment4) GetAutomationProviderForWindow(hwnd HWND) (*IUnknown, error) { - var provider *IUnknown + var value *IUnknown hr, _, err := i.Vtbl.GetAutomationProviderForWindow.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(&hwnd)), - uintptr(unsafe.Pointer(&provider)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return provider, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2Environment6.go b/pkg/webview2/ICoreWebView2Environment6.go index ac5ca31..0465381 100644 --- a/pkg/webview2/ICoreWebView2Environment6.go +++ b/pkg/webview2/ICoreWebView2Environment6.go @@ -36,14 +36,14 @@ func (i *ICoreWebView2) GetICoreWebView2Environment6() *ICoreWebView2Environment func (i *ICoreWebView2Environment6) CreatePrintSettings() (*ICoreWebView2PrintSettings, error) { - var printSettings *ICoreWebView2PrintSettings + var value *ICoreWebView2PrintSettings hr, _, err := i.Vtbl.CreatePrintSettings.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&printSettings)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return printSettings, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2Environment7.go b/pkg/webview2/ICoreWebView2Environment7.go index 596a0c9..7ff98ec 100644 --- a/pkg/webview2/ICoreWebView2Environment7.go +++ b/pkg/webview2/ICoreWebView2Environment7.go @@ -25,7 +25,7 @@ func (i *ICoreWebView2Environment7) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2Environment7() *ICoreWebView2Environment7 { var result *ICoreWebView2Environment7 - iidICoreWebView2Environment7 := NewGUID("{43C22296-3BBD-43A4-9C00-5C0DF6DD29A2}") + iidICoreWebView2Environment7 := NewGUID("{43c22296-3bbd-43a4-9c00-5c0df6dd29a2}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2Environment7)), diff --git a/pkg/webview2/ICoreWebView2Environment8.go b/pkg/webview2/ICoreWebView2Environment8.go index b0338d3..213cc1a 100644 --- a/pkg/webview2/ICoreWebView2Environment8.go +++ b/pkg/webview2/ICoreWebView2Environment8.go @@ -27,7 +27,7 @@ func (i *ICoreWebView2Environment8) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2Environment8() *ICoreWebView2Environment8 { var result *ICoreWebView2Environment8 - iidICoreWebView2Environment8 := NewGUID("{D6EB91DD-C3D2-45E5-BD29-6DC2BC4DE9CF}") + iidICoreWebView2Environment8 := NewGUID("{d6eb91dd-c3d2-45e5-bd29-6dc2bc4de9cf}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2Environment8)), diff --git a/pkg/webview2/ICoreWebView2Environment9.go b/pkg/webview2/ICoreWebView2Environment9.go index 65c6511..4a387aa 100644 --- a/pkg/webview2/ICoreWebView2Environment9.go +++ b/pkg/webview2/ICoreWebView2Environment9.go @@ -34,24 +34,24 @@ func (i *ICoreWebView2) GetICoreWebView2Environment9() *ICoreWebView2Environment return result } -func (i *ICoreWebView2Environment9) CreateContextMenuItem(label string, iconStream *IStream, kind COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND) (*ICoreWebView2ContextMenuItem, error) { +func (i *ICoreWebView2Environment9) CreateContextMenuItem(Label string, iconStream *IStream, Kind COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND) (*ICoreWebView2ContextMenuItem, error) { - // Convert string 'label' to *uint16 - _label, err := UTF16PtrFromString(label) + // Convert string 'Label' to *uint16 + _Label, err := UTF16PtrFromString(Label) if err != nil { return nil, err } - var item *ICoreWebView2ContextMenuItem + var value *ICoreWebView2ContextMenuItem hr, _, err := i.Vtbl.CreateContextMenuItem.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_label)), + uintptr(unsafe.Pointer(_Label)), uintptr(unsafe.Pointer(iconStream)), - uintptr(kind), - uintptr(unsafe.Pointer(&item)), + uintptr(Kind), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return item, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2ExecuteScriptCompletedHandler.go b/pkg/webview2/ICoreWebView2ExecuteScriptCompletedHandler.go index 12d10e0..160b520 100644 --- a/pkg/webview2/ICoreWebView2ExecuteScriptCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2ExecuteScriptCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2ExecuteScriptCompletedHandlerIUnknownRelease(this *ICoreWebVie return this.impl.Release() } -func ICoreWebView2ExecuteScriptCompletedHandlerInvoke(this *ICoreWebView2ExecuteScriptCompletedHandler, errorCode uintptr, resultObjectAsJson string) uintptr { - return this.impl.ExecuteScriptCompleted(errorCode, resultObjectAsJson) +func ICoreWebView2ExecuteScriptCompletedHandlerInvoke(this *ICoreWebView2ExecuteScriptCompletedHandler, errorCode uintptr, result string) uintptr { + return this.impl.ExecuteScriptCompleted(errorCode, result) } type ICoreWebView2ExecuteScriptCompletedHandlerImpl interface { IUnknownImpl - ExecuteScriptCompleted(errorCode uintptr, resultObjectAsJson string) uintptr + ExecuteScriptCompleted(errorCode uintptr, result string) uintptr } var ICoreWebView2ExecuteScriptCompletedHandlerFn = ICoreWebView2ExecuteScriptCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2File.go b/pkg/webview2/ICoreWebView2File.go index 086ea90..9e5ee53 100644 --- a/pkg/webview2/ICoreWebView2File.go +++ b/pkg/webview2/ICoreWebView2File.go @@ -24,17 +24,17 @@ func (i *ICoreWebView2File) AddRef() uintptr { func (i *ICoreWebView2File) GetPath() (string, error) { // Create *uint16 to hold result - var _path *uint16 + var _value *uint16 hr, _, err := i.Vtbl.GetPath.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_path)), + uintptr(unsafe.Pointer(_value)), ) if windows.Handle(hr) != windows.S_OK { return "", syscall.Errno(hr) } // Get result and cleanup - path := UTF16PtrToString(_path) - CoTaskMemFree(unsafe.Pointer(_path)) - return path, err + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err } diff --git a/pkg/webview2/ICoreWebView2FileSystemHandle.go b/pkg/webview2/ICoreWebView2FileSystemHandle.go new file mode 100644 index 0000000..010f995 --- /dev/null +++ b/pkg/webview2/ICoreWebView2FileSystemHandle.go @@ -0,0 +1,70 @@ +//go:build windows + +package webview2 + +import ( + "golang.org/x/sys/windows" + "syscall" + "unsafe" +) + +type ICoreWebView2FileSystemHandleVtbl struct { + IUnknownVtbl + GetKind ComProc + GetPath ComProc + GetPermission ComProc +} + +type ICoreWebView2FileSystemHandle struct { + Vtbl *ICoreWebView2FileSystemHandleVtbl +} + +func (i *ICoreWebView2FileSystemHandle) AddRef() uintptr { + refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) + return refCounter +} + +func (i *ICoreWebView2FileSystemHandle) GetKind() (COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND, error) { + + var value COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND + + hr, _, err := i.Vtbl.GetKind.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&value)), + ) + if windows.Handle(hr) != windows.S_OK { + return 0, syscall.Errno(hr) + } + return value, err +} + +func (i *ICoreWebView2FileSystemHandle) GetPath() (string, error) { + // Create *uint16 to hold result + var _value *uint16 + + hr, _, err := i.Vtbl.GetPath.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return "", syscall.Errno(hr) + } + // Get result and cleanup + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err +} + +func (i *ICoreWebView2FileSystemHandle) GetPermission() (COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION, error) { + + var value COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION + + hr, _, err := i.Vtbl.GetPermission.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&value)), + ) + if windows.Handle(hr) != windows.S_OK { + return 0, syscall.Errno(hr) + } + return value, err +} diff --git a/pkg/webview2/ICoreWebView2Frame3.go b/pkg/webview2/ICoreWebView2Frame3.go index e7533cc..c23affa 100644 --- a/pkg/webview2/ICoreWebView2Frame3.go +++ b/pkg/webview2/ICoreWebView2Frame3.go @@ -35,13 +35,13 @@ func (i *ICoreWebView2) GetICoreWebView2Frame3() *ICoreWebView2Frame3 { return result } -func (i *ICoreWebView2Frame3) AddPermissionRequested(handler *ICoreWebView2FramePermissionRequestedEventHandler) (EventRegistrationToken, error) { +func (i *ICoreWebView2Frame3) AddPermissionRequested(eventHandler *ICoreWebView2FramePermissionRequestedEventHandler) (EventRegistrationToken, error) { var token EventRegistrationToken hr, _, err := i.Vtbl.AddPermissionRequested.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(handler)), + uintptr(unsafe.Pointer(eventHandler)), uintptr(unsafe.Pointer(&token)), ) if windows.Handle(hr) != windows.S_OK { diff --git a/pkg/webview2/ICoreWebView2Frame4.go b/pkg/webview2/ICoreWebView2Frame4.go index f764f34..54df082 100644 --- a/pkg/webview2/ICoreWebView2Frame4.go +++ b/pkg/webview2/ICoreWebView2Frame4.go @@ -25,7 +25,7 @@ func (i *ICoreWebView2Frame4) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2Frame4() *ICoreWebView2Frame4 { var result *ICoreWebView2Frame4 - iidICoreWebView2Frame4 := NewGUID("{188782DC-92AA-4732-AB3C-FCC59F6F68B9}") + iidICoreWebView2Frame4 := NewGUID("{188782dc-92aa-4732-ab3c-fcc59f6f68b9}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2Frame4)), diff --git a/pkg/webview2/ICoreWebView2Frame5.go b/pkg/webview2/ICoreWebView2Frame5.go index ca2705b..3b28809 100644 --- a/pkg/webview2/ICoreWebView2Frame5.go +++ b/pkg/webview2/ICoreWebView2Frame5.go @@ -36,14 +36,14 @@ func (i *ICoreWebView2) GetICoreWebView2Frame5() *ICoreWebView2Frame5 { func (i *ICoreWebView2Frame5) GetFrameId() (uint32, error) { - var id uint32 + var value uint32 hr, _, err := i.Vtbl.GetFrameId.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&id)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return id, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2FrameCreatedEventArgs.go b/pkg/webview2/ICoreWebView2FrameCreatedEventArgs.go index c1c29a3..5e3a179 100644 --- a/pkg/webview2/ICoreWebView2FrameCreatedEventArgs.go +++ b/pkg/webview2/ICoreWebView2FrameCreatedEventArgs.go @@ -24,14 +24,14 @@ func (i *ICoreWebView2FrameCreatedEventArgs) AddRef() uintptr { func (i *ICoreWebView2FrameCreatedEventArgs) GetFrame() (*ICoreWebView2Frame, error) { - var frame *ICoreWebView2Frame + var value *ICoreWebView2Frame hr, _, err := i.Vtbl.GetFrame.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&frame)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return frame, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2FrameInfo.go b/pkg/webview2/ICoreWebView2FrameInfo.go index 09267cd..f45f617 100644 --- a/pkg/webview2/ICoreWebView2FrameInfo.go +++ b/pkg/webview2/ICoreWebView2FrameInfo.go @@ -25,34 +25,34 @@ func (i *ICoreWebView2FrameInfo) AddRef() uintptr { func (i *ICoreWebView2FrameInfo) GetName() (string, error) { // Create *uint16 to hold result - var _name *uint16 + var _value *uint16 hr, _, err := i.Vtbl.GetName.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_name)), + uintptr(unsafe.Pointer(_value)), ) if windows.Handle(hr) != windows.S_OK { return "", syscall.Errno(hr) } // Get result and cleanup - name := UTF16PtrToString(_name) - CoTaskMemFree(unsafe.Pointer(_name)) - return name, err + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err } func (i *ICoreWebView2FrameInfo) GetSource() (string, error) { // Create *uint16 to hold result - var _source *uint16 + var _value *uint16 hr, _, err := i.Vtbl.GetSource.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_source)), + uintptr(unsafe.Pointer(_value)), ) if windows.Handle(hr) != windows.S_OK { return "", syscall.Errno(hr) } // Get result and cleanup - source := UTF16PtrToString(_source) - CoTaskMemFree(unsafe.Pointer(_source)) - return source, err + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err } diff --git a/pkg/webview2/ICoreWebView2FrameInfoCollection.go b/pkg/webview2/ICoreWebView2FrameInfoCollection.go index 4c79bd0..652278d 100644 --- a/pkg/webview2/ICoreWebView2FrameInfoCollection.go +++ b/pkg/webview2/ICoreWebView2FrameInfoCollection.go @@ -24,14 +24,14 @@ func (i *ICoreWebView2FrameInfoCollection) AddRef() uintptr { func (i *ICoreWebView2FrameInfoCollection) GetIterator() (*ICoreWebView2FrameInfoCollectionIterator, error) { - var iterator *ICoreWebView2FrameInfoCollectionIterator + var value *ICoreWebView2FrameInfoCollectionIterator hr, _, err := i.Vtbl.GetIterator.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&iterator)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return iterator, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2FrameInfoCollectionIterator.go b/pkg/webview2/ICoreWebView2FrameInfoCollectionIterator.go index d572987..54abc12 100644 --- a/pkg/webview2/ICoreWebView2FrameInfoCollectionIterator.go +++ b/pkg/webview2/ICoreWebView2FrameInfoCollectionIterator.go @@ -26,46 +26,46 @@ func (i *ICoreWebView2FrameInfoCollectionIterator) AddRef() uintptr { func (i *ICoreWebView2FrameInfoCollectionIterator) GetHasCurrent() (bool, error) { // Create int32 to hold bool result - var _hasCurrent int32 + var _value int32 hr, _, err := i.Vtbl.GetHasCurrent.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&_hasCurrent)), + uintptr(unsafe.Pointer(&_value)), ) if windows.Handle(hr) != windows.S_OK { return false, syscall.Errno(hr) } // Get result and cleanup - hasCurrent := _hasCurrent != 0 - return hasCurrent, err + value := _value != 0 + return value, err } func (i *ICoreWebView2FrameInfoCollectionIterator) GetCurrent() (*ICoreWebView2FrameInfo, error) { - var frameInfo *ICoreWebView2FrameInfo + var value *ICoreWebView2FrameInfo hr, _, err := i.Vtbl.GetCurrent.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&frameInfo)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return frameInfo, err + return value, err } func (i *ICoreWebView2FrameInfoCollectionIterator) MoveNext() (bool, error) { // Create int32 to hold bool result - var _hasNext int32 + var _value int32 hr, _, err := i.Vtbl.MoveNext.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&_hasNext)), + uintptr(unsafe.Pointer(&_value)), ) if windows.Handle(hr) != windows.S_OK { return false, syscall.Errno(hr) } // Get result and cleanup - hasNext := _hasNext != 0 - return hasNext, err + value := _value != 0 + return value, err } diff --git a/pkg/webview2/ICoreWebView2GetCookiesCompletedHandler.go b/pkg/webview2/ICoreWebView2GetCookiesCompletedHandler.go index c5bb1d9..3db7414 100644 --- a/pkg/webview2/ICoreWebView2GetCookiesCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2GetCookiesCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2GetCookiesCompletedHandlerIUnknownRelease(this *ICoreWebView2G return this.impl.Release() } -func ICoreWebView2GetCookiesCompletedHandlerInvoke(this *ICoreWebView2GetCookiesCompletedHandler, result uintptr, cookieList *ICoreWebView2CookieList) uintptr { - return this.impl.GetCookiesCompleted(result, cookieList) +func ICoreWebView2GetCookiesCompletedHandlerInvoke(this *ICoreWebView2GetCookiesCompletedHandler, errorCode uintptr, result *ICoreWebView2CookieList) uintptr { + return this.impl.GetCookiesCompleted(errorCode, result) } type ICoreWebView2GetCookiesCompletedHandlerImpl interface { IUnknownImpl - GetCookiesCompleted(result uintptr, cookieList *ICoreWebView2CookieList) uintptr + GetCookiesCompleted(errorCode uintptr, result *ICoreWebView2CookieList) uintptr } var ICoreWebView2GetCookiesCompletedHandlerFn = ICoreWebView2GetCookiesCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2GetFaviconCompletedHandler.go b/pkg/webview2/ICoreWebView2GetFaviconCompletedHandler.go index 95c836f..7af334d 100644 --- a/pkg/webview2/ICoreWebView2GetFaviconCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2GetFaviconCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2GetFaviconCompletedHandlerIUnknownRelease(this *ICoreWebView2G return this.impl.Release() } -func ICoreWebView2GetFaviconCompletedHandlerInvoke(this *ICoreWebView2GetFaviconCompletedHandler, errorCode uintptr, faviconStream *IStream) uintptr { - return this.impl.GetFaviconCompleted(errorCode, faviconStream) +func ICoreWebView2GetFaviconCompletedHandlerInvoke(this *ICoreWebView2GetFaviconCompletedHandler, errorCode uintptr, result *IStream) uintptr { + return this.impl.GetFaviconCompleted(errorCode, result) } type ICoreWebView2GetFaviconCompletedHandlerImpl interface { IUnknownImpl - GetFaviconCompleted(errorCode uintptr, faviconStream *IStream) uintptr + GetFaviconCompleted(errorCode uintptr, result *IStream) uintptr } var ICoreWebView2GetFaviconCompletedHandlerFn = ICoreWebView2GetFaviconCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandler.go b/pkg/webview2/ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandler.go index 573c1e4..b0ecea7 100644 --- a/pkg/webview2/ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandlerIUnknownRelease return this.impl.Release() } -func ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandlerInvoke(this *ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandler, errorCode uintptr, collectionView *ICoreWebView2PermissionSettingCollectionView) uintptr { - return this.impl.GetNonDefaultPermissionSettingsCompleted(errorCode, collectionView) +func ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandlerInvoke(this *ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandler, errorCode uintptr, result *ICoreWebView2PermissionSettingCollectionView) uintptr { + return this.impl.GetNonDefaultPermissionSettingsCompleted(errorCode, result) } type ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandlerImpl interface { IUnknownImpl - GetNonDefaultPermissionSettingsCompleted(errorCode uintptr, collectionView *ICoreWebView2PermissionSettingCollectionView) uintptr + GetNonDefaultPermissionSettingsCompleted(errorCode uintptr, result *ICoreWebView2PermissionSettingCollectionView) uintptr } var ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandlerFn = ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2GetProcessExtendedInfosCompletedHandler.go b/pkg/webview2/ICoreWebView2GetProcessExtendedInfosCompletedHandler.go index f8fc51d..cae4132 100644 --- a/pkg/webview2/ICoreWebView2GetProcessExtendedInfosCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2GetProcessExtendedInfosCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2GetProcessExtendedInfosCompletedHandlerIUnknownRelease(this *I return this.impl.Release() } -func ICoreWebView2GetProcessExtendedInfosCompletedHandlerInvoke(this *ICoreWebView2GetProcessExtendedInfosCompletedHandler, errorCode uintptr, value *ICoreWebView2ProcessExtendedInfoCollection) uintptr { - return this.impl.GetProcessExtendedInfosCompleted(errorCode, value) +func ICoreWebView2GetProcessExtendedInfosCompletedHandlerInvoke(this *ICoreWebView2GetProcessExtendedInfosCompletedHandler, errorCode uintptr, result *ICoreWebView2ProcessExtendedInfoCollection) uintptr { + return this.impl.GetProcessExtendedInfosCompleted(errorCode, result) } type ICoreWebView2GetProcessExtendedInfosCompletedHandlerImpl interface { IUnknownImpl - GetProcessExtendedInfosCompleted(errorCode uintptr, value *ICoreWebView2ProcessExtendedInfoCollection) uintptr + GetProcessExtendedInfosCompleted(errorCode uintptr, result *ICoreWebView2ProcessExtendedInfoCollection) uintptr } var ICoreWebView2GetProcessExtendedInfosCompletedHandlerFn = ICoreWebView2GetProcessExtendedInfosCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2HttpRequestHeaders.go b/pkg/webview2/ICoreWebView2HttpRequestHeaders.go index 1abf2fb..6122da0 100644 --- a/pkg/webview2/ICoreWebView2HttpRequestHeaders.go +++ b/pkg/webview2/ICoreWebView2HttpRequestHeaders.go @@ -57,17 +57,17 @@ func (i *ICoreWebView2HttpRequestHeaders) GetHeaders(name string) (*ICoreWebView if err != nil { return nil, err } - var iterator *ICoreWebView2HttpHeadersCollectionIterator + var value *ICoreWebView2HttpHeadersCollectionIterator hr, _, err := i.Vtbl.GetHeaders.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(_name)), - uintptr(unsafe.Pointer(&iterator)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return iterator, err + return value, err } func (i *ICoreWebView2HttpRequestHeaders) Contains(name string) (bool, error) { @@ -77,19 +77,19 @@ func (i *ICoreWebView2HttpRequestHeaders) Contains(name string) (bool, error) { if err != nil { return false, err } // Create int32 to hold bool result - var _contains int32 + var _value int32 hr, _, err := i.Vtbl.Contains.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(_name)), - uintptr(unsafe.Pointer(&_contains)), + uintptr(unsafe.Pointer(&_value)), ) if windows.Handle(hr) != windows.S_OK { return false, syscall.Errno(hr) } // Get result and cleanup - contains := _contains != 0 - return contains, err + value := _value != 0 + return value, err } func (i *ICoreWebView2HttpRequestHeaders) SetHeader(name string, value string) error { @@ -136,14 +136,14 @@ func (i *ICoreWebView2HttpRequestHeaders) RemoveHeader(name string) error { func (i *ICoreWebView2HttpRequestHeaders) GetIterator() (*ICoreWebView2HttpHeadersCollectionIterator, error) { - var iterator *ICoreWebView2HttpHeadersCollectionIterator + var value *ICoreWebView2HttpHeadersCollectionIterator hr, _, err := i.Vtbl.GetIterator.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&iterator)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return iterator, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2HttpResponseHeaders.go b/pkg/webview2/ICoreWebView2HttpResponseHeaders.go index c1e3dec..b219e23 100644 --- a/pkg/webview2/ICoreWebView2HttpResponseHeaders.go +++ b/pkg/webview2/ICoreWebView2HttpResponseHeaders.go @@ -57,19 +57,19 @@ func (i *ICoreWebView2HttpResponseHeaders) Contains(name string) (bool, error) { if err != nil { return false, err } // Create int32 to hold bool result - var _contains int32 + var _value int32 hr, _, err := i.Vtbl.Contains.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(_name)), - uintptr(unsafe.Pointer(&_contains)), + uintptr(unsafe.Pointer(&_value)), ) if windows.Handle(hr) != windows.S_OK { return false, syscall.Errno(hr) } // Get result and cleanup - contains := _contains != 0 - return contains, err + value := _value != 0 + return value, err } func (i *ICoreWebView2HttpResponseHeaders) GetHeader(name string) (string, error) { @@ -102,29 +102,29 @@ func (i *ICoreWebView2HttpResponseHeaders) GetHeaders(name string) (*ICoreWebVie if err != nil { return nil, err } - var iterator *ICoreWebView2HttpHeadersCollectionIterator + var value *ICoreWebView2HttpHeadersCollectionIterator hr, _, err := i.Vtbl.GetHeaders.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(_name)), - uintptr(unsafe.Pointer(&iterator)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return iterator, err + return value, err } func (i *ICoreWebView2HttpResponseHeaders) GetIterator() (*ICoreWebView2HttpHeadersCollectionIterator, error) { - var iterator *ICoreWebView2HttpHeadersCollectionIterator + var value *ICoreWebView2HttpHeadersCollectionIterator hr, _, err := i.Vtbl.GetIterator.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&iterator)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return iterator, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2NavigationCompletedEventArgs2.go b/pkg/webview2/ICoreWebView2NavigationCompletedEventArgs2.go index 81c065f..0899067 100644 --- a/pkg/webview2/ICoreWebView2NavigationCompletedEventArgs2.go +++ b/pkg/webview2/ICoreWebView2NavigationCompletedEventArgs2.go @@ -25,7 +25,7 @@ func (i *ICoreWebView2NavigationCompletedEventArgs2) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2NavigationCompletedEventArgs2() *ICoreWebView2NavigationCompletedEventArgs2 { var result *ICoreWebView2NavigationCompletedEventArgs2 - iidICoreWebView2NavigationCompletedEventArgs2 := NewGUID("{FDF8B738-EE1E-4DB2-A329-8D7D7B74D792}") + iidICoreWebView2NavigationCompletedEventArgs2 := NewGUID("{fdf8b738-ee1e-4db2-a329-8d7d7b74d792}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2NavigationCompletedEventArgs2)), @@ -36,14 +36,14 @@ func (i *ICoreWebView2) GetICoreWebView2NavigationCompletedEventArgs2() *ICoreWe func (i *ICoreWebView2NavigationCompletedEventArgs2) GetHttpStatusCode() (int, error) { - var http_status_code int + var value int hr, _, err := i.Vtbl.GetHttpStatusCode.Call( uintptr(unsafe.Pointer(i)), - uintptr(http_status_code), + uintptr(value), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return http_status_code, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2NavigationStartingEventArgs2.go b/pkg/webview2/ICoreWebView2NavigationStartingEventArgs2.go index 1cb77a5..5054d6c 100644 --- a/pkg/webview2/ICoreWebView2NavigationStartingEventArgs2.go +++ b/pkg/webview2/ICoreWebView2NavigationStartingEventArgs2.go @@ -26,7 +26,7 @@ func (i *ICoreWebView2NavigationStartingEventArgs2) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2NavigationStartingEventArgs2() *ICoreWebView2NavigationStartingEventArgs2 { var result *ICoreWebView2NavigationStartingEventArgs2 - iidICoreWebView2NavigationStartingEventArgs2 := NewGUID("{9086BE93-91AA-472D-A7E0-579F2BA006AD}") + iidICoreWebView2NavigationStartingEventArgs2 := NewGUID("{9086be93-91aa-472d-a7e0-579f2ba006ad}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2NavigationStartingEventArgs2)), diff --git a/pkg/webview2/ICoreWebView2NavigationStartingEventArgs3.go b/pkg/webview2/ICoreWebView2NavigationStartingEventArgs3.go index cd9fdce..4d266e1 100644 --- a/pkg/webview2/ICoreWebView2NavigationStartingEventArgs3.go +++ b/pkg/webview2/ICoreWebView2NavigationStartingEventArgs3.go @@ -25,7 +25,7 @@ func (i *ICoreWebView2NavigationStartingEventArgs3) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2NavigationStartingEventArgs3() *ICoreWebView2NavigationStartingEventArgs3 { var result *ICoreWebView2NavigationStartingEventArgs3 - iidICoreWebView2NavigationStartingEventArgs3 := NewGUID("{DDFFE494-4942-4BD2-AB73-35B8FF40E19F}") + iidICoreWebView2NavigationStartingEventArgs3 := NewGUID("{ddffe494-4942-4bd2-ab73-35b8ff40e19f}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2NavigationStartingEventArgs3)), @@ -36,14 +36,14 @@ func (i *ICoreWebView2) GetICoreWebView2NavigationStartingEventArgs3() *ICoreWeb func (i *ICoreWebView2NavigationStartingEventArgs3) GetNavigationKind() (COREWEBVIEW2_NAVIGATION_KIND, error) { - var navigation_kind COREWEBVIEW2_NAVIGATION_KIND + var value COREWEBVIEW2_NAVIGATION_KIND hr, _, err := i.Vtbl.GetNavigationKind.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&navigation_kind)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return navigation_kind, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2NewWindowRequestedEventArgs3.go b/pkg/webview2/ICoreWebView2NewWindowRequestedEventArgs3.go index c47b403..4513a73 100644 --- a/pkg/webview2/ICoreWebView2NewWindowRequestedEventArgs3.go +++ b/pkg/webview2/ICoreWebView2NewWindowRequestedEventArgs3.go @@ -36,14 +36,14 @@ func (i *ICoreWebView2) GetICoreWebView2NewWindowRequestedEventArgs3() *ICoreWeb func (i *ICoreWebView2NewWindowRequestedEventArgs3) GetOriginalSourceFrameInfo() (*ICoreWebView2FrameInfo, error) { - var frameInfo *ICoreWebView2FrameInfo + var value *ICoreWebView2FrameInfo hr, _, err := i.Vtbl.GetOriginalSourceFrameInfo.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&frameInfo)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return frameInfo, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2Notification.go b/pkg/webview2/ICoreWebView2Notification.go new file mode 100644 index 0000000..b567e61 --- /dev/null +++ b/pkg/webview2/ICoreWebView2Notification.go @@ -0,0 +1,311 @@ +//go:build windows + +package webview2 + +import ( + "golang.org/x/sys/windows" + "syscall" + "unsafe" +) + +type ICoreWebView2NotificationVtbl struct { + IUnknownVtbl + AddCloseRequested ComProc + RemoveCloseRequested ComProc + ReportShown ComProc + ReportClicked ComProc + ReportClosed ComProc + GetBody ComProc + GetDirection ComProc + GetLanguage ComProc + GetTag ComProc + GetIconUri ComProc + GetTitle ComProc + GetBadgeUri ComProc + GetBodyImageUri ComProc + GetShouldRenotify ComProc + GetRequiresInteraction ComProc + GetIsSilent ComProc + GetTimestamp ComProc + GetVibrationPattern ComProc +} + +type ICoreWebView2Notification struct { + Vtbl *ICoreWebView2NotificationVtbl +} + +func (i *ICoreWebView2Notification) AddRef() uintptr { + refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) + return refCounter +} + +func (i *ICoreWebView2Notification) AddCloseRequested(eventHandler *ICoreWebView2NotificationCloseRequestedEventHandler) (EventRegistrationToken, error) { + + var token EventRegistrationToken + + hr, _, err := i.Vtbl.AddCloseRequested.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(eventHandler)), + uintptr(unsafe.Pointer(&token)), + ) + if windows.Handle(hr) != windows.S_OK { + return EventRegistrationToken{}, syscall.Errno(hr) + } + return token, err +} + +func (i *ICoreWebView2Notification) RemoveCloseRequested(token EventRegistrationToken) error { + + hr, _, err := i.Vtbl.RemoveCloseRequested.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&token)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} + +func (i *ICoreWebView2Notification) ReportShown() error { + + hr, _, err := i.Vtbl.ReportShown.Call( + uintptr(unsafe.Pointer(i)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} + +func (i *ICoreWebView2Notification) ReportClicked() error { + + hr, _, err := i.Vtbl.ReportClicked.Call( + uintptr(unsafe.Pointer(i)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} + +func (i *ICoreWebView2Notification) ReportClosed() error { + + hr, _, err := i.Vtbl.ReportClosed.Call( + uintptr(unsafe.Pointer(i)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} + +func (i *ICoreWebView2Notification) GetBody() (string, error) { + // Create *uint16 to hold result + var _value *uint16 + + hr, _, err := i.Vtbl.GetBody.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return "", syscall.Errno(hr) + } + // Get result and cleanup + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err +} + +func (i *ICoreWebView2Notification) GetDirection() (COREWEBVIEW2_TEXT_DIRECTION_KIND, error) { + + var value COREWEBVIEW2_TEXT_DIRECTION_KIND + + hr, _, err := i.Vtbl.GetDirection.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&value)), + ) + if windows.Handle(hr) != windows.S_OK { + return 0, syscall.Errno(hr) + } + return value, err +} + +func (i *ICoreWebView2Notification) GetLanguage() (string, error) { + // Create *uint16 to hold result + var _value *uint16 + + hr, _, err := i.Vtbl.GetLanguage.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return "", syscall.Errno(hr) + } + // Get result and cleanup + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err +} + +func (i *ICoreWebView2Notification) GetTag() (string, error) { + // Create *uint16 to hold result + var _value *uint16 + + hr, _, err := i.Vtbl.GetTag.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return "", syscall.Errno(hr) + } + // Get result and cleanup + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err +} + +func (i *ICoreWebView2Notification) GetIconUri() (string, error) { + // Create *uint16 to hold result + var _value *uint16 + + hr, _, err := i.Vtbl.GetIconUri.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return "", syscall.Errno(hr) + } + // Get result and cleanup + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err +} + +func (i *ICoreWebView2Notification) GetTitle() (string, error) { + // Create *uint16 to hold result + var _value *uint16 + + hr, _, err := i.Vtbl.GetTitle.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return "", syscall.Errno(hr) + } + // Get result and cleanup + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err +} + +func (i *ICoreWebView2Notification) GetBadgeUri() (string, error) { + // Create *uint16 to hold result + var _value *uint16 + + hr, _, err := i.Vtbl.GetBadgeUri.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return "", syscall.Errno(hr) + } + // Get result and cleanup + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err +} + +func (i *ICoreWebView2Notification) GetBodyImageUri() (string, error) { + // Create *uint16 to hold result + var _value *uint16 + + hr, _, err := i.Vtbl.GetBodyImageUri.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return "", syscall.Errno(hr) + } + // Get result and cleanup + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err +} + +func (i *ICoreWebView2Notification) GetShouldRenotify() (bool, error) { + // Create int32 to hold bool result + var _value int32 + + hr, _, err := i.Vtbl.GetShouldRenotify.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return false, syscall.Errno(hr) + } + // Get result and cleanup + value := _value != 0 + return value, err +} + +func (i *ICoreWebView2Notification) GetRequiresInteraction() (bool, error) { + // Create int32 to hold bool result + var _value int32 + + hr, _, err := i.Vtbl.GetRequiresInteraction.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return false, syscall.Errno(hr) + } + // Get result and cleanup + value := _value != 0 + return value, err +} + +func (i *ICoreWebView2Notification) GetIsSilent() (bool, error) { + // Create int32 to hold bool result + var _value int32 + + hr, _, err := i.Vtbl.GetIsSilent.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return false, syscall.Errno(hr) + } + // Get result and cleanup + value := _value != 0 + return value, err +} + +func (i *ICoreWebView2Notification) GetTimestamp() (float64, error) { + + var value float64 + + hr, _, err := i.Vtbl.GetTimestamp.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&value)), + ) + if windows.Handle(hr) != windows.S_OK { + return 0.0, syscall.Errno(hr) + } + return value, err +} + +func (i *ICoreWebView2Notification) GetVibrationPattern() (uint32, *uint64, error) { + + var count uint32 + var vibrationPattern *uint64 + + hr, _, err := i.Vtbl.GetVibrationPattern.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&count)), + uintptr(unsafe.Pointer(&vibrationPattern)), + ) + if windows.Handle(hr) != windows.S_OK { + return 0, nil, syscall.Errno(hr) + } + return count, vibrationPattern, err +} diff --git a/pkg/webview2/ICoreWebView2NotificationCloseRequestedEventHandler.go b/pkg/webview2/ICoreWebView2NotificationCloseRequestedEventHandler.go new file mode 100644 index 0000000..d00158a --- /dev/null +++ b/pkg/webview2/ICoreWebView2NotificationCloseRequestedEventHandler.go @@ -0,0 +1,59 @@ +//go:build windows + +package webview2 + +import ( + "unsafe" +) + +type ICoreWebView2NotificationCloseRequestedEventHandlerVtbl struct { + IUnknownVtbl + Invoke ComProc +} + +type ICoreWebView2NotificationCloseRequestedEventHandler struct { + Vtbl *ICoreWebView2NotificationCloseRequestedEventHandlerVtbl + impl ICoreWebView2NotificationCloseRequestedEventHandlerImpl +} + +func (i *ICoreWebView2NotificationCloseRequestedEventHandler) AddRef() uintptr { + refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) + return refCounter +} + +func ICoreWebView2NotificationCloseRequestedEventHandlerIUnknownQueryInterface(this *ICoreWebView2NotificationCloseRequestedEventHandler, refiid, object uintptr) uintptr { + return this.impl.QueryInterface(refiid, object) +} + +func ICoreWebView2NotificationCloseRequestedEventHandlerIUnknownAddRef(this *ICoreWebView2NotificationCloseRequestedEventHandler) uintptr { + return this.impl.AddRef() +} + +func ICoreWebView2NotificationCloseRequestedEventHandlerIUnknownRelease(this *ICoreWebView2NotificationCloseRequestedEventHandler) uintptr { + return this.impl.Release() +} + +func ICoreWebView2NotificationCloseRequestedEventHandlerInvoke(this *ICoreWebView2NotificationCloseRequestedEventHandler, sender *ICoreWebView2Notification, args *IUnknown) uintptr { + return this.impl.NotificationCloseRequested(sender, args) +} + +type ICoreWebView2NotificationCloseRequestedEventHandlerImpl interface { + IUnknownImpl + NotificationCloseRequested(sender *ICoreWebView2Notification, args *IUnknown) uintptr +} + +var ICoreWebView2NotificationCloseRequestedEventHandlerFn = ICoreWebView2NotificationCloseRequestedEventHandlerVtbl{ + IUnknownVtbl{ + NewComProc(ICoreWebView2NotificationCloseRequestedEventHandlerIUnknownQueryInterface), + NewComProc(ICoreWebView2NotificationCloseRequestedEventHandlerIUnknownAddRef), + NewComProc(ICoreWebView2NotificationCloseRequestedEventHandlerIUnknownRelease), + }, + NewComProc(ICoreWebView2NotificationCloseRequestedEventHandlerInvoke), +} + +func NewICoreWebView2NotificationCloseRequestedEventHandler(impl ICoreWebView2NotificationCloseRequestedEventHandlerImpl) *ICoreWebView2NotificationCloseRequestedEventHandler { + return &ICoreWebView2NotificationCloseRequestedEventHandler{ + Vtbl: &ICoreWebView2NotificationCloseRequestedEventHandlerFn, + impl: impl, + } +} diff --git a/pkg/webview2/ICoreWebView2NotificationReceivedEventArgs.go b/pkg/webview2/ICoreWebView2NotificationReceivedEventArgs.go new file mode 100644 index 0000000..68c4bc8 --- /dev/null +++ b/pkg/webview2/ICoreWebView2NotificationReceivedEventArgs.go @@ -0,0 +1,100 @@ +//go:build windows + +package webview2 + +import ( + "golang.org/x/sys/windows" + "syscall" + "unsafe" +) + +type ICoreWebView2NotificationReceivedEventArgsVtbl struct { + IUnknownVtbl + GetSenderOrigin ComProc + GetNotification ComProc + PutHandled ComProc + GetHandled ComProc + GetDeferral ComProc +} + +type ICoreWebView2NotificationReceivedEventArgs struct { + Vtbl *ICoreWebView2NotificationReceivedEventArgsVtbl +} + +func (i *ICoreWebView2NotificationReceivedEventArgs) AddRef() uintptr { + refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) + return refCounter +} + +func (i *ICoreWebView2NotificationReceivedEventArgs) GetSenderOrigin() (string, error) { + // Create *uint16 to hold result + var _value *uint16 + + hr, _, err := i.Vtbl.GetSenderOrigin.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return "", syscall.Errno(hr) + } + // Get result and cleanup + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err +} + +func (i *ICoreWebView2NotificationReceivedEventArgs) GetNotification() (*ICoreWebView2Notification, error) { + + var value *ICoreWebView2Notification + + hr, _, err := i.Vtbl.GetNotification.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&value)), + ) + if windows.Handle(hr) != windows.S_OK { + return nil, syscall.Errno(hr) + } + return value, err +} + +func (i *ICoreWebView2NotificationReceivedEventArgs) PutHandled(value bool) error { + + hr, _, err := i.Vtbl.PutHandled.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&value)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} + +func (i *ICoreWebView2NotificationReceivedEventArgs) GetHandled() (bool, error) { + // Create int32 to hold bool result + var _value int32 + + hr, _, err := i.Vtbl.GetHandled.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return false, syscall.Errno(hr) + } + // Get result and cleanup + value := _value != 0 + return value, err +} + +func (i *ICoreWebView2NotificationReceivedEventArgs) GetDeferral() (*ICoreWebView2Deferral, error) { + + var deferral *ICoreWebView2Deferral + + hr, _, err := i.Vtbl.GetDeferral.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&deferral)), + ) + if windows.Handle(hr) != windows.S_OK { + return nil, syscall.Errno(hr) + } + return deferral, err +} diff --git a/pkg/webview2/ICoreWebView2NotificationReceivedEventHandler.go b/pkg/webview2/ICoreWebView2NotificationReceivedEventHandler.go new file mode 100644 index 0000000..6690d8c --- /dev/null +++ b/pkg/webview2/ICoreWebView2NotificationReceivedEventHandler.go @@ -0,0 +1,59 @@ +//go:build windows + +package webview2 + +import ( + "unsafe" +) + +type ICoreWebView2NotificationReceivedEventHandlerVtbl struct { + IUnknownVtbl + Invoke ComProc +} + +type ICoreWebView2NotificationReceivedEventHandler struct { + Vtbl *ICoreWebView2NotificationReceivedEventHandlerVtbl + impl ICoreWebView2NotificationReceivedEventHandlerImpl +} + +func (i *ICoreWebView2NotificationReceivedEventHandler) AddRef() uintptr { + refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) + return refCounter +} + +func ICoreWebView2NotificationReceivedEventHandlerIUnknownQueryInterface(this *ICoreWebView2NotificationReceivedEventHandler, refiid, object uintptr) uintptr { + return this.impl.QueryInterface(refiid, object) +} + +func ICoreWebView2NotificationReceivedEventHandlerIUnknownAddRef(this *ICoreWebView2NotificationReceivedEventHandler) uintptr { + return this.impl.AddRef() +} + +func ICoreWebView2NotificationReceivedEventHandlerIUnknownRelease(this *ICoreWebView2NotificationReceivedEventHandler) uintptr { + return this.impl.Release() +} + +func ICoreWebView2NotificationReceivedEventHandlerInvoke(this *ICoreWebView2NotificationReceivedEventHandler, sender *ICoreWebView2, args *ICoreWebView2NotificationReceivedEventArgs) uintptr { + return this.impl.NotificationReceived(sender, args) +} + +type ICoreWebView2NotificationReceivedEventHandlerImpl interface { + IUnknownImpl + NotificationReceived(sender *ICoreWebView2, args *ICoreWebView2NotificationReceivedEventArgs) uintptr +} + +var ICoreWebView2NotificationReceivedEventHandlerFn = ICoreWebView2NotificationReceivedEventHandlerVtbl{ + IUnknownVtbl{ + NewComProc(ICoreWebView2NotificationReceivedEventHandlerIUnknownQueryInterface), + NewComProc(ICoreWebView2NotificationReceivedEventHandlerIUnknownAddRef), + NewComProc(ICoreWebView2NotificationReceivedEventHandlerIUnknownRelease), + }, + NewComProc(ICoreWebView2NotificationReceivedEventHandlerInvoke), +} + +func NewICoreWebView2NotificationReceivedEventHandler(impl ICoreWebView2NotificationReceivedEventHandlerImpl) *ICoreWebView2NotificationReceivedEventHandler { + return &ICoreWebView2NotificationReceivedEventHandler{ + Vtbl: &ICoreWebView2NotificationReceivedEventHandlerFn, + impl: impl, + } +} diff --git a/pkg/webview2/ICoreWebView2ObjectCollection.go b/pkg/webview2/ICoreWebView2ObjectCollection.go new file mode 100644 index 0000000..73d88d8 --- /dev/null +++ b/pkg/webview2/ICoreWebView2ObjectCollection.go @@ -0,0 +1,61 @@ +//go:build windows + +package webview2 + +import ( + "golang.org/x/sys/windows" + "syscall" + "unsafe" +) + +type ICoreWebView2ObjectCollectionVtbl struct { + IUnknownVtbl + RemoveValueAtIndex ComProc + InsertValueAtIndex ComProc +} + +type ICoreWebView2ObjectCollection struct { + Vtbl *ICoreWebView2ObjectCollectionVtbl +} + +func (i *ICoreWebView2ObjectCollection) AddRef() uintptr { + refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) + return refCounter +} + +func (i *ICoreWebView2) GetICoreWebView2ObjectCollection() *ICoreWebView2ObjectCollection { + var result *ICoreWebView2ObjectCollection + + iidICoreWebView2ObjectCollection := NewGUID("{5cfec11c-25bd-4e8d-9e1a-7acdaeeec047}") + _, _, _ = i.Vtbl.QueryInterface.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(iidICoreWebView2ObjectCollection)), + uintptr(unsafe.Pointer(&result))) + + return result +} + +func (i *ICoreWebView2ObjectCollection) RemoveValueAtIndex(index uint32) error { + + hr, _, err := i.Vtbl.RemoveValueAtIndex.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&index)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} + +func (i *ICoreWebView2ObjectCollection) InsertValueAtIndex(index uint32, value *IUnknown) error { + + hr, _, err := i.Vtbl.InsertValueAtIndex.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&index)), + uintptr(unsafe.Pointer(value)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} diff --git a/pkg/webview2/ICoreWebView2PermissionRequestedEventArgs2.go b/pkg/webview2/ICoreWebView2PermissionRequestedEventArgs2.go index b9e0141..60827dc 100644 --- a/pkg/webview2/ICoreWebView2PermissionRequestedEventArgs2.go +++ b/pkg/webview2/ICoreWebView2PermissionRequestedEventArgs2.go @@ -37,25 +37,25 @@ func (i *ICoreWebView2) GetICoreWebView2PermissionRequestedEventArgs2() *ICoreWe func (i *ICoreWebView2PermissionRequestedEventArgs2) GetHandled() (bool, error) { // Create int32 to hold bool result - var _handled int32 + var _value int32 hr, _, err := i.Vtbl.GetHandled.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&_handled)), + uintptr(unsafe.Pointer(&_value)), ) if windows.Handle(hr) != windows.S_OK { return false, syscall.Errno(hr) } // Get result and cleanup - handled := _handled != 0 - return handled, err + value := _value != 0 + return value, err } -func (i *ICoreWebView2PermissionRequestedEventArgs2) PutHandled(handled bool) error { +func (i *ICoreWebView2PermissionRequestedEventArgs2) PutHandled(value bool) error { hr, _, err := i.Vtbl.PutHandled.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&handled)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) diff --git a/pkg/webview2/ICoreWebView2PrintCompletedHandler.go b/pkg/webview2/ICoreWebView2PrintCompletedHandler.go index 880d666..a8eb769 100644 --- a/pkg/webview2/ICoreWebView2PrintCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2PrintCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2PrintCompletedHandlerIUnknownRelease(this *ICoreWebView2PrintC return this.impl.Release() } -func ICoreWebView2PrintCompletedHandlerInvoke(this *ICoreWebView2PrintCompletedHandler, errorCode uintptr, printStatus COREWEBVIEW2_PRINT_STATUS) uintptr { - return this.impl.PrintCompleted(errorCode, printStatus) +func ICoreWebView2PrintCompletedHandlerInvoke(this *ICoreWebView2PrintCompletedHandler, errorCode uintptr, result COREWEBVIEW2_PRINT_STATUS) uintptr { + return this.impl.PrintCompleted(errorCode, result) } type ICoreWebView2PrintCompletedHandlerImpl interface { IUnknownImpl - PrintCompleted(errorCode uintptr, printStatus COREWEBVIEW2_PRINT_STATUS) uintptr + PrintCompleted(errorCode uintptr, result COREWEBVIEW2_PRINT_STATUS) uintptr } var ICoreWebView2PrintCompletedHandlerFn = ICoreWebView2PrintCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2PrintToPdfCompletedHandler.go b/pkg/webview2/ICoreWebView2PrintToPdfCompletedHandler.go index f7d7b48..f805262 100644 --- a/pkg/webview2/ICoreWebView2PrintToPdfCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2PrintToPdfCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2PrintToPdfCompletedHandlerIUnknownRelease(this *ICoreWebView2P return this.impl.Release() } -func ICoreWebView2PrintToPdfCompletedHandlerInvoke(this *ICoreWebView2PrintToPdfCompletedHandler, errorCode uintptr, isSuccessful bool) uintptr { - return this.impl.PrintToPdfCompleted(errorCode, isSuccessful) +func ICoreWebView2PrintToPdfCompletedHandlerInvoke(this *ICoreWebView2PrintToPdfCompletedHandler, errorCode uintptr, result bool) uintptr { + return this.impl.PrintToPdfCompleted(errorCode, result) } type ICoreWebView2PrintToPdfCompletedHandlerImpl interface { IUnknownImpl - PrintToPdfCompleted(errorCode uintptr, isSuccessful bool) uintptr + PrintToPdfCompleted(errorCode uintptr, result bool) uintptr } var ICoreWebView2PrintToPdfCompletedHandlerFn = ICoreWebView2PrintToPdfCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2PrintToPdfStreamCompletedHandler.go b/pkg/webview2/ICoreWebView2PrintToPdfStreamCompletedHandler.go index b133427..e37c4a6 100644 --- a/pkg/webview2/ICoreWebView2PrintToPdfStreamCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2PrintToPdfStreamCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2PrintToPdfStreamCompletedHandlerIUnknownRelease(this *ICoreWeb return this.impl.Release() } -func ICoreWebView2PrintToPdfStreamCompletedHandlerInvoke(this *ICoreWebView2PrintToPdfStreamCompletedHandler, errorCode uintptr, pdfStream *IStream) uintptr { - return this.impl.PrintToPdfStreamCompleted(errorCode, pdfStream) +func ICoreWebView2PrintToPdfStreamCompletedHandlerInvoke(this *ICoreWebView2PrintToPdfStreamCompletedHandler, errorCode uintptr, result *IStream) uintptr { + return this.impl.PrintToPdfStreamCompleted(errorCode, result) } type ICoreWebView2PrintToPdfStreamCompletedHandlerImpl interface { IUnknownImpl - PrintToPdfStreamCompleted(errorCode uintptr, pdfStream *IStream) uintptr + PrintToPdfStreamCompleted(errorCode uintptr, result *IStream) uintptr } var ICoreWebView2PrintToPdfStreamCompletedHandlerFn = ICoreWebView2PrintToPdfStreamCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2ProcessExtendedInfoCollection.go b/pkg/webview2/ICoreWebView2ProcessExtendedInfoCollection.go index 815e9c5..cd7accf 100644 --- a/pkg/webview2/ICoreWebView2ProcessExtendedInfoCollection.go +++ b/pkg/webview2/ICoreWebView2ProcessExtendedInfoCollection.go @@ -23,31 +23,31 @@ func (i *ICoreWebView2ProcessExtendedInfoCollection) AddRef() uintptr { return refCounter } -func (i *ICoreWebView2ProcessExtendedInfoCollection) GetCount() (uint, error) { +func (i *ICoreWebView2ProcessExtendedInfoCollection) GetCount() (uint32, error) { - var count uint + var value uint32 hr, _, err := i.Vtbl.GetCount.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&count)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return count, err + return value, err } func (i *ICoreWebView2ProcessExtendedInfoCollection) GetValueAtIndex(index uint32) (*ICoreWebView2ProcessExtendedInfo, error) { - var processInfo *ICoreWebView2ProcessExtendedInfo + var value *ICoreWebView2ProcessExtendedInfo hr, _, err := i.Vtbl.GetValueAtIndex.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(&index)), - uintptr(unsafe.Pointer(&processInfo)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return processInfo, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2ProcessFailedEventArgs.go b/pkg/webview2/ICoreWebView2ProcessFailedEventArgs.go index 36b7267..f452078 100644 --- a/pkg/webview2/ICoreWebView2ProcessFailedEventArgs.go +++ b/pkg/webview2/ICoreWebView2ProcessFailedEventArgs.go @@ -24,14 +24,14 @@ func (i *ICoreWebView2ProcessFailedEventArgs) AddRef() uintptr { func (i *ICoreWebView2ProcessFailedEventArgs) GetProcessFailedKind() (COREWEBVIEW2_PROCESS_FAILED_KIND, error) { - var processFailedKind COREWEBVIEW2_PROCESS_FAILED_KIND + var value COREWEBVIEW2_PROCESS_FAILED_KIND hr, _, err := i.Vtbl.GetProcessFailedKind.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&processFailedKind)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return processFailedKind, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2ProcessInfoCollection.go b/pkg/webview2/ICoreWebView2ProcessInfoCollection.go index d3c298e..8a3dcee 100644 --- a/pkg/webview2/ICoreWebView2ProcessInfoCollection.go +++ b/pkg/webview2/ICoreWebView2ProcessInfoCollection.go @@ -23,31 +23,31 @@ func (i *ICoreWebView2ProcessInfoCollection) AddRef() uintptr { return refCounter } -func (i *ICoreWebView2ProcessInfoCollection) GetCount() (uint, error) { +func (i *ICoreWebView2ProcessInfoCollection) GetCount() (uint32, error) { - var count uint + var value uint32 hr, _, err := i.Vtbl.GetCount.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&count)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return count, err + return value, err } func (i *ICoreWebView2ProcessInfoCollection) GetValueAtIndex(index uint32) (*ICoreWebView2ProcessInfo, error) { - var processInfo *ICoreWebView2ProcessInfo + var value *ICoreWebView2ProcessInfo hr, _, err := i.Vtbl.GetValueAtIndex.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(&index)), - uintptr(unsafe.Pointer(&processInfo)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return processInfo, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2Profile3.go b/pkg/webview2/ICoreWebView2Profile3.go index 397c0a7..0fa4ef3 100644 --- a/pkg/webview2/ICoreWebView2Profile3.go +++ b/pkg/webview2/ICoreWebView2Profile3.go @@ -26,7 +26,7 @@ func (i *ICoreWebView2Profile3) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2Profile3() *ICoreWebView2Profile3 { var result *ICoreWebView2Profile3 - iidICoreWebView2Profile3 := NewGUID("{B188E659-5685-4E05-BDBA-FC640E0F1992}") + iidICoreWebView2Profile3 := NewGUID("{b188e659-5685-4e05-bdba-fc640e0f1992}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2Profile3)), diff --git a/pkg/webview2/ICoreWebView2Profile4.go b/pkg/webview2/ICoreWebView2Profile4.go index 3d24a6a..75cebc4 100644 --- a/pkg/webview2/ICoreWebView2Profile4.go +++ b/pkg/webview2/ICoreWebView2Profile4.go @@ -26,7 +26,7 @@ func (i *ICoreWebView2Profile4) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2Profile4() *ICoreWebView2Profile4 { var result *ICoreWebView2Profile4 - iidICoreWebView2Profile4 := NewGUID("{8F4ae680-192e-4eC8-833a-21cfadaef628}") + iidICoreWebView2Profile4 := NewGUID("{8f4ae680-192e-4ec8-833a-21cfadaef628}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2Profile4)), @@ -35,7 +35,7 @@ func (i *ICoreWebView2) GetICoreWebView2Profile4() *ICoreWebView2Profile4 { return result } -func (i *ICoreWebView2Profile4) SetPermissionState(permissionKind COREWEBVIEW2_PERMISSION_KIND, origin string, state COREWEBVIEW2_PERMISSION_STATE, completedHandler *ICoreWebView2SetPermissionStateCompletedHandler) error { +func (i *ICoreWebView2Profile4) SetPermissionState(PermissionKind COREWEBVIEW2_PERMISSION_KIND, origin string, State COREWEBVIEW2_PERMISSION_STATE, handler *ICoreWebView2SetPermissionStateCompletedHandler) error { // Convert string 'origin' to *uint16 _origin, err := UTF16PtrFromString(origin) @@ -45,10 +45,10 @@ func (i *ICoreWebView2Profile4) SetPermissionState(permissionKind COREWEBVIEW2_P hr, _, err := i.Vtbl.SetPermissionState.Call( uintptr(unsafe.Pointer(i)), - uintptr(permissionKind), + uintptr(PermissionKind), uintptr(unsafe.Pointer(_origin)), - uintptr(state), - uintptr(unsafe.Pointer(completedHandler)), + uintptr(State), + uintptr(unsafe.Pointer(handler)), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) @@ -56,11 +56,11 @@ func (i *ICoreWebView2Profile4) SetPermissionState(permissionKind COREWEBVIEW2_P return err } -func (i *ICoreWebView2Profile4) GetNonDefaultPermissionSettings(completedHandler *ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandler) error { +func (i *ICoreWebView2Profile4) GetNonDefaultPermissionSettings(handler *ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandler) error { hr, _, err := i.Vtbl.GetNonDefaultPermissionSettings.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(completedHandler)), + uintptr(unsafe.Pointer(handler)), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) diff --git a/pkg/webview2/ICoreWebView2Profile5.go b/pkg/webview2/ICoreWebView2Profile5.go index 16f7b70..55a93c8 100644 --- a/pkg/webview2/ICoreWebView2Profile5.go +++ b/pkg/webview2/ICoreWebView2Profile5.go @@ -25,7 +25,7 @@ func (i *ICoreWebView2Profile5) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2Profile5() *ICoreWebView2Profile5 { var result *ICoreWebView2Profile5 - iidICoreWebView2Profile5 := NewGUID("{2EE5B76E-6E80-4DF2-BCD3-D4EC3340A01B}") + iidICoreWebView2Profile5 := NewGUID("{2ee5b76e-6e80-4df2-bcd3-d4ec3340a01b}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2Profile5)), @@ -36,14 +36,14 @@ func (i *ICoreWebView2) GetICoreWebView2Profile5() *ICoreWebView2Profile5 { func (i *ICoreWebView2Profile5) GetCookieManager() (*ICoreWebView2CookieManager, error) { - var cookieManager *ICoreWebView2CookieManager + var value *ICoreWebView2CookieManager hr, _, err := i.Vtbl.GetCookieManager.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&cookieManager)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return cookieManager, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2ProfileAddBrowserExtensionCompletedHandler.go b/pkg/webview2/ICoreWebView2ProfileAddBrowserExtensionCompletedHandler.go index 9d2e013..98051fb 100644 --- a/pkg/webview2/ICoreWebView2ProfileAddBrowserExtensionCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2ProfileAddBrowserExtensionCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2ProfileAddBrowserExtensionCompletedHandlerIUnknownRelease(this return this.impl.Release() } -func ICoreWebView2ProfileAddBrowserExtensionCompletedHandlerInvoke(this *ICoreWebView2ProfileAddBrowserExtensionCompletedHandler, errorCode uintptr, extension *ICoreWebView2BrowserExtension) uintptr { - return this.impl.ProfileAddBrowserExtensionCompleted(errorCode, extension) +func ICoreWebView2ProfileAddBrowserExtensionCompletedHandlerInvoke(this *ICoreWebView2ProfileAddBrowserExtensionCompletedHandler, errorCode uintptr, result *ICoreWebView2BrowserExtension) uintptr { + return this.impl.ProfileAddBrowserExtensionCompleted(errorCode, result) } type ICoreWebView2ProfileAddBrowserExtensionCompletedHandlerImpl interface { IUnknownImpl - ProfileAddBrowserExtensionCompleted(errorCode uintptr, extension *ICoreWebView2BrowserExtension) uintptr + ProfileAddBrowserExtensionCompleted(errorCode uintptr, result *ICoreWebView2BrowserExtension) uintptr } var ICoreWebView2ProfileAddBrowserExtensionCompletedHandlerFn = ICoreWebView2ProfileAddBrowserExtensionCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2ProfileGetBrowserExtensionsCompletedHandler.go b/pkg/webview2/ICoreWebView2ProfileGetBrowserExtensionsCompletedHandler.go index 52cb223..717739a 100644 --- a/pkg/webview2/ICoreWebView2ProfileGetBrowserExtensionsCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2ProfileGetBrowserExtensionsCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2ProfileGetBrowserExtensionsCompletedHandlerIUnknownRelease(thi return this.impl.Release() } -func ICoreWebView2ProfileGetBrowserExtensionsCompletedHandlerInvoke(this *ICoreWebView2ProfileGetBrowserExtensionsCompletedHandler, errorCode uintptr, extensionList *ICoreWebView2BrowserExtensionList) uintptr { - return this.impl.ProfileGetBrowserExtensionsCompleted(errorCode, extensionList) +func ICoreWebView2ProfileGetBrowserExtensionsCompletedHandlerInvoke(this *ICoreWebView2ProfileGetBrowserExtensionsCompletedHandler, errorCode uintptr, result *ICoreWebView2BrowserExtensionList) uintptr { + return this.impl.ProfileGetBrowserExtensionsCompleted(errorCode, result) } type ICoreWebView2ProfileGetBrowserExtensionsCompletedHandlerImpl interface { IUnknownImpl - ProfileGetBrowserExtensionsCompleted(errorCode uintptr, extensionList *ICoreWebView2BrowserExtensionList) uintptr + ProfileGetBrowserExtensionsCompleted(errorCode uintptr, result *ICoreWebView2BrowserExtensionList) uintptr } var ICoreWebView2ProfileGetBrowserExtensionsCompletedHandlerFn = ICoreWebView2ProfileGetBrowserExtensionsCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2SaveAsUIShowingEventArgs.go b/pkg/webview2/ICoreWebView2SaveAsUIShowingEventArgs.go new file mode 100644 index 0000000..9453ba4 --- /dev/null +++ b/pkg/webview2/ICoreWebView2SaveAsUIShowingEventArgs.go @@ -0,0 +1,210 @@ +//go:build windows + +package webview2 + +import ( + "golang.org/x/sys/windows" + "syscall" + "unsafe" +) + +type ICoreWebView2SaveAsUIShowingEventArgsVtbl struct { + IUnknownVtbl + GetContentMimeType ComProc + PutCancel ComProc + GetCancel ComProc + PutSuppressDefaultDialog ComProc + GetSuppressDefaultDialog ComProc + GetDeferral ComProc + PutSaveAsFilePath ComProc + GetSaveAsFilePath ComProc + PutAllowReplace ComProc + GetAllowReplace ComProc + PutKind ComProc + GetKind ComProc +} + +type ICoreWebView2SaveAsUIShowingEventArgs struct { + Vtbl *ICoreWebView2SaveAsUIShowingEventArgsVtbl +} + +func (i *ICoreWebView2SaveAsUIShowingEventArgs) AddRef() uintptr { + refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) + return refCounter +} + +func (i *ICoreWebView2SaveAsUIShowingEventArgs) GetContentMimeType() (string, error) { + // Create *uint16 to hold result + var _value *uint16 + + hr, _, err := i.Vtbl.GetContentMimeType.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return "", syscall.Errno(hr) + } + // Get result and cleanup + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err +} + +func (i *ICoreWebView2SaveAsUIShowingEventArgs) PutCancel(value bool) error { + + hr, _, err := i.Vtbl.PutCancel.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&value)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} + +func (i *ICoreWebView2SaveAsUIShowingEventArgs) GetCancel() (bool, error) { + // Create int32 to hold bool result + var _value int32 + + hr, _, err := i.Vtbl.GetCancel.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return false, syscall.Errno(hr) + } + // Get result and cleanup + value := _value != 0 + return value, err +} + +func (i *ICoreWebView2SaveAsUIShowingEventArgs) PutSuppressDefaultDialog(value bool) error { + + hr, _, err := i.Vtbl.PutSuppressDefaultDialog.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&value)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} + +func (i *ICoreWebView2SaveAsUIShowingEventArgs) GetSuppressDefaultDialog() (bool, error) { + // Create int32 to hold bool result + var _value int32 + + hr, _, err := i.Vtbl.GetSuppressDefaultDialog.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return false, syscall.Errno(hr) + } + // Get result and cleanup + value := _value != 0 + return value, err +} + +func (i *ICoreWebView2SaveAsUIShowingEventArgs) GetDeferral() (*ICoreWebView2Deferral, error) { + + var value *ICoreWebView2Deferral + + hr, _, err := i.Vtbl.GetDeferral.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&value)), + ) + if windows.Handle(hr) != windows.S_OK { + return nil, syscall.Errno(hr) + } + return value, err +} + +func (i *ICoreWebView2SaveAsUIShowingEventArgs) PutSaveAsFilePath(value string) error { + + // Convert string 'value' to *uint16 + _value, err := UTF16PtrFromString(value) + if err != nil { + return err + } + + hr, _, err := i.Vtbl.PutSaveAsFilePath.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} + +func (i *ICoreWebView2SaveAsUIShowingEventArgs) GetSaveAsFilePath() (string, error) { + // Create *uint16 to hold result + var _value *uint16 + + hr, _, err := i.Vtbl.GetSaveAsFilePath.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return "", syscall.Errno(hr) + } + // Get result and cleanup + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err +} + +func (i *ICoreWebView2SaveAsUIShowingEventArgs) PutAllowReplace(value bool) error { + + hr, _, err := i.Vtbl.PutAllowReplace.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&value)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} + +func (i *ICoreWebView2SaveAsUIShowingEventArgs) GetAllowReplace() (bool, error) { + // Create int32 to hold bool result + var _value int32 + + hr, _, err := i.Vtbl.GetAllowReplace.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&_value)), + ) + if windows.Handle(hr) != windows.S_OK { + return false, syscall.Errno(hr) + } + // Get result and cleanup + value := _value != 0 + return value, err +} + +func (i *ICoreWebView2SaveAsUIShowingEventArgs) PutKind(value COREWEBVIEW2_SAVE_AS_KIND) error { + + hr, _, err := i.Vtbl.PutKind.Call( + uintptr(unsafe.Pointer(i)), + uintptr(value), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} + +func (i *ICoreWebView2SaveAsUIShowingEventArgs) GetKind() (COREWEBVIEW2_SAVE_AS_KIND, error) { + + var value COREWEBVIEW2_SAVE_AS_KIND + + hr, _, err := i.Vtbl.GetKind.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&value)), + ) + if windows.Handle(hr) != windows.S_OK { + return 0, syscall.Errno(hr) + } + return value, err +} diff --git a/pkg/webview2/ICoreWebView2SaveAsUIShowingEventHandler.go b/pkg/webview2/ICoreWebView2SaveAsUIShowingEventHandler.go new file mode 100644 index 0000000..9016b3b --- /dev/null +++ b/pkg/webview2/ICoreWebView2SaveAsUIShowingEventHandler.go @@ -0,0 +1,59 @@ +//go:build windows + +package webview2 + +import ( + "unsafe" +) + +type ICoreWebView2SaveAsUIShowingEventHandlerVtbl struct { + IUnknownVtbl + Invoke ComProc +} + +type ICoreWebView2SaveAsUIShowingEventHandler struct { + Vtbl *ICoreWebView2SaveAsUIShowingEventHandlerVtbl + impl ICoreWebView2SaveAsUIShowingEventHandlerImpl +} + +func (i *ICoreWebView2SaveAsUIShowingEventHandler) AddRef() uintptr { + refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) + return refCounter +} + +func ICoreWebView2SaveAsUIShowingEventHandlerIUnknownQueryInterface(this *ICoreWebView2SaveAsUIShowingEventHandler, refiid, object uintptr) uintptr { + return this.impl.QueryInterface(refiid, object) +} + +func ICoreWebView2SaveAsUIShowingEventHandlerIUnknownAddRef(this *ICoreWebView2SaveAsUIShowingEventHandler) uintptr { + return this.impl.AddRef() +} + +func ICoreWebView2SaveAsUIShowingEventHandlerIUnknownRelease(this *ICoreWebView2SaveAsUIShowingEventHandler) uintptr { + return this.impl.Release() +} + +func ICoreWebView2SaveAsUIShowingEventHandlerInvoke(this *ICoreWebView2SaveAsUIShowingEventHandler, sender *ICoreWebView2, args *ICoreWebView2SaveAsUIShowingEventArgs) uintptr { + return this.impl.SaveAsUIShowing(sender, args) +} + +type ICoreWebView2SaveAsUIShowingEventHandlerImpl interface { + IUnknownImpl + SaveAsUIShowing(sender *ICoreWebView2, args *ICoreWebView2SaveAsUIShowingEventArgs) uintptr +} + +var ICoreWebView2SaveAsUIShowingEventHandlerFn = ICoreWebView2SaveAsUIShowingEventHandlerVtbl{ + IUnknownVtbl{ + NewComProc(ICoreWebView2SaveAsUIShowingEventHandlerIUnknownQueryInterface), + NewComProc(ICoreWebView2SaveAsUIShowingEventHandlerIUnknownAddRef), + NewComProc(ICoreWebView2SaveAsUIShowingEventHandlerIUnknownRelease), + }, + NewComProc(ICoreWebView2SaveAsUIShowingEventHandlerInvoke), +} + +func NewICoreWebView2SaveAsUIShowingEventHandler(impl ICoreWebView2SaveAsUIShowingEventHandlerImpl) *ICoreWebView2SaveAsUIShowingEventHandler { + return &ICoreWebView2SaveAsUIShowingEventHandler{ + Vtbl: &ICoreWebView2SaveAsUIShowingEventHandlerFn, + impl: impl, + } +} diff --git a/pkg/webview2/ICoreWebView2Settings2.go b/pkg/webview2/ICoreWebView2Settings2.go index 2b28ea9..3af2037 100644 --- a/pkg/webview2/ICoreWebView2Settings2.go +++ b/pkg/webview2/ICoreWebView2Settings2.go @@ -37,32 +37,32 @@ func (i *ICoreWebView2) GetICoreWebView2Settings2() *ICoreWebView2Settings2 { func (i *ICoreWebView2Settings2) GetUserAgent() (string, error) { // Create *uint16 to hold result - var _userAgent *uint16 + var _value *uint16 hr, _, err := i.Vtbl.GetUserAgent.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_userAgent)), + uintptr(unsafe.Pointer(_value)), ) if windows.Handle(hr) != windows.S_OK { return "", syscall.Errno(hr) } // Get result and cleanup - userAgent := UTF16PtrToString(_userAgent) - CoTaskMemFree(unsafe.Pointer(_userAgent)) - return userAgent, err + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err } -func (i *ICoreWebView2Settings2) PutUserAgent(userAgent string) error { +func (i *ICoreWebView2Settings2) PutUserAgent(value string) error { - // Convert string 'userAgent' to *uint16 - _userAgent, err := UTF16PtrFromString(userAgent) + // Convert string 'value' to *uint16 + _value, err := UTF16PtrFromString(value) if err != nil { return err } hr, _, err := i.Vtbl.PutUserAgent.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_userAgent)), + uintptr(unsafe.Pointer(_value)), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) diff --git a/pkg/webview2/ICoreWebView2Settings3.go b/pkg/webview2/ICoreWebView2Settings3.go index 1e5c0c7..6856315 100644 --- a/pkg/webview2/ICoreWebView2Settings3.go +++ b/pkg/webview2/ICoreWebView2Settings3.go @@ -37,25 +37,25 @@ func (i *ICoreWebView2) GetICoreWebView2Settings3() *ICoreWebView2Settings3 { func (i *ICoreWebView2Settings3) GetAreBrowserAcceleratorKeysEnabled() (bool, error) { // Create int32 to hold bool result - var _areBrowserAcceleratorKeysEnabled int32 + var _value int32 hr, _, err := i.Vtbl.GetAreBrowserAcceleratorKeysEnabled.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&_areBrowserAcceleratorKeysEnabled)), + uintptr(unsafe.Pointer(&_value)), ) if windows.Handle(hr) != windows.S_OK { return false, syscall.Errno(hr) } // Get result and cleanup - areBrowserAcceleratorKeysEnabled := _areBrowserAcceleratorKeysEnabled != 0 - return areBrowserAcceleratorKeysEnabled, err + value := _value != 0 + return value, err } -func (i *ICoreWebView2Settings3) PutAreBrowserAcceleratorKeysEnabled(areBrowserAcceleratorKeysEnabled bool) error { +func (i *ICoreWebView2Settings3) PutAreBrowserAcceleratorKeysEnabled(value bool) error { hr, _, err := i.Vtbl.PutAreBrowserAcceleratorKeysEnabled.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&areBrowserAcceleratorKeysEnabled)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) diff --git a/pkg/webview2/ICoreWebView2Settings5.go b/pkg/webview2/ICoreWebView2Settings5.go index a5c9bec..8a79fa0 100644 --- a/pkg/webview2/ICoreWebView2Settings5.go +++ b/pkg/webview2/ICoreWebView2Settings5.go @@ -37,25 +37,25 @@ func (i *ICoreWebView2) GetICoreWebView2Settings5() *ICoreWebView2Settings5 { func (i *ICoreWebView2Settings5) GetIsPinchZoomEnabled() (bool, error) { // Create int32 to hold bool result - var _enabled int32 + var _value int32 hr, _, err := i.Vtbl.GetIsPinchZoomEnabled.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&_enabled)), + uintptr(unsafe.Pointer(&_value)), ) if windows.Handle(hr) != windows.S_OK { return false, syscall.Errno(hr) } // Get result and cleanup - enabled := _enabled != 0 - return enabled, err + value := _value != 0 + return value, err } -func (i *ICoreWebView2Settings5) PutIsPinchZoomEnabled(enabled bool) error { +func (i *ICoreWebView2Settings5) PutIsPinchZoomEnabled(value bool) error { hr, _, err := i.Vtbl.PutIsPinchZoomEnabled.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&enabled)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) diff --git a/pkg/webview2/ICoreWebView2Settings6.go b/pkg/webview2/ICoreWebView2Settings6.go index 16f0f09..34a1818 100644 --- a/pkg/webview2/ICoreWebView2Settings6.go +++ b/pkg/webview2/ICoreWebView2Settings6.go @@ -37,25 +37,25 @@ func (i *ICoreWebView2) GetICoreWebView2Settings6() *ICoreWebView2Settings6 { func (i *ICoreWebView2Settings6) GetIsSwipeNavigationEnabled() (bool, error) { // Create int32 to hold bool result - var _enabled int32 + var _value int32 hr, _, err := i.Vtbl.GetIsSwipeNavigationEnabled.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&_enabled)), + uintptr(unsafe.Pointer(&_value)), ) if windows.Handle(hr) != windows.S_OK { return false, syscall.Errno(hr) } // Get result and cleanup - enabled := _enabled != 0 - return enabled, err + value := _value != 0 + return value, err } -func (i *ICoreWebView2Settings6) PutIsSwipeNavigationEnabled(enabled bool) error { +func (i *ICoreWebView2Settings6) PutIsSwipeNavigationEnabled(value bool) error { hr, _, err := i.Vtbl.PutIsSwipeNavigationEnabled.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&enabled)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) diff --git a/pkg/webview2/ICoreWebView2Settings7.go b/pkg/webview2/ICoreWebView2Settings7.go index 971b914..81d6f4d 100644 --- a/pkg/webview2/ICoreWebView2Settings7.go +++ b/pkg/webview2/ICoreWebView2Settings7.go @@ -37,23 +37,23 @@ func (i *ICoreWebView2) GetICoreWebView2Settings7() *ICoreWebView2Settings7 { func (i *ICoreWebView2Settings7) GetHiddenPdfToolbarItems() (COREWEBVIEW2_PDF_TOOLBAR_ITEMS, error) { - var hidden_pdf_toolbar_items COREWEBVIEW2_PDF_TOOLBAR_ITEMS + var value COREWEBVIEW2_PDF_TOOLBAR_ITEMS hr, _, err := i.Vtbl.GetHiddenPdfToolbarItems.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&hidden_pdf_toolbar_items)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return hidden_pdf_toolbar_items, err + return value, err } -func (i *ICoreWebView2Settings7) PutHiddenPdfToolbarItems(hidden_pdf_toolbar_items COREWEBVIEW2_PDF_TOOLBAR_ITEMS) error { +func (i *ICoreWebView2Settings7) PutHiddenPdfToolbarItems(value COREWEBVIEW2_PDF_TOOLBAR_ITEMS) error { hr, _, err := i.Vtbl.PutHiddenPdfToolbarItems.Call( uintptr(unsafe.Pointer(i)), - uintptr(hidden_pdf_toolbar_items), + uintptr(value), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) diff --git a/pkg/webview2/ICoreWebView2Settings9.go b/pkg/webview2/ICoreWebView2Settings9.go index a6948e2..2e098a1 100644 --- a/pkg/webview2/ICoreWebView2Settings9.go +++ b/pkg/webview2/ICoreWebView2Settings9.go @@ -26,7 +26,7 @@ func (i *ICoreWebView2Settings9) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2Settings9() *ICoreWebView2Settings9 { var result *ICoreWebView2Settings9 - iidICoreWebView2Settings9 := NewGUID("{0528A73B-E92D-49F4-927A-E547DDDAA37D}") + iidICoreWebView2Settings9 := NewGUID("{0528a73b-e92d-49f4-927a-e547dddaa37d}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2Settings9)), @@ -37,25 +37,25 @@ func (i *ICoreWebView2) GetICoreWebView2Settings9() *ICoreWebView2Settings9 { func (i *ICoreWebView2Settings9) GetIsNonClientRegionSupportEnabled() (bool, error) { // Create int32 to hold bool result - var _enabled int32 + var _value int32 hr, _, err := i.Vtbl.GetIsNonClientRegionSupportEnabled.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&_enabled)), + uintptr(unsafe.Pointer(&_value)), ) if windows.Handle(hr) != windows.S_OK { return false, syscall.Errno(hr) } // Get result and cleanup - enabled := _enabled != 0 - return enabled, err + value := _value != 0 + return value, err } -func (i *ICoreWebView2Settings9) PutIsNonClientRegionSupportEnabled(enabled bool) error { +func (i *ICoreWebView2Settings9) PutIsNonClientRegionSupportEnabled(value bool) error { hr, _, err := i.Vtbl.PutIsNonClientRegionSupportEnabled.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&enabled)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) diff --git a/pkg/webview2/ICoreWebView2ShowSaveAsUICompletedHandler.go b/pkg/webview2/ICoreWebView2ShowSaveAsUICompletedHandler.go new file mode 100644 index 0000000..53ac4b4 --- /dev/null +++ b/pkg/webview2/ICoreWebView2ShowSaveAsUICompletedHandler.go @@ -0,0 +1,59 @@ +//go:build windows + +package webview2 + +import ( + "unsafe" +) + +type ICoreWebView2ShowSaveAsUICompletedHandlerVtbl struct { + IUnknownVtbl + Invoke ComProc +} + +type ICoreWebView2ShowSaveAsUICompletedHandler struct { + Vtbl *ICoreWebView2ShowSaveAsUICompletedHandlerVtbl + impl ICoreWebView2ShowSaveAsUICompletedHandlerImpl +} + +func (i *ICoreWebView2ShowSaveAsUICompletedHandler) AddRef() uintptr { + refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) + return refCounter +} + +func ICoreWebView2ShowSaveAsUICompletedHandlerIUnknownQueryInterface(this *ICoreWebView2ShowSaveAsUICompletedHandler, refiid, object uintptr) uintptr { + return this.impl.QueryInterface(refiid, object) +} + +func ICoreWebView2ShowSaveAsUICompletedHandlerIUnknownAddRef(this *ICoreWebView2ShowSaveAsUICompletedHandler) uintptr { + return this.impl.AddRef() +} + +func ICoreWebView2ShowSaveAsUICompletedHandlerIUnknownRelease(this *ICoreWebView2ShowSaveAsUICompletedHandler) uintptr { + return this.impl.Release() +} + +func ICoreWebView2ShowSaveAsUICompletedHandlerInvoke(this *ICoreWebView2ShowSaveAsUICompletedHandler, errorCode uintptr, result COREWEBVIEW2_SAVE_AS_UI_RESULT) uintptr { + return this.impl.ShowSaveAsUICompleted(errorCode, result) +} + +type ICoreWebView2ShowSaveAsUICompletedHandlerImpl interface { + IUnknownImpl + ShowSaveAsUICompleted(errorCode uintptr, result COREWEBVIEW2_SAVE_AS_UI_RESULT) uintptr +} + +var ICoreWebView2ShowSaveAsUICompletedHandlerFn = ICoreWebView2ShowSaveAsUICompletedHandlerVtbl{ + IUnknownVtbl{ + NewComProc(ICoreWebView2ShowSaveAsUICompletedHandlerIUnknownQueryInterface), + NewComProc(ICoreWebView2ShowSaveAsUICompletedHandlerIUnknownAddRef), + NewComProc(ICoreWebView2ShowSaveAsUICompletedHandlerIUnknownRelease), + }, + NewComProc(ICoreWebView2ShowSaveAsUICompletedHandlerInvoke), +} + +func NewICoreWebView2ShowSaveAsUICompletedHandler(impl ICoreWebView2ShowSaveAsUICompletedHandlerImpl) *ICoreWebView2ShowSaveAsUICompletedHandler { + return &ICoreWebView2ShowSaveAsUICompletedHandler{ + Vtbl: &ICoreWebView2ShowSaveAsUICompletedHandlerFn, + impl: impl, + } +} diff --git a/pkg/webview2/ICoreWebView2SourceChangedEventArgs.go b/pkg/webview2/ICoreWebView2SourceChangedEventArgs.go index e21f65d..a2a912f 100644 --- a/pkg/webview2/ICoreWebView2SourceChangedEventArgs.go +++ b/pkg/webview2/ICoreWebView2SourceChangedEventArgs.go @@ -24,16 +24,16 @@ func (i *ICoreWebView2SourceChangedEventArgs) AddRef() uintptr { func (i *ICoreWebView2SourceChangedEventArgs) GetIsNewDocument() (bool, error) { // Create int32 to hold bool result - var _isNewDocument int32 + var _value int32 hr, _, err := i.Vtbl.GetIsNewDocument.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&_isNewDocument)), + uintptr(unsafe.Pointer(&_value)), ) if windows.Handle(hr) != windows.S_OK { return false, syscall.Errno(hr) } // Get result and cleanup - isNewDocument := _isNewDocument != 0 - return isNewDocument, err + value := _value != 0 + return value, err } diff --git a/pkg/webview2/ICoreWebView2StringCollection.go b/pkg/webview2/ICoreWebView2StringCollection.go index 6fc1484..98a4866 100644 --- a/pkg/webview2/ICoreWebView2StringCollection.go +++ b/pkg/webview2/ICoreWebView2StringCollection.go @@ -23,9 +23,9 @@ func (i *ICoreWebView2StringCollection) AddRef() uintptr { return refCounter } -func (i *ICoreWebView2StringCollection) GetCount() (uint, error) { +func (i *ICoreWebView2StringCollection) GetCount() (uint32, error) { - var value uint + var value uint32 hr, _, err := i.Vtbl.GetCount.Call( uintptr(unsafe.Pointer(i)), @@ -37,7 +37,7 @@ func (i *ICoreWebView2StringCollection) GetCount() (uint, error) { return value, err } -func (i *ICoreWebView2StringCollection) GetValueAtIndex(index uint) (string, error) { +func (i *ICoreWebView2StringCollection) GetValueAtIndex(index uint32) (string, error) { // Create *uint16 to hold result var _value *uint16 diff --git a/pkg/webview2/ICoreWebView2TrySuspendCompletedHandler.go b/pkg/webview2/ICoreWebView2TrySuspendCompletedHandler.go index a5212e5..b4399f9 100644 --- a/pkg/webview2/ICoreWebView2TrySuspendCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2TrySuspendCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2TrySuspendCompletedHandlerIUnknownRelease(this *ICoreWebView2T return this.impl.Release() } -func ICoreWebView2TrySuspendCompletedHandlerInvoke(this *ICoreWebView2TrySuspendCompletedHandler, errorCode uintptr, isSuccessful bool) uintptr { - return this.impl.TrySuspendCompleted(errorCode, isSuccessful) +func ICoreWebView2TrySuspendCompletedHandlerInvoke(this *ICoreWebView2TrySuspendCompletedHandler, errorCode uintptr, result bool) uintptr { + return this.impl.TrySuspendCompleted(errorCode, result) } type ICoreWebView2TrySuspendCompletedHandlerImpl interface { IUnknownImpl - TrySuspendCompleted(errorCode uintptr, isSuccessful bool) uintptr + TrySuspendCompleted(errorCode uintptr, result bool) uintptr } var ICoreWebView2TrySuspendCompletedHandlerFn = ICoreWebView2TrySuspendCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2WebMessageReceivedEventArgs.go b/pkg/webview2/ICoreWebView2WebMessageReceivedEventArgs.go index 55a4bde..15a4e64 100644 --- a/pkg/webview2/ICoreWebView2WebMessageReceivedEventArgs.go +++ b/pkg/webview2/ICoreWebView2WebMessageReceivedEventArgs.go @@ -26,51 +26,51 @@ func (i *ICoreWebView2WebMessageReceivedEventArgs) AddRef() uintptr { func (i *ICoreWebView2WebMessageReceivedEventArgs) GetSource() (string, error) { // Create *uint16 to hold result - var _source *uint16 + var _value *uint16 hr, _, err := i.Vtbl.GetSource.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_source)), + uintptr(unsafe.Pointer(_value)), ) if windows.Handle(hr) != windows.S_OK { return "", syscall.Errno(hr) } // Get result and cleanup - source := UTF16PtrToString(_source) - CoTaskMemFree(unsafe.Pointer(_source)) - return source, err + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err } func (i *ICoreWebView2WebMessageReceivedEventArgs) GetWebMessageAsJson() (string, error) { // Create *uint16 to hold result - var _webMessageAsJson *uint16 + var _value *uint16 hr, _, err := i.Vtbl.GetWebMessageAsJson.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_webMessageAsJson)), + uintptr(unsafe.Pointer(_value)), ) if windows.Handle(hr) != windows.S_OK { return "", syscall.Errno(hr) } // Get result and cleanup - webMessageAsJson := UTF16PtrToString(_webMessageAsJson) - CoTaskMemFree(unsafe.Pointer(_webMessageAsJson)) - return webMessageAsJson, err + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err } func (i *ICoreWebView2WebMessageReceivedEventArgs) TryGetWebMessageAsString() (string, error) { // Create *uint16 to hold result - var _webMessageAsString *uint16 + var _value *uint16 hr, _, err := i.Vtbl.TryGetWebMessageAsString.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_webMessageAsString)), + uintptr(unsafe.Pointer(_value)), ) if windows.Handle(hr) != windows.S_OK { return "", syscall.Errno(hr) } // Get result and cleanup - webMessageAsString := UTF16PtrToString(_webMessageAsString) - CoTaskMemFree(unsafe.Pointer(_webMessageAsString)) - return webMessageAsString, err + value := UTF16PtrToString(_value) + CoTaskMemFree(unsafe.Pointer(_value)) + return value, err } diff --git a/pkg/webview2/ICoreWebView2WebResourceRequestedEventArgs2.go b/pkg/webview2/ICoreWebView2WebResourceRequestedEventArgs2.go index 54729f7..173705c 100644 --- a/pkg/webview2/ICoreWebView2WebResourceRequestedEventArgs2.go +++ b/pkg/webview2/ICoreWebView2WebResourceRequestedEventArgs2.go @@ -25,7 +25,7 @@ func (i *ICoreWebView2WebResourceRequestedEventArgs2) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2WebResourceRequestedEventArgs2() *ICoreWebView2WebResourceRequestedEventArgs2 { var result *ICoreWebView2WebResourceRequestedEventArgs2 - iidICoreWebView2WebResourceRequestedEventArgs2 := NewGUID("{9C562C24-B219-4D7F-92F6-B187FBBADD56}") + iidICoreWebView2WebResourceRequestedEventArgs2 := NewGUID("{9c562c24-b219-4d7f-92f6-b187fbbadd56}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2WebResourceRequestedEventArgs2)), @@ -36,14 +36,14 @@ func (i *ICoreWebView2) GetICoreWebView2WebResourceRequestedEventArgs2() *ICoreW func (i *ICoreWebView2WebResourceRequestedEventArgs2) GetRequestedSourceKind() (COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS, error) { - var requestedSourceKind COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS + var value COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS hr, _, err := i.Vtbl.GetRequestedSourceKind.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&requestedSourceKind)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return requestedSourceKind, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2WebResourceResponseReceivedEventArgs.go b/pkg/webview2/ICoreWebView2WebResourceResponseReceivedEventArgs.go index b408882..2cc30ee 100644 --- a/pkg/webview2/ICoreWebView2WebResourceResponseReceivedEventArgs.go +++ b/pkg/webview2/ICoreWebView2WebResourceResponseReceivedEventArgs.go @@ -25,28 +25,28 @@ func (i *ICoreWebView2WebResourceResponseReceivedEventArgs) AddRef() uintptr { func (i *ICoreWebView2WebResourceResponseReceivedEventArgs) GetRequest() (*ICoreWebView2WebResourceRequest, error) { - var request *ICoreWebView2WebResourceRequest + var value *ICoreWebView2WebResourceRequest hr, _, err := i.Vtbl.GetRequest.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&request)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return request, err + return value, err } func (i *ICoreWebView2WebResourceResponseReceivedEventArgs) GetResponse() (*ICoreWebView2WebResourceResponseView, error) { - var response *ICoreWebView2WebResourceResponseView + var value *ICoreWebView2WebResourceResponseView hr, _, err := i.Vtbl.GetResponse.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&response)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return nil, syscall.Errno(hr) } - return response, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2WebResourceResponseViewGetContentCompletedHandler.go b/pkg/webview2/ICoreWebView2WebResourceResponseViewGetContentCompletedHandler.go index 1fff6f9..f7b55eb 100644 --- a/pkg/webview2/ICoreWebView2WebResourceResponseViewGetContentCompletedHandler.go +++ b/pkg/webview2/ICoreWebView2WebResourceResponseViewGetContentCompletedHandler.go @@ -33,13 +33,13 @@ func ICoreWebView2WebResourceResponseViewGetContentCompletedHandlerIUnknownRelea return this.impl.Release() } -func ICoreWebView2WebResourceResponseViewGetContentCompletedHandlerInvoke(this *ICoreWebView2WebResourceResponseViewGetContentCompletedHandler, errorCode uintptr, content *IStream) uintptr { - return this.impl.WebResourceResponseViewGetContentCompleted(errorCode, content) +func ICoreWebView2WebResourceResponseViewGetContentCompletedHandlerInvoke(this *ICoreWebView2WebResourceResponseViewGetContentCompletedHandler, errorCode uintptr, result *IStream) uintptr { + return this.impl.WebResourceResponseViewGetContentCompleted(errorCode, result) } type ICoreWebView2WebResourceResponseViewGetContentCompletedHandlerImpl interface { IUnknownImpl - WebResourceResponseViewGetContentCompleted(errorCode uintptr, content *IStream) uintptr + WebResourceResponseViewGetContentCompleted(errorCode uintptr, result *IStream) uintptr } var ICoreWebView2WebResourceResponseViewGetContentCompletedHandlerFn = ICoreWebView2WebResourceResponseViewGetContentCompletedHandlerVtbl{ diff --git a/pkg/webview2/ICoreWebView2_13.go b/pkg/webview2/ICoreWebView2_13.go index ed4d1cc..a89a17b 100644 --- a/pkg/webview2/ICoreWebView2_13.go +++ b/pkg/webview2/ICoreWebView2_13.go @@ -25,7 +25,7 @@ func (i *ICoreWebView2_13) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2_13() *ICoreWebView2_13 { var result *ICoreWebView2_13 - iidICoreWebView2_13 := NewGUID("{F75F09A8-667E-4983-88D6-C8773F315E84}") + iidICoreWebView2_13 := NewGUID("{f75f09a8-667e-4983-88d6-c8773f315e84}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2_13)), diff --git a/pkg/webview2/ICoreWebView2_14.go b/pkg/webview2/ICoreWebView2_14.go index b8ecce2..e1c0784 100644 --- a/pkg/webview2/ICoreWebView2_14.go +++ b/pkg/webview2/ICoreWebView2_14.go @@ -27,7 +27,7 @@ func (i *ICoreWebView2_14) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2_14() *ICoreWebView2_14 { var result *ICoreWebView2_14 - iidICoreWebView2_14 := NewGUID("{6DAA4F10-4A90-4753-8898-77C5DF534165}") + iidICoreWebView2_14 := NewGUID("{6daa4f10-4a90-4753-8898-77c5df534165}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2_14)), diff --git a/pkg/webview2/ICoreWebView2_17.go b/pkg/webview2/ICoreWebView2_17.go index df2c490..92e4616 100644 --- a/pkg/webview2/ICoreWebView2_17.go +++ b/pkg/webview2/ICoreWebView2_17.go @@ -25,7 +25,7 @@ func (i *ICoreWebView2_17) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2_17() *ICoreWebView2_17 { var result *ICoreWebView2_17 - iidICoreWebView2_17 := NewGUID("{702E75D4-FD44-434D-9D70-1A68A6B1192A}") + iidICoreWebView2_17 := NewGUID("{702e75d4-fd44-434d-9d70-1a68a6b1192a}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2_17)), diff --git a/pkg/webview2/ICoreWebView2_18.go b/pkg/webview2/ICoreWebView2_18.go index 3c4a921..bd28e3b 100644 --- a/pkg/webview2/ICoreWebView2_18.go +++ b/pkg/webview2/ICoreWebView2_18.go @@ -26,7 +26,7 @@ func (i *ICoreWebView2_18) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2_18() *ICoreWebView2_18 { var result *ICoreWebView2_18 - iidICoreWebView2_18 := NewGUID("{7A626017-28BE-49B2-B865-3BA2B3522D90}") + iidICoreWebView2_18 := NewGUID("{7a626017-28be-49b2-b865-3ba2b3522d90}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2_18)), diff --git a/pkg/webview2/ICoreWebView2_19.go b/pkg/webview2/ICoreWebView2_19.go index 5dfedde..1238cd9 100644 --- a/pkg/webview2/ICoreWebView2_19.go +++ b/pkg/webview2/ICoreWebView2_19.go @@ -26,7 +26,7 @@ func (i *ICoreWebView2_19) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2_19() *ICoreWebView2_19 { var result *ICoreWebView2_19 - iidICoreWebView2_19 := NewGUID("{6921F954-79B0-437F-A997-C85811897C68}") + iidICoreWebView2_19 := NewGUID("{6921f954-79b0-437f-a997-c85811897c68}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2_19)), @@ -37,23 +37,23 @@ func (i *ICoreWebView2) GetICoreWebView2_19() *ICoreWebView2_19 { func (i *ICoreWebView2_19) GetMemoryUsageTargetLevel() (COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL, error) { - var level COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL + var value COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL hr, _, err := i.Vtbl.GetMemoryUsageTargetLevel.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&level)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return level, err + return value, err } -func (i *ICoreWebView2_19) PutMemoryUsageTargetLevel(level COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL) error { +func (i *ICoreWebView2_19) PutMemoryUsageTargetLevel(value COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL) error { hr, _, err := i.Vtbl.PutMemoryUsageTargetLevel.Call( uintptr(unsafe.Pointer(i)), - uintptr(level), + uintptr(value), ) if windows.Handle(hr) != windows.S_OK { return syscall.Errno(hr) diff --git a/pkg/webview2/ICoreWebView2_20.go b/pkg/webview2/ICoreWebView2_20.go index 6d78b61..9db3678 100644 --- a/pkg/webview2/ICoreWebView2_20.go +++ b/pkg/webview2/ICoreWebView2_20.go @@ -36,14 +36,14 @@ func (i *ICoreWebView2) GetICoreWebView2_20() *ICoreWebView2_20 { func (i *ICoreWebView2_20) GetFrameId() (uint32, error) { - var id uint32 + var value uint32 hr, _, err := i.Vtbl.GetFrameId.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(&id)), + uintptr(unsafe.Pointer(&value)), ) if windows.Handle(hr) != windows.S_OK { return 0, syscall.Errno(hr) } - return id, err + return value, err } diff --git a/pkg/webview2/ICoreWebView2_22.go b/pkg/webview2/ICoreWebView2_22.go index 4c13848..a9bdb8d 100644 --- a/pkg/webview2/ICoreWebView2_22.go +++ b/pkg/webview2/ICoreWebView2_22.go @@ -26,7 +26,7 @@ func (i *ICoreWebView2_22) AddRef() uintptr { func (i *ICoreWebView2) GetICoreWebView2_22() *ICoreWebView2_22 { var result *ICoreWebView2_22 - iidICoreWebView2_22 := NewGUID("{DB75DFC7-A857-4632-A398-6969DDE26C0A}") + iidICoreWebView2_22 := NewGUID("{db75dfc7-a857-4632-a398-6969dde26c0a}") _, _, _ = i.Vtbl.QueryInterface.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(iidICoreWebView2_22)), @@ -35,7 +35,7 @@ func (i *ICoreWebView2) GetICoreWebView2_22() *ICoreWebView2_22 { return result } -func (i *ICoreWebView2_22) AddWebResourceRequestedFilterWithRequestSourceKinds(uri string, resourceContext COREWEBVIEW2_WEB_RESOURCE_CONTEXT, requestSourceKinds COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS) error { +func (i *ICoreWebView2_22) AddWebResourceRequestedFilterWithRequestSourceKinds(uri string, ResourceContext COREWEBVIEW2_WEB_RESOURCE_CONTEXT, requestSourceKinds COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS) error { // Convert string 'uri' to *uint16 _uri, err := UTF16PtrFromString(uri) @@ -46,7 +46,7 @@ func (i *ICoreWebView2_22) AddWebResourceRequestedFilterWithRequestSourceKinds(u hr, _, err := i.Vtbl.AddWebResourceRequestedFilterWithRequestSourceKinds.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(_uri)), - uintptr(resourceContext), + uintptr(ResourceContext), uintptr(requestSourceKinds), ) if windows.Handle(hr) != windows.S_OK { @@ -55,7 +55,7 @@ func (i *ICoreWebView2_22) AddWebResourceRequestedFilterWithRequestSourceKinds(u return err } -func (i *ICoreWebView2_22) RemoveWebResourceRequestedFilterWithRequestSourceKinds(uri string, resourceContext COREWEBVIEW2_WEB_RESOURCE_CONTEXT, requestSourceKinds COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS) error { +func (i *ICoreWebView2_22) RemoveWebResourceRequestedFilterWithRequestSourceKinds(uri string, ResourceContext COREWEBVIEW2_WEB_RESOURCE_CONTEXT, requestSourceKinds COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS) error { // Convert string 'uri' to *uint16 _uri, err := UTF16PtrFromString(uri) @@ -66,7 +66,7 @@ func (i *ICoreWebView2_22) RemoveWebResourceRequestedFilterWithRequestSourceKind hr, _, err := i.Vtbl.RemoveWebResourceRequestedFilterWithRequestSourceKinds.Call( uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(_uri)), - uintptr(resourceContext), + uintptr(ResourceContext), uintptr(requestSourceKinds), ) if windows.Handle(hr) != windows.S_OK { diff --git a/pkg/webview2/ICoreWebView2_23.go b/pkg/webview2/ICoreWebView2_23.go new file mode 100644 index 0000000..4c4636c --- /dev/null +++ b/pkg/webview2/ICoreWebView2_23.go @@ -0,0 +1,54 @@ +//go:build windows + +package webview2 + +import ( + "golang.org/x/sys/windows" + "syscall" + "unsafe" +) + +type ICoreWebView2_23Vtbl struct { + IUnknownVtbl + PostWebMessageAsJsonWithAdditionalObjects ComProc +} + +type ICoreWebView2_23 struct { + Vtbl *ICoreWebView2_23Vtbl +} + +func (i *ICoreWebView2_23) AddRef() uintptr { + refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) + return refCounter +} + +func (i *ICoreWebView2) GetICoreWebView2_23() *ICoreWebView2_23 { + var result *ICoreWebView2_23 + + iidICoreWebView2_23 := NewGUID("{508f0db5-90c4-5872-90a7-267a91377502}") + _, _, _ = i.Vtbl.QueryInterface.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(iidICoreWebView2_23)), + uintptr(unsafe.Pointer(&result))) + + return result +} + +func (i *ICoreWebView2_23) PostWebMessageAsJsonWithAdditionalObjects(webMessageAsJson string, additionalObjects *ICoreWebView2ObjectCollectionView) error { + + // Convert string 'webMessageAsJson' to *uint16 + _webMessageAsJson, err := UTF16PtrFromString(webMessageAsJson) + if err != nil { + return err + } + + hr, _, err := i.Vtbl.PostWebMessageAsJsonWithAdditionalObjects.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(_webMessageAsJson)), + uintptr(unsafe.Pointer(additionalObjects)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} diff --git a/pkg/webview2/ICoreWebView2_24.go b/pkg/webview2/ICoreWebView2_24.go new file mode 100644 index 0000000..4cfaa66 --- /dev/null +++ b/pkg/webview2/ICoreWebView2_24.go @@ -0,0 +1,63 @@ +//go:build windows + +package webview2 + +import ( + "golang.org/x/sys/windows" + "syscall" + "unsafe" +) + +type ICoreWebView2_24Vtbl struct { + IUnknownVtbl + AddNotificationReceived ComProc + RemoveNotificationReceived ComProc +} + +type ICoreWebView2_24 struct { + Vtbl *ICoreWebView2_24Vtbl +} + +func (i *ICoreWebView2_24) AddRef() uintptr { + refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) + return refCounter +} + +func (i *ICoreWebView2) GetICoreWebView2_24() *ICoreWebView2_24 { + var result *ICoreWebView2_24 + + iidICoreWebView2_24 := NewGUID("{39a7ad55-4287-5cc1-88a1-c6f458593824}") + _, _, _ = i.Vtbl.QueryInterface.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(iidICoreWebView2_24)), + uintptr(unsafe.Pointer(&result))) + + return result +} + +func (i *ICoreWebView2_24) AddNotificationReceived(eventHandler *ICoreWebView2NotificationReceivedEventHandler) (EventRegistrationToken, error) { + + var token EventRegistrationToken + + hr, _, err := i.Vtbl.AddNotificationReceived.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(eventHandler)), + uintptr(unsafe.Pointer(&token)), + ) + if windows.Handle(hr) != windows.S_OK { + return EventRegistrationToken{}, syscall.Errno(hr) + } + return token, err +} + +func (i *ICoreWebView2_24) RemoveNotificationReceived(token EventRegistrationToken) error { + + hr, _, err := i.Vtbl.RemoveNotificationReceived.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&token)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} diff --git a/pkg/webview2/ICoreWebView2_25.go b/pkg/webview2/ICoreWebView2_25.go new file mode 100644 index 0000000..a44670d --- /dev/null +++ b/pkg/webview2/ICoreWebView2_25.go @@ -0,0 +1,76 @@ +//go:build windows + +package webview2 + +import ( + "golang.org/x/sys/windows" + "syscall" + "unsafe" +) + +type ICoreWebView2_25Vtbl struct { + IUnknownVtbl + AddSaveAsUIShowing ComProc + RemoveSaveAsUIShowing ComProc + ShowSaveAsUI ComProc +} + +type ICoreWebView2_25 struct { + Vtbl *ICoreWebView2_25Vtbl +} + +func (i *ICoreWebView2_25) AddRef() uintptr { + refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) + return refCounter +} + +func (i *ICoreWebView2) GetICoreWebView2_25() *ICoreWebView2_25 { + var result *ICoreWebView2_25 + + iidICoreWebView2_25 := NewGUID("{b5a86092-df50-5b4f-a17b-6c8f8b40b771}") + _, _, _ = i.Vtbl.QueryInterface.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(iidICoreWebView2_25)), + uintptr(unsafe.Pointer(&result))) + + return result +} + +func (i *ICoreWebView2_25) AddSaveAsUIShowing(eventHandler *ICoreWebView2SaveAsUIShowingEventHandler) (EventRegistrationToken, error) { + + var token EventRegistrationToken + + hr, _, err := i.Vtbl.AddSaveAsUIShowing.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(eventHandler)), + uintptr(unsafe.Pointer(&token)), + ) + if windows.Handle(hr) != windows.S_OK { + return EventRegistrationToken{}, syscall.Errno(hr) + } + return token, err +} + +func (i *ICoreWebView2_25) RemoveSaveAsUIShowing(token EventRegistrationToken) error { + + hr, _, err := i.Vtbl.RemoveSaveAsUIShowing.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(&token)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} + +func (i *ICoreWebView2_25) ShowSaveAsUI(handler *ICoreWebView2ShowSaveAsUICompletedHandler) error { + + hr, _, err := i.Vtbl.ShowSaveAsUI.Call( + uintptr(unsafe.Pointer(i)), + uintptr(unsafe.Pointer(handler)), + ) + if windows.Handle(hr) != windows.S_OK { + return syscall.Errno(hr) + } + return err +} diff --git a/pkg/webview2/ICoreWebView2_7.go b/pkg/webview2/ICoreWebView2_7.go index 6fbedb1..7fea785 100644 --- a/pkg/webview2/ICoreWebView2_7.go +++ b/pkg/webview2/ICoreWebView2_7.go @@ -34,17 +34,17 @@ func (i *ICoreWebView2) GetICoreWebView2_7() *ICoreWebView2_7 { return result } -func (i *ICoreWebView2_7) PrintToPdf(resultFilePath string, printSettings *ICoreWebView2PrintSettings, handler *ICoreWebView2PrintToPdfCompletedHandler) error { +func (i *ICoreWebView2_7) PrintToPdf(ResultFilePath string, printSettings *ICoreWebView2PrintSettings, handler *ICoreWebView2PrintToPdfCompletedHandler) error { - // Convert string 'resultFilePath' to *uint16 - _resultFilePath, err := UTF16PtrFromString(resultFilePath) + // Convert string 'ResultFilePath' to *uint16 + _ResultFilePath, err := UTF16PtrFromString(ResultFilePath) if err != nil { return err } hr, _, err := i.Vtbl.PrintToPdf.Call( uintptr(unsafe.Pointer(i)), - uintptr(unsafe.Pointer(_resultFilePath)), + uintptr(unsafe.Pointer(_ResultFilePath)), uintptr(unsafe.Pointer(printSettings)), uintptr(unsafe.Pointer(handler)), ) diff --git a/scripts/WebView2.1.0.2739.15.idl b/scripts/WebView2.1.0.2739.15.idl new file mode 100644 index 0000000..11a094f --- /dev/null +++ b/scripts/WebView2.1.0.2739.15.idl @@ -0,0 +1,10680 @@ +// Copyright (C) Microsoft Corporation. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +import "objidl.idl"; +import "oaidl.idl"; +import "EventToken.idl"; + +[uuid(26d34152-879f-4065-bea2-3daa2cfadfb8), version(1.0)] +library WebView2 { + +// Interface forward declarations + + +interface ICoreWebView2; +interface ICoreWebView2ContainsFullScreenElementChangedEventHandler; +interface ICoreWebView2ContentLoadingEventHandler; +interface ICoreWebView2DocumentTitleChangedEventHandler; +// Skipping ICoreWebView2NavigationCompletedEventHandler forward declaration +// Skipping ICoreWebView2NavigationStartingEventHandler forward declaration +interface ICoreWebView2HistoryChangedEventHandler; +interface ICoreWebView2NavigationCompletedEventHandler; +interface ICoreWebView2NavigationStartingEventHandler; +interface ICoreWebView2NewWindowRequestedEventHandler; +interface ICoreWebView2PermissionRequestedEventHandler; +interface ICoreWebView2ProcessFailedEventHandler; +interface ICoreWebView2ScriptDialogOpeningEventHandler; +interface ICoreWebView2SourceChangedEventHandler; +interface ICoreWebView2WebMessageReceivedEventHandler; +interface ICoreWebView2WebResourceRequestedEventHandler; +interface ICoreWebView2WindowCloseRequestedEventHandler; +interface ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler; +interface ICoreWebView2ExecuteScriptCompletedHandler; +interface ICoreWebView2CapturePreviewCompletedHandler; +interface ICoreWebView2CallDevToolsProtocolMethodCompletedHandler; +interface ICoreWebView2_2; +interface ICoreWebView2DOMContentLoadedEventHandler; +interface ICoreWebView2WebResourceResponseReceivedEventHandler; +interface ICoreWebView2_3; +interface ICoreWebView2TrySuspendCompletedHandler; +interface ICoreWebView2_4; +interface ICoreWebView2DownloadStartingEventHandler; +interface ICoreWebView2FrameCreatedEventHandler; +interface ICoreWebView2_5; +interface ICoreWebView2ClientCertificateRequestedEventHandler; +interface ICoreWebView2_6; +interface ICoreWebView2_7; +interface ICoreWebView2PrintToPdfCompletedHandler; +interface ICoreWebView2_8; +interface ICoreWebView2IsDocumentPlayingAudioChangedEventHandler; +interface ICoreWebView2IsMutedChangedEventHandler; +interface ICoreWebView2_9; +interface ICoreWebView2IsDefaultDownloadDialogOpenChangedEventHandler; +interface ICoreWebView2_10; +interface ICoreWebView2BasicAuthenticationRequestedEventHandler; +interface ICoreWebView2_11; +interface ICoreWebView2ContextMenuRequestedEventHandler; +// Skipping ICoreWebView2CallDevToolsProtocolMethodCompletedHandler forward declaration +interface ICoreWebView2_12; +interface ICoreWebView2StatusBarTextChangedEventHandler; +interface ICoreWebView2_13; +interface ICoreWebView2_14; +interface ICoreWebView2ServerCertificateErrorDetectedEventHandler; +interface ICoreWebView2ClearServerCertificateErrorActionsCompletedHandler; +interface ICoreWebView2_15; +interface ICoreWebView2FaviconChangedEventHandler; +interface ICoreWebView2GetFaviconCompletedHandler; +interface ICoreWebView2_16; +interface ICoreWebView2PrintCompletedHandler; +interface ICoreWebView2PrintToPdfStreamCompletedHandler; +interface ICoreWebView2_17; +interface ICoreWebView2_18; +interface ICoreWebView2LaunchingExternalUriSchemeEventHandler; +interface ICoreWebView2_19; +interface ICoreWebView2_20; +interface ICoreWebView2_21; +interface ICoreWebView2ExecuteScriptWithResultCompletedHandler; +interface ICoreWebView2_22; +interface ICoreWebView2_23; +interface ICoreWebView2_24; +interface ICoreWebView2NotificationReceivedEventHandler; +interface ICoreWebView2_25; +interface ICoreWebView2SaveAsUIShowingEventHandler; +interface ICoreWebView2ShowSaveAsUICompletedHandler; +interface ICoreWebView2AcceleratorKeyPressedEventArgs; +interface ICoreWebView2AcceleratorKeyPressedEventArgs2; +interface ICoreWebView2BasicAuthenticationRequestedEventArgs; +interface ICoreWebView2BasicAuthenticationResponse; +interface ICoreWebView2BrowserExtension; +interface ICoreWebView2BrowserExtensionRemoveCompletedHandler; +interface ICoreWebView2BrowserExtensionEnableCompletedHandler; +interface ICoreWebView2BrowserProcessExitedEventArgs; +interface ICoreWebView2Certificate; +interface ICoreWebView2ClientCertificate; +interface ICoreWebView2ClientCertificateRequestedEventArgs; +interface ICoreWebView2StringCollection; +interface ICoreWebView2ClientCertificateCollection; +interface ICoreWebView2CompositionController; +interface ICoreWebView2CursorChangedEventHandler; +interface ICoreWebView2CompositionController2; +interface ICoreWebView2CompositionController3; +interface ICoreWebView2CompositionController4; +interface ICoreWebView2NonClientRegionChangedEventHandler; +interface ICoreWebView2RegionRectCollectionView; +interface ICoreWebView2ContentLoadingEventArgs; +interface ICoreWebView2ContextMenuItem; +interface ICoreWebView2CustomItemSelectedEventHandler; +interface ICoreWebView2ContextMenuItemCollection; +interface ICoreWebView2ContextMenuRequestedEventArgs; +interface ICoreWebView2ContextMenuTarget; +interface ICoreWebView2Controller; +interface ICoreWebView2AcceleratorKeyPressedEventHandler; +interface ICoreWebView2FocusChangedEventHandler; +// Skipping ICoreWebView2FocusChangedEventHandler forward declaration +interface ICoreWebView2MoveFocusRequestedEventHandler; +interface ICoreWebView2ZoomFactorChangedEventHandler; +interface ICoreWebView2Controller2; +interface ICoreWebView2Controller3; +interface ICoreWebView2RasterizationScaleChangedEventHandler; +interface ICoreWebView2Controller4; +interface ICoreWebView2ControllerOptions; +interface ICoreWebView2ControllerOptions2; +interface ICoreWebView2Cookie; +interface ICoreWebView2CookieManager; +interface ICoreWebView2GetCookiesCompletedHandler; +interface ICoreWebView2CookieList; +interface ICoreWebView2CustomSchemeRegistration; +interface ICoreWebView2DOMContentLoadedEventArgs; +interface ICoreWebView2Deferral; +interface ICoreWebView2DevToolsProtocolEventReceivedEventArgs; +interface ICoreWebView2DevToolsProtocolEventReceivedEventArgs2; +interface ICoreWebView2DevToolsProtocolEventReceiver; +interface ICoreWebView2DevToolsProtocolEventReceivedEventHandler; +interface ICoreWebView2DownloadOperation; +interface ICoreWebView2BytesReceivedChangedEventHandler; +interface ICoreWebView2EstimatedEndTimeChangedEventHandler; +interface ICoreWebView2StateChangedEventHandler; +interface ICoreWebView2DownloadStartingEventArgs; +interface ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler; +// Skipping ICoreWebView2CreateCoreWebView2EnvironmentWithOptionsCompletedHandler forward declaration +interface ICoreWebView2Environment; +interface ICoreWebView2NewBrowserVersionAvailableEventHandler; +interface ICoreWebView2CreateCoreWebView2ControllerCompletedHandler; +interface ICoreWebView2Environment2; +interface ICoreWebView2Environment3; +interface ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler; +interface ICoreWebView2Environment4; +interface ICoreWebView2Environment5; +interface ICoreWebView2BrowserProcessExitedEventHandler; +interface ICoreWebView2Environment6; +interface ICoreWebView2Environment7; +interface ICoreWebView2Environment8; +interface ICoreWebView2ProcessInfosChangedEventHandler; +interface ICoreWebView2ProcessInfoCollection; +interface ICoreWebView2Environment9; +interface ICoreWebView2Environment10; +// Skipping ICoreWebView2CreateCoreWebView2ControllerCompletedHandler forward declaration +// Skipping ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler forward declaration +interface ICoreWebView2Environment11; +interface ICoreWebView2Environment12; +interface ICoreWebView2Environment13; +interface ICoreWebView2GetProcessExtendedInfosCompletedHandler; +interface ICoreWebView2ProcessExtendedInfoCollection; +interface ICoreWebView2Environment14; +interface ICoreWebView2EnvironmentOptions; +interface ICoreWebView2EnvironmentOptions2; +interface ICoreWebView2EnvironmentOptions3; +interface ICoreWebView2EnvironmentOptions4; +interface ICoreWebView2EnvironmentOptions5; +interface ICoreWebView2EnvironmentOptions6; +interface ICoreWebView2EnvironmentOptions7; +interface ICoreWebView2EnvironmentOptions8; +interface ICoreWebView2ExecuteScriptResult; +interface ICoreWebView2File; +interface ICoreWebView2FileSystemHandle; +interface ICoreWebView2Frame; +interface ICoreWebView2FrameDestroyedEventHandler; +interface ICoreWebView2FrameNameChangedEventHandler; +interface ICoreWebView2Frame2; +interface ICoreWebView2FrameContentLoadingEventHandler; +interface ICoreWebView2FrameDOMContentLoadedEventHandler; +interface ICoreWebView2FrameNavigationCompletedEventHandler; +interface ICoreWebView2FrameNavigationStartingEventHandler; +interface ICoreWebView2FrameWebMessageReceivedEventHandler; +// Skipping ICoreWebView2ExecuteScriptCompletedHandler forward declaration +interface ICoreWebView2Frame3; +interface ICoreWebView2FramePermissionRequestedEventHandler; +interface ICoreWebView2Frame4; +interface ICoreWebView2Frame5; +interface ICoreWebView2FrameCreatedEventArgs; +interface ICoreWebView2FrameInfo; +interface ICoreWebView2FrameInfo2; +interface ICoreWebView2FrameInfoCollection; +interface ICoreWebView2FrameInfoCollectionIterator; +interface ICoreWebView2HttpHeadersCollectionIterator; +interface ICoreWebView2HttpRequestHeaders; +interface ICoreWebView2HttpResponseHeaders; +interface ICoreWebView2LaunchingExternalUriSchemeEventArgs; +interface ICoreWebView2MoveFocusRequestedEventArgs; +interface ICoreWebView2NavigationCompletedEventArgs; +interface ICoreWebView2NavigationCompletedEventArgs2; +interface ICoreWebView2NavigationStartingEventArgs; +interface ICoreWebView2NavigationStartingEventArgs2; +interface ICoreWebView2NavigationStartingEventArgs3; +interface ICoreWebView2NewWindowRequestedEventArgs; +interface ICoreWebView2NewWindowRequestedEventArgs2; +interface ICoreWebView2NewWindowRequestedEventArgs3; +interface ICoreWebView2NonClientRegionChangedEventArgs; +interface ICoreWebView2Notification; +interface ICoreWebView2NotificationCloseRequestedEventHandler; +interface ICoreWebView2NotificationReceivedEventArgs; +interface ICoreWebView2ObjectCollectionView; +interface ICoreWebView2ObjectCollection; +interface ICoreWebView2PermissionRequestedEventArgs; +interface ICoreWebView2PermissionRequestedEventArgs2; +interface ICoreWebView2PermissionRequestedEventArgs3; +interface ICoreWebView2PermissionSetting; +interface ICoreWebView2PointerInfo; +interface ICoreWebView2PrintSettings; +interface ICoreWebView2PrintSettings2; +interface ICoreWebView2ProcessExtendedInfo; +interface ICoreWebView2ProcessFailedEventArgs; +interface ICoreWebView2ProcessFailedEventArgs2; +interface ICoreWebView2ProcessFailedEventArgs3; +interface ICoreWebView2ProcessInfo; +interface ICoreWebView2Profile; +interface ICoreWebView2Profile2; +interface ICoreWebView2ClearBrowsingDataCompletedHandler; +// Skipping ICoreWebView2ClearBrowsingDataCompletedHandler forward declaration +// Skipping ICoreWebView2ClearBrowsingDataCompletedHandler forward declaration +interface ICoreWebView2Profile3; +interface ICoreWebView2Profile4; +interface ICoreWebView2SetPermissionStateCompletedHandler; +interface ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandler; +interface ICoreWebView2Profile5; +interface ICoreWebView2Profile6; +interface ICoreWebView2Profile7; +interface ICoreWebView2ProfileAddBrowserExtensionCompletedHandler; +interface ICoreWebView2ProfileGetBrowserExtensionsCompletedHandler; +interface ICoreWebView2BrowserExtensionList; +interface ICoreWebView2Profile8; +interface ICoreWebView2ProfileDeletedEventHandler; +interface ICoreWebView2SaveAsUIShowingEventArgs; +interface ICoreWebView2ScriptDialogOpeningEventArgs; +interface ICoreWebView2ScriptException; +interface ICoreWebView2ServerCertificateErrorDetectedEventArgs; +interface ICoreWebView2Settings; +interface ICoreWebView2Settings2; +interface ICoreWebView2Settings3; +interface ICoreWebView2Settings4; +interface ICoreWebView2Settings5; +interface ICoreWebView2Settings6; +interface ICoreWebView2Settings7; +interface ICoreWebView2Settings8; +interface ICoreWebView2Settings9; +interface ICoreWebView2SharedBuffer; +interface ICoreWebView2SourceChangedEventArgs; +interface ICoreWebView2WebMessageReceivedEventArgs; +interface ICoreWebView2WebMessageReceivedEventArgs2; +interface ICoreWebView2WebResourceRequest; +interface ICoreWebView2WebResourceRequestedEventArgs; +interface ICoreWebView2WebResourceRequestedEventArgs2; +interface ICoreWebView2WebResourceResponse; +interface ICoreWebView2WebResourceResponseReceivedEventArgs; +interface ICoreWebView2WebResourceResponseView; +interface ICoreWebView2WebResourceResponseViewGetContentCompletedHandler; +interface ICoreWebView2WindowFeatures; + +// Enums and structs + + +/// Mode for how the Bounds property is interpreted in relation to the RasterizationScale property. +[v1_enum] +typedef enum COREWEBVIEW2_BOUNDS_MODE { + /// Bounds property represents raw pixels. Physical size of Webview is not impacted by RasterizationScale. + COREWEBVIEW2_BOUNDS_MODE_USE_RAW_PIXELS, + /// Bounds property represents logical pixels and the RasterizationScale property is used to get the physical size of the WebView. + COREWEBVIEW2_BOUNDS_MODE_USE_RASTERIZATION_SCALE, +} COREWEBVIEW2_BOUNDS_MODE; + +/// Specifies the browser process exit type used in the +/// `ICoreWebView2BrowserProcessExitedEventArgs` interface. +[v1_enum] +typedef enum COREWEBVIEW2_BROWSER_PROCESS_EXIT_KIND { + /// Indicates that the browser process ended normally. + COREWEBVIEW2_BROWSER_PROCESS_EXIT_KIND_NORMAL, + /// Indicates that the browser process ended unexpectedly. + /// A `ProcessFailed` event will also be sent to listening WebViews from the + /// `ICoreWebView2Environment` associated to the failed process. + COREWEBVIEW2_BROWSER_PROCESS_EXIT_KIND_FAILED, +} COREWEBVIEW2_BROWSER_PROCESS_EXIT_KIND; + +/// Specifies the datatype for the +/// `ICoreWebView2Profile2::ClearBrowsingData` method. +[v1_enum] +typedef enum COREWEBVIEW2_BROWSING_DATA_KINDS { + /// Specifies file systems data. + COREWEBVIEW2_BROWSING_DATA_KINDS_FILE_SYSTEMS = 0x1, + /// Specifies data stored by the IndexedDB DOM feature. + COREWEBVIEW2_BROWSING_DATA_KINDS_INDEXED_DB = 0x2, + /// Specifies data stored by the localStorage DOM API. + COREWEBVIEW2_BROWSING_DATA_KINDS_LOCAL_STORAGE = 0x4, + /// Specifies data stored by the Web SQL database DOM API. + COREWEBVIEW2_BROWSING_DATA_KINDS_WEB_SQL = 0x8, + /// Specifies data stored by the CacheStorage DOM API. + COREWEBVIEW2_BROWSING_DATA_KINDS_CACHE_STORAGE = 0x10, + /// Specifies DOM storage data, now and future. This browsing data kind is + /// inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_FILE_SYSTEMS, + /// COREWEBVIEW2_BROWSING_DATA_KINDS_INDEXED_DB, + /// COREWEBVIEW2_BROWSING_DATA_KINDS_LOCAL_STORAGE, + /// COREWEBVIEW2_BROWSING_DATA_KINDS_WEB_SQL, + /// COREWEBVIEW2_BROWSING_DATA_KINDS_SERVICE_WORKERS, + /// COREWEBVIEW2_BROWSING_DATA_KINDS_CACHE_STORAGE, + /// and some other data kinds not listed yet to keep consistent with + /// [DOM-accessible storage](https://www.w3.org/TR/clear-site-data/#storage). + COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_DOM_STORAGE = 0x20, + /// Specifies HTTP cookies data. + COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES = 0x40, + /// Specifies all site data, now and future. This browsing data kind + /// is inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_DOM_STORAGE and + /// COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES. New site data types + /// may be added to this data kind in the future. + COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_SITE = 0x80, + /// Specifies disk cache. + COREWEBVIEW2_BROWSING_DATA_KINDS_DISK_CACHE = 0x100, + /// Specifies download history data. + COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY = 0x200, + /// Specifies general autofill form data. + /// This excludes password information and includes information like: + /// names, street and email addresses, phone numbers, and arbitrary input. + /// This also includes payment data. + COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL = 0x400, + /// Specifies password autosave data. + COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE = 0x800, + /// Specifies browsing history data. + COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY = 0x1000, + /// Specifies settings data. + COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS = 0x2000, + /// Specifies profile data that should be wiped to make it look like a new profile. + /// This does not delete account-scoped data like passwords but will remove access + /// to account-scoped data by signing the user out. + /// Specifies all profile data, now and future. New profile data types may be added + /// to this data kind in the future. + /// This browsing data kind is inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_SITE, + /// COREWEBVIEW2_BROWSING_DATA_KINDS_DISK_CACHE, + /// COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY, + /// COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL, + /// COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE, + /// COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY, and + /// COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS. + COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_PROFILE = 0x4000, + /// Specifies service workers registered for an origin, and clear will result in + /// termination and deregistration of them. + COREWEBVIEW2_BROWSING_DATA_KINDS_SERVICE_WORKERS = 0x8000, +} COREWEBVIEW2_BROWSING_DATA_KINDS; +cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(COREWEBVIEW2_BROWSING_DATA_KINDS)") + +/// Specifies the image format for the `ICoreWebView2::CapturePreview` method. +[v1_enum] +typedef enum COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT { + /// Indicates that the PNG image format is used. + COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT_PNG, + /// Indicates the JPEG image format is used. + COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT_JPEG, +} COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT; + +/// The channel search kind determines the order that release channels are +/// searched for during environment creation. The default behavior is to search +/// for and use the most stable channel found on the device. The order from most +/// to least stable is: WebView2 Runtime -> Beta -> Dev -> Canary. Switch the +/// order to prefer the least stable channel in order to perform pre-release +/// testing. See `COREWEBVIEW2_RELEASE_CHANNELS` for descriptions of channels. +[v1_enum] +typedef enum COREWEBVIEW2_CHANNEL_SEARCH_KIND { + /// Search for a release channel from most to least stable: + /// WebView2 Runtime -> Beta -> Dev -> Canary. This is the default behavior. + COREWEBVIEW2_CHANNEL_SEARCH_KIND_MOST_STABLE, + /// Search for a release channel from least to most stable: + /// Canary -> Dev -> Beta -> WebView2 Runtime. + COREWEBVIEW2_CHANNEL_SEARCH_KIND_LEAST_STABLE, +} COREWEBVIEW2_CHANNEL_SEARCH_KIND; + +/// Specifies the client certificate kind. +[v1_enum] +typedef enum COREWEBVIEW2_CLIENT_CERTIFICATE_KIND { + /// Specifies smart card certificate. + COREWEBVIEW2_CLIENT_CERTIFICATE_KIND_SMART_CARD, + /// Specifies PIN certificate. + COREWEBVIEW2_CLIENT_CERTIFICATE_KIND_PIN, + /// Specifies other certificate. + COREWEBVIEW2_CLIENT_CERTIFICATE_KIND_OTHER, +} COREWEBVIEW2_CLIENT_CERTIFICATE_KIND; + +/// Specifies the menu item kind +/// for the `ICoreWebView2ContextMenuItem::get_Kind` method +[v1_enum] +typedef enum COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND { + /// Specifies a command menu item kind. + COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_COMMAND, + /// Specifies a check box menu item kind. `ContextMenuItem` objects of this kind + /// will need the `IsChecked` property to determine current state of the check box. + COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_CHECK_BOX, + /// Specifies a radio button menu item kind. `ContextMenuItem` objects of this kind + /// will need the `IsChecked` property to determine current state of the radio button. + COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_RADIO, + /// Specifies a separator menu item kind. `ContextMenuItem` objects of this kind + /// are used to signal a visual separator with no functionality. + COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_SEPARATOR, + /// Specifies a submenu menu item kind. `ContextMenuItem` objects of this kind will contain + /// a `ContextMenuItemCollection` of its children `ContextMenuItem` objects. + COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_SUBMENU, +} COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND; + +/// Indicates the kind of context for which the context menu was created +/// for the `ICoreWebView2ContextMenuTarget::get_Kind` method. +/// This enum will always represent the active element that caused the context menu request. +/// If there is a selection with multiple images, audio and text, for example, the element that +/// the end user right clicks on within this selection will be the option represented by this enum. +[v1_enum] +typedef enum COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND { + /// Indicates that the context menu was created for the page without any additional content. + COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND_PAGE, + /// Indicates that the context menu was created for an image element. + COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND_IMAGE, + /// Indicates that the context menu was created for selected text. + COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND_SELECTED_TEXT, + /// Indicates that the context menu was created for an audio element. + COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND_AUDIO, + /// Indicates that the context menu was created for a video element. + COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND_VIDEO, +} COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND; + +/// Kind of cookie SameSite status used in the ICoreWebView2Cookie interface. +/// These fields match those as specified in https://developer.mozilla.org/docs/Web/HTTP/Cookies#. +/// Learn more about SameSite cookies here: https://tools.ietf.org/html/draft-west-first-party-cookies-07 +[v1_enum] +typedef enum COREWEBVIEW2_COOKIE_SAME_SITE_KIND { + /// None SameSite type. No restrictions on cross-site requests. + COREWEBVIEW2_COOKIE_SAME_SITE_KIND_NONE, + /// Lax SameSite type. The cookie will be sent with "same-site" requests, and with "cross-site" top level navigation. + COREWEBVIEW2_COOKIE_SAME_SITE_KIND_LAX, + /// Strict SameSite type. The cookie will only be sent along with "same-site" requests. + COREWEBVIEW2_COOKIE_SAME_SITE_KIND_STRICT, +} COREWEBVIEW2_COOKIE_SAME_SITE_KIND; + +/// The default download dialog can be aligned to any of the WebView corners +/// by setting the `DefaultDownloadDialogCornerAlignment` property. The default +/// position is top-right corner. +[v1_enum] +typedef enum COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT { + /// Top-left corner of the WebView. + COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT_TOP_LEFT, + /// Top-right corner of the WebView. + COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT_TOP_RIGHT, + /// Bottom-left corner of the WebView. + COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT_BOTTOM_LEFT, + /// Bottom-right corner of the WebView. + COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT_BOTTOM_RIGHT, +} COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT; + +/// Reason why a download was interrupted. +[v1_enum] +typedef enum COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON { + /// + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_NONE, + /// Generic file error. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, + /// Access denied due to security restrictions. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED, + /// Disk full. User should free some space or choose a different location to + /// store the file. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, + /// Result file path with file name is too long. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, + /// File is too large for file system. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_TOO_LARGE, + /// Microsoft Defender Smartscreen detected a virus in the file. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_MALICIOUS, + /// File was in use, too many files opened, or out of memory. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR, + /// File blocked by local policy. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_BLOCKED_BY_POLICY, + /// Security check failed unexpectedly. Microsoft Defender SmartScreen could + /// not scan this file. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED, + /// Seeking past the end of a file in opening a file, as part of resuming an + /// interrupted download. The file did not exist or was not as large as + /// expected. Partially downloaded file was truncated or deleted, and download + /// will be restarted automatically. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_TOO_SHORT, + /// Partial file did not match the expected hash and was deleted. Download + /// will be restarted automatically. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_HASH_MISMATCH, + /// Generic network error. User can retry the download manually. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, + /// Network operation timed out. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, + /// Network connection lost. User can retry the download manually. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED, + /// Server has gone down. User can retry the download manually. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_NETWORK_SERVER_DOWN, + /// Network request invalid because original or redirected URI is invalid, has + /// an unsupported scheme, or is disallowed by network policy. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST, + /// Generic server error. User can retry the download manually. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, + /// Server does not support range requests. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE, + /// Server does not have the requested data. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, + /// Server did not authorize access to resource. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED, + /// Server certificate problem. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_CERTIFICATE_PROBLEM, + /// Server access forbidden. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_FORBIDDEN, + /// Unexpected server response. Responding server may not be intended server. + /// User can retry the download manually. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_UNEXPECTED_RESPONSE, + /// Server sent fewer bytes than the Content-Length header. Content-length + /// header may be invalid or connection may have closed. Download is treated + /// as complete unless there are + /// [strong validators](https://tools.ietf.org/html/rfc7232#section-2) present + /// to interrupt the download. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_CONTENT_LENGTH_MISMATCH, + /// Unexpected cross-origin redirect. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_CROSS_ORIGIN_REDIRECT, + /// User canceled the download. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_USER_CANCELED, + /// User shut down the WebView. Resuming downloads that were interrupted + /// during shutdown is not yet supported. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN, + /// User paused the download. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_USER_PAUSED, + /// WebView crashed. + COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_DOWNLOAD_PROCESS_CRASHED, +} COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON; + +/// State of the download operation. +[v1_enum] +typedef enum COREWEBVIEW2_DOWNLOAD_STATE { + /// The download is in progress. + COREWEBVIEW2_DOWNLOAD_STATE_IN_PROGRESS, + /// The connection with the file host was broken. The `InterruptReason` property + /// can be accessed from `ICoreWebView2DownloadOperation`. See + /// `COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON` for descriptions of kinds of + /// interrupt reasons. Host can check whether an interrupted download can be + /// resumed with the `CanResume` property on the `ICoreWebView2DownloadOperation`. + /// Once resumed, a download is in the `COREWEBVIEW2_DOWNLOAD_STATE_IN_PROGRESS` state. + COREWEBVIEW2_DOWNLOAD_STATE_INTERRUPTED, + /// The download completed successfully. + COREWEBVIEW2_DOWNLOAD_STATE_COMPLETED, +} COREWEBVIEW2_DOWNLOAD_STATE; + +/// Specifies the image format to use for favicon. +[v1_enum] +typedef enum COREWEBVIEW2_FAVICON_IMAGE_FORMAT { + /// Indicates that the PNG image format is used. + COREWEBVIEW2_FAVICON_IMAGE_FORMAT_PNG, + /// Indicates the JPEG image format is used. + COREWEBVIEW2_FAVICON_IMAGE_FORMAT_JPEG, +} COREWEBVIEW2_FAVICON_IMAGE_FORMAT; + +/// Kind of CoreWebView2FileSystemHandle as described in +/// [FileSystemHandle.kind](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/kind) +[v1_enum] +typedef enum COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND { + /// FileSystemHandle is for a file + /// (i.e. [FileSystemFileHandle](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle)) + COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND_FILE, + /// FileSystemHandle is for a directory + /// (i.e. [FileSystemDirectoryHandle](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle)) + COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND_DIRECTORY, +} COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND; + +/// Allowed permissions of a CoreWebView2FileSystemHandle as described in +/// [FileSystemHandle.requestPermission()](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/requestPermission) +[v1_enum] +typedef enum COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION { + /// Read-only permission for FileSystemHandle + COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION_READ_ONLY, + /// Read and write permissions for FileSystemHandle + COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION_READ_WRITE, +} COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION; + +/// Indicates the frame type used in the `ICoreWebView2FrameInfo` interface. +[v1_enum] +typedef enum COREWEBVIEW2_FRAME_KIND { + /// Indicates that the frame is an unknown type frame. We may extend this enum + /// type to identify more frame kinds in the future. + COREWEBVIEW2_FRAME_KIND_UNKNOWN, + /// Indicates that the frame is a primary main frame(webview). + COREWEBVIEW2_FRAME_KIND_MAIN_FRAME, + /// Indicates that the frame is an iframe. + COREWEBVIEW2_FRAME_KIND_IFRAME, + /// Indicates that the frame is an embed element. + COREWEBVIEW2_FRAME_KIND_EMBED, + /// Indicates that the frame is an object element. + COREWEBVIEW2_FRAME_KIND_OBJECT, +} COREWEBVIEW2_FRAME_KIND; + +/// Kind of cross origin resource access allowed for host resources during download. +/// Note that other normal access checks like same origin DOM access check and [Content +/// Security Policy](https://developer.mozilla.org/docs/Web/HTTP/CSP) still apply. +/// The following table illustrates the host resource cross origin access according to +/// access context and `COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND`. +/// +/// Cross Origin Access Context | DENY | ALLOW | DENY_CORS +/// --- | --- | --- | --- +/// From DOM like src of img, script or iframe element| Deny | Allow | Allow +/// From Script like Fetch or XMLHttpRequest| Deny | Allow | Deny +[v1_enum] +typedef enum COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND { + /// All cross origin resource access is denied, including normal sub resource access + /// as src of a script or image element. + COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY, + /// All cross origin resource access is allowed, including accesses that are + /// subject to Cross-Origin Resource Sharing(CORS) check. The behavior is similar to + /// a web site sends back http header Access-Control-Allow-Origin: *. + COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_ALLOW, + /// Cross origin resource access is allowed for normal sub resource access like + /// as src of a script or image element, while any access that subjects to CORS check + /// will be denied. + /// See [Cross-Origin Resource Sharing](https://developer.mozilla.org/docs/Web/HTTP/CORS) + /// for more information. + COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY_CORS, +} COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND; + +/// Specifies the key event type that triggered an `AcceleratorKeyPressed` +/// event. +[v1_enum] +typedef enum COREWEBVIEW2_KEY_EVENT_KIND { + /// Specifies that the key event type corresponds to window message + /// `WM_KEYDOWN`. + COREWEBVIEW2_KEY_EVENT_KIND_KEY_DOWN, + /// Specifies that the key event type corresponds to window message + /// `WM_KEYUP`. + COREWEBVIEW2_KEY_EVENT_KIND_KEY_UP, + /// Specifies that the key event type corresponds to window message + /// `WM_SYSKEYDOWN`. + COREWEBVIEW2_KEY_EVENT_KIND_SYSTEM_KEY_DOWN, + /// Specifies that the key event type corresponds to window message + /// `WM_SYSKEYUP`. + COREWEBVIEW2_KEY_EVENT_KIND_SYSTEM_KEY_UP, +} COREWEBVIEW2_KEY_EVENT_KIND; + +/// Specifies memory usage target level of WebView. +[v1_enum] +typedef enum COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL { + /// Specifies normal memory usage target level. + COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL_NORMAL, + /// Specifies low memory usage target level. + /// Used for inactivate WebView for reduced memory consumption. + COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL_LOW, +} COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL; + +/// Mouse event type used by SendMouseInput to convey the type of mouse event +/// being sent to WebView. The values of this enum align with the matching +/// WM_* window messages. +[v1_enum] +typedef enum COREWEBVIEW2_MOUSE_EVENT_KIND { + /// Mouse horizontal wheel scroll event, WM_MOUSEHWHEEL. + COREWEBVIEW2_MOUSE_EVENT_KIND_HORIZONTAL_WHEEL = 526, + /// Left button double click mouse event, WM_LBUTTONDBLCLK. + COREWEBVIEW2_MOUSE_EVENT_KIND_LEFT_BUTTON_DOUBLE_CLICK = 515, + /// Left button down mouse event, WM_LBUTTONDOWN. + COREWEBVIEW2_MOUSE_EVENT_KIND_LEFT_BUTTON_DOWN = 513, + /// Left button up mouse event, WM_LBUTTONUP. + COREWEBVIEW2_MOUSE_EVENT_KIND_LEFT_BUTTON_UP = 514, + /// Mouse leave event, WM_MOUSELEAVE. + COREWEBVIEW2_MOUSE_EVENT_KIND_LEAVE = 675, + /// Middle button double click mouse event, WM_MBUTTONDBLCLK. + COREWEBVIEW2_MOUSE_EVENT_KIND_MIDDLE_BUTTON_DOUBLE_CLICK = 521, + /// Middle button down mouse event, WM_MBUTTONDOWN. + COREWEBVIEW2_MOUSE_EVENT_KIND_MIDDLE_BUTTON_DOWN = 519, + /// Middle button up mouse event, WM_MBUTTONUP. + COREWEBVIEW2_MOUSE_EVENT_KIND_MIDDLE_BUTTON_UP = 520, + /// Mouse move event, WM_MOUSEMOVE. + COREWEBVIEW2_MOUSE_EVENT_KIND_MOVE = 512, + /// Right button double click mouse event, WM_RBUTTONDBLCLK. + COREWEBVIEW2_MOUSE_EVENT_KIND_RIGHT_BUTTON_DOUBLE_CLICK = 518, + /// Right button down mouse event, WM_RBUTTONDOWN. + COREWEBVIEW2_MOUSE_EVENT_KIND_RIGHT_BUTTON_DOWN = 516, + /// Right button up mouse event, WM_RBUTTONUP. + COREWEBVIEW2_MOUSE_EVENT_KIND_RIGHT_BUTTON_UP = 517, + /// Mouse wheel scroll event, WM_MOUSEWHEEL. + COREWEBVIEW2_MOUSE_EVENT_KIND_WHEEL = 522, + /// First or second X button double click mouse event, WM_XBUTTONDBLCLK. + COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_DOUBLE_CLICK = 525, + /// First or second X button down mouse event, WM_XBUTTONDOWN. + COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_DOWN = 523, + /// First or second X button up mouse event, WM_XBUTTONUP. + COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_UP = 524, + /// Mouse Right Button Down event over a nonclient area, WM_NCRBUTTONDOWN. + COREWEBVIEW2_MOUSE_EVENT_KIND_NON_CLIENT_RIGHT_BUTTON_DOWN = 164, + /// Mouse Right Button up event over a nonclient area, WM_NCRBUTTONUP. + COREWEBVIEW2_MOUSE_EVENT_KIND_NON_CLIENT_RIGHT_BUTTON_UP = 165, +} COREWEBVIEW2_MOUSE_EVENT_KIND; + +/// Mouse event virtual keys associated with a COREWEBVIEW2_MOUSE_EVENT_KIND for +/// SendMouseInput. These values can be combined into a bit flag if more than +/// one virtual key is pressed for the event. The values of this enum align +/// with the matching MK_* mouse keys. +[v1_enum] +typedef enum COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS { + /// No additional keys pressed. + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_NONE = 0x0, + /// Left mouse button is down, MK_LBUTTON. + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_LEFT_BUTTON = 0x1, + /// Right mouse button is down, MK_RBUTTON. + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_RIGHT_BUTTON = 0x2, + /// SHIFT key is down, MK_SHIFT. + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_SHIFT = 0x4, + /// CTRL key is down, MK_CONTROL. + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_CONTROL = 0x8, + /// Middle mouse button is down, MK_MBUTTON. + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_MIDDLE_BUTTON = 0x10, + /// First X button is down, MK_XBUTTON1 + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_X_BUTTON1 = 0x20, + /// Second X button is down, MK_XBUTTON2 + COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS_X_BUTTON2 = 0x40, +} COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS; +cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS)") + +/// Specifies the reason for moving focus. +[v1_enum] +typedef enum COREWEBVIEW2_MOVE_FOCUS_REASON { + /// Specifies that the code is setting focus into WebView. + COREWEBVIEW2_MOVE_FOCUS_REASON_PROGRAMMATIC, + /// Specifies that the focus is moving due to Tab traversal forward. + COREWEBVIEW2_MOVE_FOCUS_REASON_NEXT, + /// Specifies that the focus is moving due to Tab traversal backward. + COREWEBVIEW2_MOVE_FOCUS_REASON_PREVIOUS, +} COREWEBVIEW2_MOVE_FOCUS_REASON; + +/// Specifies the navigation kind of each navigation. +[v1_enum] +typedef enum COREWEBVIEW2_NAVIGATION_KIND { + /// A navigation caused by `CoreWebView2.Reload()`, `location.reload()`, the end user + /// using F5 or other UX, or other reload mechanisms to reload the current document + /// without modifying the navigation history. + COREWEBVIEW2_NAVIGATION_KIND_RELOAD, + /// A navigation back or forward to a different entry in the session navigation history, + /// like via `CoreWebView2.Back()`, `location.back()`, the end user pressing Alt+Left + /// or other UX, or other mechanisms to navigate back or forward in the current + /// session navigation history. + /// + COREWEBVIEW2_NAVIGATION_KIND_BACK_OR_FORWARD, + /// A navigation to another document, which can be caused by `CoreWebView2.Navigate()`, + /// `window.location.href = ...`, or other WebView2 or DOM APIs that navigate to a new URI. + COREWEBVIEW2_NAVIGATION_KIND_NEW_DOCUMENT, +} COREWEBVIEW2_NAVIGATION_KIND; + +/// This enum contains values representing possible regions a given +/// point lies within +[v1_enum] +typedef enum COREWEBVIEW2_NON_CLIENT_REGION_KIND { + /// A hit test region out of bounds of the WebView2. + /// This has the same value as the Win32 HTNOWHERE + COREWEBVIEW2_NON_CLIENT_REGION_KIND_NOWHERE, + /// A hit test region in the WebView2 which does not have the CSS style + /// `-webkit-app-region: drag` set. This is normal web content that should not be + /// considered part of the app window's title bar. This has the same value + /// as the Win32 HTCLIENT constant. + COREWEBVIEW2_NON_CLIENT_REGION_KIND_CLIENT, + /// A hit test region in the WebView2 which has the CSS style + /// `-webkit-app-region: drag` set. Web content should use this CSS + /// style to identify regions that should be treated like the app + /// window's title bar. This has the same value as the Win32 HTCAPTION + /// constant. + COREWEBVIEW2_NON_CLIENT_REGION_KIND_CAPTION, +} COREWEBVIEW2_NON_CLIENT_REGION_KIND; + +/// Specifies the PDF toolbar item types used for the `ICoreWebView2Settings::put_HiddenPdfToolbarItems` method. +[v1_enum] +typedef enum COREWEBVIEW2_PDF_TOOLBAR_ITEMS { + /// No item. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_NONE = 0x0, + /// The save button. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_SAVE = 0x1, + /// The print button. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_PRINT = 0x2, + /// The save as button. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_SAVE_AS = 0x4, + /// The zoom in button. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_ZOOM_IN = 0x8, + /// The zoom out button. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_ZOOM_OUT = 0x10, + /// The rotate button. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_ROTATE = 0x20, + /// The fit page button. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_FIT_PAGE = 0x40, + /// The page layout button. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_PAGE_LAYOUT = 0x80, + /// The bookmarks button. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_BOOKMARKS = 0x100, + /// The page select button. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_PAGE_SELECTOR = 0x200, + /// The search button. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_SEARCH = 0x400, + /// The full screen button. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_FULL_SCREEN = 0x800, + /// The more settings button. + COREWEBVIEW2_PDF_TOOLBAR_ITEMS_MORE_SETTINGS = 0x1000, +} COREWEBVIEW2_PDF_TOOLBAR_ITEMS; +cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(COREWEBVIEW2_PDF_TOOLBAR_ITEMS)") + +/// Indicates the type of a permission request. +[v1_enum] +typedef enum COREWEBVIEW2_PERMISSION_KIND { + /// Indicates an unknown permission. + COREWEBVIEW2_PERMISSION_KIND_UNKNOWN_PERMISSION, + /// Indicates permission to capture audio. + COREWEBVIEW2_PERMISSION_KIND_MICROPHONE, + /// Indicates permission to capture video. + COREWEBVIEW2_PERMISSION_KIND_CAMERA, + /// Indicates permission to access geolocation. + COREWEBVIEW2_PERMISSION_KIND_GEOLOCATION, + /// Indicates permission to send web notifications. Apps that would like to + /// show notifications should handle `PermissionRequested` events + /// and no browser permission prompt will be shown for notification requests. + /// Note that push notifications are currently unavailable in WebView2. + COREWEBVIEW2_PERMISSION_KIND_NOTIFICATIONS, + /// Indicates permission to access generic sensor. Generic Sensor covering + /// ambient-light-sensor, accelerometer, gyroscope, and magnetometer. + COREWEBVIEW2_PERMISSION_KIND_OTHER_SENSORS, + /// Indicates permission to read the system clipboard without a user gesture. + COREWEBVIEW2_PERMISSION_KIND_CLIPBOARD_READ, + /// Indicates permission to automatically download multiple files. Permission + /// is requested when multiple downloads are triggered in quick succession. + COREWEBVIEW2_PERMISSION_KIND_MULTIPLE_AUTOMATIC_DOWNLOADS, + /// Indicates permission to read and write to files or folders on the device. + /// Permission is requested when developers use the [File System Access API](https://developer.mozilla.org/docs/Web/API/File_System_Access_API) + /// to show the file or folder picker to the end user, and then request + /// "readwrite" permission for the user's selection. + COREWEBVIEW2_PERMISSION_KIND_FILE_READ_WRITE, + /// Indicates permission to play audio and video automatically on sites. This + /// permission affects the autoplay attribute and play method of the audio and + /// video HTML elements, and the start method of the Web Audio API. See the + /// [Autoplay guide for media and Web Audio APIs](https://developer.mozilla.org/docs/Web/Media/Autoplay_guide) for details. + COREWEBVIEW2_PERMISSION_KIND_AUTOPLAY, + /// Indicates permission to use fonts on the device. Permission is requested + /// when developers use the [Local Font Access API](https://wicg.github.io/local-font-access/) + /// to query the system fonts available for styling web content. + COREWEBVIEW2_PERMISSION_KIND_LOCAL_FONTS, + /// Indicates permission to send and receive system exclusive messages to/from MIDI + /// (Musical Instrument Digital Interface) devices. Permission is requested + /// when developers use the [Web MIDI API](https://developer.mozilla.org/docs/Web/API/Web_MIDI_API) + /// to request access to system exclusive MIDI messages. + COREWEBVIEW2_PERMISSION_KIND_MIDI_SYSTEM_EXCLUSIVE_MESSAGES, + /// Indicates permission to open and place windows on the screen. Permission is + /// requested when developers use the [Multi-Screen Window Placement API](https://www.w3.org/TR/window-placement/) + /// to get screen details. + COREWEBVIEW2_PERMISSION_KIND_WINDOW_MANAGEMENT, +} COREWEBVIEW2_PERMISSION_KIND; + +/// Specifies the response to a permission request. +[v1_enum] +typedef enum COREWEBVIEW2_PERMISSION_STATE { + /// Specifies that the default browser behavior is used, which normally + /// prompt users for decision. + COREWEBVIEW2_PERMISSION_STATE_DEFAULT, + /// Specifies that the permission request is granted. + COREWEBVIEW2_PERMISSION_STATE_ALLOW, + /// Specifies that the permission request is denied. + COREWEBVIEW2_PERMISSION_STATE_DENY, +} COREWEBVIEW2_PERMISSION_STATE; + +/// Pointer event type used by SendPointerInput to convey the type of pointer +/// event being sent to WebView. The values of this enum align with the +/// matching WM_POINTER* window messages. +[v1_enum] +typedef enum COREWEBVIEW2_POINTER_EVENT_KIND { + /// Corresponds to WM_POINTERACTIVATE. + COREWEBVIEW2_POINTER_EVENT_KIND_ACTIVATE = 587, + /// Corresponds to WM_POINTERDOWN. + COREWEBVIEW2_POINTER_EVENT_KIND_DOWN = 582, + /// Corresponds to WM_POINTERENTER. + COREWEBVIEW2_POINTER_EVENT_KIND_ENTER = 585, + /// Corresponds to WM_POINTERLEAVE. + COREWEBVIEW2_POINTER_EVENT_KIND_LEAVE = 586, + /// Corresponds to WM_POINTERUP. + COREWEBVIEW2_POINTER_EVENT_KIND_UP = 583, + /// Corresponds to WM_POINTERUPDATE. + COREWEBVIEW2_POINTER_EVENT_KIND_UPDATE = 581, +} COREWEBVIEW2_POINTER_EVENT_KIND; + +/// An enum to represent the options for WebView2 color scheme: auto, light, or dark. +[v1_enum] +typedef enum COREWEBVIEW2_PREFERRED_COLOR_SCHEME { + /// Auto color scheme. + COREWEBVIEW2_PREFERRED_COLOR_SCHEME_AUTO, + /// Light color scheme. + COREWEBVIEW2_PREFERRED_COLOR_SCHEME_LIGHT, + /// Dark color scheme. + COREWEBVIEW2_PREFERRED_COLOR_SCHEME_DARK, +} COREWEBVIEW2_PREFERRED_COLOR_SCHEME; + +/// Specifies the collation for a print. +[v1_enum] +typedef enum COREWEBVIEW2_PRINT_COLLATION { + /// The default collation for a printer. + COREWEBVIEW2_PRINT_COLLATION_DEFAULT, + /// Indicate that the collation has been selected for the printed output. + COREWEBVIEW2_PRINT_COLLATION_COLLATED, + /// Indicate that the collation has not been selected for the printed output. + COREWEBVIEW2_PRINT_COLLATION_UNCOLLATED, +} COREWEBVIEW2_PRINT_COLLATION; + +/// Specifies the color mode for a print. +[v1_enum] +typedef enum COREWEBVIEW2_PRINT_COLOR_MODE { + /// The default color mode for a printer. + COREWEBVIEW2_PRINT_COLOR_MODE_DEFAULT, + /// Indicate that the printed output will be in color. + COREWEBVIEW2_PRINT_COLOR_MODE_COLOR, + /// Indicate that the printed output will be in shades of gray. + COREWEBVIEW2_PRINT_COLOR_MODE_GRAYSCALE, +} COREWEBVIEW2_PRINT_COLOR_MODE; + +/// Specifies the print dialog kind. +[v1_enum] +typedef enum COREWEBVIEW2_PRINT_DIALOG_KIND { + /// Opens the browser print preview dialog. + COREWEBVIEW2_PRINT_DIALOG_KIND_BROWSER, + /// Opens the system print dialog. + COREWEBVIEW2_PRINT_DIALOG_KIND_SYSTEM, +} COREWEBVIEW2_PRINT_DIALOG_KIND; + +/// Specifies the duplex option for a print. +[v1_enum] +typedef enum COREWEBVIEW2_PRINT_DUPLEX { + /// The default duplex for a printer. + COREWEBVIEW2_PRINT_DUPLEX_DEFAULT, + /// Print on only one side of the sheet. + COREWEBVIEW2_PRINT_DUPLEX_ONE_SIDED, + /// Print on both sides of the sheet, flipped along the long edge. + COREWEBVIEW2_PRINT_DUPLEX_TWO_SIDED_LONG_EDGE, + /// Print on both sides of the sheet, flipped along the short edge. + COREWEBVIEW2_PRINT_DUPLEX_TWO_SIDED_SHORT_EDGE, +} COREWEBVIEW2_PRINT_DUPLEX; + +/// Specifies the media size for a print. +[v1_enum] +typedef enum COREWEBVIEW2_PRINT_MEDIA_SIZE { + /// The default media size for a printer. + COREWEBVIEW2_PRINT_MEDIA_SIZE_DEFAULT, + /// Indicate custom media size that is specific to the printer. + COREWEBVIEW2_PRINT_MEDIA_SIZE_CUSTOM, +} COREWEBVIEW2_PRINT_MEDIA_SIZE; + +/// The orientation for printing, used by the `Orientation` property on +/// `ICoreWebView2PrintSettings`. +[v1_enum] +typedef enum COREWEBVIEW2_PRINT_ORIENTATION { + /// Print the page(s) in portrait orientation. + COREWEBVIEW2_PRINT_ORIENTATION_PORTRAIT, + /// Print the page(s) in landscape orientation. + COREWEBVIEW2_PRINT_ORIENTATION_LANDSCAPE, +} COREWEBVIEW2_PRINT_ORIENTATION; + +/// Indicates the status for printing. +[v1_enum] +typedef enum COREWEBVIEW2_PRINT_STATUS { + /// Indicates that the print operation is succeeded. + COREWEBVIEW2_PRINT_STATUS_SUCCEEDED, + /// Indicates that the printer is not available. + COREWEBVIEW2_PRINT_STATUS_PRINTER_UNAVAILABLE, + /// Indicates that the print operation is failed. + COREWEBVIEW2_PRINT_STATUS_OTHER_ERROR, +} COREWEBVIEW2_PRINT_STATUS; + +/// Specifies the process failure type used in the +/// `ICoreWebView2ProcessFailedEventArgs` interface. The values in this enum +/// make reference to the process kinds in the Chromium architecture. For more +/// information about what these processes are and what they do, see +/// [Browser Architecture - Inside look at modern web browser](https://developers.google.com/web/updates/2018/09/inside-browser-part1). +[v1_enum] +typedef enum COREWEBVIEW2_PROCESS_FAILED_KIND { + /// Indicates that the browser process ended unexpectedly. The WebView + /// automatically moves to the Closed state. The app has to recreate a new + /// WebView to recover from this failure. + COREWEBVIEW2_PROCESS_FAILED_KIND_BROWSER_PROCESS_EXITED, + /// Indicates that the main frame's render process ended unexpectedly. Any + /// subframes in the WebView will be gone too. A new render process is + /// created automatically and navigated to an error page. You can use the + /// `Reload` method to try to recover from this failure. Alternatively, you + /// can `Close` and recreate the WebView. + COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_EXITED, + /// Indicates that the main frame's render process is unresponsive. Renderer + /// process unresponsiveness can happen for the following reasons: + /// + /// * There is a **long-running script** being executed. For example, the + /// web content in your WebView might be performing a synchronous XHR, or have + /// entered an infinite loop. + /// * The **system is busy**. + /// + /// The `ProcessFailed` event will continue to be raised every few seconds + /// until the renderer process has become responsive again. The application + /// can consider taking action if the event keeps being raised. For example, + /// the application might show UI for the user to decide to keep waiting or + /// reload the page, or navigate away. + COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_UNRESPONSIVE, + /// Indicates that a frame-only render process ended unexpectedly. The process + /// exit does not affect the top-level document, only a subset of the + /// subframes within it. The content in these frames is replaced with an error + /// page in the frame. Your application can communicate with the main frame to + /// recover content in the impacted frames, using + /// `ICoreWebView2ProcessFailedEventArgs2::FrameInfosForFailedProcess` to get + /// information about the impacted frames. + COREWEBVIEW2_PROCESS_FAILED_KIND_FRAME_RENDER_PROCESS_EXITED, + /// Indicates that a utility process ended unexpectedly. The failed process + /// is recreated automatically. Your application does **not** need to handle + /// recovery for this event, but can use `ICoreWebView2ProcessFailedEventArgs` + /// and `ICoreWebView2ProcessFailedEventArgs2` to collect information about + /// the failure, including `ProcessDescription`. + COREWEBVIEW2_PROCESS_FAILED_KIND_UTILITY_PROCESS_EXITED, + /// Indicates that a sandbox helper process ended unexpectedly. This failure + /// is not fatal. Your application does **not** need to handle recovery for + /// this event, but can use `ICoreWebView2ProcessFailedEventArgs` and + /// `ICoreWebView2ProcessFailedEventArgs2` to collect information about + /// the failure. + COREWEBVIEW2_PROCESS_FAILED_KIND_SANDBOX_HELPER_PROCESS_EXITED, + /// Indicates that the GPU process ended unexpectedly. The failed process + /// is recreated automatically. Your application does **not** need to handle + /// recovery for this event, but can use `ICoreWebView2ProcessFailedEventArgs` + /// and `ICoreWebView2ProcessFailedEventArgs2` to collect information about + /// the failure. + COREWEBVIEW2_PROCESS_FAILED_KIND_GPU_PROCESS_EXITED, + /// Indicates that a PPAPI plugin process ended unexpectedly. This failure + /// is not fatal. Your application does **not** need to handle recovery for + /// this event, but can use `ICoreWebView2ProcessFailedEventArgs` and + /// `ICoreWebView2ProcessFailedEventArgs2` to collect information about + /// the failure, including `ProcessDescription`. + COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_PLUGIN_PROCESS_EXITED, + /// Indicates that a PPAPI plugin broker process ended unexpectedly. This failure + /// is not fatal. Your application does **not** need to handle recovery for + /// this event, but can use `ICoreWebView2ProcessFailedEventArgs` and + /// `ICoreWebView2ProcessFailedEventArgs2` to collect information about + /// the failure. + COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_BROKER_PROCESS_EXITED, + /// Indicates that a process of unspecified kind ended unexpectedly. Your + /// application can use `ICoreWebView2ProcessFailedEventArgs` and + /// `ICoreWebView2ProcessFailedEventArgs2` to collect information about + /// the failure. + COREWEBVIEW2_PROCESS_FAILED_KIND_UNKNOWN_PROCESS_EXITED, +} COREWEBVIEW2_PROCESS_FAILED_KIND; + +/// Specifies the process failure reason used in the +/// `ICoreWebView2ProcessFailedEventArgs` interface. For process failures where +/// a process has exited, it indicates the type of issue that produced the +/// process exit. +[v1_enum] +typedef enum COREWEBVIEW2_PROCESS_FAILED_REASON { + /// An unexpected process failure occurred. + COREWEBVIEW2_PROCESS_FAILED_REASON_UNEXPECTED, + /// The process became unresponsive. + /// This only applies to the main frame's render process. + COREWEBVIEW2_PROCESS_FAILED_REASON_UNRESPONSIVE, + /// The process was terminated. For example, from Task Manager. + COREWEBVIEW2_PROCESS_FAILED_REASON_TERMINATED, + /// The process crashed. Most crashes will generate dumps in the location + /// indicated by `ICoreWebView2Environment11::get_FailureReportFolderPath`. + COREWEBVIEW2_PROCESS_FAILED_REASON_CRASHED, + /// The process failed to launch. + COREWEBVIEW2_PROCESS_FAILED_REASON_LAUNCH_FAILED, + /// The process terminated due to running out of memory. + COREWEBVIEW2_PROCESS_FAILED_REASON_OUT_OF_MEMORY, + /// The process exited because its corresponding profile was deleted. + COREWEBVIEW2_PROCESS_FAILED_REASON_PROFILE_DELETED, +} COREWEBVIEW2_PROCESS_FAILED_REASON; + +/// Indicates the process type used in the ICoreWebView2ProcessInfo interface. +[v1_enum] +typedef enum COREWEBVIEW2_PROCESS_KIND { + /// Indicates the browser process kind. + COREWEBVIEW2_PROCESS_KIND_BROWSER, + /// Indicates the render process kind. + COREWEBVIEW2_PROCESS_KIND_RENDERER, + /// Indicates the utility process kind. + COREWEBVIEW2_PROCESS_KIND_UTILITY, + /// Indicates the sandbox helper process kind. + COREWEBVIEW2_PROCESS_KIND_SANDBOX_HELPER, + /// Indicates the GPU process kind. + COREWEBVIEW2_PROCESS_KIND_GPU, + /// Indicates the PPAPI plugin process kind. + COREWEBVIEW2_PROCESS_KIND_PPAPI_PLUGIN, + /// Indicates the PPAPI plugin broker process kind. + COREWEBVIEW2_PROCESS_KIND_PPAPI_BROKER, +} COREWEBVIEW2_PROCESS_KIND; + +/// The WebView2 release channels. Use `ReleaseChannels` and `ChannelSearchKind` +/// on `ICoreWebView2EnvironmentOptions` to control which channel is searched +/// for during environment creation. +/// +/// |Channel|Primary purpose|How often updated with new features| +/// |:---:|---|:---:| +/// |Stable (WebView2 Runtime)|Broad Deployment|Monthly| +/// |Beta|Flighting with inner rings, automated testing|Monthly| +/// |Dev|Automated testing, selfhosting to test new APIs and features|Weekly| +/// |Canary|Automated testing, selfhosting to test new APIs and features|Daily| +[v1_enum] +typedef enum COREWEBVIEW2_RELEASE_CHANNELS { + /// No release channel. Passing only this value to `ReleaseChannels` results + /// in HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND). + COREWEBVIEW2_RELEASE_CHANNELS_NONE = 0x0, + /// The stable WebView2 Runtime that is released every 4 weeks. + COREWEBVIEW2_RELEASE_CHANNELS_STABLE = 0x1, + /// The Beta release channel that is released every 4 weeks, a week before the + /// stable release. + COREWEBVIEW2_RELEASE_CHANNELS_BETA = 0x2, + /// The Dev release channel that is released weekly. + COREWEBVIEW2_RELEASE_CHANNELS_DEV = 0x4, + /// The Canary release channel that is released daily. + COREWEBVIEW2_RELEASE_CHANNELS_CANARY = 0x8, +} COREWEBVIEW2_RELEASE_CHANNELS; +cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(COREWEBVIEW2_RELEASE_CHANNELS)") + +/// Specifies Save As kind selection options for +/// `ICoreWebView2SaveAsUIShowingEventArgs`. +/// +/// For HTML documents, we support 3 Save As kinds: HTML_ONLY, SINGLE_FILE and +/// COMPLETE. For non-HTML documents, you must use DEFAULT. MIME types of `text/html` and +/// `application/xhtml+xml` are considered HTML documents. +[v1_enum] +typedef enum COREWEBVIEW2_SAVE_AS_KIND { + /// Default kind to save non-HTML content. If this kind is selected for an HTML + /// page, the behavior is the same as the `HTML_ONLY` kind. + COREWEBVIEW2_SAVE_AS_KIND_DEFAULT, + /// Save the page as HTML. Only the top-level document is saved, excluding + /// subresources. + COREWEBVIEW2_SAVE_AS_KIND_HTML_ONLY, + /// Save the page as [MHTML](https://en.wikipedia.org/wiki/MHTML). + COREWEBVIEW2_SAVE_AS_KIND_SINGLE_FILE, + /// Save the page as HTML and download the page-related source files + /// (for example: CSS, JavaScript, images, etc.) in a directory with + /// the same filename prefix. + COREWEBVIEW2_SAVE_AS_KIND_COMPLETE, +} COREWEBVIEW2_SAVE_AS_KIND; + +/// Status of a programmatic Save As call. Indicates the result +/// of the `ShowSaveAsUI` method. +[v1_enum] +typedef enum COREWEBVIEW2_SAVE_AS_UI_RESULT { + /// The ShowSaveAsUI method call completed successfully. By default, the system + /// Save As dialog opens. If `SuppressDefaultDialog` is set to TRUE, the system + /// dialog is skipped. + COREWEBVIEW2_SAVE_AS_UI_RESULT_SUCCESS, + /// Could not perform Save As because the destination file path is an invalid path. + /// + /// The path is invalid when it is empty, a relative path, or a directory, + /// or when the parent path does not exist. + COREWEBVIEW2_SAVE_AS_UI_RESULT_INVALID_PATH, + /// Could not perform Save As because the destination file path already exists and + /// replacing files was not allowed by the `AllowReplace` property. + COREWEBVIEW2_SAVE_AS_UI_RESULT_FILE_ALREADY_EXISTS, + /// Could not perform Save As because the `Kind` property selection is not + /// supported due to content MIME type or system limits. + /// + /// See the `COREWEBVIEW2_SAVE_AS_KIND` enum for MIME type limits. + /// + /// System limits include when the `HTML_ONLY` kind is selected for an error page + /// at child mode, or when the `COMPLETE` kind is selected and the WebView is + /// running in an App Container. + COREWEBVIEW2_SAVE_AS_UI_RESULT_KIND_NOT_SUPPORTED, + /// Did not perform Save As because the end user cancelled or the + /// `Cancel` property on `ICoreWebView2SaveAsUIShowingEventArgs` was set to TRUE. + COREWEBVIEW2_SAVE_AS_UI_RESULT_CANCELLED, +} COREWEBVIEW2_SAVE_AS_UI_RESULT; + +/// Specifies the JavaScript dialog type used in the +/// `ICoreWebView2ScriptDialogOpeningEventHandler` interface. +[v1_enum] +typedef enum COREWEBVIEW2_SCRIPT_DIALOG_KIND { + /// Indicates that the dialog uses the `window.alert` JavaScript function. + COREWEBVIEW2_SCRIPT_DIALOG_KIND_ALERT, + /// Indicates that the dialog uses the `window.confirm` JavaScript function. + COREWEBVIEW2_SCRIPT_DIALOG_KIND_CONFIRM, + /// Indicates that the dialog uses the `window.prompt` JavaScript function. + COREWEBVIEW2_SCRIPT_DIALOG_KIND_PROMPT, + /// Indicates that the dialog uses the `beforeunload` JavaScript event. + COREWEBVIEW2_SCRIPT_DIALOG_KIND_BEFOREUNLOAD, +} COREWEBVIEW2_SCRIPT_DIALOG_KIND; + +/// Set ScrollBar style on `ICoreWebView2EnvironmentOptions` during environment creation. +[v1_enum] +typedef enum COREWEBVIEW2_SCROLLBAR_STYLE { + /// Browser default ScrollBar style + COREWEBVIEW2_SCROLLBAR_STYLE_DEFAULT, + /// Window style fluent overlay scroll bar + /// Please see [Fluent UI](https://developer.microsoft.com/fluentui#/) + /// for more details on fluent UI. + COREWEBVIEW2_SCROLLBAR_STYLE_FLUENT_OVERLAY, +} COREWEBVIEW2_SCROLLBAR_STYLE; + +/// Specifies the action type when server certificate error is detected to be +/// used in the `ICoreWebView2ServerCertificateErrorDetectedEventArgs` +/// interface. +[v1_enum] +typedef enum COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION { + /// Indicates to ignore the warning and continue the request with the TLS + /// certificate. This decision is cached for the RequestUri's host and the + /// server certificate in the session. + COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION_ALWAYS_ALLOW, + /// Indicates to reject the certificate and cancel the request. + COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION_CANCEL, + /// Indicates to display the default TLS interstitial error page to user for + /// page navigations. + /// For others TLS certificate is rejected and the request is cancelled. + COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION_DEFAULT, +} COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION; + +/// Specifies the desired access from script to `CoreWebView2SharedBuffer`. +[v1_enum] +typedef enum COREWEBVIEW2_SHARED_BUFFER_ACCESS { + /// Script from web page only has read access to the shared buffer. + COREWEBVIEW2_SHARED_BUFFER_ACCESS_READ_ONLY, + /// Script from web page has read and write access to the shared buffer. + COREWEBVIEW2_SHARED_BUFFER_ACCESS_READ_WRITE, +} COREWEBVIEW2_SHARED_BUFFER_ACCESS; + +/// Indicates the text direction of the notification. +[v1_enum] +typedef enum COREWEBVIEW2_TEXT_DIRECTION_KIND { + /// Indicates that the notification text direction adopts the browser's language setting behavior. + COREWEBVIEW2_TEXT_DIRECTION_KIND_DEFAULT, + /// Indicates that the notification text is left-to-right. + COREWEBVIEW2_TEXT_DIRECTION_KIND_LEFT_TO_RIGHT, + /// Indicates that the notification text is right-to-left. + COREWEBVIEW2_TEXT_DIRECTION_KIND_RIGHT_TO_LEFT, +} COREWEBVIEW2_TEXT_DIRECTION_KIND; + +/// Tracking prevention levels. +[v1_enum] +typedef enum COREWEBVIEW2_TRACKING_PREVENTION_LEVEL { + /// Tracking prevention is turned off. + COREWEBVIEW2_TRACKING_PREVENTION_LEVEL_NONE, + /// The least restrictive level of tracking prevention. Set to this level to + /// protect against malicious trackers but allows most other trackers and + /// personalize content and ads. + /// + /// See [Current tracking prevention + /// behavior](/microsoft-edge/web-platform/tracking-prevention#current-tracking-prevention-behavior) + /// for fine-grained information on what is being blocked with this level and + /// can change with different Edge versions. + COREWEBVIEW2_TRACKING_PREVENTION_LEVEL_BASIC, + /// The default level of tracking prevention. Set to this level to + /// protect against social media tracking on top of malicious trackers. + /// Content and ads will likely be less personalized. + /// + /// See [Current tracking prevention + /// behavior](/microsoft-edge/web-platform/tracking-prevention#current-tracking-prevention-behavior) + /// for fine-grained information on what is being blocked with this level and + /// can change with different Edge versions. + COREWEBVIEW2_TRACKING_PREVENTION_LEVEL_BALANCED, + /// The most restrictive level of tracking prevention. Set to this level to + /// protect + /// against malicious trackers and most trackers across sites. Content and ads + /// will likely have minimal personalization. + /// + /// This level blocks the most trackers but could cause some websites to not + /// behave as expected. + /// + /// See [Current tracking prevention + /// behavior](/microsoft-edge/web-platform/tracking-prevention#current-tracking-prevention-behavior) + /// for fine-grained information on what is being blocked with this level and + /// can change with different Edge versions. + COREWEBVIEW2_TRACKING_PREVENTION_LEVEL_STRICT, +} COREWEBVIEW2_TRACKING_PREVENTION_LEVEL; + +/// Indicates the error status values for web navigations. +[v1_enum] +typedef enum COREWEBVIEW2_WEB_ERROR_STATUS { + /// Indicates that an unknown error occurred. + COREWEBVIEW2_WEB_ERROR_STATUS_UNKNOWN, + /// Indicates that the SSL certificate common name does not match the web + /// address. + COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_COMMON_NAME_IS_INCORRECT, + /// Indicates that the SSL certificate has expired. + COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_EXPIRED, + /// Indicates that the SSL client certificate contains errors. + COREWEBVIEW2_WEB_ERROR_STATUS_CLIENT_CERTIFICATE_CONTAINS_ERRORS, + /// Indicates that the SSL certificate has been revoked. + COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_REVOKED, + /// Indicates that the SSL certificate is not valid. The certificate may not + /// match the public key pins for the host name, the certificate is signed + /// by an untrusted authority or using a weak sign algorithm, the certificate + /// claimed DNS names violate name constraints, the certificate contains a + /// weak key, the validity period of the certificate is too long, lack of + /// revocation information or revocation mechanism, non-unique host name, + /// lack of certificate transparency information, or the certificate is + /// chained to a + /// [legacy Symantec root](https://security.googleblog.com/2018/03/distrust-of-symantec-pki-immediate.html). + COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_IS_INVALID, + /// Indicates that the host is unreachable. + COREWEBVIEW2_WEB_ERROR_STATUS_SERVER_UNREACHABLE, + /// Indicates that the connection has timed out. + COREWEBVIEW2_WEB_ERROR_STATUS_TIMEOUT, + /// Indicates that the server returned an invalid or unrecognized response. + COREWEBVIEW2_WEB_ERROR_STATUS_ERROR_HTTP_INVALID_SERVER_RESPONSE, + /// Indicates that the connection was stopped. + COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_ABORTED, + /// Indicates that the connection was reset. + COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_RESET, + /// Indicates that the Internet connection has been lost. + COREWEBVIEW2_WEB_ERROR_STATUS_DISCONNECTED, + /// Indicates that a connection to the destination was not established. + COREWEBVIEW2_WEB_ERROR_STATUS_CANNOT_CONNECT, + /// Indicates that the provided host name was not able to be resolved. + COREWEBVIEW2_WEB_ERROR_STATUS_HOST_NAME_NOT_RESOLVED, + /// Indicates that the operation was canceled. This status code is also used + /// in the following cases: + /// - When the app cancels a navigation via NavigationStarting event. + /// - For original navigation if the app navigates the WebView2 in a rapid succession + /// away after the load for original navigation commenced, but before it completed. + COREWEBVIEW2_WEB_ERROR_STATUS_OPERATION_CANCELED, + /// Indicates that the request redirect failed. + COREWEBVIEW2_WEB_ERROR_STATUS_REDIRECT_FAILED, + /// Indicates that an unexpected error occurred. + COREWEBVIEW2_WEB_ERROR_STATUS_UNEXPECTED_ERROR, + /// Indicates that user is prompted with a login, waiting on user action. + /// Initial navigation to a login site will always return this even if app provides + /// credential using BasicAuthenticationRequested. + /// HTTP response status code in this case is 401. + /// See status code reference here: https://developer.mozilla.org/docs/Web/HTTP/Status. + COREWEBVIEW2_WEB_ERROR_STATUS_VALID_AUTHENTICATION_CREDENTIALS_REQUIRED, + /// Indicates that user lacks proper authentication credentials for a proxy server. + /// HTTP response status code in this case is 407. + /// See status code reference here: https://developer.mozilla.org/docs/Web/HTTP/Status. + COREWEBVIEW2_WEB_ERROR_STATUS_VALID_PROXY_AUTHENTICATION_REQUIRED, +} COREWEBVIEW2_WEB_ERROR_STATUS; + +/// Specifies the web resource request contexts. +[v1_enum] +typedef enum COREWEBVIEW2_WEB_RESOURCE_CONTEXT { + /// Specifies all resources. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL, + /// Specifies a document resource. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_DOCUMENT, + /// Specifies a CSS resource. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_STYLESHEET, + /// Specifies an image resource. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_IMAGE, + /// Specifies another media resource such as a video. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_MEDIA, + /// Specifies a font resource. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_FONT, + /// Specifies a script resource. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_SCRIPT, + /// Specifies an XML HTTP request, Fetch and EventSource API communication. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_XML_HTTP_REQUEST, + /// Specifies a Fetch API communication. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_FETCH, + /// Specifies a TextTrack resource. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_TEXT_TRACK, + /// Specifies an EventSource API communication. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_EVENT_SOURCE, + /// Specifies a WebSocket API communication. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_WEBSOCKET, + /// Specifies a Web App Manifest. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_MANIFEST, + /// Specifies a Signed HTTP Exchange. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_SIGNED_EXCHANGE, + /// Specifies a Ping request. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_PING, + /// Specifies a CSP Violation Report. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_CSP_VIOLATION_REPORT, + /// Specifies an other resource. + COREWEBVIEW2_WEB_RESOURCE_CONTEXT_OTHER, +} COREWEBVIEW2_WEB_RESOURCE_CONTEXT; + +/// Specifies the source of `WebResourceRequested` event. +[v1_enum] +typedef enum COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS { + /// + COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_NONE = 0x0, + /// Indicates that web resource is requested from main page including dedicated workers and iframes. + COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_DOCUMENT = 0x1, + /// Indicates that web resource is requested from shared worker. + COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_SHARED_WORKER = 0x2, + /// Indicates that web resource is requested from service worker. + COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_SERVICE_WORKER = 0x4, + /// Indicates that web resource is requested from any supported source. + COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_ALL = 0xFFFFFFFF, +} COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS; +cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS)") + + +/// A value representing RGBA color (Red, Green, Blue, Alpha) for WebView2. +/// Each component takes a value from 0 to 255, with 0 being no intensity +/// and 255 being the highest intensity. +typedef struct COREWEBVIEW2_COLOR { + /// Specifies the intensity of the Alpha ie. opacity value. 0 is transparent, + /// 255 is opaque. + BYTE A; + /// Specifies the intensity of the Red color. + BYTE R; + /// Specifies the intensity of the Green color. + BYTE G; + /// Specifies the intensity of the Blue color. + BYTE B; +} COREWEBVIEW2_COLOR; + +/// Contains the information packed into the `LPARAM` sent to a Win32 key +/// event. For more information about `WM_KEYDOWN`, navigate to +/// [WM_KEYDOWN message](/windows/win32/inputdev/wm-keydown). +typedef struct COREWEBVIEW2_PHYSICAL_KEY_STATUS { + /// Specifies the repeat count for the current message. + UINT32 RepeatCount; + /// Specifies the scan code. + UINT32 ScanCode; + /// Indicates that the key is an extended key. + BOOL IsExtendedKey; + /// Indicates that a menu key is held down (context code). + BOOL IsMenuKeyDown; + /// Indicates that the key was held down. + BOOL WasKeyDown; + /// Indicates that the key was released. + BOOL IsKeyReleased; +} COREWEBVIEW2_PHYSICAL_KEY_STATUS; + + +// End of enums and structs + + +/// Receives the result of the `AddScriptToExecuteOnDocumentCreated` method. +[uuid(b99369f3-9b11-47b5-bc6f-8e7895fcea17), object, pointer_default(unique)] +interface ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] LPCWSTR result); +} +/// Receives the result of the `ExecuteScript` method. +[uuid(49511172-cc67-4bca-9923-137112f4c4cc), object, pointer_default(unique)] +interface ICoreWebView2ExecuteScriptCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] LPCWSTR result); +} +/// Receives the result of the `CapturePreview` method. +[uuid(697e05e9-3d8f-45fa-96f4-8ffe1ededaf5), object, pointer_default(unique)] +interface ICoreWebView2CapturePreviewCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode); +} +/// Receives the result of the `CallDevToolsProtocolMethod` method. +[uuid(5c4889f0-5ef6-4c5a-952c-d8f1b92d0574), object, pointer_default(unique)] +interface ICoreWebView2CallDevToolsProtocolMethodCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] LPCWSTR result); +} + +/// Receives `ContainsFullScreenElementChanged` events. +[uuid(e45d98b1-afef-45be-8baf-6c7728867f73), object, pointer_default(unique)] +interface ICoreWebView2ContainsFullScreenElementChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] IUnknown* args); +} +/// Receives `ContentLoading` events. +[uuid(364471e7-f2be-4910-bdba-d72077d51c4b), object, pointer_default(unique)] +interface ICoreWebView2ContentLoadingEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2ContentLoadingEventArgs* args); +} +/// Receives `DocumentTitleChanged` events. +[uuid(f5f2b923-953e-4042-9f95-f3a118e1afd4), object, pointer_default(unique)] +interface ICoreWebView2DocumentTitleChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] IUnknown* args); +} +// Skipping ICoreWebView2NavigationCompletedEventHandler redefinition + +// Skipping ICoreWebView2NavigationStartingEventHandler redefinition + +/// Receives `HistoryChanged` events. +[uuid(c79a420c-efd9-4058-9295-3e8b4bcab645), object, pointer_default(unique)] +interface ICoreWebView2HistoryChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] IUnknown* args); +} +/// Receives `NavigationCompleted` events. +[uuid(d33a35bf-1c49-4f98-93ab-006e0533fe1c), object, pointer_default(unique)] +interface ICoreWebView2NavigationCompletedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2NavigationCompletedEventArgs* args); +} +/// Receives `NavigationStarting` events. +[uuid(9adbe429-f36d-432b-9ddc-f8881fbd76e3), object, pointer_default(unique)] +interface ICoreWebView2NavigationStartingEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2NavigationStartingEventArgs* args); +} +/// Receives `NewWindowRequested` events. +[uuid(d4c185fe-c81c-4989-97af-2d3fa7ab5651), object, pointer_default(unique)] +interface ICoreWebView2NewWindowRequestedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2NewWindowRequestedEventArgs* args); +} +/// Receives `PermissionRequested` events. +[uuid(15e1c6a3-c72a-4df3-91d7-d097fbec6bfd), object, pointer_default(unique)] +interface ICoreWebView2PermissionRequestedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2PermissionRequestedEventArgs* args); +} +/// Receives `ProcessFailed` events. +[uuid(79e0aea4-990b-42d9-aa1d-0fcc2e5bc7f1), object, pointer_default(unique)] +interface ICoreWebView2ProcessFailedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2ProcessFailedEventArgs* args); +} +/// Receives `ScriptDialogOpening` events. +[uuid(ef381bf9-afa8-4e37-91c4-8ac48524bdfb), object, pointer_default(unique)] +interface ICoreWebView2ScriptDialogOpeningEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2ScriptDialogOpeningEventArgs* args); +} +/// Receives `SourceChanged` events. +[uuid(3c067f9f-5388-4772-8b48-79f7ef1ab37c), object, pointer_default(unique)] +interface ICoreWebView2SourceChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2SourceChangedEventArgs* args); +} +/// Receives `WebMessageReceived` events. +[uuid(57213f19-00e6-49fa-8e07-898ea01ecbd2), object, pointer_default(unique)] +interface ICoreWebView2WebMessageReceivedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2WebMessageReceivedEventArgs* args); +} +/// Receives `WebResourceRequested` events. +[uuid(ab00b74c-15f1-4646-80e8-e76341d25d71), object, pointer_default(unique)] +interface ICoreWebView2WebResourceRequestedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2WebResourceRequestedEventArgs* args); +} +/// Receives `WindowCloseRequested` events. +[uuid(5c19e9e0-092f-486b-affa-ca8231913039), object, pointer_default(unique)] +interface ICoreWebView2WindowCloseRequestedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] IUnknown* args); +} + +/// Receives `DOMContentLoaded` events. +[uuid(4bac7e9c-199e-49ed-87ed-249303acf019), object, pointer_default(unique)] +interface ICoreWebView2DOMContentLoadedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2DOMContentLoadedEventArgs* args); +} +/// Receives `WebResourceResponseReceived` events. +[uuid(7de9898a-24f5-40c3-a2de-d4f458e69828), object, pointer_default(unique)] +interface ICoreWebView2WebResourceResponseReceivedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2WebResourceResponseReceivedEventArgs* args); +} + +/// Receives the result of the `TrySuspend` method. +[uuid(00f206a7-9d17-4605-91f6-4e8e4de192e3), object, pointer_default(unique)] +interface ICoreWebView2TrySuspendCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] BOOL result); +} + +/// Receives `DownloadStarting` events. +[uuid(efedc989-c396-41ca-83f7-07f845a55724), object, pointer_default(unique)] +interface ICoreWebView2DownloadStartingEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2DownloadStartingEventArgs* args); +} +/// Receives `FrameCreated` events. +[uuid(38059770-9baa-11eb-a8b3-0242ac130003), object, pointer_default(unique)] +interface ICoreWebView2FrameCreatedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2FrameCreatedEventArgs* args); +} + +/// Receives `IsDocumentPlayingAudioChanged` events. +[uuid(5def109a-2f4b-49fa-b7f6-11c39e513328), object, pointer_default(unique)] +interface ICoreWebView2IsDocumentPlayingAudioChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] IUnknown* args); +} +/// Receives `IsMutedChanged` events. +[uuid(57d90347-cd0e-4952-a4a2-7483a2756f08), object, pointer_default(unique)] +interface ICoreWebView2IsMutedChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] IUnknown* args); +} + +/// Receives `IsDefaultDownloadDialogOpenChanged` events. +[uuid(3117da26-ae13-438d-bd46-edbeb2c4ce81), object, pointer_default(unique)] +interface ICoreWebView2IsDefaultDownloadDialogOpenChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] IUnknown* args); +} + +/// Receives `ContextMenuRequested` events. +[uuid(04d3fe1d-ab87-42fb-a898-da241d35b63c), object, pointer_default(unique)] +interface ICoreWebView2ContextMenuRequestedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2ContextMenuRequestedEventArgs* args); +} + +/// Receives `StatusBarTextChanged` events. +[uuid(a5e3b0d0-10df-4156-bfad-3b43867acac6), object, pointer_default(unique)] +interface ICoreWebView2StatusBarTextChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] IUnknown* args); +} + +/// Receives the result of the `GetFavicon` method. +[uuid(a2508329-7da8-49d7-8c05-fa125e4aee8d), object, pointer_default(unique)] +interface ICoreWebView2GetFaviconCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] IStream* result); +} + +/// Receives `FaviconChanged` events. +[uuid(2913da94-833d-4de0-8dca-900fc524a1a4), object, pointer_default(unique)] +interface ICoreWebView2FaviconChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] IUnknown* args); +} + +/// Receives the result of the `Print` method. +[uuid(8fd80075-ed08-42db-8570-f5d14977461e), object, pointer_default(unique)] +interface ICoreWebView2PrintCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] COREWEBVIEW2_PRINT_STATUS result); +} +/// Receives the result of the `PrintToPdfStream` method. +[uuid(4c9f8229-8f93-444f-a711-2c0dfd6359d5), object, pointer_default(unique)] +interface ICoreWebView2PrintToPdfStreamCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] IStream* result); +} + +/// Receives `CursorChanged` events. +[uuid(9da43ccc-26e1-4dad-b56c-d8961c94c571), object, pointer_default(unique)] +interface ICoreWebView2CursorChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2CompositionController* sender, + [in] IUnknown* args); +} + +/// Receives `NonClientRegionChanged` events. +[uuid(4a794e66-aa6c-46bd-93a3-382196837680), object, pointer_default(unique)] +interface ICoreWebView2NonClientRegionChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2CompositionController* sender, + [in] ICoreWebView2NonClientRegionChangedEventArgs* args); +} + +/// A collection of RECT. +[uuid(333353b8-48bf-4449-8fcc-22697faf5753), object, pointer_default(unique)] +interface ICoreWebView2RegionRectCollectionView : IUnknown { + /// The number of elements contained in the collection. + [propget] HRESULT Count([out, retval] UINT32* value); + + /// Gets the element at the given index. + HRESULT GetValueAtIndex([in] UINT32 index, [out, retval] RECT* value); +} + +/// Receives `AcceleratorKeyPressed` events. +[uuid(b29c7e28-fa79-41a8-8e44-65811c76dcb2), object, pointer_default(unique)] +interface ICoreWebView2AcceleratorKeyPressedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Controller* sender, + [in] ICoreWebView2AcceleratorKeyPressedEventArgs* args); +} +/// Receives `GotFocus` events. +[uuid(05ea24bd-6452-4926-9014-4b82b498135d), object, pointer_default(unique)] +interface ICoreWebView2FocusChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Controller* sender, + [in] IUnknown* args); +} +// Skipping ICoreWebView2FocusChangedEventHandler redefinition + +/// Receives `MoveFocusRequested` events. +[uuid(69035451-6dc7-4cb8-9bce-b2bd70ad289f), object, pointer_default(unique)] +interface ICoreWebView2MoveFocusRequestedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Controller* sender, + [in] ICoreWebView2MoveFocusRequestedEventArgs* args); +} +/// Receives `ZoomFactorChanged` events. +[uuid(b52d71d6-c4df-4543-a90c-64a3e60f38cb), object, pointer_default(unique)] +interface ICoreWebView2ZoomFactorChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Controller* sender, + [in] IUnknown* args); +} + +/// Receives `RasterizationScaleChanged` events. +[uuid(9c98c8b1-ac53-427e-a345-3049b5524bbe), object, pointer_default(unique)] +interface ICoreWebView2RasterizationScaleChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Controller* sender, + [in] IUnknown* args); +} + +/// Receives the result of the `CreateCoreWebView2Controller` method. +[uuid(6c4819f3-c9b7-4260-8127-c9f5bde7f68c), object, pointer_default(unique)] +interface ICoreWebView2CreateCoreWebView2ControllerCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] ICoreWebView2Controller* result); +} + +/// Receives `NewBrowserVersionAvailable` events. +[uuid(f9a2976e-d34e-44fc-adee-81b6b57ca914), object, pointer_default(unique)] +interface ICoreWebView2NewBrowserVersionAvailableEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Environment* sender, + [in] IUnknown* args); +} + +/// Receives the result of the `Remove` method. +[uuid(8e41909a-9b18-4bb1-8cdf-930f467a50be), object, pointer_default(unique)] +interface ICoreWebView2BrowserExtensionRemoveCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode); +} +/// Receives the result of the `Enable` method. +[uuid(30c186ce-7fad-421f-a3bc-a8eaf071ddb8), object, pointer_default(unique)] +interface ICoreWebView2BrowserExtensionEnableCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode); +} + +/// A collection of LPCWSTR. +[uuid(f41f3f8a-bcc3-11eb-8529-0242ac130003), object, pointer_default(unique)] +interface ICoreWebView2StringCollection : IUnknown { + /// The number of elements contained in the collection. + [propget] HRESULT Count([out, retval] UINT32* value); + + /// Gets the element at the given index. + HRESULT GetValueAtIndex([in] UINT32 index, [out, retval] LPWSTR* value); +} + +/// A collection of ICoreWebView2ClientCertificate. +[uuid(ef5674d2-bcc3-11eb-8529-0242ac130003), object, pointer_default(unique)] +interface ICoreWebView2ClientCertificateCollection : IUnknown { + /// The number of elements contained in the collection. + [propget] HRESULT Count([out, retval] UINT32* value); + + /// Gets the element at the given index. + HRESULT GetValueAtIndex([in] UINT32 index, [out, retval] ICoreWebView2ClientCertificate** value); +} + +/// Receives `CustomItemSelected` events. +[uuid(49e1d0bc-fe9e-4481-b7c2-32324aa21998), object, pointer_default(unique)] +interface ICoreWebView2CustomItemSelectedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2ContextMenuItem* sender, + [in] IUnknown* args); +} + +/// Receives the result of the `GetCookies` method. +[uuid(5a4f5069-5c15-47c3-8646-f4de1c116670), object, pointer_default(unique)] +interface ICoreWebView2GetCookiesCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] ICoreWebView2CookieList* result); +} + +/// A collection of ICoreWebView2Cookie. +[uuid(f7f6f714-5d2a-43c6-9503-346ece02d186), object, pointer_default(unique)] +interface ICoreWebView2CookieList : IUnknown { + /// The number of elements contained in the collection. + [propget] HRESULT Count([out, retval] UINT32* value); + + /// Gets the element at the given index. + HRESULT GetValueAtIndex([in] UINT32 index, [out, retval] ICoreWebView2Cookie** value); +} + +/// Receives `BytesReceivedChanged` events. +[uuid(828e8ab6-d94c-4264-9cef-5217170d6251), object, pointer_default(unique)] +interface ICoreWebView2BytesReceivedChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2DownloadOperation* sender, + [in] IUnknown* args); +} +/// Receives `EstimatedEndTimeChanged` events. +[uuid(28f0d425-93fe-4e63-9f8d-2aeec6d3ba1e), object, pointer_default(unique)] +interface ICoreWebView2EstimatedEndTimeChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2DownloadOperation* sender, + [in] IUnknown* args); +} +/// Receives `StateChanged` events. +[uuid(81336594-7ede-4ba9-bf71-acf0a95b58dd), object, pointer_default(unique)] +interface ICoreWebView2StateChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2DownloadOperation* sender, + [in] IUnknown* args); +} + +/// Receives `Destroyed` events. +[uuid(59dd7b4c-9baa-11eb-a8b3-0242ac130003), object, pointer_default(unique)] +interface ICoreWebView2FrameDestroyedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Frame* sender, + [in] IUnknown* args); +} +/// Receives `NameChanged` events. +[uuid(435c7dc8-9baa-11eb-a8b3-0242ac130003), object, pointer_default(unique)] +interface ICoreWebView2FrameNameChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Frame* sender, + [in] IUnknown* args); +} + +/// Receives `ContentLoading` events. +[uuid(0d6156f2-d332-49a7-9e03-7d8f2feeee54), object, pointer_default(unique)] +interface ICoreWebView2FrameContentLoadingEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Frame* sender, + [in] ICoreWebView2ContentLoadingEventArgs* args); +} +/// Receives `DOMContentLoaded` events. +[uuid(38d9520d-340f-4d1e-a775-43fce9753683), object, pointer_default(unique)] +interface ICoreWebView2FrameDOMContentLoadedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Frame* sender, + [in] ICoreWebView2DOMContentLoadedEventArgs* args); +} +/// Receives `NavigationCompleted` events. +[uuid(609302ad-0e36-4f9a-a210-6a45272842a9), object, pointer_default(unique)] +interface ICoreWebView2FrameNavigationCompletedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Frame* sender, + [in] ICoreWebView2NavigationCompletedEventArgs* args); +} +/// Receives `NavigationStarting` events. +[uuid(e79908bf-2d5d-4968-83db-263fea2c1da3), object, pointer_default(unique)] +interface ICoreWebView2FrameNavigationStartingEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Frame* sender, + [in] ICoreWebView2NavigationStartingEventArgs* args); +} +/// Receives `WebMessageReceived` events. +[uuid(e371e005-6d1d-4517-934b-a8f1629c62a5), object, pointer_default(unique)] +interface ICoreWebView2FrameWebMessageReceivedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Frame* sender, + [in] ICoreWebView2WebMessageReceivedEventArgs* args); +} + +/// Receives `Deleted` events. +[uuid(df35055d-772e-4dbe-b743-5fbf74a2b258), object, pointer_default(unique)] +interface ICoreWebView2ProfileDeletedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Profile* sender, + [in] IUnknown* args); +} + +/// Receives the result of the `GetContent` method. +[uuid(875738e1-9fa2-40e3-8b74-2e8972dd6fe7), object, pointer_default(unique)] +interface ICoreWebView2WebResourceResponseViewGetContentCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] IStream* result); +} + +/// Receives `CloseRequested` events. +[uuid(47c32d23-1e94-4733-85f1-d9bf4acd0974), object, pointer_default(unique)] +interface ICoreWebView2NotificationCloseRequestedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Notification* sender, + [in] IUnknown* args); +} + +/// WebView2 enables you to host web content using the latest Microsoft Edge +/// browser and web technology. + +[uuid(76eceacb-0462-4d94-ac83-423a6793775e), object, pointer_default(unique)] +interface ICoreWebView2 : IUnknown { + + /// The `ICoreWebView2Settings` object contains various modifiable settings + /// for the running WebView. + + [propget] HRESULT Settings([out, retval] ICoreWebView2Settings** settings); + + /// The URI of the current top level document. This value potentially + /// changes as a part of the `SourceChanged` event that runs for some cases + /// such as navigating to a different site or fragment navigations. It + /// remains the same for other types of navigations such as page refreshes + /// or `history.pushState` with the same URL as the current page. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + /// + /// \snippet ControlComponent.cpp SourceChanged + [propget] HRESULT Source([out, retval] LPWSTR* uri); + + /// Cause a navigation of the top-level document to run to the specified URI. + /// For more information, navigate to [Navigation + /// events](/microsoft-edge/webview2/concepts/navigation-events). + /// + /// \> [!NOTE]\n\> This operation starts a navigation and the corresponding + /// `NavigationStarting` event triggers sometime after `Navigate` runs. + /// + /// \snippet ControlComponent.cpp Navigate + HRESULT Navigate([in] LPCWSTR uri); + + /// Initiates a navigation to htmlContent as source HTML of a new document. + /// The `htmlContent` parameter may not be larger than 2 MB (2 * 1024 * 1024 bytes) in total size. + /// The origin of the new page is `about:blank`. + /// + /// ```cpp + /// SetVirtualHostNameToFolderMapping( + /// L"appassets.example", L"assets", + /// COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY); + /// + /// WCHAR c_navString[] = LR" + /// + /// + /// + ///

Click me

+ /// "; + /// m_webView->NavigateToString(c_navString); + /// ``` + /// \snippet SettingsComponent.cpp NavigateToString + HRESULT NavigateToString([in] LPCWSTR htmlContent); + + /// Add an event handler for the `NavigationStarting` event. + /// `NavigationStarting` runs when the WebView main frame is requesting + /// permission to navigate to a different URI. Redirects trigger this + /// operation as well, and the navigation id is the same as the original + /// one. + /// + /// Navigations will be blocked until all `NavigationStarting` event handlers + /// return. + /// + /// \snippet SettingsComponent.cpp NavigationStarting + HRESULT add_NavigationStarting( + [in] ICoreWebView2NavigationStartingEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_NavigationStarting`. + HRESULT remove_NavigationStarting( + [in] EventRegistrationToken token); + + /// Add an event handler for the `ContentLoading` event. `ContentLoading` + /// triggers before any content is loaded, including scripts added with + /// `AddScriptToExecuteOnDocumentCreated`. `ContentLoading` does not trigger + /// if a same page navigation occurs (such as through `fragment` + /// navigations or `history.pushState` navigations). This operation + /// follows the `NavigationStarting` and `SourceChanged` events and precedes + /// the `HistoryChanged` and `NavigationCompleted` events. + HRESULT add_ContentLoading( + [in] ICoreWebView2ContentLoadingEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_ContentLoading`. + HRESULT remove_ContentLoading( + [in] EventRegistrationToken token); + + /// Add an event handler for the `SourceChanged` event. `SourceChanged` + /// triggers when the `Source` property changes. `SourceChanged` runs when + /// navigating to a different site or fragment navigations. It does not + /// trigger for other types of navigations such as page refreshes or + /// `history.pushState` with the same URL as the current page. + /// `SourceChanged` runs before `ContentLoading` for navigation to a new + /// document. + /// + /// \snippet ControlComponent.cpp SourceChanged + HRESULT add_SourceChanged( + [in] ICoreWebView2SourceChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_SourceChanged`. + HRESULT remove_SourceChanged( + [in] EventRegistrationToken token); + + /// Add an event handler for the `HistoryChanged` event. `HistoryChanged` is + /// raised for changes to joint session history, which consists of top-level + /// and manual frame navigations. Use `HistoryChanged` to verify that the + /// `CanGoBack` or `CanGoForward` value has changed. `HistoryChanged` also + /// runs for using `GoBack` or `GoForward`. `HistoryChanged` runs after + /// `SourceChanged` and `ContentLoading`. `CanGoBack` is false for + /// navigations initiated through ICoreWebView2Frame APIs if there has not yet + /// been a user gesture. + /// + /// \snippet ControlComponent.cpp HistoryChanged + HRESULT add_HistoryChanged( + [in] ICoreWebView2HistoryChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_HistoryChanged`. + HRESULT remove_HistoryChanged( + [in] EventRegistrationToken token); + + /// Add an event handler for the `NavigationCompleted` event. + /// `NavigationCompleted` runs when the WebView has completely loaded + /// (concurrently when `body.onload` runs) or loading stopped with error. + /// + /// \snippet ControlComponent.cpp NavigationCompleted + HRESULT add_NavigationCompleted( + [in] ICoreWebView2NavigationCompletedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_NavigationCompleted`. + HRESULT remove_NavigationCompleted( + [in] EventRegistrationToken token); + + /// Add an event handler for the `FrameNavigationStarting` event. + /// `FrameNavigationStarting` triggers when a child frame in the WebView + /// requests permission to navigate to a different URI. Redirects trigger + /// this operation as well, and the navigation id is the same as the original + /// one. + /// + /// Navigations will be blocked until all `FrameNavigationStarting` event + /// handlers return. + /// + /// \snippet SettingsComponent.cpp FrameNavigationStarting + HRESULT add_FrameNavigationStarting( + [in] ICoreWebView2NavigationStartingEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with + /// `add_FrameNavigationStarting`. + HRESULT remove_FrameNavigationStarting( + [in] EventRegistrationToken token); + + /// Add an event handler for the `FrameNavigationCompleted` event. + /// `FrameNavigationCompleted` triggers when a child frame has completely + /// loaded (concurrently when `body.onload` has triggered) or loading stopped with error. + /// + /// \snippet ControlComponent.cpp FrameNavigationCompleted + HRESULT add_FrameNavigationCompleted( + [in] ICoreWebView2NavigationCompletedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with + /// `add_FrameNavigationCompleted`. + HRESULT remove_FrameNavigationCompleted( + [in] EventRegistrationToken token); + + /// Add an event handler for the `ScriptDialogOpening` event. + /// `ScriptDialogOpening` runs when a JavaScript dialog (`alert`, `confirm`, + /// `prompt`, or `beforeunload`) displays for the webview. This event only + /// triggers if the `ICoreWebView2Settings::AreDefaultScriptDialogsEnabled` + /// property is set to `FALSE`. The `ScriptDialogOpening` event suppresses + /// dialogs or replaces default dialogs with custom dialogs. + /// + /// If a deferral is not taken on the event args, the subsequent scripts are + /// blocked until the event handler returns. If a deferral is taken, the + /// scripts are blocked until the deferral is completed. + /// + /// \snippet SettingsComponent.cpp ScriptDialogOpening + HRESULT add_ScriptDialogOpening( + [in] ICoreWebView2ScriptDialogOpeningEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_ScriptDialogOpening`. + HRESULT remove_ScriptDialogOpening( + [in] EventRegistrationToken token); + + /// Add an event handler for the `PermissionRequested` event. + /// `PermissionRequested` runs when content in a WebView requests permission + /// to access some privileged resources. + /// + /// If a deferral is not taken on the event args, the subsequent scripts are + /// blocked until the event handler returns. If a deferral is taken, the + /// scripts are blocked until the deferral is completed. + /// + /// \snippet SettingsComponent.cpp PermissionRequested0 + /// \snippet SettingsComponent.cpp PermissionRequested1 + HRESULT add_PermissionRequested( + [in] ICoreWebView2PermissionRequestedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_PermissionRequested`. + HRESULT remove_PermissionRequested( + [in] EventRegistrationToken token); + + /// Add an event handler for the `ProcessFailed` event. + /// `ProcessFailed` runs when any of the processes in the + /// [WebView2 Process Group](/microsoft-edge/webview2/concepts/process-model?tabs=csharp#processes-in-the-webview2-runtime) + /// encounters one of the following conditions: + /// + /// Condition | Details + /// ---|--- + /// Unexpected exit | The process indicated by the event args has exited unexpectedly (usually due to a crash). The failure might or might not be recoverable and some failures are auto-recoverable. + /// Unresponsiveness | The process indicated by the event args has become unresponsive to user input. This is only reported for renderer processes, and will run every few seconds until the process becomes responsive again. + /// + /// \> [!NOTE]\n\> When the failing process is the browser process, a + /// `ICoreWebView2Environment5::BrowserProcessExited` event will run too. + /// + /// Your application can use `ICoreWebView2ProcessFailedEventArgs` and + /// `ICoreWebView2ProcessFailedEventArgs2` to identify which condition and + /// process the event is for, and to collect diagnostics and handle recovery + /// if necessary. For more details about which cases need to be handled by + /// your application, see `COREWEBVIEW2_PROCESS_FAILED_KIND`. + /// + /// \snippet ProcessComponent.cpp ProcessFailed + HRESULT add_ProcessFailed( + [in] ICoreWebView2ProcessFailedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_ProcessFailed`. + HRESULT remove_ProcessFailed( + [in] EventRegistrationToken token); + + /// Add the provided JavaScript to a list of scripts that should be run after + /// the global object has been created, but before the HTML document has + /// been parsed and before any other script included by the HTML document is + /// run. This method injects a script that runs on all top-level document + /// and child frame page navigations. This method runs asynchronously, and + /// you must wait for the completion handler to finish before the injected + /// script is ready to run. When this method completes, the `Invoke` method + /// of the handler is run with the `id` of the injected script. `id` is a + /// string. To remove the injected script, use + /// `RemoveScriptToExecuteOnDocumentCreated`. + /// + /// If the method is run in add_NewWindowRequested handler it should be called + /// before the new window is set. If called after setting the NewWindow property, the initial script + /// may or may not apply to the initial navigation and may only apply to the subsequent navigation. + /// For more details see `ICoreWebView2NewWindowRequestedEventArgs::put_NewWindow`. + /// + /// \> [!NOTE]\n\> If an HTML document is running in a sandbox of some kind using + /// [sandbox](https://developer.mozilla.org/docs/Web/HTML/Element/iframe#attr-sandbox) + /// properties or the + /// [Content-Security-Policy](https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Security-Policy) + /// HTTP header affects the script that runs. For example, if the + /// `allow-modals` keyword is not set then requests to run the `alert` + /// function are ignored. + /// + /// \snippet ScriptComponent.cpp AddScriptToExecuteOnDocumentCreated + HRESULT AddScriptToExecuteOnDocumentCreated( + [in] LPCWSTR javaScript, + [in] ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler* handler); + + /// Remove the corresponding JavaScript added using + /// `AddScriptToExecuteOnDocumentCreated` with the specified script ID. The + /// script ID should be the one returned by the `AddScriptToExecuteOnDocumentCreated`. + /// Both use `AddScriptToExecuteOnDocumentCreated` and this method in `NewWindowRequested` + /// event handler at the same time sometimes causes trouble. Since invalid scripts will + /// be ignored, the script IDs you got may not be valid anymore. + HRESULT RemoveScriptToExecuteOnDocumentCreated([in] LPCWSTR id); + + /// Run JavaScript code from the javascript parameter in the current + /// top-level document rendered in the WebView. The result of evaluating + /// the provided JavaScript is used in this parameter. The result value is + /// a JSON encoded string. If the result is undefined, contains a reference + /// cycle, or otherwise is not able to be encoded into JSON, then the result + /// is considered to be null, which is encoded in JSON as the string "null". + /// + /// \> [!NOTE]\n\> A function that has no explicit return value returns undefined. If the + /// script that was run throws an unhandled exception, then the result is + /// also "null". This method is applied asynchronously. If the method is + /// run after the `NavigationStarting` event during a navigation, the script + /// runs in the new document when loading it, around the time + /// `ContentLoading` is run. This operation executes the script even if + /// `ICoreWebView2Settings::IsScriptEnabled` is set to `FALSE`. + /// + /// \snippet ScriptComponent.cpp ExecuteScript + HRESULT ExecuteScript( + [in] LPCWSTR javaScript, + [in] ICoreWebView2ExecuteScriptCompletedHandler* handler); + + /// Capture an image of what WebView is displaying. Specify the format of + /// the image with the `imageFormat` parameter. The resulting image binary + /// data is written to the provided `imageStream` parameter. When + /// `CapturePreview` finishes writing to the stream, the `Invoke` method on + /// the provided `handler` parameter is run. This method fails if called + /// before the first ContentLoading event. For example if this is called in + /// the NavigationStarting event for the first navigation it will fail. + /// For subsequent navigations, the method may not fail, but will not capture + /// an image of a given webpage until the ContentLoading event has been fired + /// for it. Any call to this method prior to that will result in a capture of + /// the page being navigated away from. + /// + /// \snippet FileComponent.cpp CapturePreview + HRESULT CapturePreview( + [in] COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT imageFormat, + [in] IStream* imageStream, + [in] ICoreWebView2CapturePreviewCompletedHandler* handler); + + /// Reload the current page. This is similar to navigating to the URI of + /// current top level document including all navigation events firing and + /// respecting any entries in the HTTP cache. But, the back or forward + /// history are not modified. + HRESULT Reload(); + + /// Post the specified webMessage to the top level document in this WebView. + /// The main page receives the message by subscribing to the `message` event of the + /// `window.chrome.webview` of the page document. + /// + /// ```cpp + /// window.chrome.webview.addEventListener('message', handler) + /// window.chrome.webview.removeEventListener('message', handler) + /// ``` + /// + /// The event args is an instance of `MessageEvent`. The + /// `ICoreWebView2Settings::IsWebMessageEnabled` setting must be `TRUE` or + /// the web message will not be sent. The `data` property of the event + /// arg is the `webMessage` string parameter parsed as a JSON string into a + /// JavaScript object. The `source` property of the event arg is a reference + /// to the `window.chrome.webview` object. For information about sending + /// messages from the HTML document in the WebView to the host, navigate to + /// [add_WebMessageReceived](/microsoft-edge/webview2/reference/win32/icorewebview2#add_webmessagereceived). + /// The message is delivered asynchronously. If a navigation occurs before + /// the message is posted to the page, the message is discarded. + /// + /// \snippet ScenarioWebMessage.cpp WebMessageReceived + HRESULT PostWebMessageAsJson([in] LPCWSTR webMessageAsJson); + + /// Posts a message that is a simple string rather than a JSON string + /// representation of a JavaScript object. This behaves in exactly the same + /// manner as `PostWebMessageAsJson`, but the `data` property of the event + /// arg of the `window.chrome.webview` message is a string with the same + /// value as `webMessageAsString`. Use this instead of + /// `PostWebMessageAsJson` if you want to communicate using simple strings + /// rather than JSON objects. + HRESULT PostWebMessageAsString([in] LPCWSTR webMessageAsString); + + /// Add an event handler for the `WebMessageReceived` event. + /// `WebMessageReceived` runs when the + /// `ICoreWebView2Settings::IsWebMessageEnabled` setting is set and the + /// top-level document of the WebView runs + /// `window.chrome.webview.postMessage`. The `postMessage` function is + /// `void postMessage(object)` where object is any object supported by JSON + /// conversion. + /// + /// \snippet assets\ScenarioWebMessage.html chromeWebView + /// + /// When the page calls `postMessage`, the object parameter is converted to a + /// JSON string and is posted asynchronously to the host process. This will + /// result in the handler's `Invoke` method being called with the JSON string + /// as a parameter. + /// + /// \snippet ScenarioWebMessage.cpp WebMessageReceived + /// + /// If the same page calls `postMessage` multiple times, the corresponding + /// `WebMessageReceived` events are guaranteed to be fired in the same order. + /// However, if multiple frames call `postMessage`, there is no guaranteed + /// order. In addition, `WebMessageReceived` events caused by calls to + /// `postMessage` are not guaranteed to be sequenced with events caused by DOM + /// APIs. For example, if the page runs + /// + /// ```javascript + /// chrome.webview.postMessage("message"); + /// window.open(); + /// ``` + /// + /// then the `NewWindowRequested` event might be fired before the + /// `WebMessageReceived` event. If you need the `WebMessageReceived` event + /// to happen before anything else, then in the `WebMessageReceived` handler + /// you can post a message back to the page and have the page wait until it + /// receives that message before continuing. + HRESULT add_WebMessageReceived( + [in] ICoreWebView2WebMessageReceivedEventHandler* handler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_WebMessageReceived`. + HRESULT remove_WebMessageReceived( + [in] EventRegistrationToken token); + + /// Runs an asynchronous `DevToolsProtocol` method. For more information + /// about available methods, navigate to + /// [DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/tot) + /// . The `methodName` parameter is the full name of the method in the + /// `{domain}.{method}` format. The `parametersAsJson` parameter is a JSON + /// formatted string containing the parameters for the corresponding method. + /// The `Invoke` method of the `handler` is run when the method + /// asynchronously completes. `Invoke` is run with the return object of the + /// method as a JSON string. This function returns E_INVALIDARG if the `methodName` is + /// unknown or the `parametersAsJson` has an error. In the case of such an error, the + /// `returnObjectAsJson` parameter of the handler will include information + /// about the error. + /// Note even though WebView2 dispatches the CDP messages in the order called, + /// CDP method calls may be processed out of order. + /// If you require CDP methods to run in a particular order, you should wait + /// for the previous method's completed handler to run before calling the + /// next method. + + /// If the method is to run in add_NewWindowRequested handler it should be called + /// before the new window is set if the cdp message should affect the initial navigation. If + /// called after setting the NewWindow property, the cdp messages + /// may or may not apply to the initial navigation and may only apply to the subsequent navigation. + /// For more details see `ICoreWebView2NewWindowRequestedEventArgs::put_NewWindow`. + /// + /// \snippet ScriptComponent.cpp CallDevToolsProtocolMethod + HRESULT CallDevToolsProtocolMethod( + [in] LPCWSTR methodName, + [in] LPCWSTR parametersAsJson, + [in] ICoreWebView2CallDevToolsProtocolMethodCompletedHandler* handler); + + /// The process ID of the browser process that hosts the WebView. + [propget] HRESULT BrowserProcessId([out, retval] UINT32* value); + + /// `TRUE` if the WebView is able to navigate to a previous page in the + /// navigation history. If `CanGoBack` changes value, the `HistoryChanged` + /// event runs. + [propget] HRESULT CanGoBack([out, retval] BOOL* canGoBack); + + /// `TRUE` if the WebView is able to navigate to a next page in the + /// navigation history. If `CanGoForward` changes value, the + /// `HistoryChanged` event runs. + [propget] HRESULT CanGoForward([out, retval] BOOL* canGoForward); + + /// Navigates the WebView to the previous page in the navigation history. + HRESULT GoBack(); + + /// Navigates the WebView to the next page in the navigation history. + HRESULT GoForward(); + + /// Get a DevTools Protocol event receiver that allows you to subscribe to a + /// DevTools Protocol event. The `eventName` parameter is the full name of + /// the event in the format `{domain}.{event}`. For more information about + /// DevTools Protocol events description and event args, navigate to + /// [DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/tot). + /// + /// \snippet ScriptComponent.cpp DevToolsProtocolEventReceived + HRESULT GetDevToolsProtocolEventReceiver( + [in] LPCWSTR eventName, + [out, retval] ICoreWebView2DevToolsProtocolEventReceiver** receiver); + + /// Stop all navigations and pending resource fetches. Does not stop scripts. + HRESULT Stop(); + + /// Add an event handler for the `NewWindowRequested` event. + /// `NewWindowRequested` runs when content inside the WebView requests to + /// open a new window, such as through `window.open`. The app can pass a + /// target WebView that is considered the opened window or mark the event as + /// `Handled`, in which case WebView2 does not open a window. + /// If either `Handled` or `NewWindow` properties are not set, the target + /// content will be opened on a popup window. + /// + /// If a deferral is not taken on the event args, scripts that resulted in the + /// new window that are requested are blocked until the event handler returns. + /// If a deferral is taken, then scripts are blocked until the deferral is + /// completed or new window is set. + /// + /// For more details and considerations on the target WebView to be supplied + /// at the opened window, see `ICoreWebView2NewWindowRequestedEventArgs::put_NewWindow`. + /// + /// \snippet AppWindow.cpp NewWindowRequested + HRESULT add_NewWindowRequested( + [in] ICoreWebView2NewWindowRequestedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_NewWindowRequested`. + HRESULT remove_NewWindowRequested( + [in] EventRegistrationToken token); + + /// Add an event handler for the `DocumentTitleChanged` event. + /// `DocumentTitleChanged` runs when the `DocumentTitle` property of the + /// WebView changes and may run before or after the `NavigationCompleted` + /// event. + /// + /// \snippet FileComponent.cpp DocumentTitleChanged + HRESULT add_DocumentTitleChanged( + [in] ICoreWebView2DocumentTitleChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_DocumentTitleChanged`. + HRESULT remove_DocumentTitleChanged( + [in] EventRegistrationToken token); + + /// The title for the current top-level document. If the document has no + /// explicit title or is otherwise empty, a default that may or may not match + /// the URI of the document is used. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT DocumentTitle([out, retval] LPWSTR* title); + + /// Add the provided host object to script running in the WebView with the + /// specified name. Host objects are exposed as host object proxies using + /// `window.chrome.webview.hostObjects.{name}`. Host object proxies are + /// promises and resolves to an object representing the host object. The + /// promise is rejected if the app has not added an object with the name. + /// When JavaScript code access a property or method of the object, a promise + /// is return, which resolves to the value returned from the host for the + /// property or method, or rejected in case of error, for example, no + /// property or method on the object or parameters are not valid. + /// + /// \> [!NOTE]\n\> While simple types, `IDispatch` and array are supported, and + /// `IUnknown` objects that also implement `IDispatch` are treated as `IDispatch`, + /// generic `IUnknown`, `VT_DECIMAL`, or `VT_RECORD` variant is not supported. + /// Remote JavaScript objects like callback functions are represented as an + /// `VT_DISPATCH` `VARIANT` with the object implementing `IDispatch`. The + /// JavaScript callback method may be invoked using `DISPID_VALUE` for the + /// `DISPID`. Such callback method invocations will return immediately and will + /// not wait for the JavaScript function to run and so will not provide the return + /// value of the JavaScript function. + /// Nested arrays are supported up to a depth of 3. Arrays of by + /// reference types are not supported. `VT_EMPTY` and `VT_NULL` are mapped + /// into JavaScript as `null`. In JavaScript, `null` and undefined are + /// mapped to `VT_EMPTY`. + /// + /// Additionally, all host objects are exposed as + /// `window.chrome.webview.hostObjects.sync.{name}`. Here the host objects + /// are exposed as synchronous host object proxies. These are not promises + /// and function runtimes or property access synchronously block running + /// script waiting to communicate cross process for the host code to run. + /// Accordingly the result may have reliability issues and it is recommended + /// that you use the promise-based asynchronous + /// `window.chrome.webview.hostObjects.{name}` API. + /// + /// Synchronous host object proxies and asynchronous host object proxies may + /// both use a proxy to the same host object. Remote changes made by one + /// proxy propagates to any other proxy of that same host object whether + /// the other proxies and synchronous or asynchronous. + /// + /// While JavaScript is blocked on a synchronous run to native code, that + /// native code is unable to run back to JavaScript. Attempts to do so fail + /// with `HRESULT_FROM_WIN32(ERROR_POSSIBLE_DEADLOCK)`. + /// + /// Host object proxies are JavaScript Proxy objects that intercept all + /// property get, property set, and method invocations. Properties or methods + /// that are a part of the Function or Object prototype are run locally. + /// Additionally any property or method in the + /// `chrome.webview.hostObjects.options.forceLocalProperties` + /// array are also run locally. This defaults to including optional methods + /// that have meaning in JavaScript like `toJSON` and `Symbol.toPrimitive`. + /// Add more to the array as required. + /// + /// The `chrome.webview.hostObjects.cleanupSome` method performs a best + /// effort garbage collection on host object proxies. + /// + /// The `chrome.webview.hostObjects.options` object provides the ability to + /// change some functionality of host objects. + /// + /// Options property | Details + /// ---|--- + /// `forceLocalProperties` | This is an array of host object property names that will be run locally, instead of being called on the native host object. This defaults to `then`, `toJSON`, `Symbol.toString`, and `Symbol.toPrimitive`. You can add other properties to specify that they should be run locally on the javascript host object proxy. + /// `log` | This is a callback that will be called with debug information. For example, you can set this to `console.log.bind(console)` to have it print debug information to the console to help when troubleshooting host object usage. By default this is null. + /// `shouldSerializeDates` | By default this is false, and javascript Date objects will be sent to host objects as a string using `JSON.stringify`. You can set this property to true to have Date objects properly serialize as a `VT_DATE` when sending to the native host object, and have `VT_DATE` properties and return values create a javascript Date object. + /// `defaultSyncProxy` | When calling a method on a synchronous proxy, the result should also be a synchronous proxy. But in some cases, the sync/async context is lost (for example, when providing to native code a reference to a function, and then calling that function in native code). In these cases, the proxy will be asynchronous, unless this property is set. + /// `forceAsyncMethodMatches ` | This is an array of regular expressions. When calling a method on a synchronous proxy, the method call will be performed asynchronously if the method name matches a string or regular expression in this array. Setting this value to `Async` will make any method that ends with Async be an asynchronous method call. If an async method doesn't match here and isn't forced to be asynchronous, the method will be invoked synchronously, blocking execution of the calling JavaScript and then returning the resolution of the promise, rather than returning a promise. + /// `ignoreMemberNotFoundError` | By default, an exception is thrown when attempting to get the value of a proxy property that doesn't exist on the corresponding native class. Setting this property to `true` switches the behavior to match Chakra WinRT projection (and general JavaScript) behavior of returning `undefined` with no error. + /// `shouldPassTypedArraysAsArrays` | By default, typed arrays are passed to the host as `IDispatch`. To instead pass typed arrays to the host as `array`, set this to `true`. + /// + /// Host object proxies additionally have the following methods which run + /// locally. + /// + /// Method name | Details + /// ---|--- + ///`applyHostFunction`, `getHostProperty`, `setHostProperty` | Perform a method invocation, property get, or property set on the host object. Use the methods to explicitly force a method or property to run remotely if a conflicting local method or property exists. For instance, `proxy.toString()` runs the local `toString` method on the proxy object. But proxy.applyHostFunction('toString') runs `toString` on the host proxied object instead. + ///`getLocalProperty`, `setLocalProperty` | Perform property get, or property set locally. Use the methods to force getting or setting a property on the host object proxy rather than on the host object it represents. For instance, `proxy.unknownProperty` gets the property named `unknownProperty` from the host proxied object. But proxy.getLocalProperty('unknownProperty') gets the value of the property `unknownProperty` on the proxy object. + ///`sync` | Asynchronous host object proxies expose a sync method which returns a promise for a synchronous host object proxy for the same host object. For example, `chrome.webview.hostObjects.sample.methodCall()` returns an asynchronous host object proxy. Use the `sync` method to obtain a synchronous host object proxy instead: `const syncProxy = await chrome.webview.hostObjects.sample.methodCall().sync()`. + ///`async` | Synchronous host object proxies expose an async method which blocks and returns an asynchronous host object proxy for the same host object. For example, `chrome.webview.hostObjects.sync.sample.methodCall()` returns a synchronous host object proxy. Running the `async` method on this blocks and then returns an asynchronous host object proxy for the same host object: `const asyncProxy = chrome.webview.hostObjects.sync.sample.methodCall().async()`. + ///`then` | Asynchronous host object proxies have a `then` method. Allows proxies to be awaitable. `then` returns a promise that resolves with a representation of the host object. If the proxy represents a JavaScript literal, a copy of that is returned locally. If the proxy represents a function, a non-awaitable proxy is returned. If the proxy represents a JavaScript object with a mix of literal properties and function properties, the a copy of the object is returned with some properties as host object proxies. + /// + /// All other property and method invocations (other than the above Remote + /// object proxy methods, `forceLocalProperties` list, and properties on + /// Function and Object prototypes) are run remotely. Asynchronous host + /// object proxies return a promise representing asynchronous completion of + /// remotely invoking the method, or getting the property. The promise + /// resolves after the remote operations complete and the promises resolve to + /// the resulting value of the operation. Synchronous host object proxies + /// work similarly, but block running JavaScript and wait for the remote + /// operation to complete. + /// + /// Setting a property on an asynchronous host object proxy works slightly + /// differently. The set returns immediately and the return value is the + /// value that is set. This is a requirement of the JavaScript Proxy object. + /// If you need to asynchronously wait for the property set to complete, use + /// the `setHostProperty` method which returns a promise as described above. + /// Synchronous object property set property synchronously blocks until the + /// property is set. + /// + /// For example, suppose you have a COM object with the following interface. + /// + /// \snippet HostObjectSample.idl AddHostObjectInterface + /// + /// Add an instance of this interface into your JavaScript with + /// `AddHostObjectToScript`. In this case, name it `sample`. + /// + /// \snippet ScenarioAddHostObject.cpp AddHostObjectToScript + /// + /// In the HTML document, use the COM object using + /// `chrome.webview.hostObjects.sample`. + /// Note that `CoreWebView2.AddHostObjectToScript` only applies to the + /// top-level document and not to frames. To add host objects to frames use + /// `CoreWebView2Frame.AddHostObjectToScript`. + /// + /// \snippet assets\ScenarioAddHostObject.html HostObjectUsage + /// + /// Exposing host objects to script has security risk. For more information + /// about best practices, navigate to + /// [Best practices for developing secure WebView2 applications](/microsoft-edge/webview2/concepts/security). + HRESULT AddHostObjectToScript([in] LPCWSTR name, [in] VARIANT* object); + + /// Remove the host object specified by the name so that it is no longer + /// accessible from JavaScript code in the WebView. While new access + /// attempts are denied, if the object is already obtained by JavaScript code + /// in the WebView, the JavaScript code continues to have access to that + /// object. Run this method for a name that is already removed or never + /// added fails. + HRESULT RemoveHostObjectFromScript([in] LPCWSTR name); + + /// Opens the DevTools window for the current document in the WebView. Does + /// nothing if run when the DevTools window is already open. + HRESULT OpenDevToolsWindow(); + + /// Add an event handler for the `ContainsFullScreenElementChanged` event. + /// `ContainsFullScreenElementChanged` triggers when the + /// `ContainsFullScreenElement` property changes. An HTML element inside the + /// WebView may enter fullscreen to the size of the WebView or leave + /// fullscreen. This event is useful when, for example, a video element + /// requests to go fullscreen. The listener of + /// `ContainsFullScreenElementChanged` may resize the WebView in response. + /// + /// \snippet AppWindow.cpp ContainsFullScreenElementChanged + HRESULT add_ContainsFullScreenElementChanged( + [in] ICoreWebView2ContainsFullScreenElementChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with + /// `add_ContainsFullScreenElementChanged`. + HRESULT remove_ContainsFullScreenElementChanged( + [in] EventRegistrationToken token); + + /// Indicates if the WebView contains a fullscreen HTML element. + [propget] HRESULT ContainsFullScreenElement( + [out, retval] BOOL* containsFullScreenElement); + + /// Add an event handler for the `WebResourceRequested` event. + /// `WebResourceRequested` runs when the WebView is performing a URL request + /// to a matching URL and resource context filter that was added with + /// `AddWebResourceRequestedFilter`. At least one filter must be added for + /// the event to run. + /// + /// The web resource requested may be blocked until the event handler returns + /// if a deferral is not taken on the event args. If a deferral is taken, + /// then the web resource requested is blocked until the deferral is + /// completed. + /// + /// If this event is subscribed in the add_NewWindowRequested handler it should be called + /// after the new window is set. For more details see `ICoreWebView2NewWindowRequestedEventArgs::put_NewWindow`. + /// + /// This event is by default raised for file, http, and https URI schemes. + /// This is also raised for registered custom URI schemes. For more details + /// see `ICoreWebView2CustomSchemeRegistration`. + /// + /// \snippet SettingsComponent.cpp WebResourceRequested0 + /// \snippet SettingsComponent.cpp WebResourceRequested1 + HRESULT add_WebResourceRequested( + [in] ICoreWebView2WebResourceRequestedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_WebResourceRequested`. + HRESULT remove_WebResourceRequested( + [in] EventRegistrationToken token); + + /// Adds a URI and resource context filter for the `WebResourceRequested` + /// event. A web resource request with a resource context that matches this + /// filter's resource context and a URI that matches this filter's URI + /// wildcard string will be raised via the `WebResourceRequested` event. + /// + /// The `uri` parameter value is a wildcard string matched against the URI + /// of the web resource request. This is a glob style + /// wildcard string in which a `*` matches zero or more characters and a `?` + /// matches exactly one character. + /// These wildcard characters can be escaped using a backslash just before + /// the wildcard character in order to represent the literal `*` or `?`. + /// + /// The matching occurs over the URI as a whole string and not limiting + /// wildcard matches to particular parts of the URI. + /// The wildcard filter is compared to the URI after the URI has been + /// normalized, any URI fragment has been removed, and non-ASCII hostnames + /// have been converted to punycode. + /// + /// Specifying a `nullptr` for the uri is equivalent to an empty string which + /// matches no URIs. + /// + /// For more information about resource context filters, navigate to + /// [COREWEBVIEW2_WEB_RESOURCE_CONTEXT](/microsoft-edge/webview2/reference/win32/webview2-idl#corewebview2_web_resource_context). + /// + /// | URI Filter String | Request URI | Match | Notes | + /// | ---- | ---- | ---- | ---- | + /// | `*` | `https://contoso.com/a/b/c` | Yes | A single * will match all URIs | + /// | `*://contoso.com/*` | `https://contoso.com/a/b/c` | Yes | Matches everything in contoso.com across all schemes | + /// | `*://contoso.com/*` | `https://example.com/?https://contoso.com/` | Yes | But also matches a URI with just the same text anywhere in the URI | + /// | `example` | `https://contoso.com/example` | No | The filter does not perform partial matches | + /// | `*example` | `https://contoso.com/example` | Yes | The filter matches across URI parts | + /// | `*example` | `https://contoso.com/path/?example` | Yes | The filter matches across URI parts | + /// | `*example` | `https://contoso.com/path/?query#example` | No | The filter is matched against the URI with no fragment | + /// | `*example` | `https://example` | No | The URI is normalized before filter matching so the actual URI used for comparison is `https://example/` | + /// | `*example/` | `https://example` | Yes | Just like above, but this time the filter ends with a / just like the normalized URI | + /// | `https://xn--qei.example/` | `https://❤.example/` | Yes | Non-ASCII hostnames are normalized to punycode before wildcard comparison | + /// | `https://❤.example/` | `https://xn--qei.example/` | No | Non-ASCII hostnames are normalized to punycode before wildcard comparison | + HRESULT AddWebResourceRequestedFilter( + [in] LPCWSTR const uri, + [in] COREWEBVIEW2_WEB_RESOURCE_CONTEXT const resourceContext); + + /// Removes a matching WebResource filter that was previously added for the + /// `WebResourceRequested` event. If the same filter was added multiple + /// times, then it must be removed as many times as it was added for the + /// removal to be effective. Returns `E_INVALIDARG` for a filter that was + /// never added. + HRESULT RemoveWebResourceRequestedFilter( + [in] LPCWSTR const uri, + [in] COREWEBVIEW2_WEB_RESOURCE_CONTEXT const resourceContext); + + /// Add an event handler for the `WindowCloseRequested` event. + /// `WindowCloseRequested` triggers when content inside the WebView + /// requested to close the window, such as after `window.close` is run. The + /// app should close the WebView and related app window if that makes sense + /// to the app. After the first window.close() call, this event may not fire + /// for any immediate back to back window.close() calls. + /// + /// \snippet AppWindow.cpp WindowCloseRequested + HRESULT add_WindowCloseRequested( + [in] ICoreWebView2WindowCloseRequestedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_WindowCloseRequested`. + HRESULT remove_WindowCloseRequested( + [in] EventRegistrationToken token); +} + +/// A continuation of the ICoreWebView2 interface. +[uuid(9E8F0CF8-E670-4B5E-B2BC-73E061E3184C), object, pointer_default(unique)] +interface ICoreWebView2_2 : ICoreWebView2 { + /// Add an event handler for the WebResourceResponseReceived event. + /// WebResourceResponseReceived is raised when the WebView receives the + /// response for a request for a web resource (any URI resolution performed by + /// the WebView; such as HTTP/HTTPS, file and data requests from redirects, + /// navigations, declarations in HTML, implicit favicon lookups, and fetch API + /// usage in the document). The host app can use this event to view the actual + /// request and response for a web resource. There is no guarantee about the + /// order in which the WebView processes the response and the host app's + /// handler runs. The app's handler will not block the WebView from processing + /// the response. + /// \snippet ScenarioAuthentication.cpp WebResourceResponseReceived + HRESULT add_WebResourceResponseReceived( + [in] ICoreWebView2WebResourceResponseReceivedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + /// Remove an event handler previously added with + /// add_WebResourceResponseReceived. + HRESULT remove_WebResourceResponseReceived( + [in] EventRegistrationToken token); + + /// Navigates using a constructed WebResourceRequest object. This lets you + /// provide post data or additional request headers during navigation. + /// The headers in the WebResourceRequest override headers + /// added by WebView2 runtime except for Cookie headers. + /// Method can only be either "GET" or "POST". Provided post data will only + /// be sent only if the method is "POST" and the uri scheme is HTTP(S). + /// \snippet ScenarioNavigateWithWebResourceRequest.cpp NavigateWithWebResourceRequest + HRESULT NavigateWithWebResourceRequest([in] ICoreWebView2WebResourceRequest* request); + + /// Add an event handler for the DOMContentLoaded event. + /// DOMContentLoaded is raised when the initial html document has been parsed. + /// This aligns with the document's DOMContentLoaded event in html. + /// + /// \snippet ScenarioDOMContentLoaded.cpp DOMContentLoaded + HRESULT add_DOMContentLoaded( + [in] ICoreWebView2DOMContentLoadedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with add_DOMContentLoaded. + HRESULT remove_DOMContentLoaded( + [in] EventRegistrationToken token); + + /// Gets the cookie manager object associated with this ICoreWebView2. + /// See ICoreWebView2CookieManager. + /// + /// \snippet ScenarioCookieManagement.cpp CookieManager + [propget] HRESULT CookieManager([out, retval] ICoreWebView2CookieManager** cookieManager); + + /// Exposes the CoreWebView2Environment used to create this CoreWebView2. + [propget] HRESULT Environment([out, retval] ICoreWebView2Environment** environment); +} + +/// A continuation of the ICoreWebView2_2 interface. +[uuid(A0D6DF20-3B92-416D-AA0C-437A9C727857), object, pointer_default(unique)] +interface ICoreWebView2_3 : ICoreWebView2_2 { + /// An app may call the `TrySuspend` API to have the WebView2 consume less memory. + /// This is useful when a Win32 app becomes invisible, or when a Universal Windows + /// Platform app is being suspended, during the suspended event handler before completing + /// the suspended event. + /// The CoreWebView2Controller's IsVisible property must be false when the API is called. + /// Otherwise, the API fails with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)`. + /// Suspending is similar to putting a tab to sleep in the Edge browser. Suspending pauses + /// WebView script timers and animations, minimizes CPU usage for the associated + /// browser renderer process and allows the operating system to reuse the memory that was + /// used by the renderer process for other processes. + /// Note that Suspend is best effort and considered completed successfully once the request + /// is sent to browser renderer process. If there is a running script, the script will continue + /// to run and the renderer process will be suspended after that script is done. + /// See [Sleeping Tabs FAQ](https://techcommunity.microsoft.com/t5/articles/sleeping-tabs-faq/m-p/1705434) + /// for conditions that might prevent WebView from being suspended. In those situations, + /// the completed handler will be invoked with isSuccessful as false and errorCode as S_OK. + /// The WebView will be automatically resumed when it becomes visible. Therefore, the + /// app normally does not have to call `Resume` explicitly. + /// The app can call `Resume` and then `TrySuspend` periodically for an invisible WebView so that + /// the invisible WebView can sync up with latest data and the page ready to show fresh content + /// when it becomes visible. + /// All WebView APIs can still be accessed when a WebView is suspended. Some APIs like Navigate + /// will auto resume the WebView. To avoid unexpected auto resume, check `IsSuspended` property + /// before calling APIs that might change WebView state. + /// + /// \snippet ViewComponent.cpp ToggleIsVisibleOnMinimize + /// + /// \snippet ViewComponent.cpp Suspend + HRESULT TrySuspend([in] ICoreWebView2TrySuspendCompletedHandler* handler); + + /// Resumes the WebView so that it resumes activities on the web page. + /// This API can be called while the WebView2 controller is invisible. + /// The app can interact with the WebView immediately after `Resume`. + /// WebView will be automatically resumed when it becomes visible. + /// + /// \snippet ViewComponent.cpp ToggleIsVisibleOnMinimize + /// + /// \snippet ViewComponent.cpp Resume + HRESULT Resume(); + + /// Whether WebView is suspended. + /// `TRUE` when WebView is suspended, from the time when TrySuspend has completed + /// successfully until WebView is resumed. + [propget] HRESULT IsSuspended([out, retval] BOOL* isSuspended); + + /// Sets a mapping between a virtual host name and a folder path to make available to web sites + /// via that host name. + /// + /// After setting the mapping, documents loaded in the WebView can use HTTP or HTTPS URLs at + /// the specified host name specified by hostName to access files in the local folder specified + /// by folderPath. + /// + /// This mapping applies to both top-level document and iframe navigations as well as subresource + /// references from a document. This also applies to web workers including dedicated/shared worker + /// and service worker, for loading either worker scripts or subresources + /// (importScripts(), fetch(), XHR, etc.) issued from within a worker. + /// For virtual host mapping to work with service worker, please keep the virtual host name + /// mappings consistent among all WebViews sharing the same browser instance. As service worker + /// works independently of WebViews, we merge mappings from all WebViews when resolving virtual + /// host name, inconsistent mappings between WebViews would lead unexpected behavior. + /// + /// Due to a current implementation limitation, media files accessed using virtual host name can be + /// very slow to load. + /// As the resource loaders for the current page might have already been created and running, + /// changes to the mapping might not be applied to the current page and a reload of the page is + /// needed to apply the new mapping. + /// + /// Both absolute and relative paths are supported for folderPath. Relative paths are interpreted + /// as relative to the folder where the exe of the app is in. + /// + /// Note that the folderPath length must not exceed the Windows MAX_PATH limit. + /// + /// accessKind specifies the level of access to resources under the virtual host from other sites. + /// + /// For example, after calling + /// ```cpp + /// SetVirtualHostNameToFolderMapping( + /// L"appassets.example", L"assets", + /// COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY); + /// ``` + /// navigating to `https://appassets.example/my-local-file.html` will + /// show the content from my-local-file.html in the assets subfolder located on disk under + /// the same path as the app's executable file. + /// + /// DOM elements that want to reference local files will have their host reference virtual host in the source. + /// If there are multiple folders being used, define one unique virtual host per folder. + /// For example, you can embed a local image like this + /// ```cpp + /// WCHAR c_navString[] = L""; + /// m_webView->NavigateToString(c_navString); + /// ``` + /// The example above shows the image wv2.png by resolving the folder mapping above. + /// + /// You should typically choose virtual host names that are never used by real sites. + /// If you own a domain such as example.com, another option is to use a subdomain reserved for + /// the app (like my-app.example.com). + /// + /// [RFC 6761](https://tools.ietf.org/html/rfc6761) has reserved several special-use domain + /// names that are guaranteed to not be used by real sites (for example, .example, .test, and + /// .invalid.) + /// + /// Note that using `.local` as the top-level domain name will work but can cause a delay + /// during navigations. You should avoid using `.local` if you can. + /// + /// Apps should use distinct domain names when mapping folder from different sources that + /// should be isolated from each other. For instance, the app might use app-file.example for + /// files that ship as part of the app, and book1.example might be used for files containing + /// books from a less trusted source that were previously downloaded and saved to the disk by + /// the app. + /// + /// The host name used in the APIs is canonicalized using Chromium's host name parsing logic + /// before being used internally. For more information see [HTML5 2.6 URLs](https://dev.w3.org/html5/spec-LC/urls.html). + /// + /// All host names that are canonicalized to the same string are considered identical. + /// For example, `EXAMPLE.COM` and `example.com` are treated as the same host name. + /// An international host name and its Punycode-encoded host name are considered the same host + /// name. There is no DNS resolution for host name and the trailing '.' is not normalized as + /// part of canonicalization. + /// + /// Therefore `example.com` and `example.com.` are treated as different host names. Similarly, + /// `virtual-host-name` and `virtual-host-name.example.com` are treated as different host names + /// even if the machine has a DNS suffix of `example.com`. + /// + /// Specify the minimal cross-origin access necessary to run the app. If there is not a need to + /// access local resources from other origins, use COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY. + /// + /// \snippet AppWindow.cpp AddVirtualHostNameToFolderMapping + /// + /// \snippet AppWindow.cpp LocalUrlUsage + HRESULT SetVirtualHostNameToFolderMapping( + [in] LPCWSTR hostName, + [in] LPCWSTR folderPath, + [in] COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND accessKind); + + /// Clears a host name mapping for local folder that was added by `SetVirtualHostNameToFolderMapping`. + HRESULT ClearVirtualHostNameToFolderMapping( + [in] LPCWSTR hostName); +} + +/// A continuation of the ICoreWebView2_3 interface to support FrameCreated and +/// DownloadStarting events. +[uuid(20d02d59-6df2-42dc-bd06-f98a694b1302), object, pointer_default(unique)] +interface ICoreWebView2_4 : ICoreWebView2_3 { + /// Raised when a new iframe is created. + /// Handle this event to get access to ICoreWebView2Frame objects. + /// Use ICoreWebView2Frame.add_Destroyed to listen for when this iframe goes + /// away. + HRESULT add_FrameCreated( + [in] ICoreWebView2FrameCreatedEventHandler * eventHandler, + [out] EventRegistrationToken * token); + + /// Remove an event handler previously added with add_FrameCreated. + HRESULT remove_FrameCreated([in] EventRegistrationToken token); + + /// Add an event handler for the `DownloadStarting` event. This event is + /// raised when a download has begun, blocking the default download dialog, + /// but not blocking the progress of the download. + /// + /// The host can choose to cancel a download, change the result file path, + /// and hide the default download dialog. + /// If the host chooses to cancel the download, the download is not saved, no + /// dialog is shown, and the state is changed to + /// COREWEBVIEW2_DOWNLOAD_STATE_INTERRUPTED with interrupt reason + /// COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_USER_CANCELED. Otherwise, the + /// download is saved to the default path after the event completes, + /// and default download dialog is shown if the host did not choose to hide it. + /// The host can change the visibility of the download dialog using the + /// `Handled` property. If the event is not handled, downloads complete + /// normally with the default dialog shown. + /// + /// \snippet ScenarioCustomDownloadExperience.cpp DownloadStarting + HRESULT add_DownloadStarting( + [in] ICoreWebView2DownloadStartingEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_DownloadStarting`. + HRESULT remove_DownloadStarting( + [in] EventRegistrationToken token); +} + +/// This interface is an extension of `ICoreWebView2_7` that supports media features. +[uuid(E9632730-6E1E-43AB-B7B8-7B2C9E62E094), object, pointer_default(unique)] +interface ICoreWebView2_8 : ICoreWebView2_7 { + /// Adds an event handler for the `IsMutedChanged` event. + /// `IsMutedChanged` is raised when the IsMuted property changes value. + /// + /// \snippet AudioComponent.cpp IsMutedChanged + HRESULT add_IsMutedChanged( + [in] ICoreWebView2IsMutedChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_IsMutedChanged`. + HRESULT remove_IsMutedChanged( + [in] EventRegistrationToken token); + + /// Indicates whether all audio output from this CoreWebView2 is muted or not. + /// + /// \snippet AudioComponent.cpp ToggleIsMuted + [propget] HRESULT IsMuted([out, retval] BOOL* value); + + /// Sets the `IsMuted` property. + /// + /// \snippet AudioComponent.cpp ToggleIsMuted + [propput] HRESULT IsMuted([in] BOOL value); + + /// Adds an event handler for the `IsDocumentPlayingAudioChanged` event. + /// `IsDocumentPlayingAudioChanged` is raised when the IsDocumentPlayingAudio property changes value. + /// + /// \snippet AudioComponent.cpp IsDocumentPlayingAudioChanged + HRESULT add_IsDocumentPlayingAudioChanged( + [in] ICoreWebView2IsDocumentPlayingAudioChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_IsDocumentPlayingAudioChanged`. + HRESULT remove_IsDocumentPlayingAudioChanged( + [in] EventRegistrationToken token); + + /// Indicates whether any audio output from this CoreWebView2 is playing. + /// This property will be true if audio is playing even if IsMuted is true. + /// + /// \snippet AudioComponent.cpp IsDocumentPlayingAudio + [propget] HRESULT IsDocumentPlayingAudio([out, retval] BOOL* value); +} + +/// This interface is an extension of `ICoreWebView2_8` that default download +/// dialog positioning and anchoring. +[uuid(4d7b2eab-9fdc-468d-b998-a9260b5ed651), object, pointer_default(unique)] +interface ICoreWebView2_9 : ICoreWebView2_8 { + /// Raised when the `IsDefaultDownloadDialogOpen` property changes. This event + /// comes after the `DownloadStarting` event. Setting the `Handled` property + /// on the `DownloadStartingEventArgs` disables the default download dialog + /// and ensures that this event is never raised. + HRESULT add_IsDefaultDownloadDialogOpenChanged( + [in] ICoreWebView2IsDefaultDownloadDialogOpenChangedEventHandler* handler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with + /// `add_IsDefaultDownloadDialogOpenChanged`. + HRESULT remove_IsDefaultDownloadDialogOpenChanged( + [in] EventRegistrationToken token); + + /// `TRUE` if the default download dialog is currently open. The value of this + /// property changes only when the default download dialog is explicitly + /// opened or closed. Hiding the WebView implicitly hides the dialog, but does + /// not change the value of this property. + [propget] HRESULT IsDefaultDownloadDialogOpen([out, retval] BOOL* value); + + /// Open the default download dialog. If the dialog is opened before there + /// are recent downloads, the dialog shows all past downloads for the + /// current profile. Otherwise, the dialog shows only the recent downloads + /// with a "See more" button for past downloads. Calling this method raises + /// the `IsDefaultDownloadDialogOpenChanged` event if the dialog was closed. + /// No effect if the dialog is already open. + /// + /// \snippet ViewComponent.cpp ToggleDefaultDownloadDialog + HRESULT OpenDefaultDownloadDialog(); + + /// Close the default download dialog. Calling this method raises the + /// `IsDefaultDownloadDialogOpenChanged` event if the dialog was open. No + /// effect if the dialog is already closed. + HRESULT CloseDefaultDownloadDialog(); + + /// Get the default download dialog corner alignment. + [propget] HRESULT DefaultDownloadDialogCornerAlignment( + [out, retval] COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT* value); + + /// Set the default download dialog corner alignment. The dialog can be + /// aligned to any of the WebView corners (see + /// COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT). When the WebView + /// or dialog changes size, the dialog keeps its position relative to the + /// corner. The dialog may become partially or completely outside of the + /// WebView bounds if the WebView is small enough. Set the margin relative to + /// the corner with the `DefaultDownloadDialogMargin` property. The corner + /// alignment and margin should be set during initialization to ensure that + /// they are correctly applied when the layout is first computed, otherwise + /// they will not take effect until the next time the WebView position or size + /// is updated. + /// + /// \snippet ViewComponent.cpp SetDefaultDownloadDialogPosition + [propput] HRESULT DefaultDownloadDialogCornerAlignment( + [in] COREWEBVIEW2_DEFAULT_DOWNLOAD_DIALOG_CORNER_ALIGNMENT value); + + /// Get the default download dialog margin. + [propget] HRESULT DefaultDownloadDialogMargin([out, retval] POINT* value); + + /// Set the default download dialog margin relative to the WebView corner + /// specified by `DefaultDownloadDialogCornerAlignment`. The margin is a + /// point that describes the vertical and horizontal distances between the + /// chosen WebView corner and the default download dialog corner nearest to + /// it. Positive values move the dialog towards the center of the WebView from + /// the chosen WebView corner, and negative values move the dialog away from + /// it. Use (0, 0) to align the dialog to the WebView corner with no margin. + /// The corner alignment and margin should be set during initialization to + /// ensure that they are correctly applied when the layout is first computed, + /// otherwise they will not take effect until the next time the WebView + /// position or size is updated. + [propput] HRESULT DefaultDownloadDialogMargin([in] POINT value); +} + +/// This interface is an extension of `ICoreWebView2_10` that supports sessionId +/// for CDP method calls and ContextMenuRequested event. +[uuid(0be78e56-c193-4051-b943-23b460c08bdb), object, pointer_default(unique)] +interface ICoreWebView2_11 : ICoreWebView2_10 { + /// Runs an asynchronous `DevToolsProtocol` method for a specific session of + /// an attached target. + /// There could be multiple `DevToolsProtocol` targets in a WebView. + /// Besides the top level page, iframes from different origin and web workers + /// are also separate targets. Attaching to these targets allows interaction with them. + /// When the DevToolsProtocol is attached to a target, the connection is identified + /// by a sessionId. + /// To use this API, you must set the `flatten` parameter to true when calling + /// `Target.attachToTarget` or `Target.setAutoAttach` `DevToolsProtocol` method. + /// Using `Target.setAutoAttach` is recommended as that would allow you to attach + /// to dedicated worker targets, which are not discoverable via other APIs like + /// `Target.getTargets`. + /// For more information about targets and sessions, navigate to + /// [DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/tot/Target). + /// For more information about available methods, navigate to + /// [DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/tot) + /// The `sessionId` parameter is the sessionId for an attached target. + /// nullptr or empty string is treated as the session for the default target for the top page. + /// The `methodName` parameter is the full name of the method in the + /// `{domain}.{method}` format. The `parametersAsJson` parameter is a JSON + /// formatted string containing the parameters for the corresponding method. + /// The `Invoke` method of the `handler` is run when the method + /// asynchronously completes. `Invoke` is run with the return object of the + /// method as a JSON string. This function returns E_INVALIDARG if the `methodName` is + /// unknown or the `parametersAsJson` has an error. In the case of such an error, the + /// `returnObjectAsJson` parameter of the handler will include information + /// about the error. + /// + /// \snippet ScriptComponent.cpp DevToolsProtocolMethodMultiSession + /// + /// \snippet ScriptComponent.cpp CallDevToolsProtocolMethodForSession + HRESULT CallDevToolsProtocolMethodForSession( + [in] LPCWSTR sessionId, + [in] LPCWSTR methodName, + [in] LPCWSTR parametersAsJson, + [in] ICoreWebView2CallDevToolsProtocolMethodCompletedHandler* handler); + + /// Add an event handler for the `ContextMenuRequested` event. + /// `ContextMenuRequested` event is raised when a context menu is requested by the user + /// and the content inside WebView hasn't disabled context menus. + /// The host has the option to create their own context menu with the information provided in + /// the event or can add items to or remove items from WebView context menu. + /// If the host doesn't handle the event, WebView will display the default context menu. + /// + /// \snippet SettingsComponent.cpp EnableCustomMenu + HRESULT add_ContextMenuRequested( + [in] ICoreWebView2ContextMenuRequestedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_ContextMenuRequested`. + HRESULT remove_ContextMenuRequested( + [in] EventRegistrationToken token); +} + +/// This interface is an extension of `ICoreWebView2_11` that supports +/// StatusBarTextChanged event. +[uuid(35D69927-BCFA-4566-9349-6B3E0D154CAC), object, pointer_default(unique)] +interface ICoreWebView2_12 : ICoreWebView2_11 { + /// Add an event handler for the `StatusBarTextChanged` event. + /// `StatusBarTextChanged` fires when the WebView is showing a status message, + /// a URL, or an empty string (an indication to hide the status bar). + /// \snippet SettingsComponent.cpp StatusBarTextChanged + HRESULT add_StatusBarTextChanged( + [in] ICoreWebView2StatusBarTextChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_StatusBarTextChanged`. + HRESULT remove_StatusBarTextChanged([in] EventRegistrationToken token); + + /// The status message text. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT StatusBarText([out, retval] LPWSTR* value); +} + +/// This interface is an extension of `ICoreWebView2_14` that supports status Favicons. +[uuid(517B2D1D-7DAE-4A66-A4F4-10352FFB9518), object, pointer_default(unique)] +interface ICoreWebView2_15 : ICoreWebView2_14 { + /// Add an event handler for the `FaviconChanged` event. + /// The `FaviconChanged` event is raised when the + /// [favicon](https://developer.mozilla.org/docs/Glossary/Favicon) + /// had a different URL then the previous URL. + /// The FaviconChanged event will be raised for first navigating to a new + /// document, whether or not a document declares a Favicon in HTML if the + /// favicon is different from the previous fav icon. The event will + /// be raised again if a favicon is declared in its HTML or has script + /// to set its favicon. The favicon information can then be retrieved with + /// `GetFavicon` and `FaviconUri`. + HRESULT add_FaviconChanged( + [in] ICoreWebView2FaviconChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove the event handler for `FaviconChanged` event. + HRESULT remove_FaviconChanged( + [in] EventRegistrationToken token); + + /// Get the current Uri of the favicon as a string. + /// If the value is null, then the return value is `E_POINTER`, otherwise it is `S_OK`. + /// If a page has no favicon then the value is an empty string. + [propget] HRESULT FaviconUri([out, retval] LPWSTR* value); + + /// Async function for getting the actual image data of the favicon. + /// The image is copied to the `imageStream` object in `ICoreWebView2GetFaviconCompletedHandler`. + /// If there is no image then no data would be copied into the imageStream. + /// The `format` is the file format to return the image stream. + /// `completedHandler` is executed at the end of the operation. + /// + /// \snippet SettingsComponent.cpp FaviconChanged + HRESULT GetFavicon( + [in] COREWEBVIEW2_FAVICON_IMAGE_FORMAT format, + [in] ICoreWebView2GetFaviconCompletedHandler* completedHandler); +} + +/// A continuation of the `ICoreWebView2` interface to support printing. +[uuid(0EB34DC9-9F91-41E1-8639-95CD5943906B), object, pointer_default(unique)] +interface ICoreWebView2_16 : ICoreWebView2_15 { + /// Print the current web page asynchronously to the specified printer with the provided settings. + /// See `ICoreWebView2PrintSettings` for description of settings. Passing + /// nullptr for `printSettings` results in default print settings used. + /// + /// The handler will return `errorCode` as `S_OK` and `printStatus` as COREWEBVIEW2_PRINT_STATUS_PRINTER_UNAVAILABLE + /// if `printerName` doesn't match with the name of any installed printers on the user OS. The handler + /// will return `errorCode` as `E_INVALIDARG` and `printStatus` as COREWEBVIEW2_PRINT_STATUS_OTHER_ERROR + /// if the caller provides invalid settings for a given printer. + /// + /// The async `Print` operation completes when it finishes printing to the printer. + /// At this time the `ICoreWebView2PrintCompletedHandler` is invoked. + /// Only one `Printing` operation can be in progress at a time. If `Print` is called while a `Print` or `PrintToPdf` + /// or `PrintToPdfStream` or `ShowPrintUI` job is in progress, the completed handler is immediately invoked + /// with `E_ABORT` and `printStatus` is COREWEBVIEW2_PRINT_STATUS_OTHER_ERROR. + /// This is only for printing operation on one webview. + /// + /// | errorCode | printStatus | Notes | + /// | --- | --- | --- | + /// | S_OK | COREWEBVIEW2_PRINT_STATUS_SUCCEEDED | Print operation succeeded. | + /// | S_OK | COREWEBVIEW2_PRINT_STATUS_PRINTER_UNAVAILABLE | If specified printer is not found or printer status is not available, offline or error state. | + /// | S_OK | COREWEBVIEW2_PRINT_STATUS_OTHER_ERROR | Print operation is failed. | + /// | E_INVALIDARG | COREWEBVIEW2_PRINT_STATUS_OTHER_ERROR | If the caller provides invalid settings for the specified printer. | + /// | E_ABORT | COREWEBVIEW2_PRINT_STATUS_OTHER_ERROR | Print operation is failed as printing job already in progress. | + /// + /// \snippet AppWindow.cpp PrintToPrinter + HRESULT Print( + [in] ICoreWebView2PrintSettings* printSettings, + [in] ICoreWebView2PrintCompletedHandler* handler); + + /// Opens the print dialog to print the current web page. See `COREWEBVIEW2_PRINT_DIALOG_KIND` + /// for descriptions of print dialog kinds. + /// + /// Invoking browser or system print dialog doesn't open new print dialog if + /// it is already open. + /// + /// \snippet AppWindow.cpp ShowPrintUI + HRESULT ShowPrintUI([in] COREWEBVIEW2_PRINT_DIALOG_KIND printDialogKind); + + /// Provides the Pdf data of current web page asynchronously for the provided settings. + /// Stream will be rewound to the start of the pdf data. + /// + /// See `ICoreWebView2PrintSettings` for description of settings. Passing + /// nullptr for `printSettings` results in default print settings used. + /// + /// The async `PrintToPdfStream` operation completes when it finishes + /// writing to the stream. At this time the `ICoreWebView2PrintToPdfStreamCompletedHandler` + /// is invoked. Only one `Printing` operation can be in progress at a time. If + /// `PrintToPdfStream` is called while a `PrintToPdfStream` or `PrintToPdf` or `Print` + /// or `ShowPrintUI` job is in progress, the completed handler is immediately invoked with `E_ABORT`. + /// This is only for printing operation on one webview. + /// + /// \snippet AppWindow.cpp PrintToPdfStream + HRESULT PrintToPdfStream([in] ICoreWebView2PrintSettings* printSettings, + [in] ICoreWebView2PrintToPdfStreamCompletedHandler* handler); +} + +/// Defines properties that enable, disable, or modify WebView features. +/// Changes to `IsGeneralAutofillEnabled` and `IsPasswordAutosaveEnabled` +/// apply immediately, while other setting changes made after `NavigationStarting` +/// event do not apply until the next top-level navigation. + +[uuid(e562e4f0-d7fa-43ac-8d71-c05150499f00), object, pointer_default(unique)] +interface ICoreWebView2Settings : IUnknown { + + /// Controls if running JavaScript is enabled in all future navigations in + /// the WebView. This only affects scripts in the document. Scripts + /// injected with `ExecuteScript` runs even if script is disabled. + /// The default value is `TRUE`. + /// + /// \snippet SettingsComponent.cpp IsScriptEnabled + [propget] HRESULT IsScriptEnabled( + [out, retval] BOOL* isScriptEnabled); + + /// Sets the `IsScriptEnabled` property. + [propput] HRESULT IsScriptEnabled([in] BOOL isScriptEnabled); + + /// The `IsWebMessageEnabled` property is used when loading a new HTML + /// document. If set to `TRUE`, communication from the host to the top-level + /// HTML document of the WebView is allowed using `PostWebMessageAsJson`, + /// `PostWebMessageAsString`, and message event of `window.chrome.webview`. + /// For more information, navigate to PostWebMessageAsJson. Communication + /// from the top-level HTML document of the WebView to the host is allowed + /// using the postMessage function of `window.chrome.webview` and + /// `add_WebMessageReceived` method. For more information, navigate to + /// [add_WebMessageReceived](/microsoft-edge/webview2/reference/win32/icorewebview2#add_webmessagereceived). + /// If set to false, then communication is disallowed. `PostWebMessageAsJson` + /// and `PostWebMessageAsString` fails with `E_ACCESSDENIED` and + /// `window.chrome.webview.postMessage` fails by throwing an instance of an + /// `Error` object. The default value is `TRUE`. + /// + /// \snippet ScenarioWebMessage.cpp IsWebMessageEnabled + [propget] HRESULT IsWebMessageEnabled( + [out, retval] BOOL* isWebMessageEnabled); + + /// Sets the `IsWebMessageEnabled` property. + [propput] HRESULT IsWebMessageEnabled([in] BOOL isWebMessageEnabled); + + /// `AreDefaultScriptDialogsEnabled` is used when loading a new HTML + /// document. If set to `FALSE`, WebView2 does not render the default JavaScript + /// dialog box (Specifically those displayed by the JavaScript alert, + /// confirm, prompt functions and `beforeunload` event). Instead, if an + /// event handler is set using `add_ScriptDialogOpening`, WebView sends an + /// event that contains all of the information for the dialog and allow the + /// host app to show a custom UI. + /// The default value is `TRUE`. + [propget] HRESULT AreDefaultScriptDialogsEnabled( + [out, retval] BOOL* areDefaultScriptDialogsEnabled); + + /// Sets the `AreDefaultScriptDialogsEnabled` property. + [propput] HRESULT AreDefaultScriptDialogsEnabled( + [in] BOOL areDefaultScriptDialogsEnabled); + + /// `IsStatusBarEnabled` controls whether the status bar is displayed. The + /// status bar is usually displayed in the lower left of the WebView and + /// shows things such as the URI of a link when the user hovers over it and + /// other information. + /// The default value is `TRUE`. + /// The status bar UI can be altered by web content and should not be considered secure. + [propget] HRESULT IsStatusBarEnabled([out, retval] BOOL* isStatusBarEnabled); + + /// Sets the `IsStatusBarEnabled` property. + [propput] HRESULT IsStatusBarEnabled([in] BOOL isStatusBarEnabled); + + /// `AreDevToolsEnabled` controls whether the user is able to use the context + /// menu or keyboard shortcuts to open the DevTools window. + /// The default value is `TRUE`. + [propget] HRESULT AreDevToolsEnabled([out, retval] BOOL* areDevToolsEnabled); + + /// Sets the `AreDevToolsEnabled` property. + [propput] HRESULT AreDevToolsEnabled([in] BOOL areDevToolsEnabled); + + /// The `AreDefaultContextMenusEnabled` property is used to prevent default + /// context menus from being shown to user in WebView. + /// The default value is `TRUE`. + /// + /// \snippet SettingsComponent.cpp DisableContextMenu + [propget] HRESULT AreDefaultContextMenusEnabled([out, retval] BOOL* enabled); + + /// Sets the `AreDefaultContextMenusEnabled` property. + [propput] HRESULT AreDefaultContextMenusEnabled([in] BOOL enabled); + + /// The `AreHostObjectsAllowed` property is used to control whether host + /// objects are accessible from the page in WebView. + /// The default value is `TRUE`. + /// + /// \snippet SettingsComponent.cpp HostObjectsAccess + [propget] HRESULT AreHostObjectsAllowed([out, retval] BOOL* allowed); + + /// Sets the `AreHostObjectsAllowed` property. + + [propput] HRESULT AreHostObjectsAllowed([in] BOOL allowed); + + /// The `IsZoomControlEnabled` property is used to prevent the user from + /// impacting the zoom of the WebView. When disabled, the user is not able + /// to zoom using Ctrl++, Ctrl+-, or Ctrl+mouse wheel, but the zoom + /// is set using `ZoomFactor` API. The default value is `TRUE`. + /// + /// \snippet SettingsComponent.cpp DisableZoomControl + + [propget] HRESULT IsZoomControlEnabled([out, retval] BOOL* enabled); + + /// Sets the `IsZoomControlEnabled` property. + + [propput] HRESULT IsZoomControlEnabled([in] BOOL enabled); + + /// The `IsBuiltInErrorPageEnabled` property is used to disable built in + /// error page for navigation failure and render process failure. When + /// disabled, a blank page is displayed when the related error happens. + /// The default value is `TRUE`. + /// + /// \snippet SettingsComponent.cpp BuiltInErrorPageEnabled + [propget] HRESULT IsBuiltInErrorPageEnabled([out, retval] BOOL* enabled); + + /// Sets the `IsBuiltInErrorPageEnabled` property. + [propput] HRESULT IsBuiltInErrorPageEnabled([in] BOOL enabled); +} + +/// A continuation of the ICoreWebView2Settings interface to manage autofill. +[uuid(cb56846c-4168-4d53-b04f-03b6d6796ff2), object, pointer_default(unique)] +interface ICoreWebView2Settings4 : ICoreWebView2Settings3 { + /// IsPasswordAutosaveEnabled controls whether autosave for password + /// information is enabled. The IsPasswordAutosaveEnabled property behaves + /// independently of the IsGeneralAutofillEnabled property. When IsPasswordAutosaveEnabled is + /// false, no new password data is saved and no Save/Update Password prompts are displayed. + /// However, if there was password data already saved before disabling this setting, + /// then that password information is auto-populated, suggestions are shown and clicking on + /// one will populate the fields. + /// When IsPasswordAutosaveEnabled is true, password information is auto-populated, + /// suggestions are shown and clicking on one will populate the fields, new data + /// is saved, and a Save/Update Password prompt is displayed. + /// It will take effect immediately after setting. + /// The default value is `FALSE`. + /// This property has the same value as + /// `CoreWebView2Profile.IsPasswordAutosaveEnabled`, and changing one will + /// change the other. All `CoreWebView2`s with the same `CoreWebView2Profile` + /// will share the same value for this property, so for the `CoreWebView2`s + /// with the same profile, their + /// `CoreWebView2Settings.IsPasswordAutosaveEnabled` and + /// `CoreWebView2Profile.IsPasswordAutosaveEnabled` will always have the same + /// value. + /// + /// \snippet SettingsComponent.cpp PasswordAutosaveEnabled + [propget] HRESULT IsPasswordAutosaveEnabled([out, retval] BOOL* value); + + /// Set the IsPasswordAutosaveEnabled property. + [propput] HRESULT IsPasswordAutosaveEnabled([in] BOOL value); + + /// IsGeneralAutofillEnabled controls whether autofill for information + /// like names, street and email addresses, phone numbers, and arbitrary input + /// is enabled. This excludes password and credit card information. When + /// IsGeneralAutofillEnabled is false, no suggestions appear, and no new information + /// is saved. When IsGeneralAutofillEnabled is true, information is saved, suggestions + /// appear and clicking on one will populate the form fields. + /// It will take effect immediately after setting. + /// The default value is `TRUE`. + /// This property has the same value as + /// `CoreWebView2Profile.IsGeneralAutofillEnabled`, and changing one will + /// change the other. All `CoreWebView2`s with the same `CoreWebView2Profile` + /// will share the same value for this property, so for the `CoreWebView2`s + /// with the same profile, their + /// `CoreWebView2Settings.IsGeneralAutofillEnabled` and + /// `CoreWebView2Profile.IsGeneralAutofillEnabled` will always have the same + /// value. + /// + /// \snippet SettingsComponent.cpp GeneralAutofillEnabled + [propget] HRESULT IsGeneralAutofillEnabled([out, retval] BOOL* value); + + /// Set the IsGeneralAutofillEnabled property. + [propput] HRESULT IsGeneralAutofillEnabled([in] BOOL value); +} + +/// The owner of the `CoreWebView2` object that provides support for resizing, +/// showing and hiding, focusing, and other functionality related to +/// windowing and composition. The `CoreWebView2Controller` owns the +/// `CoreWebView2`, and if all references to the `CoreWebView2Controller` go +/// away, the WebView is closed. +[uuid(4d00c0d1-9434-4eb6-8078-8697a560334f), object, pointer_default(unique)] +interface ICoreWebView2Controller : IUnknown { + + /// The `IsVisible` property determines whether to show or hide the WebView2. + /// If `IsVisible` is set to `FALSE`, the WebView2 is transparent and is + /// not rendered. However, this does not affect the window containing the + /// WebView2 (the `HWND` parameter that was passed to + /// `CreateCoreWebView2Controller`). If you want that window to disappear + /// too, run `ShowWindow` on it directly in addition to modifying the + /// `IsVisible` property. WebView2 as a child window does not get window + /// messages when the top window is minimized or restored. For performance + /// reasons, developers should set the `IsVisible` property of the WebView to + /// `FALSE` when the app window is minimized and back to `TRUE` when the app + /// window is restored. The app window does this by handling + /// `SIZE_MINIMIZED and SIZE_RESTORED` command upon receiving `WM_SIZE` + /// message. + /// + /// There are CPU and memory benefits when the page is hidden. For instance, + /// Chromium has code that throttles activities on the page like animations + /// and some tasks are run less frequently. Similarly, WebView2 will + /// purge some caches to reduce memory usage. + /// + /// \snippet ViewComponent.cpp ToggleIsVisible + [propget] HRESULT IsVisible([out, retval] BOOL* isVisible); + + /// Sets the `IsVisible` property. + /// + /// \snippet ViewComponent.cpp ToggleIsVisibleOnMinimize + [propput] HRESULT IsVisible([in] BOOL isVisible); + + /// The WebView bounds. Bounds are relative to the parent `HWND`. The app + /// has two ways to position a WebView. + /// + /// * Create a child `HWND` that is the WebView parent `HWND`. Position + /// the window where the WebView should be. Use `(0, 0)` for the + /// top-left corner (the offset) of the `Bounds` of the WebView. + /// * Use the top-most window of the app as the WebView parent HWND. For + /// example, to position WebView correctly in the app, set the top-left + /// corner of the Bound of the WebView. + /// + /// The values of `Bounds` are limited by the coordinate space of the host. + + [propget] HRESULT Bounds([out, retval] RECT* bounds); + + /// Sets the `Bounds` property. + /// + /// \snippet ViewComponent.cpp ResizeWebView + + [propput] HRESULT Bounds([in] RECT bounds); + + /// The zoom factor for the WebView. + /// + /// \> [!NOTE]\n\> Changing zoom factor may cause `window.innerWidth`, + /// `window.innerHeight`, both, and page layout to change. A zoom factor + /// that is applied by the host by running `ZoomFactor` becomes the new + /// default zoom for the WebView. The zoom factor applies across navigations + /// and is the zoom factor WebView is returned to when the user chooses + /// Ctrl+0. When the zoom factor is changed by the user (resulting in + /// the app receiving `ZoomFactorChanged`), that zoom applies only for the + /// current page. Any user applied zoom is only for the current page and is + /// reset on a navigation. Specifying a `zoomFactor` less than or equal to + /// `0` is not allowed. WebView also has an internal supported zoom factor + /// range. When a specified zoom factor is out of that range, it is + /// normalized to be within the range, and a `ZoomFactorChanged` event is + /// triggered for the real applied zoom factor. When the range normalization + /// happens, the `ZoomFactor` property reports the zoom factor specified + /// during the previous modification of the `ZoomFactor` property until the + /// `ZoomFactorChanged` event is received after WebView applies the + /// normalized zoom factor. + + [propget] HRESULT ZoomFactor([out, retval] double* zoomFactor); + + /// Sets the `ZoomFactor` property. + + [propput] HRESULT ZoomFactor([in] double zoomFactor); + + /// Adds an event handler for the `ZoomFactorChanged` event. + /// `ZoomFactorChanged` runs when the `ZoomFactor` property of the WebView + /// changes. The event may run because the `ZoomFactor` property was + /// modified, or due to the user manually modifying the zoom. When it is + /// modified using the `ZoomFactor` property, the internal zoom factor is + /// updated immediately and no `ZoomFactorChanged` event is triggered. + /// WebView associates the last used zoom factor for each site. It is + /// possible for the zoom factor to change when navigating to a different + /// page. When the zoom factor changes due to a navigation change, the + /// `ZoomFactorChanged` event runs right after the `ContentLoading` event. + /// + /// \snippet ViewComponent.cpp ZoomFactorChanged + + HRESULT add_ZoomFactorChanged( + [in] ICoreWebView2ZoomFactorChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_ZoomFactorChanged`. + + HRESULT remove_ZoomFactorChanged( + [in] EventRegistrationToken token); + + /// Updates `Bounds` and `ZoomFactor` properties at the same time. This + /// operation is atomic from the perspective of the host. After returning + /// from this function, the `Bounds` and `ZoomFactor` properties are both + /// updated if the function is successful, or neither is updated if the + /// function fails. If `Bounds` and `ZoomFactor` are both updated by the + /// same scale (for example, `Bounds` and `ZoomFactor` are both doubled), + /// then the page does not display a change in `window.innerWidth` or + /// `window.innerHeight` and the WebView renders the content at the new size + /// and zoom without intermediate renderings. This function also updates + /// just one of `ZoomFactor` or `Bounds` by passing in the new value for one + /// and the current value for the other. + /// + /// \snippet ViewComponent.cpp SetBoundsAndZoomFactor + + HRESULT SetBoundsAndZoomFactor([in] RECT bounds, [in] double zoomFactor); + + /// Moves focus into WebView. WebView gets focus and focus is set to + /// correspondent element in the page hosted in the WebView. For + /// Programmatic reason, focus is set to previously focused element or the + /// default element if no previously focused element exists. For `Next` + /// reason, focus is set to the first element. For `Previous` reason, focus + /// is set to the last element. WebView changes focus through user + /// interaction including selecting into a WebView or Tab into it. For + /// tabbing, the app runs MoveFocus with Next or Previous to align with Tab + /// and Shift+Tab respectively when it decides the WebView is the next + /// element that may exist in a tab. Or, the app runs `IsDialogMessage` + /// as part of the associated message loop to allow the platform to auto + /// handle tabbing. The platform rotates through all windows with + /// `WS_TABSTOP`. When the WebView gets focus from `IsDialogMessage`, it is + /// internally put the focus on the first or last element for tab and + /// Shift+Tab respectively. + /// + /// \snippet App.cpp MoveFocus0 + /// + /// \snippet ControlComponent.cpp MoveFocus1 + /// + /// \snippet ControlComponent.cpp MoveFocus2 + + HRESULT MoveFocus([in] COREWEBVIEW2_MOVE_FOCUS_REASON reason); + + /// Adds an event handler for the `MoveFocusRequested` event. + /// `MoveFocusRequested` runs when user tries to tab out of the WebView. The + /// focus of the WebView has not changed when this event is run. + /// + /// \snippet ControlComponent.cpp MoveFocusRequested + + HRESULT add_MoveFocusRequested( + [in] ICoreWebView2MoveFocusRequestedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_MoveFocusRequested`. + + HRESULT remove_MoveFocusRequested( + [in] EventRegistrationToken token); + + /// Adds an event handler for the `GotFocus` event. `GotFocus` runs when + /// WebView has focus. + + HRESULT add_GotFocus( + [in] ICoreWebView2FocusChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_GotFocus`. + + HRESULT remove_GotFocus( + [in] EventRegistrationToken token); + + /// Adds an event handler for the `LostFocus` event. `LostFocus` runs when + /// WebView loses focus. In the case where `MoveFocusRequested` event is + /// run, the focus is still on WebView when `MoveFocusRequested` event runs. + /// `LostFocus` only runs afterwards when code of the app or default action + /// of `MoveFocusRequested` event set focus away from WebView. + + HRESULT add_LostFocus( + [in] ICoreWebView2FocusChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_LostFocus`. + + HRESULT remove_LostFocus( + [in] EventRegistrationToken token); + + /// Adds an event handler for the `AcceleratorKeyPressed` event. + /// `AcceleratorKeyPressed` runs when an accelerator key or key combo is + /// pressed or released while the WebView is focused. A key is considered an + /// accelerator if either of the following conditions are true. + /// + /// * Ctrl or Alt is currently being held. + /// * The pressed key does not map to a character. + /// + /// A few specific keys are never considered accelerators, such as Shift. + /// The `Escape` key is always considered an accelerator. + /// + /// Auto-repeated key events caused by holding the key down also triggers + /// this event. Filter out the auto-repeated key events by verifying the + /// `KeyEventLParam` or `PhysicalKeyStatus` event args. + /// + /// In windowed mode, the event handler is run synchronously. Until you + /// run `Handled()` on the event args or the event handler returns, the + /// browser process is blocked and outgoing cross-process COM requests fail + /// with `RPC_E_CANTCALLOUT_ININPUTSYNCCALL`. All `CoreWebView2` API methods + /// work, however. + /// + /// In windowless mode, the event handler is run asynchronously. Further + /// input do not reach the browser until the event handler returns or + /// `Handled()` is run, but the browser process is not blocked, and outgoing + /// COM requests work normally. + /// + /// It is recommended to run `Handled(TRUE)` as early as are able to know + /// that you want to handle the accelerator key. + /// + /// \snippet ControlComponent.cpp AcceleratorKeyPressed + + HRESULT add_AcceleratorKeyPressed( + [in] ICoreWebView2AcceleratorKeyPressedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with + /// `add_AcceleratorKeyPressed`. + + HRESULT remove_AcceleratorKeyPressed( + [in] EventRegistrationToken token); + + /// The parent window provided by the app that this WebView is using to + /// render content. This API initially returns the window passed into + /// `CreateCoreWebView2Controller`. + + [propget] HRESULT ParentWindow([out, retval] HWND* parentWindow); + + /// Sets the parent window for the WebView. This causes the WebView to + /// re-parent the main WebView window to the newly provided window. + + [propput] HRESULT ParentWindow([in] HWND parentWindow); + + /// This is a notification separate from `Bounds` that tells WebView that the + /// main WebView parent (or any ancestor) `HWND` moved. This is needed + /// for accessibility and certain dialogs in WebView to work correctly. + /// + /// \snippet ViewComponent.cpp NotifyParentWindowPositionChanged + + HRESULT NotifyParentWindowPositionChanged(); + + /// Closes the WebView and cleans up the underlying browser instance. + /// Cleaning up the browser instance releases the resources powering the + /// WebView. The browser instance is shut down if no other WebViews are + /// using it. + /// + /// After running `Close`, most methods will fail and event handlers stop + /// running. Specifically, the WebView releases the associated references to + /// any associated event handlers when `Close` is run. + /// + /// `Close` is implicitly run when the `CoreWebView2Controller` loses the + /// final reference and is destructed. But it is best practice to + /// explicitly run `Close` to avoid any accidental cycle of references + /// between the WebView and the app code. Specifically, if you capture a + /// reference to the WebView in an event handler you create a reference cycle + /// between the WebView and the event handler. Run `Close` to break the + /// cycle by releasing all event handlers. But to avoid the situation, it is + /// best to both explicitly run `Close` on the WebView and to not capture a + /// reference to the WebView to ensure the WebView is cleaned up correctly. + /// `Close` is synchronous and won't trigger the `beforeunload` event. + /// + /// \snippet AppWindow.cpp Close + HRESULT Close(); + + /// Gets the `CoreWebView2` associated with this `CoreWebView2Controller`. + + [propget] HRESULT CoreWebView2([out, retval] ICoreWebView2** coreWebView2); +} + +/// A continuation of the ICoreWebView2Controller2 interface. +[uuid(f9614724-5d2b-41dc-aef7-73d62b51543b), object, pointer_default(unique)] +interface ICoreWebView2Controller3 : ICoreWebView2Controller2 { + /// The rasterization scale for the WebView. The rasterization scale is the + /// combination of the monitor DPI scale and text scaling set by the user. + /// This value should be updated when the DPI scale of the app's top level + /// window changes (i.e. monitor DPI scale changes or window changes monitor) + /// or when the text scale factor of the system changes. + /// + /// \snippet AppWindow.cpp DPIChanged + /// + /// \snippet AppWindow.cpp TextScaleChanged1 + /// + /// \snippet AppWindow.cpp TextScaleChanged2 + /// + /// Rasterization scale applies to the WebView content, as well as + /// popups, context menus, scroll bars, and so on. Normal app scaling + /// scenarios should use the ZoomFactor property or SetBoundsAndZoomFactor + /// API which only scale the rendered HTML content and not popups, context + /// menus, scroll bars, and so on. + /// + /// \snippet ViewComponent.cpp RasterizationScale + [propget] HRESULT RasterizationScale([out, retval] double* scale); + /// Set the rasterization scale property. + [propput] HRESULT RasterizationScale([in] double scale); + + /// ShouldDetectMonitorScaleChanges property determines whether the WebView + /// attempts to track monitor DPI scale changes. When true, the WebView will + /// track monitor DPI scale changes, update the RasterizationScale property, + /// and raises RasterizationScaleChanged event. When false, the WebView will + /// not track monitor DPI scale changes, and the app must update the + /// RasterizationScale property itself. RasterizationScaleChanged event will + /// never raise when ShouldDetectMonitorScaleChanges is false. Apps that want + /// to set their own rasterization scale should set this property to false to + /// avoid the WebView2 updating the RasterizationScale property to match the + /// monitor DPI scale. + [propget] HRESULT ShouldDetectMonitorScaleChanges([out, retval] BOOL* value); + /// Set the ShouldDetectMonitorScaleChanges property. + [propput] HRESULT ShouldDetectMonitorScaleChanges([in] BOOL value); + + /// Add an event handler for the RasterizationScaleChanged event. + /// The event is raised when the WebView detects that the monitor DPI scale + /// has changed, ShouldDetectMonitorScaleChanges is true, and the WebView has + /// changed the RasterizationScale property. + /// + /// \snippet ViewComponent.cpp RasterizationScaleChanged + HRESULT add_RasterizationScaleChanged( + [in] ICoreWebView2RasterizationScaleChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + /// Remove an event handler previously added with + /// add_RasterizationScaleChanged. + HRESULT remove_RasterizationScaleChanged( + [in] EventRegistrationToken token); + + /// BoundsMode affects how setting the Bounds and RasterizationScale + /// properties work. Bounds mode can either be in COREWEBVIEW2_BOUNDS_MODE_USE_RAW_PIXELS + /// mode or COREWEBVIEW2_BOUNDS_MODE_USE_RASTERIZATION_SCALE mode. + /// + /// When the mode is in COREWEBVIEW2_BOUNDS_MODE_USE_RAW_PIXELS, setting the bounds + /// property will set the size of the WebView in raw screen pixels. Changing + /// the rasterization scale in this mode won't change the raw pixel size of + /// the WebView and will only change the rasterization scale. + /// + /// When the mode is in COREWEBVIEW2_BOUNDS_MODE_USE_RASTERIZATION_SCALE, setting the + /// bounds property will change the logical size of the WebView which can be + /// described by the following equation: + /// ```text + /// Logical size * rasterization scale = Raw Pixel size + /// ``` + /// In this case, changing the rasterization scale will keep the logical size + /// the same and change the raw pixel size. + /// + /// \snippet ViewComponent.cpp BoundsMode + [propget] HRESULT BoundsMode( + [out, retval] COREWEBVIEW2_BOUNDS_MODE* boundsMode); + /// Set the BoundsMode property. + [propput] HRESULT BoundsMode([in] COREWEBVIEW2_BOUNDS_MODE boundsMode); +} + +/// Represents the WebView2 Environment. WebViews created from an environment +/// run on the browser process specified with environment parameters and +/// objects created from an environment should be used in the same +/// environment. Using it in different environments are not guaranteed to be +/// compatible and may fail. + +[uuid(b96d755e-0319-4e92-a296-23436f46a1fc), object, pointer_default(unique)] +interface ICoreWebView2Environment : IUnknown { + + /// Asynchronously create a new WebView. + /// + /// `parentWindow` is the `HWND` in which the WebView should be displayed and + /// from which receive input. The WebView adds a child window to the + /// provided window before this function returns. Z-order and other things + /// impacted by sibling window order are affected accordingly. If you want to + /// move the WebView to a different parent after it has been created, you must + /// call put_ParentWindow to update tooltip positions, accessibility trees, + /// and such. + /// + /// HWND_MESSAGE is a valid parameter for `parentWindow` for an invisible + /// WebView for Windows 8 and above. In this case the window will never + /// become visible. You are not able to reparent the window after you have + /// created the WebView. This is not supported in Windows 7 or below. + /// Passing this parameter in Windows 7 or below will return + /// ERROR_INVALID_WINDOW_HANDLE in the controller callback. + /// + /// It is recommended that the app set Application User Model ID for the + /// process or the app window. If none is set, during WebView creation a + /// generated Application User Model ID is set to root window of + /// `parentWindow`. + /// + /// \snippet AppWindow.cpp CreateCoreWebView2Controller + /// + /// It is recommended that the app handles restart manager messages, to + /// gracefully restart it in the case when the app is using the WebView2 + /// Runtime from a certain installation and that installation is being + /// uninstalled. For example, if a user installs a version of the WebView2 + /// Runtime and opts to use another version of the WebView2 Runtime for + /// testing the app, and then uninstalls the 1st version of the WebView2 + /// Runtime without closing the app, the app restarts to allow + /// un-installation to succeed. + /// + /// \snippet AppWindow.cpp RestartManager + /// + /// The app should retry `CreateCoreWebView2Controller` upon failure, unless the + /// error code is `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)`. + /// When the app retries `CreateCoreWebView2Controller` upon failure, it is + /// recommended that the app restarts from creating a new WebView2 + /// Environment. If a WebView2 Runtime update happens, the version + /// associated with a WebView2 Environment may have been removed and causing + /// the object to no longer work. Creating a new WebView2 Environment works + /// since it uses the latest version. + /// + /// WebView creation fails with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` if a + /// running instance using the same user data folder exists, and the Environment + /// objects have different `EnvironmentOptions`. For example, if a WebView was + /// created with one language, an attempt to create a WebView with a different + /// language using the same user data folder will fail. + /// + /// The creation will fail with `E_ABORT` if `parentWindow` is destroyed + /// before the creation is finished. If this is caused by a call to + /// `DestroyWindow`, the creation completed handler will be invoked before + /// `DestroyWindow` returns, so you can use this to cancel creation and clean + /// up resources synchronously when quitting a thread. + /// + /// In rare cases the creation can fail with `E_UNEXPECTED` if runtime does not have + /// permissions to the user data folder. + + HRESULT CreateCoreWebView2Controller( + HWND parentWindow, + ICoreWebView2CreateCoreWebView2ControllerCompletedHandler* handler); + + /// Create a new web resource response object. The `headers` parameter is + /// the raw response header string delimited by newline. It is also possible + /// to create this object with null headers string and then use the + /// `ICoreWebView2HttpResponseHeaders` to construct the headers line by line. + /// For more information about other parameters, navigate to + /// [ICoreWebView2WebResourceResponse](/microsoft-edge/webview2/reference/win32/icorewebview2webresourceresponse). + /// + /// \snippet SettingsComponent.cpp WebResourceRequested0 + /// \snippet SettingsComponent.cpp WebResourceRequested1 + HRESULT CreateWebResourceResponse( + [in] IStream* content, + [in] int statusCode, + [in] LPCWSTR reasonPhrase, + [in] LPCWSTR headers, + [out, retval] ICoreWebView2WebResourceResponse** response); + + /// The browser version info of the current `ICoreWebView2Environment`, + /// including channel name if it is not the WebView2 Runtime. It matches the + /// format of the `GetAvailableCoreWebView2BrowserVersionString` API. + /// Channel names are `beta`, `dev`, and `canary`. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + /// + /// \snippet AppWindow.cpp GetBrowserVersionString + [propget] HRESULT BrowserVersionString([out, retval] LPWSTR* versionInfo); + + /// Add an event handler for the `NewBrowserVersionAvailable` event. + /// `NewBrowserVersionAvailable` runs when a newer version of the WebView2 + /// Runtime is installed and available using WebView2. To use the newer + /// version of the browser you must create a new environment and WebView. + /// The event only runs for new version from the same WebView2 Runtime from + /// which the code is running. When not running with installed WebView2 + /// Runtime, no event is run. + /// + /// Because a user data folder is only able to be used by one browser + /// process at a time, if you want to use the same user data folder in the + /// WebView using the new version of the browser, you must close the + /// environment and instance of WebView that are using the older version of + /// the browser first. Or simply prompt the user to restart the app. + /// + /// \snippet AppWindow.cpp NewBrowserVersionAvailable + HRESULT add_NewBrowserVersionAvailable( + [in] ICoreWebView2NewBrowserVersionAvailableEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_NewBrowserVersionAvailable`. + HRESULT remove_NewBrowserVersionAvailable( + [in] EventRegistrationToken token); +} + +/// Options used to create WebView2 Environment. A default implementation is +/// provided in `WebView2EnvironmentOptions.h`. +/// +/// \snippet AppWindow.cpp CreateCoreWebView2EnvironmentWithOptions + +[uuid(2fde08a8-1e9a-4766-8c05-95a9ceb9d1c5), object, pointer_default(unique)] +interface ICoreWebView2EnvironmentOptions : IUnknown { + + /// Changes the behavior of the WebView. The arguments are passed to the + /// browser process as part of the command. For more information about + /// using command-line switches with Chromium browser processes, navigate to + /// [Run Chromium with Flags](https://www.chromium.org/developers/how-tos/run-chromium-with-flags). + /// The value appended to a switch is appended to the browser process, for + /// example, in `--edge-webview-switches=xxx` the value is `xxx`. If you + /// specify a switch that is important to WebView functionality, it is + /// ignored, for example, `--user-data-dir`. Specific features are disabled + /// internally and blocked from being enabled. If a switch is specified + /// multiple times, only the last instance is used. + /// + /// \> [!NOTE]\n\> A merge of the different values of the same switch is not attempted, + /// except for disabled and enabled features. The features specified by + /// `--enable-features` and `--disable-features` are merged with simple + /// logic.\n\> * The features is the union of the specified features + /// and built-in features. If a feature is disabled, it is removed from the + /// enabled features list. + /// + /// If you specify command-line switches and use the + /// `additionalBrowserArguments` parameter, the `--edge-webview-switches` + /// value takes precedence and is processed last. If a switch fails to + /// parse, the switch is ignored. The default state for the operation is + /// to run the browser process with no extra flags. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT AdditionalBrowserArguments([out, retval] LPWSTR* value); + + /// Sets the `AdditionalBrowserArguments` property. + /// + /// Please note that calling this API twice will replace the previous value + /// rather than appending to it. If there are multiple switches, there + /// should be a space in between them. The one exception is if multiple + /// features are being enabled/disabled for a single switch, in which + /// case the features should be comma-seperated. + /// Ex. "--disable-features=feature1,feature2 --some-other-switch --do-something" + [propput] HRESULT AdditionalBrowserArguments([in] LPCWSTR value); + + /// The default display language for WebView. It applies to browser UI such as + /// context menu and dialogs. It also applies to the `accept-languages` HTTP + /// header that WebView sends to websites. The intended locale value is in the + /// format of BCP 47 Language Tags. More information can be found from + /// [IETF BCP47](https://www.ietf.org/rfc/bcp/bcp47.html). + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Language([out, retval] LPWSTR* value); + + /// Sets the `Language` property. + [propput] HRESULT Language([in] LPCWSTR value); + + /// Specifies the version of the WebView2 Runtime binaries required to be + /// compatible with your app. This defaults to the WebView2 Runtime version + /// that corresponds with the version of the SDK the app is using. The + /// format of this value is the same as the format of the + /// `BrowserVersionString` property and other `BrowserVersion` values. Only + /// the version part of the `BrowserVersion` value is respected. The channel + /// suffix, if it exists, is ignored. The version of the WebView2 Runtime + /// binaries actually used may be different from the specified + /// `TargetCompatibleBrowserVersion`. The binaries are only guaranteed to be + /// compatible. Verify the actual version on the `BrowserVersionString` + /// property on the `ICoreWebView2Environment`. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT TargetCompatibleBrowserVersion([out, retval] LPWSTR* value); + + /// Sets the `TargetCompatibleBrowserVersion` property. + [propput] HRESULT TargetCompatibleBrowserVersion([in] LPCWSTR value); + + /// The `AllowSingleSignOnUsingOSPrimaryAccount` property is used to enable + /// single sign on with Azure Active Directory (AAD) and personal Microsoft + /// Account (MSA) resources inside WebView. All AAD accounts, connected to + /// Windows and shared for all apps, are supported. For MSA, SSO is only enabled + /// for the account associated for Windows account login, if any. + /// Default is disabled. Universal Windows Platform apps must also declare + /// `enterpriseCloudSSO` + /// [Restricted capabilities](/windows/uwp/packaging/app-capability-declarations\#restricted-capabilities) + /// for the single sign on (SSO) to work. + [propget] HRESULT AllowSingleSignOnUsingOSPrimaryAccount([out, retval] BOOL* allow); + + /// Sets the `AllowSingleSignOnUsingOSPrimaryAccount` property. + [propput] HRESULT AllowSingleSignOnUsingOSPrimaryAccount([in] BOOL allow); +} + +/// Event args for the `AcceleratorKeyPressed` event. + +[uuid(9f760f8a-fb79-42be-9990-7b56900fa9c7), object, pointer_default(unique)] +interface ICoreWebView2AcceleratorKeyPressedEventArgs : IUnknown { + + /// The key event type that caused the event to run. + + [propget] HRESULT KeyEventKind([out, retval] COREWEBVIEW2_KEY_EVENT_KIND* keyEventKind); + + /// The Win32 virtual key code of the key that was pressed or released. It + /// is one of the Win32 virtual key constants such as `VK_RETURN` or an + /// (uppercase) ASCII value such as `A`. Verify whether Ctrl or Alt + /// are pressed by running `GetKeyState(VK_CONTROL)` or + /// `GetKeyState(VK_MENU)`. + + [propget] HRESULT VirtualKey([out, retval] UINT* virtualKey); + + /// The `LPARAM` value that accompanied the window message. For more + /// information, navigate to [WM_KEYDOWN](/windows/win32/inputdev/wm-keydown) + /// and [WM_KEYUP](/windows/win32/inputdev/wm-keyup). + + [propget] HRESULT KeyEventLParam([out, retval] INT* lParam); + + /// A structure representing the information passed in the `LPARAM` of the + /// window message. + + [propget] HRESULT PhysicalKeyStatus( + [out, retval] COREWEBVIEW2_PHYSICAL_KEY_STATUS* physicalKeyStatus); + + /// During `AcceleratorKeyPressedEvent` handler invocation the WebView is + /// blocked waiting for the decision of if the accelerator is handled by the + /// host (or not). If the `Handled` property is set to `TRUE` then this + /// prevents the WebView from performing the default action for this + /// accelerator key. Otherwise the WebView performs the default action for + /// the accelerator key. + + [propget] HRESULT Handled([out, retval] BOOL* handled); + + /// Sets the `Handled` property. + + [propput] HRESULT Handled([in] BOOL handled); +} + +/// Event args for the BasicAuthenticationRequested event. Will contain the +/// request that led to the HTTP authorization challenge, the challenge +/// and allows the host to provide authentication response or cancel the request. +[uuid(ef05516f-d897-4f9e-b672-d8e2307a3fb0), object, pointer_default(unique)] +interface ICoreWebView2BasicAuthenticationRequestedEventArgs : IUnknown { + /// The URI that led to the authentication challenge. For proxy authentication + /// requests, this will be the URI of the proxy server. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Uri([out, retval] LPWSTR* value); + + /// The authentication challenge string + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Challenge([out, retval] LPWSTR* challenge); + + /// Response to the authentication request with credentials. This object will be populated by the app + /// if the host would like to provide authentication credentials. + [propget] HRESULT Response([out, retval] ICoreWebView2BasicAuthenticationResponse** response); + + /// Cancel the authentication request. False by default. + /// If set to true, Response will be ignored. + [propget] HRESULT Cancel([out, retval] BOOL* cancel); + /// Set the Cancel property. + [propput] HRESULT Cancel([in] BOOL cancel); + + /// Returns an `ICoreWebView2Deferral` object. Use this deferral to + /// defer the decision to show the Basic Authentication dialog. + HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral); +} + +/// Represents a Basic HTTP authentication response that contains a user name +/// and a password as according to RFC7617 (https://tools.ietf.org/html/rfc7617) +[uuid(07023f7d-2d77-4d67-9040-6e7d428c6a40), object, pointer_default(unique)] +interface ICoreWebView2BasicAuthenticationResponse : IUnknown { + /// User name provided for authentication. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT UserName([out, retval] LPWSTR* userName); + /// Set user name property + [propput] HRESULT UserName([in] LPCWSTR userName); + + /// Password provided for authentication. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Password([out, retval] LPWSTR* password); + /// Set password property + [propput] HRESULT Password([in] LPCWSTR password); +} + +/// Provides a set of properties for managing an Extension, which includes +/// an ID, name, and whether it is enabled or not, and the ability to Remove +/// the Extension, and enable or disable it. +[uuid(7EF7FFA0-FAC5-462C-B189-3D9EDBE575DA), object, pointer_default(unique)] +interface ICoreWebView2BrowserExtension : IUnknown { + /// This is the browser extension's ID. This is the same browser extension ID returned by + /// the browser extension API [`chrome.runtime.id`](https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime/id). + /// Please see that documentation for more details on how the ID is generated. + /// After an extension is removed, calling `Id` will return the id of the extension that is removed. + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Id([out, retval] LPWSTR* value); + /// This is the browser extension's name. This value is defined in this browser extension's + /// manifest.json file. If manifest.json define extension's localized name, this value will + /// be the localized version of the name. + /// Please see [Manifest.json name](https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/manifest.json/name) + /// for more details. + /// After an extension is removed, calling `Name` will return the name of the extension that is removed. + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Name([out, retval] LPWSTR* value); + /// Removes this browser extension from its WebView2 Profile. The browser extension is removed + /// immediately including from all currently running HTML documents associated with this + /// WebView2 Profile. The removal is persisted and future uses of this profile will not have this + /// extension installed. After an extension is removed, calling `Remove` again will cause an exception. + HRESULT Remove([in] ICoreWebView2BrowserExtensionRemoveCompletedHandler* handler); + /// If `isEnabled` is true then the Extension is enabled and running in WebView instances. + /// If it is false then the Extension is disabled and not running in WebView instances. + /// When a Extension is first installed, `IsEnable` are default to be `TRUE`. + /// `isEnabled` is persisted per profile. + /// After an extension is removed, calling `isEnabled` will return the value at the time it was removed. + [propget] HRESULT IsEnabled([out, retval] BOOL* value); + /// Sets whether this browser extension is enabled or disabled. This change applies immediately + /// to the extension in all HTML documents in all WebView2s associated with this profile. + /// After an extension is removed, calling `Enable` will not change the value of `IsEnabled`. + HRESULT Enable([in] BOOL isEnabled, [in] ICoreWebView2BrowserExtensionEnableCompletedHandler* handler); +} + +/// Provides access to the certificate metadata. +[uuid(C5FB2FCE-1CAC-4AEE-9C79-5ED0362EAAE0), object, pointer_default(unique)] +interface ICoreWebView2Certificate : IUnknown { + /// Subject of the certificate. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Subject([out, retval] LPWSTR* value); + /// Name of the certificate authority that issued the certificate. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Issuer([out, retval] LPWSTR* value); + /// The valid start date and time for the certificate as the number of seconds since + /// the UNIX epoch. + [propget] HRESULT ValidFrom([out, retval] double* value); + /// The valid expiration date and time for the certificate as the number of seconds since + /// the UNIX epoch. + [propget] HRESULT ValidTo([out, retval] double* value); + /// Base64 encoding of DER encoded serial number of the certificate. + /// Read more about DER at [RFC 7468 DER] + /// (https://tools.ietf.org/html/rfc7468#appendix-B). + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT DerEncodedSerialNumber([out, retval] LPWSTR* value); + /// Display name for a certificate. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings) + [propget] HRESULT DisplayName([out, retval] LPWSTR* value); + /// PEM encoded data for the certificate. + /// Returns Base64 encoding of DER encoded certificate. + /// Read more about PEM at [RFC 1421 Privacy Enhanced Mail] + /// (https://tools.ietf.org/html/rfc1421). + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings) + HRESULT ToPemEncoding([out, retval] LPWSTR* pemEncodedData); + /// Collection of PEM encoded certificate issuer chain. + /// In this collection first element is the current certificate followed by + /// intermediate1, intermediate2...intermediateN-1. Root certificate is the + /// last element in collection. + [propget] HRESULT PemEncodedIssuerCertificateChain([out, retval] + ICoreWebView2StringCollection** value); +} + +/// Provides access to the client certificate metadata. +[uuid(e7188076-bcc3-11eb-8529-0242ac130003), object, pointer_default(unique)] +interface ICoreWebView2ClientCertificate : IUnknown { + /// Subject of the certificate. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Subject([out, retval] LPWSTR* value); + /// Name of the certificate authority that issued the certificate. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Issuer([out, retval] LPWSTR* value); + /// The valid start date and time for the certificate as the number of seconds since + /// the UNIX epoch. + [propget] HRESULT ValidFrom([out, retval] double* value); + /// The valid expiration date and time for the certificate as the number of seconds since + /// the UNIX epoch. + [propget] HRESULT ValidTo([out, retval] double* value); + /// Base64 encoding of DER encoded serial number of the certificate. + /// Read more about DER at [RFC 7468 DER] + /// (https://tools.ietf.org/html/rfc7468#appendix-B). + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT DerEncodedSerialNumber([out, retval] LPWSTR* value); + /// Display name for a certificate. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT DisplayName([out, retval] LPWSTR* value); + /// PEM encoded data for the certificate. + /// Returns Base64 encoding of DER encoded certificate. + /// Read more about PEM at [RFC 1421 Privacy Enhanced Mail] + /// (https://tools.ietf.org/html/rfc1421). + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + HRESULT ToPemEncoding([out, retval] LPWSTR* pemEncodedData); + /// Collection of PEM encoded client certificate issuer chain. + /// In this collection first element is the current certificate followed by + /// intermediate1, intermediate2...intermediateN-1. Root certificate is the + /// last element in collection. + [propget] HRESULT PemEncodedIssuerCertificateChain([out, retval] + ICoreWebView2StringCollection** value); + /// Kind of a certificate (eg., smart card, pin, other). + [propget] HRESULT Kind([out, retval] + COREWEBVIEW2_CLIENT_CERTIFICATE_KIND* value); +} + +/// Event args for the `ClientCertificateRequested` event. +[uuid(bc59db28-bcc3-11eb-8529-0242ac130003), object, pointer_default(unique)] +interface ICoreWebView2ClientCertificateRequestedEventArgs : IUnknown { + /// Host name of the server that requested client certificate authentication. + /// Normalization rules applied to the hostname are: + /// * Convert to lowercase characters for ascii characters. + /// * Punycode is used for representing non ascii characters. + /// * Strip square brackets for IPV6 address. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Host([out, retval] LPWSTR* value); + + /// Port of the server that requested client certificate authentication. + [propget] HRESULT Port([out, retval] int* value); + + /// Returns true if the server that issued this request is an http proxy. + /// Returns false if the server is the origin server. + [propget] HRESULT IsProxy([out, retval] BOOL* value); + + /// Returns the `ICoreWebView2StringCollection`. + /// The collection contains Base64 encoding of DER encoded distinguished names of + /// certificate authorities allowed by the server. + [propget] HRESULT AllowedCertificateAuthorities([out, retval] + ICoreWebView2StringCollection** value); + + /// Returns the `ICoreWebView2ClientCertificateCollection` when client + /// certificate authentication is requested. The collection contains mutually + /// trusted CA certificates. + [propget] HRESULT MutuallyTrustedCertificates([out, retval] + ICoreWebView2ClientCertificateCollection** value); + + /// Returns the selected certificate. + [propget] HRESULT SelectedCertificate([out, retval] + ICoreWebView2ClientCertificate** value); + + /// Sets the certificate to respond to the server. + [propput] HRESULT SelectedCertificate( + [in] ICoreWebView2ClientCertificate* value); + + /// You may set this flag to cancel the certificate selection. If canceled, + /// the request is aborted regardless of the `Handled` property. By default the + /// value is `FALSE`. + [propget] HRESULT Cancel([out, retval] BOOL* value); + + /// Sets the `Cancel` property. + [propput] HRESULT Cancel([in] BOOL value); + + /// You may set this flag to `TRUE` to respond to the server with or + /// without a certificate. If this flag is `TRUE` with a `SelectedCertificate` + /// it responds to the server with the selected certificate otherwise respond to the + /// server without a certificate. By default the value of `Handled` and `Cancel` are `FALSE` + /// and display default client certificate selection dialog prompt to allow the user to + /// choose a certificate. The `SelectedCertificate` is ignored unless `Handled` is set `TRUE`. + [propget] HRESULT Handled([out, retval] BOOL* value); + + /// Sets the `Handled` property. + [propput] HRESULT Handled([in] BOOL value); + + /// Returns an `ICoreWebView2Deferral` object. Use this operation to + /// complete the event at a later time. + HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral); +} + +/// This interface is an extension of the ICoreWebView2Controller interface to +/// support visual hosting. An object implementing the +/// ICoreWebView2CompositionController interface will also implement +/// ICoreWebView2Controller. Callers are expected to use +/// ICoreWebView2Controller for resizing, visibility, focus, and so on, and +/// then use ICoreWebView2CompositionController to connect to a composition +/// tree and provide input meant for the WebView. +[uuid(3df9b733-b9ae-4a15-86b4-eb9ee9826469), object, pointer_default(unique)] +interface ICoreWebView2CompositionController : IUnknown { + /// The RootVisualTarget is a visual in the hosting app's visual tree. This + /// visual is where the WebView will connect its visual tree. The app uses + /// this visual to position the WebView within the app. The app still needs + /// to use the Bounds property to size the WebView. The RootVisualTarget + /// property can be an IDCompositionVisual or a + /// Windows::UI::Composition::ContainerVisual. WebView will connect its visual + /// tree to the provided visual before returning from the property setter. The + /// app needs to commit on its device setting the RootVisualTarget property. + /// The RootVisualTarget property supports being set to nullptr to disconnect + /// the WebView from the app's visual tree. + /// \snippet ViewComponent.cpp SetRootVisualTarget + /// \snippet ViewComponent.cpp BuildDCompTree + [propget] HRESULT RootVisualTarget([out, retval] IUnknown** target); + /// Set the RootVisualTarget property. + [propput] HRESULT RootVisualTarget([in] IUnknown* target); + + /// If eventKind is COREWEBVIEW2_MOUSE_EVENT_KIND_HORIZONTAL_WHEEL or + /// COREWEBVIEW2_MOUSE_EVENT_KIND_WHEEL, then mouseData specifies the amount of + /// wheel movement. A positive value indicates that the wheel was rotated + /// forward, away from the user; a negative value indicates that the wheel was + /// rotated backward, toward the user. One wheel click is defined as + /// WHEEL_DELTA, which is 120. + /// If eventKind is COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_DOUBLE_CLICK + /// COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_DOWN, or + /// COREWEBVIEW2_MOUSE_EVENT_KIND_X_BUTTON_UP, then mouseData specifies which X + /// buttons were pressed or released. This value should be 1 if the first X + /// button is pressed/released and 2 if the second X button is + /// pressed/released. + /// If eventKind is COREWEBVIEW2_MOUSE_EVENT_KIND_LEAVE, then virtualKeys, + /// mouseData, and point should all be zero. + /// If eventKind is any other value, then mouseData should be zero. + /// Point is expected to be in the client coordinate space of the WebView. + /// To track mouse events that start in the WebView and can potentially move + /// outside of the WebView and host application, calling SetCapture and + /// ReleaseCapture is recommended. + /// To dismiss hover popups, it is also recommended to send + /// COREWEBVIEW2_MOUSE_EVENT_KIND_LEAVE messages. + /// \snippet ViewComponent.cpp SendMouseInput + HRESULT SendMouseInput( + [in] COREWEBVIEW2_MOUSE_EVENT_KIND eventKind, + [in] COREWEBVIEW2_MOUSE_EVENT_VIRTUAL_KEYS virtualKeys, + [in] UINT32 mouseData, + [in] POINT point); + + /// SendPointerInput accepts touch or pen pointer input of types defined in + /// COREWEBVIEW2_POINTER_EVENT_KIND. Any pointer input from the system must be + /// converted into an ICoreWebView2PointerInfo first. + HRESULT SendPointerInput( + [in] COREWEBVIEW2_POINTER_EVENT_KIND eventKind, + [in] ICoreWebView2PointerInfo* pointerInfo); + + /// The current cursor that WebView thinks it should be. The cursor should be + /// set in WM_SETCURSOR through \::SetCursor or set on the corresponding + /// parent/ancestor HWND of the WebView through \::SetClassLongPtr. The HCURSOR + /// can be freed so CopyCursor/DestroyCursor is recommended to keep your own + /// copy if you are doing more than immediately setting the cursor. + [propget] HRESULT Cursor([out, retval] HCURSOR* cursor); + + /// The current system cursor ID reported by the underlying rendering engine + /// for WebView. For example, most of the time, when the cursor is over text, + /// this will return the int value for IDC_IBEAM. The systemCursorId is only + /// valid if the rendering engine reports a default Windows cursor resource + /// value. Navigate to + /// [LoadCursorW](/windows/win32/api/winuser/nf-winuser-loadcursorw) for more + /// details. Otherwise, if custom CSS cursors are being used, this will return + /// 0. To actually use systemCursorId in LoadCursor or LoadImage, + /// MAKEINTRESOURCE must be called on it first. + /// + /// \snippet ViewComponent.cpp SystemCursorId + [propget] HRESULT SystemCursorId([out, retval] UINT32* systemCursorId); + + /// Add an event handler for the CursorChanged event. + /// The event is raised when WebView thinks the cursor should be changed. For + /// example, when the mouse cursor is currently the default cursor but is then + /// moved over text, it may try to change to the IBeam cursor. + /// + /// It is expected for the developer to send + /// COREWEBVIEW2_MOUSE_EVENT_KIND_LEAVE messages (in addition to + /// COREWEBVIEW2_MOUSE_EVENT_KIND_MOVE messages) through the SendMouseInput + /// API. This is to ensure that the mouse is actually within the WebView that + /// sends out CursorChanged events. + /// + /// \snippet ViewComponent.cpp CursorChanged + HRESULT add_CursorChanged( + [in] ICoreWebView2CursorChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + /// Remove an event handler previously added with add_CursorChanged. + HRESULT remove_CursorChanged( + [in] EventRegistrationToken token); +} + +/// This interface is the continuation of the +/// ICoreWebView2CompositionController2 interface to manage drag and drop. +[uuid(9570570e-4d76-4361-9ee1-f04d0dbdfb1e), object, pointer_default(unique)] +interface ICoreWebView2CompositionController3 : ICoreWebView2CompositionController2 { + /// This function corresponds to [IDropTarget::DragEnter](/windows/win32/api/oleidl/nf-oleidl-idroptarget-dragenter). + /// + /// This function has a dependency on AllowExternalDrop property of + /// CoreWebView2Controller and return E_FAIL to callers to indicate this + /// operation is not allowed if AllowExternalDrop property is set to false. + /// + /// The hosting application must register as an IDropTarget and implement + /// and forward DragEnter calls to this function. + /// + /// point parameter must be modified to include the WebView's offset and be in + /// the WebView's client coordinates (Similar to how SendMouseInput works). + /// + /// \snippet DropTarget.cpp DragEnter + HRESULT DragEnter( + [in] IDataObject* dataObject, + [in] DWORD keyState, + [in] POINT point, + [out, retval] DWORD* effect); + + /// This function corresponds to [IDropTarget::DragLeave](/windows/win32/api/oleidl/nf-oleidl-idroptarget-dragleave). + /// + /// This function has a dependency on AllowExternalDrop property of + /// CoreWebView2Controller and return E_FAIL to callers to indicate this + /// operation is not allowed if AllowExternalDrop property is set to false. + /// + /// The hosting application must register as an IDropTarget and implement + /// and forward DragLeave calls to this function. + /// + /// \snippet DropTarget.cpp DragLeave + HRESULT DragLeave(); + + /// This function corresponds to [IDropTarget::DragOver](/windows/win32/api/oleidl/nf-oleidl-idroptarget-dragover). + /// + /// This function has a dependency on AllowExternalDrop property of + /// CoreWebView2Controller and return E_FAIL to callers to indicate this + /// operation is not allowed if AllowExternalDrop property is set to false. + /// + /// The hosting application must register as an IDropTarget and implement + /// and forward DragOver calls to this function. + /// + /// point parameter must be modified to include the WebView's offset and be in + /// the WebView's client coordinates (Similar to how SendMouseInput works). + /// + /// \snippet DropTarget.cpp DragOver + HRESULT DragOver( + [in] DWORD keyState, + [in] POINT point, + [out, retval] DWORD* effect); + + /// This function corresponds to [IDropTarget::Drop](/windows/win32/api/oleidl/nf-oleidl-idroptarget-drop). + /// + /// This function has a dependency on AllowExternalDrop property of + /// CoreWebView2Controller and return E_FAIL to callers to indicate this + /// operation is not allowed if AllowExternalDrop property is set to false. + /// + /// The hosting application must register as an IDropTarget and implement + /// and forward Drop calls to this function. + /// + /// point parameter must be modified to include the WebView's offset and be in + /// the WebView's client coordinates (Similar to how SendMouseInput works). + /// + /// \snippet DropTarget.cpp Drop + HRESULT Drop( + [in] IDataObject* dataObject, + [in] DWORD keyState, + [in] POINT point, + [out, retval] DWORD* effect); +} + +/// This Interface includes an API which enables non-client hit-testing support for WebView2. +[uuid(7C367B9B-3D2B-450F-9E58-D61A20F486AA), object, pointer_default(unique)] +interface ICoreWebView2CompositionController4 : ICoreWebView2CompositionController3 { + /// If you are hosting a WebView2 using CoreWebView2CompositionController, you can call + /// this method in your Win32 WndProc to determine if the mouse is moving over or + /// clicking on WebView2 web content that should be considered part of a non-client region. + + /// The point parameter is expected to be in the client coordinate space of WebView2. + /// The method sets the out parameter value as follows: + /// - COREWEBVIEW2_NON_CLIENT_REGION_KIND_CAPTION when point corresponds to + /// a region (HTML element) within the WebView2 with + /// `-webkit-app-region: drag` CSS style set. + /// - COREWEBVIEW2_NON_CLIENT_REGION_KIND_CLIENT when point corresponds to + /// a region (HTML element) within the WebView2 without + /// `-webkit-app-region: drag` CSS style set. + /// - COREWEBVIEW2_NON_CLIENT_REGION_KIND_NOWHERE when point is not within the WebView2. + /// + /// NOTE: in order for WebView2 to properly handle the title bar system menu, + /// the app needs to send WM_NCRBUTTONDOWN and WM_NCRBUTTONUP to SendMouseInput. + /// See sample code below. + /// \snippet ViewComponent.cpp DraggableRegions2 + /// + /// \snippet ViewComponent.cpp DraggableRegions1 + HRESULT GetNonClientRegionAtPoint( + [in] POINT point, + [out, retval] COREWEBVIEW2_NON_CLIENT_REGION_KIND* value); + + /// This method is used to get the collection of rects that correspond + /// to a particular COREWEBVIEW2_NON_CLIENT_REGION_KIND. This is to be used in + /// the callback of add_NonClientRegionChanged whose event args object contains + /// a region property of type COREWEBVIEW2_NON_CLIENT_REGION_KIND. + /// + /// \snippet ScenarioNonClientRegionSupport.cpp AddChangeListener + HRESULT QueryNonClientRegion( + [in] COREWEBVIEW2_NON_CLIENT_REGION_KIND kind, + [out, retval] ICoreWebView2RegionRectCollectionView** rects); + + /// This method is used to add a listener for NonClientRegionChanged. + /// The event is fired when regions which are marked as non-client in the + /// app html have changed. So either when new regions have been marked, + /// or unmarked, or the region(s) have been changed to a different kind. + /// + /// \snippet ScenarioNonClientRegionSupport.cpp AddChangeListener + HRESULT add_NonClientRegionChanged( + [in] ICoreWebView2NonClientRegionChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// This method is used to remove an event handler previously added with + /// add_NonClientRegionChanged + HRESULT remove_NonClientRegionChanged([in] EventRegistrationToken token); +} + +/// Represents a context menu item of a context menu displayed by WebView. +[uuid(7aed49e3-a93f-497a-811c-749c6b6b6c65), object, pointer_default(unique)] +interface ICoreWebView2ContextMenuItem : IUnknown { + /// Gets the unlocalized name for the `ContextMenuItem`. Use this to + /// distinguish between context menu item types. This will be the English + /// label of the menu item in lower camel case. For example, the "Save as" + /// menu item will be "saveAs". Extension menu items will be "extension", + /// custom menu items will be "custom" and spellcheck items will be + /// "spellCheck". + /// Some example context menu item names are: + /// - "saveAs" + /// - "copyImage" + /// - "openLinkInNewWindow" + /// - "cut" + /// - "copy" + /// - "paste" + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Name([out, retval] LPWSTR* value); + + /// Gets the localized label for the `ContextMenuItem`. Will contain an + /// ampersand for characters to be used as keyboard accelerator. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Label([out, retval] LPWSTR* value); + + /// Gets the Command ID for the `ContextMenuItem`. Use this to report the + /// `SelectedCommandId` in `ContextMenuRequested` event. + [propget] HRESULT CommandId([out, retval] INT32* value); + + /// Gets the localized keyboard shortcut for this ContextMenuItem. It will be + /// the empty string if there is no keyboard shortcut. This is text intended + /// to be displayed to the end user to show the keyboard shortcut. For example + /// this property is Ctrl+Shift+I for the "Inspect" `ContextMenuItem`. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT ShortcutKeyDescription([out, retval] LPWSTR* value); + + /// Gets the Icon for the `ContextMenuItem` in PNG, Bitmap or SVG formats in the form of an IStream. + /// Stream will be rewound to the start of the image data. + [propget] HRESULT Icon([out, retval] IStream** value); + + /// Gets the `ContextMenuItem` kind. + [propget] HRESULT Kind([out, retval] COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND* value); + + /// Sets the enabled property of the `ContextMenuItem`. Must only be used in the case of a + /// custom context menu item. The default value for this is `TRUE`. + [propput] HRESULT IsEnabled([in] BOOL value); + + /// Gets the enabled property of the `ContextMenuItem`. + [propget] HRESULT IsEnabled([out, retval] BOOL* value); + + /// Sets the checked property of the `ContextMenuItem`. Must only be used for custom context + /// menu items that are of kind Check box or Radio. + [propput] HRESULT IsChecked([in] BOOL value); + + /// Gets the checked property of the `ContextMenuItem`, used if the kind is Check box or Radio. + [propget] HRESULT IsChecked([out, retval] BOOL* value); + + /// Gets the list of children menu items through a `ContextMenuItemCollection` + /// if the kind is Submenu. If the kind is not submenu, will return null. + [propget] HRESULT Children([out, retval] ICoreWebView2ContextMenuItemCollection** value); + + /// Add an event handler for the `CustomItemSelected` event. + /// `CustomItemSelected` event is raised when the user selects this `ContextMenuItem`. + /// Will only be raised for end developer created context menu items + HRESULT add_CustomItemSelected( + [in] ICoreWebView2CustomItemSelectedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_CustomItemSelected`. + HRESULT remove_CustomItemSelected( + [in] EventRegistrationToken token); +} + +/// Represents the information regarding the context menu target. +/// Includes the context selected and the appropriate data used for the actions of a context menu. +[uuid(b8611d99-eed6-4f3f-902c-a198502ad472), object, pointer_default(unique)] +interface ICoreWebView2ContextMenuTarget : IUnknown { + /// Gets the kind of context that the user selected. + [propget] HRESULT Kind([out, retval] COREWEBVIEW2_CONTEXT_MENU_TARGET_KIND* value); + + /// Returns TRUE if the context menu is requested on an editable component. + [propget] HRESULT IsEditable([out, retval] BOOL* value); + + /// Returns TRUE if the context menu was requested on the main frame and + /// FALSE if invoked on another frame. + [propget] HRESULT IsRequestedForMainFrame([out, retval] BOOL* value); + + /// Gets the uri of the page. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT PageUri([out, retval] LPWSTR* value); + + /// Gets the uri of the frame. Will match the PageUri if `IsRequestedForMainFrame` is TRUE. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT FrameUri([out, retval] LPWSTR* value); + + /// Returns TRUE if the context menu is requested on HTML containing an anchor tag. + [propget] HRESULT HasLinkUri([out, retval] BOOL* value); + + /// Gets the uri of the link (if `HasLinkUri` is TRUE, null otherwise). + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT LinkUri([out, retval] LPWSTR* value); + + /// Returns TRUE if the context menu is requested on text element that contains an anchor tag. + [propget] HRESULT HasLinkText([out, retval] BOOL* value); + + /// Gets the text of the link (if `HasLinkText` is TRUE, null otherwise). + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT LinkText([out, retval] LPWSTR * value); + + /// Returns TRUE if the context menu is requested on HTML containing a source uri. + [propget] HRESULT HasSourceUri([out, retval] BOOL* value); + + /// Gets the active source uri of element (if `HasSourceUri` is TRUE, null otherwise). + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT SourceUri([out, retval] LPWSTR* value); + + /// Returns TRUE if the context menu is requested on a selection. + [propget] HRESULT HasSelection([out, retval] BOOL* value); + + /// Gets the selected text (if `HasSelection` is TRUE, null otherwise). + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT SelectionText([out, retval] LPWSTR* value); +} + +/// Event args for the `ContextMenuRequested` event. Will contain the selection information +/// and a collection of all of the default context menu items that the WebView +/// would show. Allows the app to draw its own context menu or add/remove +/// from the default context menu. +[uuid(a1d309ee-c03f-11eb-8529-0242ac130003), object, pointer_default(unique)] +interface ICoreWebView2ContextMenuRequestedEventArgs : IUnknown { + /// Gets the collection of `ContextMenuItem` objects. + /// See `ICoreWebView2ContextMenuItemCollection` for more details. + [propget] HRESULT MenuItems([out, retval] ICoreWebView2ContextMenuItemCollection** value); + + /// Gets the target information associated with the requested context menu. + /// See `ICoreWebView2ContextMenuTarget` for more details. + [propget] HRESULT ContextMenuTarget([out, retval] ICoreWebView2ContextMenuTarget** value); + + /// Gets the coordinates where the context menu request occurred in relation to the upper + /// left corner of the WebView bounds. + [propget] HRESULT Location([out, retval] POINT* value); + + /// Sets the selected context menu item's command ID. When this is set, + /// WebView will execute the selected command. This + /// value should always be obtained via the selected `ContextMenuItem`'s `CommandId` property. + /// The default value is -1 which means that no selection occurred. The app can + /// also report the selected command ID for a custom context menu item, which + /// will cause the `CustomItemSelected` event to be fired for the custom item, however + /// while command IDs for each custom context menu item is unique + /// during a ContextMenuRequested event, CoreWebView2 may reassign command ID + /// values of deleted custom ContextMenuItems to new objects and the command + /// ID assigned to the same custom item can be different between each app runtime. + [propput] HRESULT SelectedCommandId([in] INT32 value); + + /// Gets the selected CommandId. + [propget] HRESULT SelectedCommandId([out, retval] INT32* value); + + /// Sets whether the `ContextMenuRequested` event is handled by host after + /// the event handler completes or if there is a deferral then after the deferral is completed. + /// If `Handled` is set to TRUE then WebView will not display a context menu and will instead + /// use the `SelectedCommandId` property to indicate which, if any, context menu item command to invoke. + /// If after the event handler or deferral completes `Handled` is set to FALSE then WebView + /// will display a context menu based on the contents of the `MenuItems` property. + /// The default value is FALSE. + [propput] HRESULT Handled([in] BOOL value); + + /// Gets whether the `ContextMenuRequested` event is handled by host. + [propget] HRESULT Handled([out, retval] BOOL* value); + + /// Returns an `ICoreWebView2Deferral` object. Use this operation to + /// complete the event when the custom context menu is closed. + HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral); +} + +/// This interface is used to manage profile options that created by 'CreateCoreWebView2ControllerOptions'. +/// +/// \snippet AppWindow.cpp CreateControllerWithOptions +[uuid(12aae616-8ccb-44ec-bcb3-eb1831881635), object, pointer_default(unique)] +interface ICoreWebView2ControllerOptions : IUnknown { + /// `ProfileName` property is to specify a profile name, which is only allowed to contain + /// the following ASCII characters. It has a maximum length of 64 characters excluding the null-terminator. + /// It is ASCII case insensitive. + /// + /// * alphabet characters: a-z and A-Z + /// * digit characters: 0-9 + /// * and '#', '@', '$', '(', ')', '+', '-', '_', '~', '.', ' ' (space). + /// + /// Note: the text must not end with a period '.' or ' ' (space). And, although upper-case letters are + /// allowed, they're treated just as lower-case counterparts because the profile name will be mapped to + /// the real profile directory path on disk and Windows file system handles path names in a case-insensitive way. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT ProfileName([out, retval] LPWSTR* value); + /// Sets the `ProfileName` property. + [propput] HRESULT ProfileName([in] LPCWSTR value); + + /// `IsInPrivateModeEnabled` property is to enable/disable InPrivate mode. + [propget] HRESULT IsInPrivateModeEnabled([out, retval] BOOL* value); + /// Sets the `IsInPrivateModeEnabled` property. + [propput] HRESULT IsInPrivateModeEnabled([in] BOOL value); +} + +/// Provides a set of properties that are used to manage an +/// ICoreWebView2Cookie. +/// +/// \snippet ScenarioCookieManagement.cpp CookieObject +[uuid(AD26D6BE-1486-43E6-BF87-A2034006CA21), object, pointer_default(unique)] +interface ICoreWebView2Cookie : IUnknown { + /// Cookie name. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Name([out, retval] LPWSTR* name); + + /// Cookie value. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Value([out, retval] LPWSTR* value); + /// Set the cookie value property. + [propput] HRESULT Value([in] LPCWSTR value); + + /// The domain for which the cookie is valid. + /// The default is the host that this cookie has been received from. + /// Note that, for instance, ".bing.com", "bing.com", and "www.bing.com" are + /// considered different domains. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Domain([out, retval] LPWSTR* domain); + + /// The path for which the cookie is valid. The default is "/", which means + /// this cookie will be sent to all pages on the Domain. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Path([out, retval] LPWSTR* path); + + /// The expiration date and time for the cookie as the number of seconds since the UNIX epoch. + /// The default is -1.0, which means cookies are session cookies by default. + [propget] HRESULT Expires([out, retval] double* expires); + /// Set the Expires property. Cookies are session cookies and will not be + /// persistent if Expires is set to -1.0. NaN, infinity, and any negative + /// value set other than -1.0 is disallowed. + [propput] HRESULT Expires([in] double expires); + + /// Whether this cookie is http-only. + /// True if a page script or other active content cannot access this + /// cookie. The default is false. + [propget] HRESULT IsHttpOnly([out, retval] BOOL* isHttpOnly); + /// Set the IsHttpOnly property. + [propput] HRESULT IsHttpOnly([in] BOOL isHttpOnly); + + /// SameSite status of the cookie which represents the enforcement mode of the cookie. + /// The default is COREWEBVIEW2_COOKIE_SAME_SITE_KIND_LAX. + [propget] HRESULT SameSite([out, retval] COREWEBVIEW2_COOKIE_SAME_SITE_KIND* sameSite); + /// Set the SameSite property. + [propput] HRESULT SameSite([in] COREWEBVIEW2_COOKIE_SAME_SITE_KIND sameSite); + + /// The security level of this cookie. True if the client is only to return + /// the cookie in subsequent requests if those requests use HTTPS. + /// The default is false. + /// Note that cookie that requests COREWEBVIEW2_COOKIE_SAME_SITE_KIND_NONE but + /// is not marked Secure will be rejected. + [propget] HRESULT IsSecure([out, retval] BOOL* isSecure); + /// Set the IsSecure property. + [propput] HRESULT IsSecure([in] BOOL isSecure); + + /// Whether this is a session cookie. The default is false. + [propget] HRESULT IsSession([out, retval] BOOL* isSession); +} + +/// Creates, adds or updates, gets, or or view the cookies. The changes would +/// apply to the context of the user profile. That is, other WebViews under the +/// same user profile could be affected. +[uuid(177CD9E7-B6F5-451A-94A0-5D7A3A4C4141), object, pointer_default(unique)] +interface ICoreWebView2CookieManager : IUnknown { + /// Create a cookie object with a specified name, value, domain, and path. + /// One can set other optional properties after cookie creation. + /// This only creates a cookie object and it is not added to the cookie + /// manager until you call AddOrUpdateCookie. + /// Leading or trailing whitespace(s), empty string, and special characters + /// are not allowed for name. + /// See ICoreWebView2Cookie for more details. + HRESULT CreateCookie( + [in] LPCWSTR name, + [in] LPCWSTR value, + [in] LPCWSTR domain, + [in] LPCWSTR path, + [out, retval] ICoreWebView2Cookie** cookie); + + /// Creates a cookie whose params matches those of the specified cookie. + HRESULT CopyCookie( + [in] ICoreWebView2Cookie* cookieParam, + [out, retval] ICoreWebView2Cookie** cookie); + + /// Gets a list of cookies matching the specific URI. + /// If uri is empty string or null, all cookies under the same profile are + /// returned. + /// You can modify the cookie objects by calling + /// ICoreWebView2CookieManager::AddOrUpdateCookie, and the changes + /// will be applied to the webview. + /// \snippet ScenarioCookieManagement.cpp GetCookies + HRESULT GetCookies( + [in] LPCWSTR uri, + [in] ICoreWebView2GetCookiesCompletedHandler* handler); + + /// Adds or updates a cookie with the given cookie data; may overwrite + /// cookies with matching name, domain, and path if they exist. + /// This method will fail if the domain of the given cookie is not specified. + /// \snippet ScenarioCookieManagement.cpp AddOrUpdateCookie + HRESULT AddOrUpdateCookie([in] ICoreWebView2Cookie* cookie); + + /// Deletes a cookie whose name and domain/path pair + /// match those of the specified cookie. + HRESULT DeleteCookie([in] ICoreWebView2Cookie* cookie); + + /// Deletes cookies with matching name and uri. + /// Cookie name is required. + /// All cookies with the given name where domain + /// and path match provided URI are deleted. + HRESULT DeleteCookies([in] LPCWSTR name, [in] LPCWSTR uri); + + /// Deletes cookies with matching name and domain/path pair. + /// Cookie name is required. + /// If domain is specified, deletes only cookies with the exact domain. + /// If path is specified, deletes only cookies with the exact path. + HRESULT DeleteCookiesWithDomainAndPath([in] LPCWSTR name, [in] LPCWSTR domain, [in] LPCWSTR path); + + /// Deletes all cookies under the same profile. + /// This could affect other WebViews under the same user profile. + HRESULT DeleteAllCookies(); +} + +/// Represents the registration of a custom scheme with the +/// CoreWebView2Environment. +/// This allows the WebView2 app to be able to handle WebResourceRequested +/// event for requests with the specified scheme and be able to navigate the +/// WebView2 to the custom scheme. Once the environment is created, the +/// registrations are valid and immutable throughout the lifetime of the +/// associated WebView2s' browser process and any WebView2 environments +/// sharing the browser process must be created with identical custom scheme +/// registrations, otherwise the environment creation will fail. +/// Any further attempts to register the same scheme will fail during environment creation. +/// The URIs of registered custom schemes will be treated similar to http +/// URIs for their origins. +/// They will have tuple origins for URIs with host and opaque origins for +/// URIs without host as specified in +/// [7.5 Origin - HTML Living Standard](https://html.spec.whatwg.org/multipage/origin.html) +/// +/// Example: +/// `custom-scheme-with-host://hostname/path/to/resource` has origin of +/// `custom-scheme-with-host://hostname`. +/// `custom-scheme-without-host:path/to/resource` has origin of +/// `custom-scheme-without-host:path/to/resource`. +/// For WebResourceRequested event, the cases of request URIs and filter URIs +/// with custom schemes will be normalized according to generic URI syntax +/// rules. Any non-ASCII characters will be preserved. +/// The registered custom schemes also participate in +/// [CORS](https://developer.mozilla.org/docs/Web/HTTP/CORS) and +/// adheres to [CSP](https://developer.mozilla.org/docs/Web/HTTP/CSP). +/// The app needs to set the appropriate access headers in its +/// WebResourceRequested event handler to allow CORS requests. +/// \snippet AppWindow.cpp CoreWebView2CustomSchemeRegistration +[uuid(d60ac92c-37a6-4b26-a39e-95cfe59047bb), object, pointer_default(unique)] +interface ICoreWebView2CustomSchemeRegistration : IUnknown { + /// The name of the custom scheme to register. + [propget] HRESULT SchemeName([out, retval] LPWSTR* schemeName); + + /// Whether the sites with this scheme will be treated as a + /// [Secure Context](https://developer.mozilla.org/docs/Web/Security/Secure_Contexts) + /// like an HTTPS site. This flag is only effective when HasAuthorityComponent + /// is also set to `true`. + /// `false` by default. + [propget] HRESULT TreatAsSecure([out, retval] BOOL* treatAsSecure); + /// Set if the scheme will be treated as a Secure Context. + [propput] HRESULT TreatAsSecure([in] BOOL value); + + /// List of origins that are allowed to issue requests with the custom + /// scheme, such as XHRs and subresource requests that have an Origin header. + /// The origin of any request (requests that have the + /// [Origin header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Origin)) + /// to the custom scheme URI needs to be in this list. No-origin requests + /// are requests that do not have an Origin header, such as link + /// navigations, embedded images and are always allowed. + /// Note: POST requests always contain an Origin header, therefore + /// AllowedOrigins must be set for even for same origin POST requests. + /// Note that cross-origin restrictions still apply. + /// From any opaque origin (Origin header is null), no cross-origin requests + /// are allowed. + /// If the list is empty, no cross-origin request to this scheme is + /// allowed. + /// Origins are specified as a string in the format of + /// scheme://host:port. + /// The origins are string pattern matched with `*` (matches 0 or more + /// characters) and `?` (matches 0 or 1 character) wildcards just like + /// the URI matching in the + /// [AddWebResourceRequestedFilter API](/dotnet/api/microsoft.web.webview2.core.corewebview2.addwebresourcerequestedfilter). + /// For example, "http://*.example.com:80". + /// Here's a set of examples of what is allowed and not: + /// + /// | Request URI | Originating URL | AllowedOrigins | Allowed | + /// | -- | -- | -- | -- | + /// | `custom-scheme:request` | `https://www.example.com` | {"https://www.example.com"} | Yes | + /// | `custom-scheme:request` | `https://www.example.com` | {"https://*.example.com"} | Yes | + /// | `custom-scheme:request` | `https://www.example.com` | {"https://www.example2.com"} | No | + /// | `custom-scheme-with-authority://host/path` | `custom-scheme-with-authority://host2` | {""} | No | + /// | `custom-scheme-with-authority://host/path` | `custom-scheme-with-authority2://host` | {"custom-scheme-with-authority2://*"} | Yes | + /// | `custom-scheme-without-authority:path` | custom-scheme-without-authority:path2 | {"custom-scheme-without-authority:*"} | No | + /// | `custom-scheme-without-authority:path` | custom-scheme-without-authority:path2 | {"*"} | Yes | + /// + /// The returned strings and the array itself must be deallocated with + /// CoTaskMemFree. + HRESULT GetAllowedOrigins( + [out] UINT32* allowedOriginsCount, + [out] LPWSTR** allowedOrigins); + /// Set the array of origins that are allowed to use the scheme. + HRESULT SetAllowedOrigins( + [in] UINT32 allowedOriginsCount, + [in] LPCWSTR* allowedOrigins); + + /// Set this property to `true` if the URIs with this custom + /// scheme will have an authority component (a host for custom schemes). + /// Specifically, if you have a URI of the following form you should set the + /// `HasAuthorityComponent` value as listed. + /// + /// | URI | Recommended HasAuthorityComponent value | + /// | -- | -- | + /// | `custom-scheme-with-authority://host/path` | `true` | + /// | `custom-scheme-without-authority:path` | `false` | + /// + /// When this property is set to `true`, the URIs with this scheme will be + /// interpreted as having a + /// [scheme and host](https://html.spec.whatwg.org/multipage/origin.html#concept-origin-tuple) + /// origin similar to an http URI. Note that the port and user + /// information are never included in the computation of origins for + /// custom schemes. + /// If this property is set to `false`, URIs with this scheme will have an + /// [opaque origin](https://html.spec.whatwg.org/multipage/origin.html#concept-origin-opaque) + /// similar to a data URI. + /// This property is `false` by default. + /// + /// Note: For custom schemes registered as having authority component, + /// navigations to URIs without authority of such custom schemes will fail. + /// However, if the content inside WebView2 references + /// a subresource with a URI that does not have + /// an authority component, but of a custom scheme that is registered as + /// having authority component, the URI will be interpreted as a relative path + /// as specified in [RFC3986](https://www.rfc-editor.org/rfc/rfc3986). + /// For example, `custom-scheme-with-authority:path` will be interpreted + /// as `custom-scheme-with-authority://host/path`. + /// However, this behavior cannot be guaranteed to remain in future + /// releases so it is recommended not to rely on this behavior. + [propget] HRESULT HasAuthorityComponent([out, retval] BOOL* hasAuthorityComponent); + + /// Get has authority component. + [propput] HRESULT HasAuthorityComponent([in] BOOL hasAuthorityComponent); +} + +/// Represents a download operation. Gives access to the download's metadata +/// and supports a user canceling, pausing, or resuming the download. +[uuid(3d6b6cf2-afe1-44c7-a995-c65117714336), object, pointer_default(unique)] +interface ICoreWebView2DownloadOperation : IUnknown { + /// Add an event handler for the `BytesReceivedChanged` event. + /// + /// \snippet ScenarioCustomDownloadExperience.cpp BytesReceivedChanged + HRESULT add_BytesReceivedChanged( + [in] ICoreWebView2BytesReceivedChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_BytesReceivedChanged`. + HRESULT remove_BytesReceivedChanged( + [in] EventRegistrationToken token); + + /// Add an event handler for the `EstimatedEndTimeChanged` event. + HRESULT add_EstimatedEndTimeChanged( + [in] ICoreWebView2EstimatedEndTimeChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_EstimatedEndTimeChanged`. + HRESULT remove_EstimatedEndTimeChanged( + [in] EventRegistrationToken token); + + /// Add an event handler for the `StateChanged` event. + /// + /// \snippet ScenarioCustomDownloadExperience.cpp StateChanged + HRESULT add_StateChanged( + [in] ICoreWebView2StateChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_StateChanged`. + HRESULT remove_StateChanged( + [in] EventRegistrationToken token); + + /// The URI of the download. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Uri([out, retval] LPWSTR* uri); + + /// The Content-Disposition header value from the download's HTTP response. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT ContentDisposition([out, retval] LPWSTR* contentDisposition); + + /// MIME type of the downloaded content. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT MimeType([out, retval] LPWSTR* mimeType); + + /// The expected size of the download in total number of bytes based on the + /// HTTP Content-Length header. Returns -1 if the size is unknown. + [propget] HRESULT TotalBytesToReceive([out, retval] INT64* totalBytesToReceive); + + /// The number of bytes that have been written to the download file. + [propget] HRESULT BytesReceived([out, retval] INT64* bytesReceived); + + /// The estimated end time in [ISO 8601 Date and Time Format](https://www.iso.org/iso-8601-date-and-time-format.html). + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT EstimatedEndTime([out, retval] LPWSTR* estimatedEndTime); + + /// The absolute path to the download file, including file name. Host can change + /// this from `ICoreWebView2DownloadStartingEventArgs`. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT ResultFilePath([out, retval] LPWSTR* resultFilePath); + + /// The state of the download. A download can be in progress, interrupted, or + /// completed. See `COREWEBVIEW2_DOWNLOAD_STATE` for descriptions of states. + [propget] HRESULT State([out, retval] COREWEBVIEW2_DOWNLOAD_STATE* downloadState); + + /// The reason why connection with file host was broken. + [propget] HRESULT InterruptReason( + [out, retval] COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON* interruptReason); + + /// Cancels the download. If canceled, the default download dialog shows + /// that the download was canceled. Host should set the `Cancel` property from + /// `ICoreWebView2SDownloadStartingEventArgs` if the download should be + /// canceled without displaying the default download dialog. + HRESULT Cancel(); + + /// Pauses the download. If paused, the default download dialog shows that the + /// download is paused. No effect if download is already paused. Pausing a + /// download changes the state to `COREWEBVIEW2_DOWNLOAD_STATE_INTERRUPTED` + /// with `InterruptReason` set to `COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_USER_PAUSED`. + HRESULT Pause(); + + /// Resumes a paused download. May also resume a download that was interrupted + /// for another reason, if `CanResume` returns true. Resuming a download changes + /// the state from `COREWEBVIEW2_DOWNLOAD_STATE_INTERRUPTED` to + /// `COREWEBVIEW2_DOWNLOAD_STATE_IN_PROGRESS`. + HRESULT Resume(); + + /// Returns true if an interrupted download can be resumed. Downloads with + /// the following interrupt reasons may automatically resume without you + /// calling any methods: + /// `COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE`, + /// `COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_HASH_MISMATCH`, + /// `COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON_FILE_TOO_SHORT`. + /// In these cases download progress may be restarted with `BytesReceived` + /// reset to 0. + [propget] HRESULT CanResume([out, retval] BOOL* canResume); +} + +/// Event args for the `DownloadStarting` event. +[uuid(e99bbe21-43e9-4544-a732-282764eafa60), object, pointer_default(unique)] +interface ICoreWebView2DownloadStartingEventArgs : IUnknown { + /// Returns the `ICoreWebView2DownloadOperation` for the download that + /// has started. + [propget] HRESULT DownloadOperation( + [out, retval] ICoreWebView2DownloadOperation** downloadOperation); + + /// The host may set this flag to cancel the download. If canceled, the + /// download save dialog is not displayed regardless of the + /// `Handled` property. + [propget] HRESULT Cancel([out, retval] BOOL* cancel); + + /// Sets the `Cancel` property. + [propput] HRESULT Cancel([in] BOOL cancel); + + /// The path to the file. If setting the path, the host should ensure that it + /// is an absolute path, including the file name, and that the path does not + /// point to an existing file. If the path points to an existing file, the + /// file will be overwritten. If the directory does not exist, it is created. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT ResultFilePath([out, retval] LPWSTR* resultFilePath); + + /// Sets the `ResultFilePath` property. + [propput] HRESULT ResultFilePath([in] LPCWSTR resultFilePath); + + /// The host may set this flag to `TRUE` to hide the default download dialog + /// for this download. The download will progress as normal if it is not + /// canceled, there will just be no default UI shown. By default the value is + /// `FALSE` and the default download dialog is shown. + [propget] HRESULT Handled([out, retval] BOOL* handled); + + /// Sets the `Handled` property. + [propput] HRESULT Handled([in] BOOL handled); + + /// Returns an `ICoreWebView2Deferral` object. Use this operation to + /// complete the event at a later time. + HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral); +} + +/// This is the result for ExecuteScriptWithResult. +[uuid(0CE15963-3698-4DF7-9399-71ED6CDD8C9F), object, pointer_default(unique)] +interface ICoreWebView2ExecuteScriptResult : IUnknown { + /// This property is true if ExecuteScriptWithResult successfully executed script with + /// no unhandled exceptions and the result is available in the ResultAsJson property + /// or via the TryGetResultAsString method. + /// If it is false then the script execution had an unhandled exception which you + /// can get via the Exception property. + [propget] HRESULT Succeeded([out, retval] BOOL* value); + /// A function that has no explicit return value returns undefined. If the + /// script that was run throws an unhandled exception, then the result is + /// also "null". This method is applied asynchronously. If the method is + /// run before `ContentLoading`, the script will not be executed + /// and the string "null" will be returned. + + /// The return value description is as follows + /// 1. S_OK: Execution succeeds. + /// 2. E_POINTER: When the `jsonResult` is nullptr. + [propget] HRESULT ResultAsJson([out, retval] LPWSTR* jsonResult); + /// If Succeeded is true and the result of script execution is a string, this method provides the value of the string result, + /// and we will get the `FALSE` var value when the js result is not string type. + + /// The return value description is as follows + /// 1. S_OK: Execution succeeds. + /// 2. E_POINTER: When the `stringResult` or `value` is nullptr. + /// NOTE: If the `value` returns `FALSE`, the `stringResult` will be set to a empty string. + HRESULT TryGetResultAsString([out] LPWSTR* stringResult, [out] BOOL* value); + /// If Succeeded is false, you can use this property to get the unhandled exception thrown by script execution + /// Note that due to the compatibility of the WinRT/.NET interface, + /// S_OK will be returned even if the acquisition fails. + /// We can determine whether the acquisition is successful by judging whether the `exception` is nullptr. + [propget] HRESULT Exception( + [out, retval] ICoreWebView2ScriptException** exception); +} + +/// ICoreWebView2Frame provides direct access to the iframes information. +/// You can get an ICoreWebView2Frame by handling the ICoreWebView2_4::add_FrameCreated event. +[uuid(f1131a5e-9ba9-11eb-a8b3-0242ac130003), object, pointer_default(unique)] +interface ICoreWebView2Frame : IUnknown { + /// The value of iframe's window.name property. The default value equals to + /// iframe html tag declaring it. You can access this property even if the + /// iframe is destroyed. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Name([ out, retval ] LPWSTR * name); + /// Raised when the iframe changes its window.name property. + HRESULT add_NameChanged( + [in] ICoreWebView2FrameNameChangedEventHandler * eventHandler, + [out] EventRegistrationToken * token); + /// Remove an event handler previously added with add_NameChanged. + HRESULT remove_NameChanged([in] EventRegistrationToken token); + + /// Add the provided host object to script running in the iframe with the + /// specified name for the list of the specified origins. The host object + /// will be accessible for this iframe only if the iframe's origin during + /// access matches one of the origins which are passed. The provided origins + /// will be normalized before comparing to the origin of the document. + /// So the scheme name is made lower case, the host will be punycode decoded + /// as appropriate, default port values will be removed, and so on. + /// This means the origin's host may be punycode encoded or not and will match + /// regardless. If list contains malformed origin the call will fail. + /// The method can be called multiple times in a row without calling + /// RemoveHostObjectFromScript for the same object name. It will replace + /// the previous object with the new object and new list of origins. + /// List of origins will be treated as following: + /// 1. empty list - call will succeed and object will be added for the iframe + /// but it will not be exposed to any origin; + /// 2. list with origins - during access to host object from iframe the + /// origin will be checked that it belongs to this list; + /// 3. list with "*" element - host object will be available for iframe for + /// all origins. We suggest not to use this feature without understanding + /// security implications of giving access to host object from from iframes + /// with unknown origins. + /// 4. list with "file://" element - host object will be available for iframes + /// loaded via file protocol. + /// Calling this method fails if it is called after the iframe is destroyed. + /// \snippet ScenarioAddHostObject.cpp AddHostObjectToScriptWithOrigins + /// For more information about host objects navigate to + /// ICoreWebView2::AddHostObjectToScript. + HRESULT AddHostObjectToScriptWithOrigins( + [in] LPCWSTR name, + [in] VARIANT * object, + [in] UINT32 originsCount, + [ in, size_is(originsCount) ] LPCWSTR * origins); + /// Remove the host object specified by the name so that it is no longer + /// accessible from JavaScript code in the iframe. While new access + /// attempts are denied, if the object is already obtained by JavaScript code + /// in the iframe, the JavaScript code continues to have access to that + /// object. Calling this method for a name that is already removed or was + /// never added fails. If the iframe is destroyed this method will return fail + /// also. + HRESULT RemoveHostObjectFromScript([in] LPCWSTR name); + + /// The Destroyed event is raised when the iframe corresponding + /// to this CoreWebView2Frame object is removed or the document + /// containing that iframe is destroyed. + HRESULT add_Destroyed( + [in] ICoreWebView2FrameDestroyedEventHandler * eventHandler, + [out] EventRegistrationToken * token); + /// Remove an event handler previously added with add_Destroyed. + HRESULT remove_Destroyed([in] EventRegistrationToken token); + /// Check whether a frame is destroyed. Returns true during + /// the Destroyed event. + HRESULT IsDestroyed([ out, retval ] BOOL * destroyed); +} + +/// A continuation of the ICoreWebView2Frame interface with navigation events, +/// executing script and posting web messages. +[uuid(7a6a5834-d185-4dbf-b63f-4a9bc43107d4), object, pointer_default(unique)] +interface ICoreWebView2Frame2 : ICoreWebView2Frame { + /// Add an event handler for the `NavigationStarting` event. + /// A frame navigation will raise a `NavigationStarting` event and + /// a `CoreWebView2.FrameNavigationStarting` event. All of the + /// `FrameNavigationStarting` event handlers for the current frame will be + /// run before the `NavigationStarting` event handlers. All of the event handlers + /// share a common `NavigationStartingEventArgs` object. Whichever event handler is + /// last to change the `NavigationStartingEventArgs.Cancel` property will + /// decide if the frame navigation will be cancelled. Redirects raise this + /// event as well, and the navigation id is the same as the original one. + /// + /// Navigations will be blocked until all `NavigationStarting` and + /// `CoreWebView2.FrameNavigationStarting` event handlers return. + HRESULT add_NavigationStarting( + [in] ICoreWebView2FrameNavigationStartingEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_NavigationStarting`. + HRESULT remove_NavigationStarting( + [in] EventRegistrationToken token); + + /// Add an event handler for the `ContentLoading` event. `ContentLoading` + /// triggers before any content is loaded, including scripts added with + /// `AddScriptToExecuteOnDocumentCreated`. `ContentLoading` does not trigger + /// if a same page navigation occurs (such as through `fragment` + /// navigations or `history.pushState` navigations). This operation + /// follows the `NavigationStarting` and precedes `NavigationCompleted` events. + HRESULT add_ContentLoading( + [in] ICoreWebView2FrameContentLoadingEventHandler * eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_ContentLoading`. + HRESULT remove_ContentLoading( + [in] EventRegistrationToken token); + + /// Add an event handler for the `NavigationCompleted` event. + /// `NavigationCompleted` runs when the CoreWebView2Frame has completely + /// loaded (concurrently when `body.onload` runs) or loading stopped with error. + HRESULT add_NavigationCompleted( + [in] ICoreWebView2FrameNavigationCompletedEventHandler * + eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_NavigationCompleted`. + HRESULT remove_NavigationCompleted( + [in] EventRegistrationToken token); + + /// Add an event handler for the DOMContentLoaded event. + /// DOMContentLoaded is raised when the iframe html document has been parsed. + /// This aligns with the document's DOMContentLoaded event in html. + HRESULT add_DOMContentLoaded( + [in] ICoreWebView2FrameDOMContentLoadedEventHandler * eventHandler, + [out] EventRegistrationToken* token); + /// Remove an event handler previously added with add_DOMContentLoaded. + HRESULT remove_DOMContentLoaded( + [in] EventRegistrationToken token); + + /// Run JavaScript code from the javascript parameter in the current frame. + /// The result of evaluating the provided JavaScript is passed to the completion handler. + /// The result value is a JSON encoded string. If the result is undefined, + /// contains a reference cycle, or otherwise is not able to be encoded into + /// JSON, then the result is considered to be null, which is encoded + /// in JSON as the string "null". + /// + /// \> [!NOTE]\n\> A function that has no explicit return value returns undefined. If the + /// script that was run throws an unhandled exception, then the result is + /// also "null". This method is applied asynchronously. If the method is + /// run before `ContentLoading`, the script will not be executed + /// and the string "null" will be returned. + /// This operation executes the script even if `ICoreWebView2Settings::IsScriptEnabled` is + /// set to `FALSE`. + /// + /// \snippet ScenarioDOMContentLoaded.cpp ExecuteScriptFrame + HRESULT ExecuteScript( + [in] LPCWSTR javaScript, + [in] ICoreWebView2ExecuteScriptCompletedHandler* handler); + + /// Posts the specified webMessage to the frame. + /// The frame receives the message by subscribing to the `message` event of + /// the `window.chrome.webview` of the frame document. + /// + /// ```cpp + /// window.chrome.webview.addEventListener('message', handler) + /// window.chrome.webview.removeEventListener('message', handler) + /// ``` + /// + /// The event args is an instances of `MessageEvent`. The + /// `ICoreWebView2Settings::IsWebMessageEnabled` setting must be `TRUE` or + /// the message will not be sent. The `data` property of the event + /// args is the `webMessage` string parameter parsed as a JSON string into a + /// JavaScript object. The `source` property of the event args is a reference + /// to the `window.chrome.webview` object. For information about sending + /// messages from the HTML document in the WebView to the host, navigate to + /// [add_WebMessageReceived](/microsoft-edge/webview2/reference/win32/icorewebview2#add_webmessagereceived). + /// The message is delivered asynchronously. If a navigation occurs before the + /// message is posted to the page, the message is discarded. + HRESULT PostWebMessageAsJson([in] LPCWSTR webMessageAsJson); + + /// Posts a message that is a simple string rather than a JSON string + /// representation of a JavaScript object. This behaves in exactly the same + /// manner as `PostWebMessageAsJson`, but the `data` property of the event + /// args of the `window.chrome.webview` message is a string with the same + /// value as `webMessageAsString`. Use this instead of + /// `PostWebMessageAsJson` if you want to communicate using simple strings + /// rather than JSON objects. + HRESULT PostWebMessageAsString([in] LPCWSTR webMessageAsString); + + /// Add an event handler for the `WebMessageReceived` event. + /// `WebMessageReceived` runs when the + /// `ICoreWebView2Settings::IsWebMessageEnabled` setting is set and the + /// frame document runs `window.chrome.webview.postMessage`. + /// The `postMessage` function is `void postMessage(object)` + /// where object is any object supported by JSON conversion. + /// + /// \snippet assets\ScenarioWebMessage.html chromeWebView + /// + /// When the frame calls `postMessage`, the object parameter is converted to a + /// JSON string and is posted asynchronously to the host process. This will + /// result in the handlers `Invoke` method being called with the JSON string + /// as its parameter. + /// + /// \snippet ScenarioWebMessage.cpp WebMessageReceivedIFrame + HRESULT add_WebMessageReceived( + [in] ICoreWebView2FrameWebMessageReceivedEventHandler * + handler, + [out] EventRegistrationToken * token); + + /// Remove an event handler previously added with `add_WebMessageReceived`. + HRESULT remove_WebMessageReceived([in] EventRegistrationToken token); +} + +/// A continuation of the ICoreWebView2FrameInfo interface that provides +/// `ParentFrameInfo`, `FrameId` and `FrameKind` properties. +[uuid(56f85cfa-72c4-11ee-b962-0242ac120002), object, pointer_default(unique)] +interface ICoreWebView2FrameInfo2 : ICoreWebView2FrameInfo { + /// This parent frame's `FrameInfo`. `ParentFrameInfo` will only be + /// populated when obtained via calling + /// `CoreWebView2ProcessExtendedInfo.AssociatedFrameInfos`. + /// `CoreWebView2FrameInfo` objects obtained via `CoreWebView2.ProcessFailed` will + /// always have a `null ParentFrameInfo`. This property is also `null` for the + /// main frame in the WebView2 which has no parent frame. + /// Note that this `ParentFrameInfo` could be out of date as it's a snapshot. + [propget] HRESULT ParentFrameInfo([out, retval] ICoreWebView2FrameInfo** frameInfo); + /// The unique identifier of the frame associated with the current `FrameInfo`. + /// It's the same kind of ID as with the `FrameId` in `CoreWebView2` and via + /// `CoreWebView2Frame`. `FrameId` will only be populated (non-zero) when obtained + /// calling `CoreWebView2ProcessExtendedInfo.AssociatedFrameInfos`. + /// `CoreWebView2FrameInfo` objects obtained via `CoreWebView2.ProcessFailed` will + /// always have an invalid frame Id 0. + /// Note that this `FrameId` could be out of date as it's a snapshot. + /// If there's WebView2 created or destroyed or `FrameCreated/FrameDestroyed` events + /// after the asynchronous call `CoreWebView2Environment.GetProcessExtendedInfos` + /// starts, you may want to call asynchronous method again to get the updated `FrameInfo`s. + [propget] HRESULT FrameId([out, retval] UINT32* id); + /// The frame kind of the frame. `FrameKind` will only be populated when + /// obtained calling `CoreWebView2ProcessExtendedInfo.AssociatedFrameInfos`. + /// `CoreWebView2FrameInfo` objects obtained via `CoreWebView2.ProcessFailed` + /// will always have the default value `COREWEBVIEW2_FRAME_KIND_UNKNOWN`. + /// Note that this `FrameKind` could be out of date as it's a snapshot. + [propget] HRESULT FrameKind([out, retval] COREWEBVIEW2_FRAME_KIND* kind); +} + +/// Iterator for a collection of HTTP headers. For more information, navigate +/// to ICoreWebView2HttpRequestHeaders and ICoreWebView2HttpResponseHeaders. +/// +/// \snippet ScenarioWebViewEventMonitor.cpp HttpRequestHeaderIterator +[uuid(0702fc30-f43b-47bb-ab52-a42cb552ad9f), object, pointer_default(unique)] +interface ICoreWebView2HttpHeadersCollectionIterator : IUnknown { + + /// Get the name and value of the current HTTP header of the iterator. If + /// the previous `MoveNext` operation set the `hasNext` parameter to `FALSE`, + /// this method fails. + /// + /// The caller must free the returned strings with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + + HRESULT GetCurrentHeader([out] LPWSTR* name, [out] LPWSTR* value); + + /// `TRUE` when the iterator has not run out of headers. If the collection + /// over which the iterator is iterating is empty or if the iterator has gone + /// past the end of the collection then this is `FALSE`. + + [propget] HRESULT HasCurrentHeader([out, retval] BOOL* hasCurrent); + + /// Move the iterator to the next HTTP header in the collection. + /// + /// \> [!NOTE]\n \> If no more HTTP headers exist, the `hasNext` parameter is set to + /// `FALSE`. After this occurs the `GetCurrentHeader` method fails. + + HRESULT MoveNext([out, retval] BOOL* hasNext); +} + +/// Event args for `LaunchingExternalUriScheme` event. +[uuid(07D1A6C3-7175-4BA1-9306-E593CA07E46C), object, pointer_default(unique)] +interface ICoreWebView2LaunchingExternalUriSchemeEventArgs: IUnknown { + /// The URI with the external URI scheme to be launched. + + [propget] HRESULT Uri([out, retval] LPWSTR* value); + + /// The origin initiating the external URI scheme launch. + /// The origin will be an empty string if the request is initiated by calling + /// `CoreWebView2.Navigate` on the external URI scheme. If a script initiates + /// the navigation, the `InitiatingOrigin` will be the top-level document's + /// `Source`, for example, if `window.location` is set to `"calculator://"`, the + /// `InitiatingOrigin` will be set to `calculator://`. If the request is initiated + /// from a child frame, the `InitiatingOrigin` will be the source of that child frame. + /// If the `InitiatingOrigin` is + /// [opaque](https://html.spec.whatwg.org/multipage/origin.html#concept-origin-opaque), + /// the `InitiatingOrigin` reported in the event args will be its precursor origin. + /// The precursor origin is the origin that created the opaque origin. For example, if + /// a frame on example.com opens a subframe with a different opaque origin, the subframe's + /// precursor origin is example.com. + [propget] HRESULT InitiatingOrigin([out, retval] LPWSTR* value); + + /// `TRUE` when the external URI scheme request was initiated through a user gesture. + /// + /// \> [!NOTE]\n\> Being initiated through a user gesture does not mean that user intended + /// to access the associated resource. + + [propget] HRESULT IsUserInitiated([out, retval] BOOL* value); + + /// The event handler may set this property to `TRUE` to cancel the external URI scheme + /// launch. If set to `TRUE`, the external URI scheme will not be launched, and the default + /// dialog is not displayed. This property can be used to replace the normal + /// handling of launching an external URI scheme. + /// The initial value of the `Cancel` property is `FALSE`. + + [propget] HRESULT Cancel([out, retval] BOOL* value); + + /// Sets the `Cancel` property. + + [propput] HRESULT Cancel([in] BOOL value); + + /// Returns an `ICoreWebView2Deferral` object. Use this operation to + /// complete the event at a later time. + + HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** value); +} + +/// Event args for the `MoveFocusRequested` event. + +[uuid(2d6aa13b-3839-4a15-92fc-d88b3c0d9c9d), object, pointer_default(unique)] +interface ICoreWebView2MoveFocusRequestedEventArgs : IUnknown { + + /// The reason for WebView to run the `MoveFocusRequested` event. + + [propget] HRESULT Reason([out, retval] COREWEBVIEW2_MOVE_FOCUS_REASON* reason); + + /// Indicates whether the event has been handled by the app. If the app has + /// moved the focus to another desired location, it should set the `Handled` + /// property to `TRUE`. When the `Handled` property is `FALSE` after the + /// event handler returns, default action is taken. The default action is to + /// try to find the next tab stop child window in the app and try to move + /// focus to that window. If no other window exists to move focus, focus is + /// cycled within the web content of the WebView. + + [propget] HRESULT Handled([out, retval] BOOL* value); + + /// Sets the `Handled` property. + + [propput] HRESULT Handled([in] BOOL value); +} + +/// Event args for the `NavigationCompleted` event. +[uuid(30d68b7d-20d9-4752-a9ca-ec8448fbb5c1), object, pointer_default(unique)] +interface ICoreWebView2NavigationCompletedEventArgs : IUnknown { + + /// `TRUE` when the navigation is successful. `FALSE` for a navigation that + /// ended up in an error page (failures due to no network, DNS lookup + /// failure, HTTP server responds with 4xx), but may also be `FALSE` for + /// additional scenarios such as `window.stop()` run on navigated page. + /// Note that WebView2 will report the navigation as 'unsuccessful' if the load + /// for the navigation did not reach the expected completion for any reason. Such + /// reasons include potentially catastrophic issues such network and certificate + /// issues, but can also be the result of intended actions such as the app canceling a navigation or + /// navigating away before the original navigation completed. Applications should not + /// just rely on this flag, but also consider the reported WebErrorStatus to + /// determine whether the failure is indeed catastrophic in their context. + /// WebErrorStatuses that may indicate a non-catastrophic failure include: + /// - COREWEBVIEW2_WEB_ERROR_STATUS_OPERATION_CANCELED + /// - COREWEBVIEW2_WEB_ERROR_STATUS_VALID_AUTHENTICATION_CREDENTIALS_REQUIRED + /// - COREWEBVIEW2_WEB_ERROR_STATUS_VALID_PROXY_AUTHENTICATION_REQUIRED + + [propget] HRESULT IsSuccess([out, retval] BOOL* isSuccess); + + /// The error code if the navigation failed. + + [propget] HRESULT WebErrorStatus([out, retval] COREWEBVIEW2_WEB_ERROR_STATUS* + webErrorStatus); + + /// The ID of the navigation. + + [propget] HRESULT NavigationId([out, retval] UINT64* navigationId); +} + +/// Event args for the `NavigationStarting` event. +[uuid(5b495469-e119-438a-9b18-7604f25f2e49), object, pointer_default(unique)] +interface ICoreWebView2NavigationStartingEventArgs : IUnknown { + + /// The uri of the requested navigation. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + + [propget] HRESULT Uri([out, retval] LPWSTR* uri); + + /// `TRUE` when the navigation was initiated through a user gesture as + /// opposed to programmatic navigation by page script. Navigations initiated + /// via WebView2 APIs are considered as user initiated. + + [propget] HRESULT IsUserInitiated([out, retval] BOOL* isUserInitiated); + + /// `TRUE` when the navigation is redirected. + + [propget] HRESULT IsRedirected([out, retval] BOOL* isRedirected); + + /// The HTTP request headers for the navigation. + /// + /// \> [!NOTE]\n\> You are not able to modify the HTTP request headers in a + /// `NavigationStarting` event. + + [propget] HRESULT RequestHeaders([out, retval] ICoreWebView2HttpRequestHeaders** requestHeaders); + + /// The host may set this flag to cancel the navigation. If set, the + /// navigation is not longer present and the content of the current page is + /// intact. For performance reasons, `GET` HTTP requests may happen, while + /// the host is responding. You may set cookies and use part of a request + /// for the navigation. Navigations to about schemes are cancellable, unless + /// `msWebView2CancellableAboutNavigations` feature flag is disabled. + /// Cancellation of frame navigation to `srcdoc` is not supported and + /// wil be ignored. A cancelled navigation will fire a `NavigationCompleted` + /// event with a `WebErrorStatus` of + /// `COREWEBVIEW2_WEB_ERROR_STATUS_OPERATION_CANCELED`. + + [propget] HRESULT Cancel([out, retval] BOOL* cancel); + + /// Sets the `Cancel` property. + + [propput] HRESULT Cancel([in] BOOL cancel); + + /// The ID of the navigation. + + [propget] HRESULT NavigationId([out, retval] UINT64* navigationId); +} + +/// Event args for the `NewWindowRequested` event. The event is run when +/// content inside webview requested to a open a new window (through +/// `window.open()` and so on). +[uuid(34acb11c-fc37-4418-9132-f9c21d1eafb9), object, pointer_default(unique)] +interface ICoreWebView2NewWindowRequestedEventArgs : IUnknown { + + /// The target uri of the new window requested. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + + [propget] HRESULT Uri([out, retval] LPWSTR* uri); + + /// Sets a CoreWebView2 as a result of the NewWindowRequested event. Provides + /// a WebView as the target for a `window.open()` from inside the + /// requesting WebView. If this is set, the top-level window of this WebView + /// is returned as the opened + /// [WindowProxy](https://developer.mozilla.org/docs/glossary/windowproxy) + /// to the opener script. If this is not set, then `Handled` is checked to + /// determine behavior for NewWindowRequested event. + /// CoreWebView2 provided in the `NewWindow` property must be on the same + /// Environment as the opener WebView and should not have been navigated + /// previously. Don't use methods that cause navigation or interact with the + /// DOM on this CoreWebView2 until the target content has loaded. Setting event + /// handlers, changing Settings properties, or other methods are fine to call. + /// Changes to settings should be made before `put_NewWindow` is called to + /// ensure that those settings take effect for the newly setup WebView. Once the + /// NewWindow is set the underlying web contents of this CoreWebView2 will be + /// replaced and navigated as appropriate for the new window. After setting + /// new window it cannot be changed and error will be return otherwise. + /// + /// The methods which should affect the new web contents like + /// AddScriptToExecuteOnDocumentCreated has to be called and completed before setting NewWindow. + /// Other methods which should affect the new web contents like add_WebResourceRequested have to be called after setting NewWindow. + /// It is best not to use RemoveScriptToExecuteOnDocumentCreated before setting NewWindow, otherwise it may not work for later added scripts. + /// + /// The new WebView must have the same profile as the opener WebView. + + [propput] HRESULT NewWindow([in] ICoreWebView2* newWindow); + + /// Gets the new window. + + [propget] HRESULT NewWindow([out, retval] ICoreWebView2** newWindow); + + /// Sets whether the `NewWindowRequested` event is handled by host. If this + /// is `FALSE` and no `NewWindow` is set, the WebView opens a popup window + /// and it returns as opened `WindowProxy`. If set to `TRUE` and no + /// `NewWindow` is set for `window.open`, the opened `WindowProxy` is for an + /// testing window object and no window loads. + /// The default value is `FALSE`. + + [propput] HRESULT Handled([in] BOOL handled); + + /// Gets whether the `NewWindowRequested` event is handled by host. + + [propget] HRESULT Handled([out, retval] BOOL* handled); + + /// `TRUE` when the new window request was initiated through a user gesture. + /// Examples of user initiated requests are: + /// + /// - Selecting an anchor tag with target + /// - Programmatic window open from a script that directly run as a result of + /// user interaction such as via onclick handlers. + /// + /// Non-user initiated requests are programmatic window opens from a script + /// that are not directly triggered by user interaction, such as those that + /// run while loading a new page or via timers. + /// The Microsoft Edge popup blocker is disabled for WebView so the app is + /// able to use this flag to block non-user initiated popups. + + [propget] HRESULT IsUserInitiated([out, retval] BOOL* isUserInitiated); + + /// Obtain an `ICoreWebView2Deferral` object and put the event into a + /// deferred state. Use the `ICoreWebView2Deferral` object to complete the + /// window open request at a later time. While this event is deferred the + /// opener window returns a `WindowProxy` to an un-navigated window, which + /// navigates when the deferral is complete. + + HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral); + + /// Window features specified by the `window.open`. The features should be + /// considered for positioning and sizing of new webview windows. + + [propget] HRESULT WindowFeatures([out, retval] ICoreWebView2WindowFeatures** value); +} + +/// Event args for the `PermissionRequested` event. +[uuid(973ae2ef-ff18-4894-8fb2-3c758f046810), object, pointer_default(unique)] +interface ICoreWebView2PermissionRequestedEventArgs : IUnknown { + + /// The origin of the web content that requests the permission. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + + [propget] HRESULT Uri([out, retval] LPWSTR* uri); + + /// The type of the permission that is requested. + + [propget] HRESULT PermissionKind([out, retval] COREWEBVIEW2_PERMISSION_KIND* permissionKind); + + /// `TRUE` when the permission request was initiated through a user gesture. + /// + /// \> [!NOTE]\n\> Being initiated through a user gesture does not mean that user intended + /// to access the associated resource. + + [propget] HRESULT IsUserInitiated([out, retval] BOOL* isUserInitiated); + + /// The status of a permission request, (for example is the request is granted). + /// The default value is `COREWEBVIEW2_PERMISSION_STATE_DEFAULT`. + + [propget] HRESULT State([out, retval] COREWEBVIEW2_PERMISSION_STATE* state); + + /// Sets the `State` property. + + [propput] HRESULT State([in] COREWEBVIEW2_PERMISSION_STATE state); + + /// Gets an `ICoreWebView2Deferral` object. Use the deferral object to make + /// the permission decision at a later time. The deferral only applies to the + /// current request, and does not prevent the `PermissionRequested` event from + /// getting raised for new requests. However, for some permission kinds the + /// WebView will avoid creating a new request if there is a pending request of + /// the same kind. + + HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral); +} + +/// Read-only collection of `PermissionSetting`s (origin, kind, and state). Used to list +/// the nondefault permission settings on the profile that are persisted across +/// sessions. +[uuid(f5596f62-3de5-47b1-91e8-a4104b596b96), object, pointer_default(unique)] +interface ICoreWebView2PermissionSettingCollectionView : IUnknown { + /// Gets the `ICoreWebView2PermissionSetting` at the specified index. + HRESULT GetValueAtIndex( + [in] UINT32 index, + [out, retval] ICoreWebView2PermissionSetting** permissionSetting); + + /// The number of `ICoreWebView2PermissionSetting`s in the collection. + [propget] HRESULT Count([out, retval] UINT32* value); +} + +/// This mostly represents a combined win32 +/// POINTER_INFO/POINTER_TOUCH_INFO/POINTER_PEN_INFO object. It takes fields +/// from all three and excludes some win32 specific data types like HWND and +/// HANDLE. Note, sourceDevice is taken out but we expect the PointerDeviceRect +/// and DisplayRect to cover the existing use cases of sourceDevice. +/// Another big difference is that any of the point or rect locations are +/// expected to be in WebView physical coordinates. That is, coordinates +/// relative to the WebView and no DPI scaling applied. +// +// The PointerId, PointerFlags, ButtonChangeKind, PenFlags, PenMask, TouchFlags, +// and TouchMask are all #defined flags or enums in the +// POINTER_INFO/POINTER_TOUCH_INFO/POINTER_PEN_INFO structure. We define those +// properties here as UINT32 or INT32 and expect the developer to know how to +// populate those values based on the Windows definitions. +[uuid(e6995887-d10d-4f5d-9359-4ce46e4f96b9), object, pointer_default(unique)] +interface ICoreWebView2PointerInfo : IUnknown { + /// Get the PointerKind of the pointer event. This corresponds to the + /// pointerKind property of the POINTER_INFO struct. The values are defined by + /// the POINTER_INPUT_KIND enum in the Windows SDK (winuser.h). Supports + /// PT_PEN and PT_TOUCH. + [propget] HRESULT PointerKind([out, retval] DWORD* pointerKind); + /// Set the PointerKind of the pointer event. This corresponds to the + /// pointerKind property of the POINTER_INFO struct. The values are defined by + /// the POINTER_INPUT_KIND enum in the Windows SDK (winuser.h). Supports + /// PT_PEN and PT_TOUCH. + [propput] HRESULT PointerKind([in] DWORD pointerKind); + + /// Get the PointerId of the pointer event. This corresponds to the pointerId + /// property of the POINTER_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propget] HRESULT PointerId([out, retval] UINT32* pointerId); + /// Set the PointerId of the pointer event. This corresponds to the pointerId + /// property of the POINTER_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propput] HRESULT PointerId([in] UINT32 pointerId); + + /// Get the FrameID of the pointer event. This corresponds to the frameId + /// property of the POINTER_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propget] HRESULT FrameId([out, retval] UINT32* frameId); + /// Set the FrameID of the pointer event. This corresponds to the frameId + /// property of the POINTER_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propput] HRESULT FrameId([in] UINT32 frameId); + + /// Get the PointerFlags of the pointer event. This corresponds to the + /// pointerFlags property of the POINTER_INFO struct. The values are defined + /// by the POINTER_FLAGS constants in the Windows SDK (winuser.h). + [propget] HRESULT PointerFlags([out, retval] UINT32* pointerFlags); + /// Set the PointerFlags of the pointer event. This corresponds to the + /// pointerFlags property of the POINTER_INFO struct. The values are defined + /// by the POINTER_FLAGS constants in the Windows SDK (winuser.h). + [propput] HRESULT PointerFlags([in] UINT32 pointerFlags); + + /// Get the PointerDeviceRect of the sourceDevice property of the + /// POINTER_INFO struct as defined in the Windows SDK (winuser.h). + [propget] HRESULT PointerDeviceRect([out, retval] RECT* pointerDeviceRect); + /// Set the PointerDeviceRect of the sourceDevice property of the + /// POINTER_INFO struct as defined in the Windows SDK (winuser.h). + [propput] HRESULT PointerDeviceRect([in] RECT pointerDeviceRect); + + /// Get the DisplayRect of the sourceDevice property of the POINTER_INFO + /// struct as defined in the Windows SDK (winuser.h). + [propget] HRESULT DisplayRect([out, retval] RECT* displayRect); + /// Set the DisplayRect of the sourceDevice property of the POINTER_INFO + /// struct as defined in the Windows SDK (winuser.h). + [propput] HRESULT DisplayRect([in] RECT displayRect); + + /// Get the PixelLocation of the pointer event. This corresponds to the + /// ptPixelLocation property of the POINTER_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propget] HRESULT PixelLocation([out, retval] POINT* pixelLocation); + /// Set the PixelLocation of the pointer event. This corresponds to the + /// ptPixelLocation property of the POINTER_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propput] HRESULT PixelLocation([in] POINT pixelLocation); + + /// Get the HimetricLocation of the pointer event. This corresponds to the + /// ptHimetricLocation property of the POINTER_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propget] HRESULT HimetricLocation([out, retval] POINT* himetricLocation); + /// Set the HimetricLocation of the pointer event. This corresponds to the + /// ptHimetricLocation property of the POINTER_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propput] HRESULT HimetricLocation([in] POINT himetricLocation); + + /// Get the PixelLocationRaw of the pointer event. This corresponds to the + /// ptPixelLocationRaw property of the POINTER_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propget] HRESULT PixelLocationRaw([out, retval] POINT* pixelLocationRaw); + /// Set the PixelLocationRaw of the pointer event. This corresponds to the + /// ptPixelLocationRaw property of the POINTER_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propput] HRESULT PixelLocationRaw([in] POINT pixelLocationRaw); + + /// Get the HimetricLocationRaw of the pointer event. This corresponds to the + /// ptHimetricLocationRaw property of the POINTER_INFO struct as defined in + /// the Windows SDK (winuser.h). + [propget] HRESULT HimetricLocationRaw([out, retval] POINT* himetricLocationRaw); + /// Set the HimetricLocationRaw of the pointer event. This corresponds to the + /// ptHimetricLocationRaw property of the POINTER_INFO struct as defined in + /// the Windows SDK (winuser.h). + [propput] HRESULT HimetricLocationRaw([in] POINT himetricLocationRaw); + + /// Get the Time of the pointer event. This corresponds to the dwTime property + /// of the POINTER_INFO struct as defined in the Windows SDK (winuser.h). + [propget] HRESULT Time([out, retval] DWORD* time); + /// Set the Time of the pointer event. This corresponds to the dwTime property + /// of the POINTER_INFO struct as defined in the Windows SDK (winuser.h). + [propput] HRESULT Time([in] DWORD time); + + /// Get the HistoryCount of the pointer event. This corresponds to the + /// historyCount property of the POINTER_INFO struct as defined in the Windows + /// SDK (winuser.h). + [propget] HRESULT HistoryCount([out, retval] UINT32* historyCount); + /// Set the HistoryCount of the pointer event. This corresponds to the + /// historyCount property of the POINTER_INFO struct as defined in the Windows + /// SDK (winuser.h). + [propput] HRESULT HistoryCount([in] UINT32 historyCount); + + /// Get the InputData of the pointer event. This corresponds to the InputData + /// property of the POINTER_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propget] HRESULT InputData([out, retval] INT32* inputData); + /// Set the InputData of the pointer event. This corresponds to the InputData + /// property of the POINTER_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propput] HRESULT InputData([in] INT32 inputData); + + /// Get the KeyStates of the pointer event. This corresponds to the + /// dwKeyStates property of the POINTER_INFO struct as defined in the Windows + /// SDK (winuser.h). + [propget] HRESULT KeyStates([out, retval] DWORD* keyStates); + /// Set the KeyStates of the pointer event. This corresponds to the + /// dwKeyStates property of the POINTER_INFO struct as defined in the Windows + /// SDK (winuser.h). + [propput] HRESULT KeyStates([in] DWORD keyStates); + + /// Get the PerformanceCount of the pointer event. This corresponds to the + /// PerformanceCount property of the POINTER_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propget] HRESULT PerformanceCount([out, retval] UINT64* performanceCount); + /// Set the PerformanceCount of the pointer event. This corresponds to the + /// PerformanceCount property of the POINTER_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propput] HRESULT PerformanceCount([in] UINT64 performanceCount); + + /// Get the ButtonChangeKind of the pointer event. This corresponds to the + /// ButtonChangeKind property of the POINTER_INFO struct. The values are + /// defined by the POINTER_BUTTON_CHANGE_KIND enum in the Windows SDK + /// (winuser.h). + [propget] HRESULT ButtonChangeKind([out, retval] INT32* buttonChangeKind); + /// Set the ButtonChangeKind of the pointer event. This corresponds to the + /// ButtonChangeKind property of the POINTER_INFO struct. The values are + /// defined by the POINTER_BUTTON_CHANGE_KIND enum in the Windows SDK + /// (winuser.h). + [propput] HRESULT ButtonChangeKind([in] INT32 buttonChangeKind); + + // Pen specific attributes + + /// Get the PenFlags of the pointer event. This corresponds to the penFlags + /// property of the POINTER_PEN_INFO struct. The values are defined by the + /// PEN_FLAGS constants in the Windows SDK (winuser.h). + [propget] HRESULT PenFlags([out, retval] UINT32* penFLags); + /// Set the PenFlags of the pointer event. This corresponds to the penFlags + /// property of the POINTER_PEN_INFO struct. The values are defined by the + /// PEN_FLAGS constants in the Windows SDK (winuser.h). + [propput] HRESULT PenFlags([in] UINT32 penFLags); + + /// Get the PenMask of the pointer event. This corresponds to the penMask + /// property of the POINTER_PEN_INFO struct. The values are defined by the + /// PEN_MASK constants in the Windows SDK (winuser.h). + [propget] HRESULT PenMask([out, retval] UINT32* penMask); + /// Set the PenMask of the pointer event. This corresponds to the penMask + /// property of the POINTER_PEN_INFO struct. The values are defined by the + /// PEN_MASK constants in the Windows SDK (winuser.h). + [propput] HRESULT PenMask([in] UINT32 penMask); + + /// Get the PenPressure of the pointer event. This corresponds to the pressure + /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propget] HRESULT PenPressure([out, retval] UINT32* penPressure); + /// Set the PenPressure of the pointer event. This corresponds to the pressure + /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propput] HRESULT PenPressure([in] UINT32 penPressure); + + /// Get the PenRotation of the pointer event. This corresponds to the rotation + /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propget] HRESULT PenRotation([out, retval] UINT32* penRotation); + /// Set the PenRotation of the pointer event. This corresponds to the rotation + /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propput] HRESULT PenRotation([in] UINT32 penRotation); + + /// Get the PenTiltX of the pointer event. This corresponds to the tiltX + /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propget] HRESULT PenTiltX([out, retval] INT32* penTiltX); + /// Set the PenTiltX of the pointer event. This corresponds to the tiltX + /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propput] HRESULT PenTiltX([in] INT32 penTiltX); + + /// Get the PenTiltY of the pointer event. This corresponds to the tiltY + /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propget] HRESULT PenTiltY([out, retval] INT32* penTiltY); + /// Set the PenTiltY of the pointer event. This corresponds to the tiltY + /// property of the POINTER_PEN_INFO struct as defined in the Windows SDK + /// (winuser.h). + [propput] HRESULT PenTiltY([in] INT32 penTiltY); + + // Touch specific attributes + + /// Get the TouchFlags of the pointer event. This corresponds to the + /// touchFlags property of the POINTER_TOUCH_INFO struct. The values are + /// defined by the TOUCH_FLAGS constants in the Windows SDK (winuser.h). + [propget] HRESULT TouchFlags([out, retval] UINT32* touchFlags); + /// Set the TouchFlags of the pointer event. This corresponds to the + /// touchFlags property of the POINTER_TOUCH_INFO struct. The values are + /// defined by the TOUCH_FLAGS constants in the Windows SDK (winuser.h). + [propput] HRESULT TouchFlags([in] UINT32 touchFlags); + + /// Get the TouchMask of the pointer event. This corresponds to the + /// touchMask property of the POINTER_TOUCH_INFO struct. The values are + /// defined by the TOUCH_MASK constants in the Windows SDK (winuser.h). + [propget] HRESULT TouchMask([out, retval] UINT32* touchMask); + /// Set the TouchMask of the pointer event. This corresponds to the + /// touchMask property of the POINTER_TOUCH_INFO struct. The values are + /// defined by the TOUCH_MASK constants in the Windows SDK (winuser.h). + [propput] HRESULT TouchMask([in] UINT32 touchMask); + + /// Get the TouchContact of the pointer event. This corresponds to the + /// rcContact property of the POINTER_TOUCH_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propget] HRESULT TouchContact([out, retval] RECT* touchContact); + /// Set the TouchContact of the pointer event. This corresponds to the + /// rcContact property of the POINTER_TOUCH_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propput] HRESULT TouchContact([in] RECT touchContact); + + /// Get the TouchContactRaw of the pointer event. This corresponds to the + /// rcContactRaw property of the POINTER_TOUCH_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propget] HRESULT TouchContactRaw([out, retval] RECT* touchContactRaw); + /// Set the TouchContactRaw of the pointer event. This corresponds to the + /// rcContactRaw property of the POINTER_TOUCH_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propput] HRESULT TouchContactRaw([in] RECT touchContactRaw); + + /// Get the TouchOrientation of the pointer event. This corresponds to the + /// orientation property of the POINTER_TOUCH_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propget] HRESULT TouchOrientation([out, retval] UINT32* touchOrientation); + /// Set the TouchOrientation of the pointer event. This corresponds to the + /// orientation property of the POINTER_TOUCH_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propput] HRESULT TouchOrientation([in] UINT32 touchOrientation); + + /// Get the TouchPressure of the pointer event. This corresponds to the + /// pressure property of the POINTER_TOUCH_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propget] HRESULT TouchPressure([out, retval] UINT32* touchPressure); + /// Set the TouchPressure of the pointer event. This corresponds to the + /// pressure property of the POINTER_TOUCH_INFO struct as defined in the + /// Windows SDK (winuser.h). + [propput] HRESULT TouchPressure([in] UINT32 touchPressure); +} + +/// Settings used by the `PrintToPdf` method. +[uuid(377f3721-c74e-48ca-8db1-df68e51d60e2), object, pointer_default(unique)] +interface ICoreWebView2PrintSettings : IUnknown { + + /// The orientation can be portrait or landscape. The default orientation is + /// portrait. See `COREWEBVIEW2_PRINT_ORIENTATION`. + [propget] HRESULT Orientation( + [out, retval] COREWEBVIEW2_PRINT_ORIENTATION* orientation); + + /// Sets the `Orientation` property. + [propput] HRESULT Orientation( + [in] COREWEBVIEW2_PRINT_ORIENTATION orientation); + + /// The scale factor is a value between 0.1 and 2.0. The default is 1.0. + [propget] HRESULT ScaleFactor([out, retval] double* scaleFactor); + + /// Sets the `ScaleFactor` property. Returns `E_INVALIDARG` if an invalid + /// value is provided, and the current value is not changed. + [propput] HRESULT ScaleFactor([in] double scaleFactor); + + /// The page width in inches. The default width is 8.5 inches. + [propget] HRESULT PageWidth([out, retval] double* pageWidth); + + /// Sets the `PageWidth` property. Returns `E_INVALIDARG` if the page width is + /// less than or equal to zero, and the current value is not changed. + [propput] HRESULT PageWidth([in] double pageWidth); + + /// The page height in inches. The default height is 11 inches. + [propget] HRESULT PageHeight([out, retval] double* pageHeight); + + /// Sets the `PageHeight` property. Returns `E_INVALIDARG` if the page height + /// is less than or equal to zero, and the current value is not changed. + [propput] HRESULT PageHeight([in] double pageHeight); + + /// The top margin in inches. The default is 1 cm, or ~0.4 inches. + [propget] HRESULT MarginTop([out, retval] double* marginTop); + + /// Sets the `MarginTop` property. A margin cannot be less than zero. + /// Returns `E_INVALIDARG` if an invalid value is provided, and the current + /// value is not changed. + [propput] HRESULT MarginTop([in] double marginTop); + + /// The bottom margin in inches. The default is 1 cm, or ~0.4 inches. + [propget] HRESULT MarginBottom([out, retval] double* marginBottom); + + /// Sets the `MarginBottom` property. A margin cannot be less than zero. + /// Returns `E_INVALIDARG` if an invalid value is provided, and the current + /// value is not changed. + [propput] HRESULT MarginBottom([in] double marginBottom); + + /// The left margin in inches. The default is 1 cm, or ~0.4 inches. + [propget] HRESULT MarginLeft([out, retval] double* marginLeft); + + /// Sets the `MarginLeft` property. A margin cannot be less than zero. + /// Returns `E_INVALIDARG` if an invalid value is provided, and the current + /// value is not changed. + [propput] HRESULT MarginLeft([in] double marginLeft); + + /// The right margin in inches. The default is 1 cm, or ~0.4 inches. + [propget] HRESULT MarginRight([out, retval] double* marginRight); + + /// Set the `MarginRight` property.A margin cannot be less than zero. + /// Returns `E_INVALIDARG` if an invalid value is provided, and the current + /// value is not changed. + [propput] HRESULT MarginRight([in] double marginRight); + + /// `TRUE` if background colors and images should be printed. The default value + /// is `FALSE`. + [propget] HRESULT ShouldPrintBackgrounds( + [out, retval] BOOL* shouldPrintBackgrounds); + + /// Set the `ShouldPrintBackgrounds` property. + [propput] HRESULT ShouldPrintBackgrounds([in] BOOL shouldPrintBackgrounds); + + /// `TRUE` if only the current end user's selection of HTML in the document + /// should be printed. The default value is `FALSE`. + [propget] HRESULT ShouldPrintSelectionOnly( + [out, retval] BOOL* shouldPrintSelectionOnly); + + /// Set the `ShouldPrintSelectionOnly` property. + [propput] HRESULT ShouldPrintSelectionOnly( + [in] BOOL shouldPrintSelectionOnly); + + /// `TRUE` if header and footer should be printed. The default value is `FALSE`. + /// The header consists of the date and time of printing, and the title of the + /// page. The footer consists of the URI and page number. The height of the + /// header and footer is 0.5 cm, or ~0.2 inches. + [propget] HRESULT ShouldPrintHeaderAndFooter( + [out, retval] BOOL* shouldPrintHeaderAndFooter); + + /// Set the `ShouldPrintHeaderAndFooter` property. + [propput] HRESULT ShouldPrintHeaderAndFooter( + [in] BOOL shouldPrintHeaderAndFooter); + + /// The title in the header if `ShouldPrintHeaderAndFooter` is `TRUE`. The + /// default value is the title of the current document. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT HeaderTitle([out, retval] LPWSTR* headerTitle); + + /// Set the `HeaderTitle` property. If an empty string or null value is + /// provided, no title is shown in the header. + [propput] HRESULT HeaderTitle([in] LPCWSTR headerTitle); + + /// The URI in the footer if `ShouldPrintHeaderAndFooter` is `TRUE`. The + /// default value is the current URI. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT FooterUri([out, retval] LPWSTR* footerUri); + + /// Set the `FooterUri` property. If an empty string or null value is + /// provided, no URI is shown in the footer. + [propput] HRESULT FooterUri([in] LPCWSTR footerUri); +} + +/// Settings used by the `Print` method. +[uuid(CA7F0E1F-3484-41D1-8C1A-65CD44A63F8D), object, pointer_default(unique)] +interface ICoreWebView2PrintSettings2 : ICoreWebView2PrintSettings { + /// Page range to print. Defaults to empty string, which means print all pages. + /// If the Page range is empty string or null, then it applies the default. + /// + /// The PageRanges property is a list of page ranges specifying one or more pages that + /// should be printed separated by commas. Any whitespace between page ranges is ignored. + /// A valid page range is either a single integer identifying the page to print, or a range + /// in the form `[start page]-[last page]` where `start page` and `last page` are integers + /// identifying the first and last inclusive pages respectively to print. + /// Every page identifier is an integer greater than 0 unless wildcards are used (see below examples). + /// The first page is 1. + /// + /// In a page range of the form `[start page]-[last page]` the start page number must be + /// larger than 0 and less than or equal to the document's total page count. + /// If the `start page` is not present, then 1 is used as the `start page`. + /// The `last page` must be larger than the `start page`. + /// If the `last page` is not present, then the document total page count is used as the `last page`. + /// + /// Repeating a page does not print it multiple times. To print multiple times, use the `Copies` property. + /// + /// The pages are always printed in ascending order, even if specified in non-ascending order. + /// + /// If page range is not valid or if a page is greater than document total page count, + /// `ICoreWebView2PrintCompletedHandler` or `ICoreWebView2PrintToPdfStreamCompletedHandler` + /// handler will return `E_INVALIDARG`. + /// + /// The following examples assume a document with 20 total pages. + /// + /// | Example | Result | Notes | + /// | --- | --- | --- | + /// | "2" | Page 2 | | + /// | "1-4, 9, 3-6, 10, 11" | Pages 1-6, 9-11 | | + /// | "1-4, -6" | Pages 1-6 | The "-6" is interpreted as "1-6". | + /// | "2-" | Pages 2-20 | The "2-" is interpreted as "pages 2 to the end of the document". | + /// | "4-2, 11, -6" | Invalid | "4-2" is an invalid range. | + /// | "-" | Pages 1-20 | The "-" is interpreted as "page 1 to the end of the document". | + /// | "1-4dsf, 11" | Invalid | | + /// | "2-2" | Page 2 | | + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings) + [propget] HRESULT PageRanges([out, retval] LPWSTR* value); + + /// Set the `PageRanges` property. + [propput] HRESULT PageRanges([in] LPCWSTR value); + + /// Prints multiple pages of a document on a single piece of paper. Choose from 1, 2, 4, 6, 9 or 16. + /// The default value is 1. + [propget] HRESULT PagesPerSide([out, retval] INT32* value); + + /// Set the `PagesPerSide` property. Returns `E_INVALIDARG` if an invalid value is + /// provided, and the current value is not changed. + /// + /// Below examples shows print output for PagesPerSide and Duplex. + /// + /// | PagesPerSide | Total pages | Two-sided printing | Result | + /// | --- | --- | --- | --- | + /// | 1 | 1 | - | 1 page on the front side. | + /// | 2 | 1 | Yes | 1 page on the front side. | + /// | 2 | 4 | - | 2 pages on the first paper and 2 pages on the next paper. | + /// | 2 | 4 | Yes | 2 pages on the front side and 2 pages on back side. | + /// | 4 | 4 | Yes | 4 pages on the front side. | + /// | 4 | 8 | Yes | 4 pages on the front side and 4 pages on the back side. | + [propput] HRESULT PagesPerSide([in] INT32 value); + + /// Number of copies to print. Minimum value is `1` and the maximum copies count is `999`. + /// The default value is 1. + /// + /// This value is ignored in PrintToPdfStream method. + [propget] HRESULT Copies([out, retval] INT32* value); + + /// Set the `Copies` property. Returns `E_INVALIDARG` if an invalid value is provided + /// and the current value is not changed. + [propput] HRESULT Copies([in] INT32 value); + + /// Printer collation. See `COREWEBVIEW2_PRINT_COLLATION` for descriptions of + /// collation. The default value is `COREWEBVIEW2_PRINT_COLLATION_DEFAULT`. + /// + /// Printing uses default value of printer's collation if an invalid value is provided + /// for the specific printer. + /// + /// This value is ignored in PrintToPdfStream method. + [propget] HRESULT Collation([out, retval] COREWEBVIEW2_PRINT_COLLATION* value); + + /// Set the `Collation` property. + [propput] HRESULT Collation([in] COREWEBVIEW2_PRINT_COLLATION value); + + /// Printer color mode. See `COREWEBVIEW2_PRINT_COLOR_MODE` for descriptions + /// of color modes. The default value is `COREWEBVIEW2_PRINT_COLOR_MODE_DEFAULT`. + /// + /// Printing uses default value of printer supported color if an invalid value is provided + /// for the specific printer. + [propget] HRESULT ColorMode([out, retval] COREWEBVIEW2_PRINT_COLOR_MODE* value); + + /// Set the `ColorMode` property. + [propput] HRESULT ColorMode([in] COREWEBVIEW2_PRINT_COLOR_MODE value); + + /// Printer duplex settings. See `COREWEBVIEW2_PRINT_DUPLEX` for descriptions of duplex. + /// The default value is `COREWEBVIEW2_PRINT_DUPLEX_DEFAULT`. + /// + /// Printing uses default value of printer's duplex if an invalid value is provided + /// for the specific printer. + /// + /// This value is ignored in PrintToPdfStream method. + [propget] HRESULT Duplex([out, retval] COREWEBVIEW2_PRINT_DUPLEX* value); + + /// Set the `Duplex` property. + [propput] HRESULT Duplex([in] COREWEBVIEW2_PRINT_DUPLEX value); + + /// Printer media size. See `COREWEBVIEW2_PRINT_MEDIA_SIZE` for descriptions of media size. + /// The default value is `COREWEBVIEW2_PRINT_MEDIA_SIZE_DEFAULT`. + /// + /// If media size is `COREWEBVIEW2_PRINT_MEDIA_SIZE_CUSTOM`, you should set the `PageWidth` + /// and `PageHeight`. + /// + /// Printing uses default value of printer supported media size if an invalid value is provided + /// for the specific printer. + /// + /// This value is ignored in PrintToPdfStream method. + [propget] HRESULT MediaSize([out, retval] COREWEBVIEW2_PRINT_MEDIA_SIZE* value); + + /// Set the `MediaSize` property. + [propput] HRESULT MediaSize([in] COREWEBVIEW2_PRINT_MEDIA_SIZE value); + + /// The name of the printer to use. Defaults to empty string. + /// If the printer name is empty string or null, then it prints to the default + /// printer on the user OS. + /// + /// This value is ignored in PrintToPdfStream method. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings) + [propget] HRESULT PrinterName([out, retval] LPWSTR* value); + + /// Set the `PrinterName` property. If provided printer name doesn't match + /// with the name of any installed printers on the user OS, + /// `ICoreWebView2PrintCompletedHandler` handler will return `errorCode` as + /// `S_OK` and `printStatus` as COREWEBVIEW2_PRINT_STATUS_PRINTER_UNAVAILABLE. + /// + /// Use [Enum Printers](/windows/win32/printdocs/enumprinters) + /// to enumerate available printers. + [propput] HRESULT PrinterName([in] LPCWSTR value); +} + +/// Provides process with associated extended information in the `ICoreWebView2Environment`. +[uuid(af4c4c2e-45db-11ee-be56-0242ac120002), object, pointer_default(unique)] +interface ICoreWebView2ProcessExtendedInfo : IUnknown { + /// The process info of the current process. + [propget] HRESULT ProcessInfo( + [out, retval] ICoreWebView2ProcessInfo** processInfo); + + /// The collection of associated `FrameInfo`s which are actively running + /// (showing or hiding UI elements) in this renderer process. `AssociatedFrameInfos` + /// will only be populated when this `CoreWebView2ProcessExtendedInfo` + /// corresponds to a renderer process. Non-renderer processes will always + /// have an empty `AssociatedFrameInfos`. The `AssociatedFrameInfos` may + /// also be empty for renderer processes that have no active frames. + /// + /// \snippet ProcessComponent.cpp AssociatedFrameInfos + [propget] HRESULT AssociatedFrameInfos( + [out, retval] ICoreWebView2FrameInfoCollection** frames); +} + +/// A continuation of the `ICoreWebView2ProcessFailedEventArgs` interface. +[uuid(4dab9422-46fa-4c3e-a5d2-41d2071d3680), object, pointer_default(unique)] +interface ICoreWebView2ProcessFailedEventArgs2 : ICoreWebView2ProcessFailedEventArgs { + + /// The reason for the process failure. Some of the reasons are only + /// applicable to specific values of + /// `ICoreWebView2ProcessFailedEventArgs::ProcessFailedKind`, and the + /// following `ProcessFailedKind` values always return the indicated reason + /// value: + /// + /// ProcessFailedKind | Reason + /// ---|--- + /// COREWEBVIEW2_PROCESS_FAILED_KIND_BROWSER_PROCESS_EXITED | COREWEBVIEW2_PROCESS_FAILED_REASON_UNEXPECTED + /// COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_UNRESPONSIVE | COREWEBVIEW2_PROCESS_FAILED_REASON_UNRESPONSIVE + /// + /// For other `ProcessFailedKind` values, the reason may be any of the reason + /// values. To learn about what these values mean, see + /// `COREWEBVIEW2_PROCESS_FAILED_REASON`. + [propget] HRESULT Reason( + [out, retval] COREWEBVIEW2_PROCESS_FAILED_REASON* reason); + + /// The exit code of the failing process, for telemetry purposes. The exit + /// code is always `STILL_ACTIVE` (`259`) when `ProcessFailedKind` is + /// `COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_UNRESPONSIVE`. + [propget] HRESULT ExitCode( + [out, retval] int* exitCode); + + /// Description of the process assigned by the WebView2 Runtime. This is a + /// technical English term appropriate for logging or development purposes, + /// and not localized for the end user. It applies to utility processes (for + /// example, "Audio Service", "Video Capture") and plugin processes (for + /// example, "Flash"). The returned `processDescription` is empty if the + /// WebView2 Runtime did not assign a description to the process. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT ProcessDescription( + [out, retval] LPWSTR* processDescription); + + /// The collection of `FrameInfo`s for frames in the `ICoreWebView2` that were + /// being rendered by the failed process. The content in these frames is + /// replaced with an error page. + /// This is only available when `ProcessFailedKind` is + /// `COREWEBVIEW2_PROCESS_FAILED_KIND_FRAME_RENDER_PROCESS_EXITED`; + /// `frames` is `null` for all other process failure kinds, including the case + /// in which the failed process was the renderer for the main frame and + /// subframes within it, for which the failure kind is + /// `COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_EXITED`. + [propget] HRESULT FrameInfosForFailedProcess( + [out, retval] ICoreWebView2FrameInfoCollection** frames); +} + +/// Provides a set of properties for a process in the `ICoreWebView2Environment`. +[uuid(84FA7612-3F3D-4FBF-889D-FAD000492D72), object, pointer_default(unique)] +interface ICoreWebView2ProcessInfo : IUnknown { + + /// The process id of the process. + [propget] HRESULT ProcessId([out, retval] INT32* value); + + /// The kind of the process. + [propget] HRESULT Kind([out, retval] COREWEBVIEW2_PROCESS_KIND* kind); +} + +/// Provides a set of properties to configure a Profile object. +/// +/// \snippet AppWindow.cpp OnCreateCoreWebView2ControllerCompleted +[uuid(79110ad3-cd5d-4373-8bc3-c60658f17a5f), object, pointer_default(unique)] +interface ICoreWebView2Profile : IUnknown { + /// Name of the profile. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT ProfileName([out, retval] LPWSTR* value); + + /// InPrivate mode is enabled or not. + [propget] HRESULT IsInPrivateModeEnabled([out, retval] BOOL* value); + + /// Full path of the profile directory. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT ProfilePath([out, retval] LPWSTR* value); + + /// Gets the `DefaultDownloadFolderPath` property. The default value is the + /// system default download folder path for the user. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT DefaultDownloadFolderPath([out, retval] LPWSTR* value); + + /// Sets the `DefaultDownloadFolderPath` property. The default download folder + /// path is persisted in the user data folder across sessions. The value + /// should be an absolute path to a folder that the user and application can + /// write to. Returns `E_INVALIDARG` if the value is invalid, and the default + /// download folder path is not changed. Otherwise the path is changed + /// immediately. If the directory does not yet exist, it is created at the + /// time of the next download. If the host application does not have + /// permission to create the directory, then the user is prompted to provide a + /// new path through the Save As dialog. The user can override the default + /// download folder path for a given download by choosing a different path in + /// the Save As dialog. + [propput] HRESULT DefaultDownloadFolderPath([in] LPCWSTR value); + + /// The PreferredColorScheme property sets the overall color scheme of the + /// WebView2s associated with this profile. This sets the color scheme for + /// WebView2 UI like dialogs, prompts, and context menus by setting the + /// media feature `prefers-color-scheme` for websites to respond to. + /// + /// The default value for this is COREWEBVIEW2_PREFERRED_COLOR_AUTO, + /// which will follow whatever theme the OS is currently set to. + /// + /// \snippet ViewComponent.cpp SetPreferredColorScheme + /// Returns the value of the `PreferredColorScheme` property. + [propget] HRESULT PreferredColorScheme( + [out, retval] COREWEBVIEW2_PREFERRED_COLOR_SCHEME* value); + + /// Sets the `PreferredColorScheme` property. + [propput] HRESULT PreferredColorScheme( + [in] COREWEBVIEW2_PREFERRED_COLOR_SCHEME value); +} + +/// Interfaces in profile for managing password-autosave and general-autofill. +[uuid(BD82FA6A-1D65-4C33-B2B4-0393020CC61B), object, pointer_default(unique)] +interface ICoreWebView2Profile6 : ICoreWebView2Profile5 { + /// IsPasswordAutosaveEnabled controls whether autosave for password + /// information is enabled. The IsPasswordAutosaveEnabled property behaves + /// independently of the IsGeneralAutofillEnabled property. When IsPasswordAutosaveEnabled is + /// false, no new password data is saved and no Save/Update Password prompts are displayed. + /// However, if there was password data already saved before disabling this setting, + /// then that password information is auto-populated, suggestions are shown and clicking on + /// one will populate the fields. + /// When IsPasswordAutosaveEnabled is true, password information is auto-populated, + /// suggestions are shown and clicking on one will populate the fields, new data + /// is saved, and a Save/Update Password prompt is displayed. + /// It will take effect immediately after setting. + /// The default value is `FALSE`. + /// This property has the same value as + /// `CoreWebView2Settings.IsPasswordAutosaveEnabled`, and changing one will + /// change the other. All `CoreWebView2`s with the same `CoreWebView2Profile` + /// will share the same value for this property, so for the `CoreWebView2`s + /// with the same profile, their + /// `CoreWebView2Settings.IsPasswordAutosaveEnabled` and + /// `CoreWebView2Profile.IsPasswordAutosaveEnabled` will always have the same + /// value. + /// + /// \snippet SettingsComponent.cpp ToggleProfilePasswordAutosaveEnabled + [propget] HRESULT IsPasswordAutosaveEnabled([out, retval] BOOL* value); + + /// Set the IsPasswordAutosaveEnabled property. + [propput] HRESULT IsPasswordAutosaveEnabled([in] BOOL value); + + /// IsGeneralAutofillEnabled controls whether autofill for information + /// like names, street and email addresses, phone numbers, and arbitrary input + /// is enabled. This excludes password and credit card information. When + /// IsGeneralAutofillEnabled is false, no suggestions appear, and no new information + /// is saved. When IsGeneralAutofillEnabled is true, information is saved, suggestions + /// appear and clicking on one will populate the form fields. + /// It will take effect immediately after setting. + /// The default value is `TRUE`. + /// This property has the same value as + /// `CoreWebView2Settings.IsGeneralAutofillEnabled`, and changing one will + /// change the other. All `CoreWebView2`s with the same `CoreWebView2Profile` + /// will share the same value for this property, so for the `CoreWebView2`s + /// with the same profile, their + /// `CoreWebView2Settings.IsGeneralAutofillEnabled` and + /// `CoreWebView2Profile.IsGeneralAutofillEnabled` will always have the same + /// value. + /// + /// \snippet SettingsComponent.cpp ToggleProfileGeneralAutofillEnabled + [propget] HRESULT IsGeneralAutofillEnabled([out, retval] BOOL* value); + + /// Set the IsGeneralAutofillEnabled property. + [propput] HRESULT IsGeneralAutofillEnabled([in] BOOL value); +} + +/// This is the profile interface that manages profile +/// deletion. +[uuid(fbf70c2f-eb1f-4383-85a0-163e92044011), object, pointer_default(unique)] +interface ICoreWebView2Profile8 : ICoreWebView2Profile7 { + /// After the API is called, the profile will be marked for deletion. The + /// local profile's directory will be deleted at browser process exit. If it + /// fails to delete, because something else is holding the files open, + /// WebView2 will try to delete the profile at all future browser process + /// starts until successful. + /// The corresponding CoreWebView2s will be closed and the + /// CoreWebView2Profile.Deleted event will be raised. See + /// `CoreWebView2Profile.Deleted` for more information. + /// If you try to create a new profile with the same name as an existing + /// profile that has been marked as deleted but hasn't yet been deleted, + /// profile creation will fail with HRESULT_FROM_WIN32(ERROR_DELETE_PENDING). + /// + /// \snippet SettingsComponent.cpp DeleteProfile + HRESULT Delete(); + + /// Add an event handler for the `Deleted` event. The `Deleted` event is + /// raised when the profile is marked for deletion. When this event is + /// raised, the CoreWebView2Profile and its corresponding CoreWebView2s have + /// been closed, and cannot be used anymore. + /// + /// \snippet AppWindow.cpp ProfileDeleted + HRESULT add_Deleted( + [in] ICoreWebView2ProfileDeletedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_Deleted`. + HRESULT remove_Deleted( + [in] EventRegistrationToken token); +} + +/// Event args for the `ScriptDialogOpening` event. +[uuid(7390bb70-abe0-4843-9529-f143b31b03d6), object, pointer_default(unique)] +interface ICoreWebView2ScriptDialogOpeningEventArgs : IUnknown { + + /// The URI of the page that requested the dialog box. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + + [propget] HRESULT Uri([out, retval] LPWSTR* uri); + + /// The kind of JavaScript dialog box. `alert`, `confirm`, `prompt`, or + /// `beforeunload`. + + [propget] HRESULT Kind([out, retval] COREWEBVIEW2_SCRIPT_DIALOG_KIND* kind); + + /// The message of the dialog box. From JavaScript this is the first + /// parameter passed to `alert`, `confirm`, and `prompt` and is empty for + /// `beforeunload`. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + + [propget] HRESULT Message([out, retval] LPWSTR* message); + + /// The host may run this to respond with **OK** to `confirm`, `prompt`, and + /// `beforeunload` dialogs. Do not run this method to indicate cancel. + /// From JavaScript, this means that the `confirm` and `beforeunload` function + /// returns `TRUE` if `Accept` is run. And for the prompt function it returns + /// the value of `ResultText` if `Accept` is run and otherwise returns + /// `FALSE`. + + HRESULT Accept(); + + /// The second parameter passed to the JavaScript prompt dialog. + /// The result of the prompt JavaScript function uses this value as the + /// default value. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + + [propget] HRESULT DefaultText([out, retval] LPWSTR* defaultText); + + /// The return value from the JavaScript prompt function if `Accept` is run. + /// This value is ignored for dialog kinds other than prompt. If `Accept` + /// is not run, this value is ignored and `FALSE` is returned from prompt. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + + [propget] HRESULT ResultText([out, retval] LPWSTR* resultText); + + /// Sets the `ResultText` property. + + [propput] HRESULT ResultText([in] LPCWSTR resultText); + + /// Returns an `ICoreWebView2Deferral` object. Use this operation to + /// complete the event at a later time. + + HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral); +} + +/// This interface represents a JavaScript exception. +/// If the CoreWebView2.ExecuteScriptWithResult result has Succeeded as false, +/// you can use the result's Exception property to get the script exception. +[uuid(054DAE00-84A3-49FF-BC17-4012A90BC9FD), object, pointer_default(unique)] +interface ICoreWebView2ScriptException : IUnknown { + /// The line number of the source where the exception occurred. + /// In the JSON it is `exceptionDetail.lineNumber`. + /// Note that this position starts at 0. + [propget] HRESULT LineNumber([out, retval] UINT32* value); + + /// The column number of the source where the exception occurred. + /// In the JSON it is `exceptionDetail.columnNumber`. + /// Note that this position starts at 0. + [propget] HRESULT ColumnNumber([out, retval] UINT32* value); + /// The Name is the exception's class name. + /// In the JSON it is `exceptionDetail.exception.className`. + /// This is the empty string if the exception doesn't have a class name. + /// This can happen if the script throws a non-Error object such as `throw "abc";` + [propget] HRESULT Name([out, retval] LPWSTR* value); + /// The Message is the exception's message and potentially stack. + /// In the JSON it is exceptionDetail.exception.description. + /// This is the empty string if the exception doesn't have a description. + /// This can happen if the script throws a non-Error object such as throw "abc";. + [propget] HRESULT Message([out, retval] LPWSTR* value); + /// This will return all details of the exception as a JSON string. + /// In the case that script has thrown a non-Error object such as `throw "abc";` + /// or any other non-Error object, you can get object specific properties. + [propget] HRESULT ToJson([out, retval] LPWSTR* value); +} + +/// Event args for the `ServerCertificateErrorDetected` event. +[uuid(012193ED-7C13-48FF-969D-A84C1F432A14), object, pointer_default(unique)] +interface ICoreWebView2ServerCertificateErrorDetectedEventArgs : IUnknown { + /// The TLS error code for the invalid certificate. + [propget] HRESULT ErrorStatus([out, retval] COREWEBVIEW2_WEB_ERROR_STATUS* value); + + /// URI associated with the request for the invalid certificate. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT RequestUri([out, retval] LPWSTR* value); + + /// Returns the server certificate. + [propget] HRESULT ServerCertificate([out, retval] ICoreWebView2Certificate** value); + + /// The action of the server certificate error detection. + /// The default value is `COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION_DEFAULT`. + [propget] HRESULT Action([out, retval] COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION* value); + + /// Sets the `Action` property. + [propput] HRESULT Action([in] COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION value); + + /// Returns an `ICoreWebView2Deferral` object. Use this operation to + /// complete the event at a later time. + HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral); +} + +/// The shared buffer object that is created by [CreateSharedBuffer](/microsoft-edge/webview2/reference/win32/icorewebview2environment12#createsharedbuffer). +/// The object is presented to script as ArrayBuffer when posted to script with +/// [PostSharedBufferToScript](/microsoft-edge/webview2/reference/win32/icorewebview2_17#postsharedbuffertoscript). +[uuid(B747A495-0C6F-449E-97B8-2F81E9D6AB43), object, pointer_default(unique)] +interface ICoreWebView2SharedBuffer : IUnknown { + /// The size of the shared buffer in bytes. + [propget] HRESULT Size([out, retval] UINT64* value); + + /// The memory address of the shared buffer. + [propget] HRESULT Buffer([out, retval] BYTE** value); + + /// Get an IStream object that can be used to access the shared buffer. + HRESULT OpenStream([out, retval] IStream** value); + + /// Returns a handle to the file mapping object that backs this shared buffer. + /// The returned handle is owned by the shared buffer object. You should not + /// call CloseHandle on it. + /// Normal app should use `Buffer` or `OpenStream` to get memory address + /// or IStream object to access the buffer. + /// For advanced scenarios, you could use file mapping APIs to obtain other views + /// or duplicate this handle to another application process and create a view from + /// the duplicated handle in that process to access the buffer from that separate process. + [propget] HRESULT FileMappingHandle([out, retval] HANDLE* value); + + /// Release the backing shared memory. The application should call this API when no + /// access to the buffer is needed any more, to ensure that the underlying resources + /// are released timely even if the shared buffer object itself is not released due to + /// some leaked reference. + /// After the shared buffer is closed, the buffer address and file mapping handle previously + /// obtained becomes invalid and cannot be used anymore. Accessing properties of the object + /// will fail with `RO_E_CLOSED`. Operations like Read or Write on the IStream objects returned + /// from `OpenStream` will fail with `RO_E_CLOSED`. `PostSharedBufferToScript` will also + /// fail with `RO_E_CLOSED`. + /// + /// The script code should call `chrome.webview.releaseBuffer` with + /// the shared buffer as the parameter to release underlying resources as soon + /// as it does not need access the shared buffer any more. + /// When script tries to access the buffer after calling `chrome.webview.releaseBuffer`, + /// JavaScript `TypeError` exception will be raised complaining about accessing a + /// detached ArrayBuffer, the same exception when trying to access a transferred ArrayBuffer. + /// + /// Closing the buffer object on native side doesn't impact access from Script and releasing + /// the buffer from script doesn't impact access to the buffer from native side. + /// The underlying shared memory will be released by the OS when both native and script side + /// release the buffer. + HRESULT Close(); +} + +/// An HTTP request used with the `WebResourceRequested` event. +[uuid(97055cd4-512c-4264-8b5f-e3f446cea6a5), object, pointer_default(unique)] +interface ICoreWebView2WebResourceRequest : IUnknown { + + /// The request URI. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + + [propget] HRESULT Uri([out, retval] LPWSTR* uri); + + /// Sets the `Uri` property. + + [propput] HRESULT Uri([in] LPCWSTR uri); + + /// The HTTP request method. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + + [propget] HRESULT Method([out, retval] LPWSTR* method); + + /// Sets the `Method` property. + + [propput] HRESULT Method([in] LPCWSTR method); + + /// The HTTP request message body as stream. POST data should be here. If a + /// stream is set, which overrides the message body, the stream must have + /// all the content data available by the time the `WebResourceRequested` + /// event deferral of this response is completed. Stream should be agile or + /// be created from a background STA to prevent performance impact to the UI + /// thread. `Null` means no content data. `IStream` semantics apply + /// (return `S_OK` to `Read` runs until all data is exhausted). + + [propget] HRESULT Content([out, retval] IStream** content); + + /// Sets the `Content` property. + + [propput] HRESULT Content([in] IStream* content); + + /// The mutable HTTP request headers + + [propget] HRESULT Headers([out, retval] ICoreWebView2HttpRequestHeaders** headers); +} + +/// Event args for the `WebResourceRequested` event. +[uuid(453e667f-12c7-49d4-be6d-ddbe7956f57a), object, pointer_default(unique)] +interface ICoreWebView2WebResourceRequestedEventArgs : IUnknown { + + /// The Web resource request. The request object may be missing some headers + /// that are added by network stack at a later time. + + [propget] HRESULT Request([out, retval] ICoreWebView2WebResourceRequest** request); + + /// A placeholder for the web resource response object. If this object is + /// set, the web resource request is completed with the specified response. + + [propget] HRESULT Response([out, retval] ICoreWebView2WebResourceResponse** response); + + /// Sets the `Response` property. Create an empty web resource response + /// object with `CreateWebResourceResponse` and then modify it to construct + /// the response. + + [propput] HRESULT Response([in] ICoreWebView2WebResourceResponse* response); + + /// Obtain an `ICoreWebView2Deferral` object and put the event into a + /// deferred state. Use the `ICoreWebView2Deferral` object to complete the + /// request at a later time. + + HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral); + + /// The web resource request context. + + [propget] HRESULT ResourceContext([out, retval] COREWEBVIEW2_WEB_RESOURCE_CONTEXT* context); +} + +/// An HTTP response used with the `WebResourceRequested` event. +[uuid(aafcc94f-fa27-48fd-97df-830ef75aaec9), object, pointer_default(unique)] +interface ICoreWebView2WebResourceResponse : IUnknown { + + /// HTTP response content as stream. Stream must have all the content data + /// available by the time the `WebResourceRequested` event deferral of this + /// response is completed. Stream should be agile or be created from a + /// background thread to prevent performance impact to the UI thread. `Null` + /// means no content data. `IStream` semantics apply (return `S_OK` to + /// `Read` runs until all data is exhausted). + /// When providing the response data, you should consider relevant HTTP + /// request headers just like an HTTP server would do. For example, if the + /// request was for a video resource in a HTML video element, the request may + /// contain the [Range](https://developer.mozilla.org/docs/Web/HTTP/Headers/Range) + /// header to request only a part of the video that is streaming. In this + /// case, your response stream should be only the portion of the video + /// specified by the range HTTP request headers and you should set the + /// appropriate + /// [Content-Range](https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Range) + /// header in the response. + + [propget] HRESULT Content([out, retval] IStream** content); + + /// Sets the `Content` property. + + [propput] HRESULT Content([in] IStream* content); + + /// Overridden HTTP response headers. + + [propget] HRESULT Headers([out, retval] ICoreWebView2HttpResponseHeaders** headers); + + /// The HTTP response status code. + + [propget] HRESULT StatusCode([out, retval] int* statusCode); + + /// Sets the `StatusCode` property. + + [propput] HRESULT StatusCode([in] int statusCode); + + /// The HTTP response reason phrase. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + + [propget] HRESULT ReasonPhrase([out, retval] LPWSTR* reasonPhrase); + + /// Sets the `ReasonPhrase` property. + + [propput] HRESULT ReasonPhrase([in] LPCWSTR reasonPhrase); +} + +/// View of the HTTP representation for a web resource response. The properties +/// of this object are not mutable. This response view is used with the +/// WebResourceResponseReceived event. +[uuid(79701053-7759-4162-8F7D-F1B3F084928D), object, pointer_default(unique)] +interface ICoreWebView2WebResourceResponseView : IUnknown { + /// The HTTP response headers as received. + [propget] HRESULT Headers( + [out, retval] ICoreWebView2HttpResponseHeaders** headers); + /// The HTTP response status code. + [propget] HRESULT StatusCode([out, retval] int* statusCode); + /// The HTTP response reason phrase. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT ReasonPhrase([out, retval] LPWSTR* reasonPhrase); + + /// Get the response content asynchronously. The handler will receive the + /// response content stream. + /// + /// This method returns null if content size is more than 123MB or for navigations that become downloads + /// or if response is downloadable content type (e.g., application/octet-stream). + /// See `add_DownloadStarting` event to handle the response. + /// + /// If this method is being called again before a first call has completed, + /// the handler will be invoked at the same time the handlers from prior calls + /// are invoked. + /// If this method is being called after a first call has completed, the + /// handler will be invoked immediately. + /// \snippet ScenarioWebViewEventMonitor.cpp GetContent + HRESULT GetContent( + [in] ICoreWebView2WebResourceResponseViewGetContentCompletedHandler* handler); +} + +/// The window features for a WebView popup window. The fields match the +/// `windowFeatures` passed to `window.open` as specified in +/// [Window features](https://developer.mozilla.org/docs/Web/API/Window/open#Window_features) +/// on MDN. +/// +/// There is no requirement for you to respect the values. If your app does +/// not have corresponding UI features (for example, no toolbar) or if all +/// instance of WebView are opened in tabs and do not have distinct size or +/// positions, then your app does not respect the values. You may want to +/// respect values, but perhaps only some apply to the UI of you app. +/// Accordingly, you may respect all, some, or none of the properties as +/// appropriate for your app. For all numeric properties, if the value that is +/// passed to `window.open` is outside the range of an unsigned 32bit int, the +/// resulting value is the absolute value of the maximum for unsigned 32bit +/// integer. If you are not able to parse the value an integer, it is +/// considered `0`. If the value is a floating point value, it is rounded down +/// to an integer. +/// +/// In runtime versions 98 or later, the values of `ShouldDisplayMenuBar`, +/// `ShouldDisplayStatus`, `ShouldDisplayToolbar`, and `ShouldDisplayScrollBars` +/// will not directly depend on the equivalent fields in the `windowFeatures` +/// string. Instead, they will all be false if the window is expected to be a +/// popup, and true if it is not. +[uuid(5eaf559f-b46e-4397-8860-e422f287ff1e), object, pointer_default(unique)] +interface ICoreWebView2WindowFeatures : IUnknown { + + /// Specifies left and top values. + + [propget] HRESULT HasPosition([out, retval] BOOL* value); + + /// Specifies height and width values. + + [propget] HRESULT HasSize([out, retval] BOOL* value); + + /// Specifies the left position of the window. If `HasPosition` is set to + /// `FALSE`, this field is ignored. + + [propget] HRESULT Left([out, retval] UINT32* value); + + /// Specifies the top position of the window. If `HasPosition` is set to + /// `FALSE`, this field is ignored. + + [propget] HRESULT Top([out, retval] UINT32* value); + + /// Specifies the height of the window. Minimum value is `100`. If + /// `HasSize` is set to `FALSE`, this field is ignored. + + [propget] HRESULT Height([out, retval] UINT32* value); + + /// Specifies the width of the window. Minimum value is `100`. If `HasSize` + /// is set to `FALSE`, this field is ignored. + + [propget] HRESULT Width([out, retval] UINT32* value); + + /// Indicates that the menu bar is displayed. + + [propget] HRESULT ShouldDisplayMenuBar([out, retval] BOOL* value); + + /// Indicates that the status bar is displayed. + + [propget] HRESULT ShouldDisplayStatus([out, retval] BOOL* value); + + /// Indicates that the browser toolbar is displayed. + + [propget] HRESULT ShouldDisplayToolbar([out, retval] BOOL* value); + + /// Indicates that the scroll bars are displayed. + + [propget] HRESULT ShouldDisplayScrollBars([out, retval] BOOL* value); +} + +/// Represents a collection of generic objects. Used to get, remove and add +/// objects at the specified index. +[uuid(5cfec11c-25bd-4e8d-9e1a-7acdaeeec047), object, pointer_default(unique)] +interface ICoreWebView2ObjectCollection : ICoreWebView2ObjectCollectionView { + /// Removes the object at the specified index. + HRESULT RemoveValueAtIndex( + [in] UINT32 index + ); + + /// Inserts the object at the specified index. + HRESULT InsertValueAtIndex( + [in] UINT32 index, + [in] IUnknown* value + ); +} + +/// This is the ICoreWebView2Notification that represents a [HTML Notification +/// object](https://developer.mozilla.org/docs/Web/API/Notification). +[uuid(B7434D98-6BC8-419D-9DA5-FB5A96D4DACD), object, pointer_default(unique)] +interface ICoreWebView2Notification : IUnknown { + /// Add an event handler for the `CloseRequested` event. This event is raised + /// when the notification is closed by the web code, such as through + /// `notification.close()`. You don't need to call `ReportClosed` since this is + /// coming from the web code. + HRESULT add_CloseRequested( + [in] ICoreWebView2NotificationCloseRequestedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Remove an event handler previously added with `add_CloseRequested`. + HRESULT remove_CloseRequested( + [in] EventRegistrationToken token); + + /// The host may run this to report the notification has been displayed and it + /// will cause the + /// [show](https://developer.mozilla.org/docs/Web/API/Notification/show_event) + /// event to be raised for non-persistent notifications. You must not run this + /// unless you are handling the `NotificationReceived` event. Returns + /// `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` if `Handled` is `FALSE` when + /// this is called. + HRESULT ReportShown(); + + /// The host may run this to report the notification has been clicked, and it + /// will cause the + /// [click](https://developer.mozilla.org/docs/Web/API/Notification/click_event) + /// event to be raised for non-persistent notifications and the + /// [notificationclick](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope/notificationclick_event) + /// event for persistent notifications. Use `ReportClickedWithActionIndex` to + /// specify an action to activate a persistent notification. You must not run + /// this unless you are handling the `NotificationReceived` event. Returns + /// `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` if `Handled` is `FALSE` or + /// `ReportShown` has not been run when this is called. + HRESULT ReportClicked(); + + /// The host may run this to report the notification was dismissed, and it + /// will cause the + /// [close](https://developer.mozilla.org/docs/Web/API/Notification/close_event) + /// event to be raised for non-persistent notifications and the + /// [notificationclose](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope/notificationclose_event) + /// event for persistent notifications. You must not run this unless you are + /// handling the `NotificationReceived` event. Returns + /// `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` if `Handled` is `FALSE` or + /// `ReportShown` has not been run when this is called. + HRESULT ReportClosed(); + + /// A string representing the body text of the notification. + /// The default value is an empty string. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Body([out, retval] LPWSTR* value); + + /// The text direction in which to display the notification. + /// This corresponds to + /// [Notification.dir](https://developer.mozilla.org/docs/Web/API/Notification/dir) + /// DOM API. + /// The default value is `COREWEBVIEW2_TEXT_DIRECTION_KIND_DEFAULT`. + [propget] HRESULT Direction([out, retval] COREWEBVIEW2_TEXT_DIRECTION_KIND* value); + + /// The notification's language, as intended to be specified using a string + /// representing a language tag (such as `en-US`) according to + /// [BCP47](https://datatracker.ietf.org/doc/html/rfc5646). Note that no + /// validation is performed on this property and it can be any string the + /// notification sender specifies. + /// This corresponds to + /// [Notification.lang](https://developer.mozilla.org/docs/Web/API/Notification/lang) + /// DOM API. + /// The default value is an empty string. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Language([out, retval] LPWSTR* value); + + /// A string representing an identifying tag for the notification. + /// This corresponds to + /// [Notification.tag](https://developer.mozilla.org/docs/Web/API/Notification/tag) + /// DOM API. + /// The default value is an empty string. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Tag([out, retval] LPWSTR* value); + + /// A string containing the URI of an icon to be displayed in the + /// notification. + /// The default value is an empty string. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT IconUri([out, retval] LPWSTR* value); + + /// The title of the notification. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Title([out, retval] LPWSTR* value); + + /// A string containing the URI of the image used to represent the + /// notification when there isn't enough space to display the notification + /// itself. + /// The default value is an empty string. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT BadgeUri([out, retval] LPWSTR* value); + + /// A string containing the URI of an image to be displayed in the + /// notification. + /// The default value is an empty string. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT BodyImageUri([out, retval] LPWSTR* value); + + /// Indicates whether the user should be notified after a new notification + /// replaces an old one. + /// This corresponds to + /// [Notification.renotify](https://developer.mozilla.org/docs/Web/API/Notification/renotify) + /// DOM API. + /// The default value is `FALSE`. + [propget] HRESULT ShouldRenotify([out, retval] BOOL* value); + + /// A boolean value indicating that a notification should remain active until + /// the user clicks or dismisses it, rather than closing automatically. + /// This corresponds to + /// [Notification.requireInteraction](https://developer.mozilla.org/docs/Web/API/Notification/requireInteraction) + /// DOM API. Note that you may not be able to necessarily implement this due to native API limitations. + /// The default value is `FALSE`. + [propget] HRESULT RequiresInteraction([out, retval] BOOL* value); + + /// Indicates whether the notification should be silent -- i.e., no sounds or + /// vibrations should be issued, regardless of the device settings. + /// This corresponds to + /// [Notification.silent](https://developer.mozilla.org/docs/Web/API/Notification/silent) + /// DOM API. + /// The default value is `FALSE`. + [propget] HRESULT IsSilent([out, retval] BOOL* value); + + /// Indicates the time at which a notification is created or applicable (past, + /// present, or future) as the number of milliseconds since the UNIX epoch. + [propget] HRESULT Timestamp([out, retval] double* value); + + /// Gets the vibration pattern for devices with vibration hardware to emit. + /// The vibration pattern can be represented by an array of 64-bit unsigned integers + /// describing a pattern of vibrations and pauses. See [Vibration + /// API](https://developer.mozilla.org/docs/Web/API/Vibration_API) for more + /// information. + /// This corresponds to + /// [Notification.vibrate](https://developer.mozilla.org/docs/Web/API/Notification/vibrate) + /// DOM API. + /// An empty array is returned if no vibration patterns are + /// specified. + HRESULT GetVibrationPattern([out] UINT32* count, [out] UINT64** vibrationPattern); +} + +/// Event args for the `NotificationReceived` event. +/// \snippet ScenarioNotificationReceived.cpp NotificationReceived +[uuid(1512DD5B-5514-4F85-886E-21C3A4C9CFE6), object, pointer_default(unique)] +interface ICoreWebView2NotificationReceivedEventArgs : IUnknown { + /// The origin of the web content that sends the notification, such as + /// `https://example.com/` or `https://www.example.com/`. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT SenderOrigin([out, retval] LPWSTR* value); + + /// The notification that was received. You can access the + /// properties on the Notification object to show your own notification. + [propget] HRESULT Notification([out, retval] ICoreWebView2Notification** value); + + /// Sets whether the `NotificationReceived` event is handled by the host after + /// the event handler completes or if there is a deferral then after the + /// deferral is completed. + /// + /// If `Handled` is set to TRUE then WebView will not display the notification + /// with the default UI, and the host will be responsible for handling the + /// notification and for letting the web content know that the notification + /// has been displayed, clicked, or closed. You must set `Handled` to `TRUE` + /// before you call `ReportShown`, `ReportClicked`, + /// `ReportClickedWithActionIndex` and `ReportClosed`, otherwise they will + /// fail with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)`. If after the event + /// handler or deferral completes `Handled` is set to FALSE then WebView will + /// display the default notification UI. Note that you cannot un-handle this + /// event once you have set `Handled` to be `TRUE`. The initial value is + /// FALSE. + [propput] HRESULT Handled([in] BOOL value); + + /// Gets whether the `NotificationReceived` event is handled by host. + [propget] HRESULT Handled([out, retval] BOOL* value); + + /// Returns an `ICoreWebView2Deferral` object. Use this operation to complete + /// the event at a later time. + HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral); +} + +/// The event args for `SaveAsUIShowing` event. +[uuid(55902952-0e0d-5aaa-a7d0-e833cdb34f62), object, pointer_default(unique)] +interface ICoreWebView2SaveAsUIShowingEventArgs : IUnknown { + /// Get the Mime type of content to be saved. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT ContentMimeType([out, retval] LPWSTR* value); + + /// Sets the `Cancel` property. Set this property to `TRUE` to cancel the Save As action + /// and prevent the download from starting. ShowSaveAsUI returns + /// `COREWEBVIEW2_SAVE_AS_UI_RESULT_CANCELLED` in this case. The default value is `FALSE`. + [propput] HRESULT Cancel([in] BOOL value); + + /// Gets the `Cancel` property. + [propget] HRESULT Cancel([out, retval] BOOL* value); + + /// Sets the `SuppressDefaultDialog` property, which indicates whether the system + /// default dialog is suppressed. When `SuppressDefaultDialog` is `FALSE`, the default + /// Save As dialog is shown and the values assigned through `SaveAsFilePath`, `AllowReplace` + /// and `Kind` are ignored when the event args invoke completed. + /// + /// Set `SuppressDefaultDialog` to `TRUE` to perform a silent Save As. When + /// `SuppressDefaultDialog` is `TRUE`, the system dialog is skipped and the + /// `SaveAsFilePath`, `AllowReplace` and `Kind` values are used. + /// + /// The default value is FALSE. + [propput] HRESULT SuppressDefaultDialog([in] BOOL value); + + /// Gets the `SuppressDefaultDialog` property. + [propget] HRESULT SuppressDefaultDialog([out, retval] BOOL* value); + + /// Returns an `ICoreWebView2Deferral` object. This will defer showing the + /// default Save As dialog and performing the Save As operation. + HRESULT GetDeferral( + [out, retval] ICoreWebView2Deferral** value + ); + + /// Set the `SaveAsFilePath` property for Save As. `SaveAsFilePath` is an absolute path + /// of the location. It includes the file name and extension. If `SaveAsFilePath` is not + /// valid (for example, the root drive does not exist), Save As is denied and + /// `COREWEBVIEW2_SAVE_AS_INVALID_PATH` is returned. + /// + /// If the associated download completes successfully, a target file is saved at + /// this location. If the Kind property is `COREWEBVIEW2_SAVE_AS_KIND_COMPLETE`, + /// there will be an additional directory with resources files. + /// + /// The default value is a system suggested path, based on users' local environment. + [propput] HRESULT SaveAsFilePath([in] LPCWSTR value); + + + /// Gets the `SaveAsFilePath` property. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT SaveAsFilePath([out, retval] LPWSTR* value); + + /// `AllowReplace` allows user to control what happens when a file already + /// exists in the file path to which the Save As operation is saving. + /// Setting this property to `TRUE` allows existing files to be replaced. + /// Setting this property to `FALSE` will not replace existing files and will return + /// `COREWEBVIEW2_SAVE_AS_UI_RESULT_FILE_ALREADY_EXISTS`. + /// + /// The default value is `FALSE`. + [propput] HRESULT AllowReplace([in] BOOL value); + + /// Gets the `AllowReplace` property. + [propget] HRESULT AllowReplace([out, retval] BOOL* value); + + /// Sets the `Kind` property to save documents of different kinds. See the + /// `COREWEBVIEW2_SAVE_AS_KIND` enum for a description of the different options. + /// If the kind is not allowed for the current document, ShowSaveAsUI returns + /// `COREWEBVIEW2_SAVE_AS_UI_RESULT_KIND_NOT_SUPPORTED`. + /// + /// The default value is `COREWEBVIEW2_SAVE_AS_KIND_DEFAULT`. + [propput] HRESULT Kind([in] COREWEBVIEW2_SAVE_AS_KIND value); + + /// Gets the `Kind` property. + [propget] HRESULT Kind([out, retval] COREWEBVIEW2_SAVE_AS_KIND* value); +} + + + +/// This is a continuation of the ICoreWebView2AcceleratorKeyPressedEventArgs interface. +/// +[uuid(03b2c8c8-7799-4e34-bd66-ed26aa85f2bf), object, pointer_default(unique)] +interface ICoreWebView2AcceleratorKeyPressedEventArgs2 : ICoreWebView2AcceleratorKeyPressedEventArgs { + /// Gets the `IsBrowserAcceleratorKeyEnabled` property. + [propget] HRESULT IsBrowserAcceleratorKeyEnabled([out, retval] BOOL* value); + + + /// This property allows developers to enable or disable the browser from handling a specific + /// browser accelerator key such as Ctrl+P or F3, etc. + /// + /// Browser accelerator keys are the keys/key combinations that access features specific to + /// a web browser, including but not limited to: + /// - Ctrl-F and F3 for Find on Page + /// - Ctrl-P for Print + /// - Ctrl-R and F5 for Reload + /// - Ctrl-Plus and Ctrl-Minus for zooming + /// - Ctrl-Shift-C and F12 for DevTools + /// - Special keys for browser functions, such as Back, Forward, and Search + /// + /// This property does not disable accelerator keys related to movement and text editing, + /// such as: + /// - Home, End, Page Up, and Page Down + /// - Ctrl-X, Ctrl-C, Ctrl-V + /// - Ctrl-A for Select All + /// - Ctrl-Z for Undo + /// + /// The `CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled` API is a convenient setting + /// for developers to disable all the browser accelerator keys together, and sets the default + /// value for the `IsBrowserAcceleratorKeyEnabled` property. + /// By default, `CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled` is `TRUE` and + /// `IsBrowserAcceleratorKeyEnabled` is `TRUE`. + /// When developers change `CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled` setting to `FALSE`, + /// this will change default value for `IsBrowserAcceleratorKeyEnabled` to `FALSE`. + /// If developers want specific keys to be handled by the browser after changing the + /// `CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled` setting to `FALSE`, they need to enable + /// these keys by setting `IsBrowserAcceleratorKeyEnabled` to `TRUE`. + /// This API will give the event arg higher priority over the + /// `CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled` setting when we handle the keys. + /// + /// For browser accelerator keys, when an accelerator key is pressed, the propagation and + /// processing order is: + /// 1. A CoreWebView2Controller.AcceleratorKeyPressed event is raised + /// 2. WebView2 browser feature accelerator key handling + /// 3. Web Content Handling: If the key combination isn't reserved for browser actions, + /// the key event propagates to the web content, where JavaScript event listeners can + /// capture and respond to it. + /// + /// `ICoreWebView2AcceleratorKeyPressedEventArgs` has a `Handled` property, that developers + /// can use to mark a key as handled. When the key is marked as handled anywhere along + /// the path, the event propagation stops, and web content will not receive the key. + /// With `IsBrowserAcceleratorKeyEnabled` property, if developers mark + /// `IsBrowserAcceleratorKeyEnabled` as `FALSE`, the browser will skip the WebView2 + /// browser feature accelerator key handling process, but the event propagation + /// continues, and web content will receive the key combination. + /// + /// \snippet ScenarioAcceleratorKeyPressed.cpp IsBrowserAcceleratorKeyEnabled + /// Gets the `IsBrowserAcceleratorKeyEnabled` property. + /// + [propput] HRESULT IsBrowserAcceleratorKeyEnabled([in] BOOL value); + + + +} + + + +/// Event args for the `BrowserProcessExited` event. +/// +[uuid(1f00663f-af8c-4782-9cdd-dd01c52e34cb), object, pointer_default(unique)] +interface ICoreWebView2BrowserProcessExitedEventArgs : IUnknown { + /// The kind of browser process exit that has occurred. + /// + [propget] HRESULT BrowserProcessExitKind([out, retval] COREWEBVIEW2_BROWSER_PROCESS_EXIT_KIND* value); + + + /// The process ID of the browser process that has exited. + /// + [propget] HRESULT BrowserProcessId([out, retval] UINT32* value); + + + +} + + + +/// A continuation of the ICoreWebView2CompositionController interface. +/// +[uuid(0b6a3d24-49cb-4806-ba20-b5e0734a7b26), object, pointer_default(unique)] +interface ICoreWebView2CompositionController2 : ICoreWebView2CompositionController { + /// Returns the Automation Provider for the WebView. This object implements + /// IRawElementProviderSimple. + /// + [propget] HRESULT AutomationProvider([out, retval] IUnknown** value); + + + +} + + + +/// Event args for the `ContentLoading` event. +/// +[uuid(0c8a1275-9b6b-4901-87ad-70df25bafa6e), object, pointer_default(unique)] +interface ICoreWebView2ContentLoadingEventArgs : IUnknown { + /// `TRUE` if the loaded content is an error page. + /// + [propget] HRESULT IsErrorPage([out, retval] BOOL* value); + + + /// The ID of the navigation. + [propget] HRESULT NavigationId([out, retval] UINT64* value); + + + +} + + + +/// Represents a collection of `ContextMenuItem` objects. Used to get, remove and add +/// `ContextMenuItem` objects at the specified index. +/// +[uuid(f562a2f5-c415-45cf-b909-d4b7c1e276d3), object, pointer_default(unique)] +interface ICoreWebView2ContextMenuItemCollection : IUnknown { + /// Gets the number of `ContextMenuItem` objects contained in the `ContextMenuItemCollection`. + /// + [propget] HRESULT Count([out, retval] UINT32* value); + + + + /// Gets the `ContextMenuItem` at the specified index. + /// + HRESULT GetValueAtIndex( + [in] UINT32 index + , [out, retval] ICoreWebView2ContextMenuItem** value); + + /// Removes the `ContextMenuItem` at the specified index. + /// + HRESULT RemoveValueAtIndex( + [in] UINT32 index + ); + + /// Inserts the `ContextMenuItem` at the specified index. + /// + HRESULT InsertValueAtIndex( + [in] UINT32 index, + [in] ICoreWebView2ContextMenuItem* value + ); + + +} + + + +/// A continuation of the ICoreWebView2Controller interface. +/// +[uuid(c979903e-d4ca-4228-92eb-47ee3fa96eab), object, pointer_default(unique)] +interface ICoreWebView2Controller2 : ICoreWebView2Controller { + /// Gets the `DefaultBackgroundColor` property. + [propget] HRESULT DefaultBackgroundColor([out, retval] COREWEBVIEW2_COLOR* value); + + + /// The `DefaultBackgroundColor` property is the color WebView renders + /// underneath all web content. This means WebView renders this color when + /// there is no web content loaded such as before the initial navigation or + /// between navigations. This also means web pages with undefined css + /// background properties or background properties containing transparent + /// pixels will render their contents over this color. Web pages with defined + /// and opaque background properties that span the page will obscure the + /// `DefaultBackgroundColor` and display normally. The default value for this + /// property is white to resemble the native browser experience. + /// + /// The Color is specified by the COREWEBVIEW2_COLOR that represents an RGBA + /// value. The `A` represents an Alpha value, meaning + /// `DefaultBackgroundColor` can be transparent. In the case of a transparent + /// `DefaultBackgroundColor` WebView will render hosting app content as the + /// background. This Alpha value is not supported on Windows 7. Any `A` value + /// other than 255 will result in E_INVALIDARG on Windows 7. + /// It is supported on all other WebView compatible platforms. + /// + /// Semi-transparent colors are not currently supported by this API and + /// setting `DefaultBackgroundColor` to a semi-transparent color will fail + /// with E_INVALIDARG. The only supported alpha values are 0 and 255, all + /// other values will result in E_INVALIDARG. + /// `DefaultBackgroundColor` can only be an opaque color or transparent. + /// + /// This value may also be set by using the + /// `WEBVIEW2_DEFAULT_BACKGROUND_COLOR` environment variable. There is a + /// known issue with background color where setting the color by API can + /// still leave the app with a white flicker before the + /// `DefaultBackgroundColor` takes effect. Setting the color via environment + /// variable solves this issue. The value must be a hex value that can + /// optionally prepend a 0x. The value must account for the alpha value + /// which is represented by the first 2 digits. So any hex value fewer than 8 + /// digits will assume a prepended 00 to the hex value and result in a + /// transparent color. + /// `get_DefaultBackgroundColor` will return the result of this environment + /// variable if used. This environment variable can only set the + /// `DefaultBackgroundColor` once. Subsequent updates to background color + /// must be done through API call. + /// + /// \snippet ViewComponent.cpp DefaultBackgroundColor + /// + [propput] HRESULT DefaultBackgroundColor([in] COREWEBVIEW2_COLOR value); + + + +} + + + +/// This is the ICoreWebView2Controller4 interface. +/// The ICoreWebView2Controller4 provides interface to enable/disable external drop. +/// +[uuid(97d418d5-a426-4e49-a151-e1a10f327d9e), object, pointer_default(unique)] +interface ICoreWebView2Controller4 : ICoreWebView2Controller3 { + /// Gets the `AllowExternalDrop` property. + [propget] HRESULT AllowExternalDrop([out, retval] BOOL* value); + + + /// Gets the `AllowExternalDrop` property which is used to configure the + /// capability that dragging objects from outside the bounds of webview2 and + /// dropping into webview2 is allowed or disallowed. The default value is + /// TRUE. + /// + /// \snippet SettingsComponent.cpp ToggleAllowExternalDrop + /// + [propput] HRESULT AllowExternalDrop([in] BOOL value); + + + +} + + + +/// This is the interface in ControllerOptions for ScriptLocale. +/// +[uuid(06c991d8-9e7e-11ed-a8fc-0242ac120002), object, pointer_default(unique)] +interface ICoreWebView2ControllerOptions2 : ICoreWebView2ControllerOptions { + /// Gets the `ScriptLocale` property. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT ScriptLocale([out, retval] LPWSTR* value); + + + /// The default locale for the WebView2. It sets the default locale for all + /// Intl JavaScript APIs and other JavaScript APIs that depend on it, namely + /// `Intl.DateTimeFormat()` which affects string formatting like + /// in the time/date formats. Example: `Intl.DateTimeFormat().format(new Date())` + /// The intended locale value is in the format of + /// BCP 47 Language Tags. More information can be found from + /// [IETF BCP47](https://www.ietf.org/rfc/bcp/bcp47.html). + /// + /// This property sets the locale for a CoreWebView2Environment used to create the + /// WebView2ControllerOptions object, which is passed as a parameter in + /// `CreateCoreWebView2ControllerWithOptions`. + /// + /// Changes to the ScriptLocale property apply to renderer processes created after + /// the change. Any existing renderer processes will continue to use the previous + /// ScriptLocale value. To ensure changes are applied to all renderer process, + /// close and restart the CoreWebView2Environment and all associated WebView2 objects. + /// + /// The default value for ScriptLocale will depend on the WebView2 language + /// and OS region. If the language portions of the WebView2 language and OS region + /// match, then it will use the OS region. Otherwise, it will use the WebView2 + /// language. + /// + /// | OS Region | WebView2 Language | Default WebView2 ScriptLocale | + /// |-----------|-------------------|-------------------------------| + /// | en-GB | en-US | en-GB | + /// | es-MX | en-US | en-US | + /// | en-US | en-GB | en-US | + /// + /// You can set the ScriptLocale to the empty string to get the default ScriptLocale value. + /// + /// Use OS specific APIs to determine the OS region to use with this property + /// if you want to match the OS. For example: + /// + /// Win32 C++: + /// ```cpp + /// wchar_t osLocale[LOCALE_NAME_MAX_LENGTH] = {0}; + /// GetUserDefaultLocaleName(osLocale, LOCALE_NAME_MAX_LENGTH); + /// ``` + /// \snippet AppWindow.cpp ScriptLocaleSetting + /// + [propput] HRESULT ScriptLocale([in] LPCWSTR value); + + + +} + + + +/// Event args for the DOMContentLoaded event. +/// +[uuid(16b1e21a-c503-44f2-84c9-70aba5031283), object, pointer_default(unique)] +interface ICoreWebView2DOMContentLoadedEventArgs : IUnknown { + /// The ID of the navigation which corresponds to other navigation ID properties on other navigation events. + [propget] HRESULT NavigationId([out, retval] UINT64* value); + + + +} + + + +/// This interface is used to complete deferrals on event args that support +/// getting deferrals using the `GetDeferral` method. +/// +[uuid(c10e7f7b-b585-46f0-a623-8befbf3e4ee0), object, pointer_default(unique)] +interface ICoreWebView2Deferral : IUnknown { + /// Completes the associated deferred event. Complete should only be run + /// once for each deferral taken. + /// + HRESULT Complete( + ); + + +} + + + +/// Event args for the `DevToolsProtocolEventReceived` event. +/// +[uuid(653c2959-bb3a-4377-8632-b58ada4e66c4), object, pointer_default(unique)] +interface ICoreWebView2DevToolsProtocolEventReceivedEventArgs : IUnknown { + /// The parameter object of the corresponding `DevToolsProtocol` event + /// represented as a JSON string. + /// + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT ParameterObjectAsJson([out, retval] LPWSTR* value); + + + +} + + + +/// This is a continuation of the `ICoreWebView2DevToolsProtocolEventReceivedEventArgs` +/// interface that provides the session ID of the target where the event originates from. +/// +[uuid(2dc4959d-1494-4393-95ba-bea4cb9ebd1b), object, pointer_default(unique)] +interface ICoreWebView2DevToolsProtocolEventReceivedEventArgs2 : ICoreWebView2DevToolsProtocolEventReceivedEventArgs { + /// The sessionId of the target where the event originates from. + /// Empty string is returned as sessionId if the event comes from the default + /// session for the top page. + /// + /// \snippet ScriptComponent.cpp DevToolsProtocolEventReceivedSessionId + /// + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT SessionId([out, retval] LPWSTR* value); + + + +} + + +/// Receives `DevToolsProtocolEventReceived` events. +[uuid(e2fda4be-5456-406c-a261-3d452138362c), object, pointer_default(unique)] +interface ICoreWebView2DevToolsProtocolEventReceivedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2DevToolsProtocolEventReceivedEventArgs* args); +} + + +/// A Receiver is created for a particular DevTools Protocol event and allows +/// you to subscribe and unsubscribe from that event. Obtained from the +/// WebView object using `GetDevToolsProtocolEventReceiver`. +/// +[uuid(b32ca51a-8371-45e9-9317-af021d080367), object, pointer_default(unique)] +interface ICoreWebView2DevToolsProtocolEventReceiver : IUnknown { + /// Adds an event handler for the `DevToolsProtocolEventReceived` event. + /// Subscribe to a `DevToolsProtocol` event. The `Invoke` method of the + /// `handler` runs whenever the corresponding `DevToolsProtocol` event runs. + /// `Invoke` runs with an event args object containing the parameter object + /// of the DevTools Protocol event as a JSON string. + /// + /// \snippet ScriptComponent.cpp DevToolsProtocolEventReceived + /// + HRESULT add_DevToolsProtocolEventReceived( + [in] ICoreWebView2DevToolsProtocolEventReceivedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_DevToolsProtocolEventReceived`. + HRESULT remove_DevToolsProtocolEventReceived( + [in] EventRegistrationToken token); + + +} + + +// Skipping ICoreWebView2CreateCoreWebView2ControllerCompletedHandler redefinition + +// Skipping ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler redefinition + + + +/// This interface is used to create `ICoreWebView2ControllerOptions` object, which +/// can be passed as a parameter in `CreateCoreWebView2ControllerWithOptions` and +/// `CreateCoreWebView2CompositionControllerWithOptions` function for multiple profiles support. +/// The profile will be created on disk or opened when calling `CreateCoreWebView2ControllerWithOptions` or +/// `CreateCoreWebView2CompositionControllerWithOptions` no matter InPrivate mode is enabled or not, and +/// it will be released in memory when the corresponding controller is closed but still remain on disk. +/// If you create a WebView2Controller with {ProfileName="name", InPrivate=false} and then later create another +/// one with {ProfileName="name", InPrivate=true}, these two controllers using the same profile would be allowed to +/// run at the same time. +/// As WebView2 is built on top of Edge browser, it follows Edge's behavior pattern. To create an InPrivate WebView, +/// we gets an off-the-record profile (an InPrivate profile) from a regular profile, then create the WebView with the +/// off-the-record profile. +/// +/// \snippet AppWindow.cpp CreateControllerWithOptions +/// +[uuid(ee0eb9df-6f12-46ce-b53f-3f47b9c928e0), object, pointer_default(unique)] +interface ICoreWebView2Environment10 : ICoreWebView2Environment9 { + /// Create a new ICoreWebView2ControllerOptions to be passed as a parameter of + /// CreateCoreWebView2ControllerWithOptions and CreateCoreWebView2CompositionControllerWithOptions. + /// The 'options' is settable and in it the default value for profile name is the empty string, + /// and the default value for IsInPrivateModeEnabled is false. + /// Also the profile name can be reused. + /// + HRESULT CreateCoreWebView2ControllerOptions( + [out, retval] ICoreWebView2ControllerOptions** value); + + /// Create a new WebView with options. + HRESULT CreateCoreWebView2ControllerWithOptions( + [in] HWND ParentWindow, + [in] ICoreWebView2ControllerOptions* options + , [in] ICoreWebView2CreateCoreWebView2ControllerCompletedHandler* handler); + + /// Create a new WebView in visual hosting mode with options. + HRESULT CreateCoreWebView2CompositionControllerWithOptions( + [in] HWND ParentWindow, + [in] ICoreWebView2ControllerOptions* options + , [in] ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler* handler); + + +} + + + +/// A continuation of the ICoreWebView2Environment interface for +/// getting the crash dump folder path. +/// +[uuid(f0913dc6-a0ec-42ef-9805-91dff3a2966a), object, pointer_default(unique)] +interface ICoreWebView2Environment11 : ICoreWebView2Environment10 { + /// `FailureReportFolderPath` returns the path of the folder where minidump files are written. + /// Whenever a WebView2 process crashes, a crash dump file will be created in the crash dump folder. + /// The crash dump format is minidump files. Please see + /// [Minidump Files documentation](/windows/win32/debug/minidump-files) for detailed information. + /// Normally when a single child process fails, a minidump will be generated and written to disk, + /// then the `ProcessFailed` event is raised. But for unexpected crashes, a minidump file might not be generated + /// at all, despite whether `ProcessFailed` event is raised. If there are multiple + /// process failures at once, multiple minidump files could be generated. Thus `FailureReportFolderPath` + /// could contain old minidump files that are not associated with a specific `ProcessFailed` event. + /// \snippet AppWindow.cpp GetFailureReportFolder + /// + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT FailureReportFolderPath([out, retval] LPWSTR* value); + + + +} + + + +/// A continuation of the ICoreWebView2Environment interface for creating shared buffer object. +/// +[uuid(f503db9b-739f-48dd-b151-fdfcf253f54e), object, pointer_default(unique)] +interface ICoreWebView2Environment12 : ICoreWebView2Environment11 { + /// Create a shared memory based buffer with the specified size in bytes. + /// The buffer can be shared with web contents in WebView by calling + /// `PostSharedBufferToScript` on `CoreWebView2` or `CoreWebView2Frame` object. + /// Once shared, the same content of the buffer will be accessible from both + /// the app process and script in WebView. Modification to the content will be visible + /// to all parties that have access to the buffer. + /// The shared buffer is presented to the script as ArrayBuffer. All JavaScript APIs + /// that work for ArrayBuffer including Atomics APIs can be used on it. + /// There is currently a limitation that only size less than 2GB is supported. + /// + HRESULT CreateSharedBuffer( + [in] UINT64 Size + , [out, retval] ICoreWebView2SharedBuffer** value); + + +} + + +/// Receives the result of the `GetProcessExtendedInfos` method. +[uuid(f45e55aa-3bc2-11ee-be56-0242ac120002), object, pointer_default(unique)] +interface ICoreWebView2GetProcessExtendedInfosCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] ICoreWebView2ProcessExtendedInfoCollection* result); +} + +/// A collection of ICoreWebView2ProcessExtendedInfo. +[uuid(32efa696-407a-11ee-be56-0242ac120002), object, pointer_default(unique)] +interface ICoreWebView2ProcessExtendedInfoCollection : IUnknown { + /// The number of elements contained in the collection. + [propget] HRESULT Count([out, retval] UINT32* value); + + /// Gets the element at the given index. + HRESULT GetValueAtIndex([in] UINT32 index, [out, retval] ICoreWebView2ProcessExtendedInfo** value); +} + + +/// A continuation of the ICoreWebView2Environment interface for getting process +/// with associated information. +/// +[uuid(af641f58-72b2-11ee-b962-0242ac120002), object, pointer_default(unique)] +interface ICoreWebView2Environment13 : ICoreWebView2Environment12 { + /// Gets a snapshot collection of `ProcessExtendedInfo`s corresponding to all + /// currently running processes associated with this `CoreWebView2Environment` + /// excludes crashpad process. + /// This provides the same list of `ProcessInfo`s as what's provided in + /// `GetProcessInfos`, but additionally provides a list of associated `FrameInfo`s + /// which are actively running (showing or hiding UI elements) in the renderer + /// process. See `AssociatedFrameInfos` for more information. + /// + /// \snippet ProcessComponent.cpp GetProcessExtendedInfos + /// + HRESULT GetProcessExtendedInfos( + [in] ICoreWebView2GetProcessExtendedInfosCompletedHandler* handler); + + +} + + + +/// This is ICoreWebView2Environment14 that exposes new methods to +/// create Filesystem access related DOM objects. +/// +[uuid(a5e9fad9-c875-59da-9bd7-473aa5ca1cef), object, pointer_default(unique)] +interface ICoreWebView2Environment14 : ICoreWebView2Environment13 { + /// Create a `ICoreWebView2FileSystemHandle` object from a path that represents a Web + /// [FileSystemFileHandle](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle). + /// + /// The `path` is the path pointed by the file and must be a syntactically correct fully qualified + /// path, but it is not checked here whether it currently points to a file. If an invalid path is + /// passed, an E_INVALIDARG will be returned and the object will fail to create. Any other state + /// validation will be done when this handle is accessed from web content + /// and will cause the DOM exceptions described in + /// [FileSystemFileHandle methods](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle#instance_methods) + /// if access operations fail. + /// + /// `Permission` property is used to specify whether the Handle should be created with a Read-only or + /// Read-and-write web permission. For the `permission` value specified here, the DOM + /// [PermissionStatus](https://developer.mozilla.org/docs/Web/API/PermissionStatus) property + /// will be [granted](https://developer.mozilla.org/docs/Web/API/PermissionStatus/state) + /// and the unspecified permission will be + /// [prompt](https://developer.mozilla.org/docs/Web/API/PermissionStatus/state). Therefore, + /// the web content then does not need to call + /// [requestPermission](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/requestPermission) + /// for the permission that was specified before attempting the permitted operation, + /// but if it does, the promise will immediately be resolved + /// with 'granted' PermissionStatus without firing the WebView2 + /// [PermissionRequested](/microsoft-edge/webview2/reference/win32/icorewebview2permissionrequestedeventargs) + /// event or prompting the user for permission. Otherwise, `requestPermission` will behave as the + /// status of permission is currently `prompt`, which means the `PermissionRequested` event will fire + /// or the user will be prompted. + /// Additionally, the app must have the same OS permissions that have propagated to the + /// [WebView2 browser process](/microsoft-edge/webview2/concepts/process-model) + /// for the path it wishes to give the web content to read/write the file. + /// Specifically, the WebView2 browser process will run in same user, package identity, and app + /// container of the app, but other means such as security context impersonations do not get + /// propagated, so such permissions that the app has, will not be effective in WebView2. + /// Note: An exception to this is, if there is a parent directory handle that + /// has broader permissions in the same page context than specified in here, the handle will automatically + /// inherit the most permissive permission of the parent handle when posted to that page context. + /// i.e. If there is already a `FileSystemDirectoryHandle` to `C:\example` that has write permission on + /// a page, even though a WebFileSystemHandle to file `C:\example\file.txt` is created with + /// `COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION_READ_ONLY` permission, when posted to that page, write permission + /// will be automatically granted to the created handle. + /// + /// An app needs to be mindful that this object, when posted to the web content, provides it with unusual + /// access to OS file system via the Web FileSystem API! The app should therefore only post objects + /// for paths that it wants to allow access to the web content and it is not recommended that the web content + /// "asks" for this path. The app should also check the source property of the target to ensure + /// that it is sending to the web content of intended origin. + /// + /// Once the object is passed to web content, if the content is attempting a read, + /// the file must be existing and available to read similar to a file chosen by + /// [open file picker](https://developer.mozilla.org/docs/Web/API/Window/showOpenFilePicker), + /// otherwise the read operation will + /// [throw a DOM exception](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle/getFile#exceptions). + /// For write operations, the file does not need to exist as `FileSystemFileHandle` will behave + /// as a file path chosen by + /// [save file picker](https://developer.mozilla.org/docs/Web/API/Window/showSaveFilePicker) + /// and will create or overwrite the file, but the parent directory structure pointed + /// by the file must exist and an existing file must be available to write and delete + /// or the write operation will + /// [throw a DOM exception](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle/createWritable#exceptions). + HRESULT CreateWebFileSystemFileHandle( + [in] LPCWSTR path, + [in] COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION permission + , [out, retval] ICoreWebView2FileSystemHandle** value); + + /// Create a `ICoreWebView2FileSystemHandle` object from a path that represents a Web + /// [FileSystemDirectoryHandle](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle). + /// + /// The `path` is the path pointed by the directory and must be a syntactically correct fully qualified + /// path, but it is not checked here whether it currently points to a directory. Any other state + /// validation will be done when this handle is accessed from web content + /// and will cause DOM exceptions if access operations fail. If an invalid path is + /// passed, an E_INVALIDARG will be returned and the object will fail to create. + /// + /// `Permission` property is used to specify whether the Handle should be created with a Read-only or + /// Read-and-write web permission. For the `permission` value specified here, the Web + /// [PermissionStatus](https://developer.mozilla.org/docs/Web/API/PermissionStatus) + /// will be [granted](https://developer.mozilla.org/docs/Web/API/PermissionStatus/state) + /// and the unspecified permission will be + /// [prompt](https://developer.mozilla.org/docs/Web/API/PermissionStatus/state). Therefore, + /// the web content then does not need to call + /// [requestPermission](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/requestPermission) + /// for the permission that was specified before attempting the permitted operation, + /// but if it does, the promise will immediately be resolved + /// with 'granted' PermissionStatus without firing the WebView2 + /// [PermissionRequested](/microsoft-edge/webview2/reference/win32/icorewebview2permissionrequestedeventargs) + /// event or prompting the user for permission. Otherwise, `requestPermission` will behave as the + /// status of permission is currently `Prompt`, which means the `PermissionRequested` event will fire + /// or the user will be prompted. + /// Additionally, the app must have the same OS permissions that have propagated to the + /// [WebView2 browser process](/microsoft-edge/webview2/concepts/process-model) + /// for the path it wishes to give the web content to make any operations on the directory. + /// Specifically, the WebView2 browser process will run in same user, package identity, and app + /// container of the app, but other means such as security context impersonations do not get + /// propagated, so such permissions that the app has, will not be effective in WebView2. + /// Note: An exception to this is, if there is a parent directory handle that + /// has broader permissions in the same page context than specified in here, the handle will automatically + /// inherit the most permissive permission of the parent handle when posted to that page context. + /// i.e. If there is already a `FileSystemDirectoryHandle` to `C:\example` that has write permission on + /// a page, even though a WebFileSystemHandle to directory `C:\example\directory` is created with + /// `COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION_READ_ONLY` permission, when posted to that page, write permission + /// will be automatically granted to the created handle. + /// + /// An app needs to be mindful that this object, when posted to the web content, provides it with unusual + /// access to OS file system via the Web FileSystem API! The app should therefore only post objects + /// for paths that it wants to allow access to the web content and it is not recommended that the web content + /// "asks" for this path. The app should also check the source property of the target to ensure + /// that it is sending to the web content of intended origin. + /// + /// Once the object is passed to web content, the path must point to a directory as if it was chosen via + /// [directory picker](https://developer.mozilla.org/docs/Web/API/Window/showDirectoryPicker) + /// otherwise any IO operation done on the `FileSystemDirectoryHandle` will throw a DOM exception. + HRESULT CreateWebFileSystemDirectoryHandle( + [in] LPCWSTR path, + [in] COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION permission + , [out, retval] ICoreWebView2FileSystemHandle** value); + + /// Create a generic object collection. + HRESULT CreateObjectCollection( + [in] UINT32 length, + [in, size_is(length)] IUnknown** items, + [out, retval] ICoreWebView2ObjectCollection** objectCollection); + + +} + + + +/// A continuation of the ICoreWebView2Environment interface. +/// +[uuid(41f3632b-5ef4-404f-ad82-2d606c5a9a21), object, pointer_default(unique)] +interface ICoreWebView2Environment2 : ICoreWebView2Environment { + /// Create a new web resource request object. + /// URI parameter must be absolute URI. + /// The headers string is the raw request header string delimited by CRLF + /// (optional in last header). + /// It's also possible to create this object with null headers string + /// and then use the ICoreWebView2HttpRequestHeaders to construct the headers + /// line by line. + /// For information on other parameters see ICoreWebView2WebResourceRequest. + /// + /// \snippet ScenarioNavigateWithWebResourceRequest.cpp NavigateWithWebResourceRequest + /// + HRESULT CreateWebResourceRequest( + [in] LPCWSTR uri, + [in] LPCWSTR Method, + [in] IStream* postData, + [in] LPCWSTR Headers + , [out, retval] ICoreWebView2WebResourceRequest** value); + + +} + + +/// Receives the result of the `CreateCoreWebView2CompositionController` method. +[uuid(02fab84b-1428-4fb7-ad45-1b2e64736184), object, pointer_default(unique)] +interface ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] ICoreWebView2CompositionController* result); +} + + +/// A continuation of the ICoreWebView2Environment2 interface. +/// +[uuid(80a22ae3-be7c-4ce2-afe1-5a50056cdeeb), object, pointer_default(unique)] +interface ICoreWebView2Environment3 : ICoreWebView2Environment2 { + /// Asynchronously create a new WebView for use with visual hosting. + /// + /// parentWindow is the HWND in which the app will connect the visual tree of + /// the WebView. This will be the HWND that the app will receive pointer/ + /// mouse input meant for the WebView (and will need to use SendMouseInput/ + /// SendPointerInput to forward). If the app moves the WebView visual tree to + /// underneath a different window, then it needs to call put_ParentWindow to + /// update the new parent HWND of the visual tree. + /// + /// HWND_MESSAGE is not a valid parameter for `parentWindow` for visual hosting. + /// The underlying implementation of supporting HWND_MESSAGE would break + /// accessibility for visual hosting. This is supported in windowed + /// WebViews - see CreateCoreWebView2Controller. + /// + /// Use put_RootVisualTarget on the created CoreWebView2CompositionController to + /// provide a visual to host the browser's visual tree. + /// + /// It is recommended that the application set Application User Model ID for + /// the process or the application window. If none is set, during WebView + /// creation a generated Application User Model ID is set to root window of + /// parentWindow. + /// \snippet AppWindow.cpp CreateCoreWebView2Controller + /// + /// It is recommended that the application handles restart manager messages + /// so that it can be restarted gracefully in the case when the app is using + /// Edge for WebView from a certain installation and that installation is + /// being uninstalled. For example, if a user installs Edge from Dev channel + /// and opts to use Edge from that channel for testing the app, and then + /// uninstalls Edge from that channel without closing the app, the app will + /// be restarted to allow uninstallation of the dev channel to succeed. + /// \snippet AppWindow.cpp RestartManager + /// + /// The app should retry `CreateCoreWebView2CompositionController` upon failure, + /// unless the error code is `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)`. + /// When the app retries `CreateCoreWebView2CompositionController` + /// upon failure, it is recommended that the app restarts from creating a new + /// WebView2 Environment. If a WebView2 Runtime update happens, the version + /// associated with a WebView2 Environment may have been removed and causing + /// the object to no longer work. Creating a new WebView2 Environment works + /// since it uses the latest version. + /// + /// WebView creation fails with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` if a + /// running instance using the same user data folder exists, and the Environment + /// objects have different `EnvironmentOptions`. For example, if a WebView was + /// created with one language, an attempt to create a WebView with a different + /// language using the same user data folder will fail. + /// + /// The creation will fail with `E_ABORT` if `parentWindow` is destroyed + /// before the creation is finished. If this is caused by a call to + /// `DestroyWindow`, the creation completed handler will be invoked before + /// `DestroyWindow` returns, so you can use this to cancel creation and clean + /// up resources synchronously when quitting a thread. + /// + /// In rare cases the creation can fail with `E_UNEXPECTED` if runtime does not have + /// permissions to the user data folder. + /// + /// CreateCoreWebView2CompositionController is supported in the following versions of Windows: + /// + /// - Windows 11 + /// - Windows 10 + /// - Windows Server 2019 + /// - Windows Server 2016 + /// + /// + HRESULT CreateCoreWebView2CompositionController( + [in] HWND ParentWindow + , [in] ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler* handler); + + /// Create an empty ICoreWebView2PointerInfo. The returned + /// ICoreWebView2PointerInfo needs to be populated with all of the relevant + /// info before calling SendPointerInput. + /// + HRESULT CreateCoreWebView2PointerInfo( + [out, retval] ICoreWebView2PointerInfo** value); + + +} + + + +/// A continuation of the ICoreWebView2Environment3 interface. +/// +[uuid(20944379-6dcf-41d6-a0a0-abc0fc50de0d), object, pointer_default(unique)] +interface ICoreWebView2Environment4 : ICoreWebView2Environment3 { + /// Returns the Automation Provider for the WebView that matches the provided + /// window. Host apps are expected to implement + /// IRawElementProviderHwndOverride. When GetOverrideProviderForHwnd is + /// called, the app can pass the HWND to GetAutomationProviderForWindow to + /// find the matching WebView Automation Provider. + /// + HRESULT GetAutomationProviderForWindow( + [in] HWND hwnd + , [out, retval] IUnknown** value); + + +} + + +/// Receives `BrowserProcessExited` events. +[uuid(fa504257-a216-4911-a860-fe8825712861), object, pointer_default(unique)] +interface ICoreWebView2BrowserProcessExitedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Environment* sender, + [in] ICoreWebView2BrowserProcessExitedEventArgs* args); +} + + +/// A continuation of the `ICoreWebView2Environment4` interface that supports +/// the `BrowserProcessExited` event. +/// +[uuid(319e423d-e0d7-4b8d-9254-ae9475de9b17), object, pointer_default(unique)] +interface ICoreWebView2Environment5 : ICoreWebView2Environment4 { + /// Adds an event handler for the `BrowserProcessExited` event. + /// Add an event handler for the `BrowserProcessExited` event. + /// The `BrowserProcessExited` event is raised when the collection of WebView2 + /// Runtime processes for the browser process of this environment terminate + /// due to browser process failure or normal shutdown (for example, when all + /// associated WebViews are closed), after all resources have been released + /// (including the user data folder). To learn about what these processes are, + /// go to [Process model](/microsoft-edge/webview2/concepts/process-model). + /// + /// A handler added with this method is called until removed with + /// `remove_BrowserProcessExited`, even if a new browser process is bound to + /// this environment after earlier `BrowserProcessExited` events are raised. + /// + /// Multiple app processes can share a browser process by creating their webviews + /// from a `ICoreWebView2Environment` with the same user data folder. When the entire + /// collection of WebView2Runtime processes for the browser process exit, all + /// associated `ICoreWebView2Environment` objects receive the `BrowserProcessExited` + /// event. Multiple processes sharing the same browser process need to coordinate + /// their use of the shared user data folder to avoid race conditions and + /// unnecessary waits. For example, one process should not clear the user data + /// folder at the same time that another process recovers from a crash by recreating + /// its WebView controls; one process should not block waiting for the event if + /// other app processes are using the same browser process (the browser process will + /// not exit until those other processes have closed their webviews too). + /// + /// Note this is an event from the `ICoreWebView2Environment3` interface, not + /// the `ICoreWebView2` one. The difference between `BrowserProcessExited` and + /// `ICoreWebView2`'s `ProcessFailed` is that `BrowserProcessExited` is + /// raised for any **browser process** exit (expected or unexpected, after all + /// associated processes have exited too), while `ProcessFailed` is raised for + /// **unexpected** process exits of any kind (browser, render, GPU, and all + /// other types), or for main frame **render process** unresponsiveness. To + /// learn more about the WebView2 Process Model, go to + /// [Process model](/microsoft-edge/webview2/concepts/process-model). + /// + /// In the case the browser process crashes, both `BrowserProcessExited` and + /// `ProcessFailed` events are raised, but the order is not guaranteed. These + /// events are intended for different scenarios. It is up to the app to + /// coordinate the handlers so they do not try to perform reliability recovery + /// while also trying to move to a new WebView2 Runtime version or remove the + /// user data folder. + /// + /// \snippet AppWindow.cpp Close + /// + HRESULT add_BrowserProcessExited( + [in] ICoreWebView2BrowserProcessExitedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_BrowserProcessExited`. + HRESULT remove_BrowserProcessExited( + [in] EventRegistrationToken token); + + +} + + + +/// This interface is an extension of the ICoreWebView2Environment that supports +/// creating print settings for printing to PDF. +/// +[uuid(e59ee362-acbd-4857-9a8e-d3644d9459a9), object, pointer_default(unique)] +interface ICoreWebView2Environment6 : ICoreWebView2Environment5 { + /// Creates the `ICoreWebView2PrintSettings` used by the `PrintToPdf` + /// method. + /// + HRESULT CreatePrintSettings( + [out, retval] ICoreWebView2PrintSettings** value); + + +} + + + +/// This interface is an extension of the ICoreWebView2Environment. An object +/// implementing the ICoreWebView2Environment7 interface will also +/// implement ICoreWebView2Environment. +/// +[uuid(43c22296-3bbd-43a4-9c00-5c0df6dd29a2), object, pointer_default(unique)] +interface ICoreWebView2Environment7 : ICoreWebView2Environment6 { + /// Returns the user data folder that all CoreWebView2's created from this + /// environment are using. + /// This could be either the value passed in by the developer when creating + /// the environment object or the calculated one for default handling. It + /// will always be an absolute path. + /// + /// \snippet AppWindow.cpp GetUserDataFolder + /// + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT UserDataFolder([out, retval] LPWSTR* value); + + + +} + + +/// Receives `ProcessInfosChanged` events. +[uuid(f4af0c39-44b9-40e9-8b11-0484cfb9e0a1), object, pointer_default(unique)] +interface ICoreWebView2ProcessInfosChangedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Environment* sender, + [in] IUnknown* args); +} + +/// A collection of ICoreWebView2ProcessInfo. +[uuid(402b99cd-a0cc-4fa5-b7a5-51d86a1d2339), object, pointer_default(unique)] +interface ICoreWebView2ProcessInfoCollection : IUnknown { + /// The number of elements contained in the collection. + [propget] HRESULT Count([out, retval] UINT32* value); + + /// Gets the element at the given index. + HRESULT GetValueAtIndex([in] UINT32 index, [out, retval] ICoreWebView2ProcessInfo** value); +} + + +/// A continuation of the `ICoreWebView2Environment7` interface that supports +/// the `ProcessInfosChanged` event. +/// +[uuid(d6eb91dd-c3d2-45e5-bd29-6dc2bc4de9cf), object, pointer_default(unique)] +interface ICoreWebView2Environment8 : ICoreWebView2Environment7 { + /// Adds an event handler for the `ProcessInfosChanged` event. + /// Adds an event handler for the `ProcessInfosChanged` event. + /// + /// \snippet ProcessComponent.cpp ProcessInfosChanged + /// \snippet ProcessComponent.cpp ProcessInfosChanged1 + /// + HRESULT add_ProcessInfosChanged( + [in] ICoreWebView2ProcessInfosChangedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_ProcessInfosChanged`. + HRESULT remove_ProcessInfosChanged( + [in] EventRegistrationToken token); + + + /// Returns the `ICoreWebView2ProcessInfoCollection` + /// Provide a list of all process using same user data folder except for crashpad process. + /// + HRESULT GetProcessInfos( + [out, retval] ICoreWebView2ProcessInfoCollection** value); + + +} + + + +/// A continuation of the ICoreWebView2Environment interface for +/// creating CoreWebView2 ContextMenuItem objects. +/// +[uuid(f06f41bf-4b5a-49d8-b9f6-fa16cd29f274), object, pointer_default(unique)] +interface ICoreWebView2Environment9 : ICoreWebView2Environment8 { + /// Create a custom `ContextMenuItem` object to insert into the WebView context menu. + /// CoreWebView2 will rewind the icon stream before decoding. + /// There is a limit of 1000 active custom context menu items at a given time. + /// Attempting to create more before deleting existing ones will fail with + /// ERROR_NOT_ENOUGH_QUOTA. + /// It is recommended to reuse ContextMenuItems across ContextMenuRequested events + /// for performance. + /// The returned ContextMenuItem object's `IsEnabled` property will default to `TRUE` + /// and `IsChecked` property will default to `FALSE`. A `CommandId` will be assigned + /// to the ContextMenuItem object that's unique across active custom context menu items, + /// but command ID values of deleted ContextMenuItems can be reassigned. + /// + HRESULT CreateContextMenuItem( + [in] LPCWSTR Label, + [in] IStream* iconStream, + [in] COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND Kind + , [out, retval] ICoreWebView2ContextMenuItem** value); + + +} + + + +/// Additional options used to create WebView2 Environment. A default implementation is +/// provided in `WebView2EnvironmentOptions.h`. +/// +/// \snippet AppWindow.cpp CreateCoreWebView2EnvironmentWithOptions +/// +[uuid(ff85c98a-1ba7-4a6b-90c8-2b752c89e9e2), object, pointer_default(unique)] +interface ICoreWebView2EnvironmentOptions2 : IUnknown { + /// Gets the `ExclusiveUserDataFolderAccess` property. + [propget] HRESULT ExclusiveUserDataFolderAccess([out, retval] BOOL* value); + + + /// Whether other processes can create WebView2 from WebView2Environment created with the + /// same user data folder and therefore sharing the same WebView browser process instance. + /// Default is FALSE. + /// + [propput] HRESULT ExclusiveUserDataFolderAccess([in] BOOL value); + + + +} + + + +/// Additional options used to create WebView2 Environment to manage crash +/// reporting. +/// +[uuid(4a5c436e-a9e3-4a2e-89c3-910d3513f5cc), object, pointer_default(unique)] +interface ICoreWebView2EnvironmentOptions3 : IUnknown { + /// Gets the `IsCustomCrashReportingEnabled` property. + [propget] HRESULT IsCustomCrashReportingEnabled([out, retval] BOOL* value); + + + /// When `IsCustomCrashReportingEnabled` is set to `TRUE`, Windows won't send crash data to Microsoft endpoint. + /// `IsCustomCrashReportingEnabled` is default to be `FALSE`, in this case, WebView will respect OS consent. + /// + [propput] HRESULT IsCustomCrashReportingEnabled([in] BOOL value); + + + +} + + + +/// Additional options used to create WebView2 Environment that manages custom scheme registration. +/// +[uuid(ac52d13f-0d38-475a-9dca-876580d6793e), object, pointer_default(unique)] +interface ICoreWebView2EnvironmentOptions4 : IUnknown { + /// Array of custom scheme registrations. The returned + /// ICoreWebView2CustomSchemeRegistration pointers must be released, and the + /// array itself must be deallocated with CoTaskMemFree. + /// + HRESULT GetCustomSchemeRegistrations( + [out] UINT32* count, + [out] ICoreWebView2CustomSchemeRegistration*** schemeRegistrations + ); + + /// Set the array of custom scheme registrations to be used. + /// \snippet AppWindow.cpp CoreWebView2CustomSchemeRegistration + /// + HRESULT SetCustomSchemeRegistrations( + [in] UINT32 count, + [in] ICoreWebView2CustomSchemeRegistration** schemeRegistrations + ); + + +} + + + +/// Additional options used to create WebView2 Environment to manage tracking +/// prevention. +/// +[uuid(0ae35d64-c47f-4464-814e-259c345d1501), object, pointer_default(unique)] +interface ICoreWebView2EnvironmentOptions5 : IUnknown { + /// Gets the `EnableTrackingPrevention` property. + [propget] HRESULT EnableTrackingPrevention([out, retval] BOOL* value); + + + /// The `EnableTrackingPrevention` property is used to enable/disable tracking prevention + /// feature in WebView2. This property enable/disable tracking prevention for all the + /// WebView2's created in the same environment. By default this feature is enabled to block + /// potentially harmful trackers and trackers from sites that aren't visited before and set to + /// `COREWEBVIEW2_TRACKING_PREVENTION_LEVEL_BALANCED` or whatever value was last changed/persisted + /// on the profile. + /// + /// You can set this property to false to disable the tracking prevention feature if the app only + /// renders content in the WebView2 that is known to be safe. Disabling this feature when creating + /// environment also improves runtime performance by skipping related code. + /// + /// You shouldn't disable this property if WebView2 is being used as a "full browser" with arbitrary + /// navigation and should protect end user privacy. + /// + /// There is `ICoreWebView2Profile3::PreferredTrackingPreventionLevel` property to control levels of + /// tracking prevention of the WebView2's associated with a same profile. However, you can also disable + /// tracking prevention later using `ICoreWebView2Profile3::PreferredTrackingPreventionLevel` property and + /// `COREWEBVIEW2_TRACKING_PREVENTION_LEVEL_NONE` value but that doesn't improves runtime performance. + /// + /// See `ICoreWebView2Profile3::PreferredTrackingPreventionLevel` for more details. + /// + /// Tracking prevention protects users from online tracking by restricting the ability of trackers to + /// access browser-based storage as well as the network. See [Tracking prevention](/microsoft-edge/web-platform/tracking-prevention). + /// + [propput] HRESULT EnableTrackingPrevention([in] BOOL value); + + + +} + + + +/// Additional options used to create WebView2 Environment to manage browser extensions. +/// +[uuid(57d29cc3-c84f-42a0-b0e2-effbd5e179de), object, pointer_default(unique)] +interface ICoreWebView2EnvironmentOptions6 : IUnknown { + /// Gets the `AreBrowserExtensionsEnabled` property. + [propget] HRESULT AreBrowserExtensionsEnabled([out, retval] BOOL* value); + + + /// When `AreBrowserExtensionsEnabled` is set to `TRUE`, new extensions can be added to user + /// profile and used. `AreBrowserExtensionsEnabled` is default to be `FALSE`, in this case, + /// new extensions can't be installed, and already installed extension won't be + /// available to use in user profile. + /// If connecting to an already running environment with a different value for `AreBrowserExtensionsEnabled` + /// property, it will fail with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)`. + /// See `ICoreWebView2BrowserExtension` for Extensions API details. + /// + [propput] HRESULT AreBrowserExtensionsEnabled([in] BOOL value); + + + +} + + + +/// Additional options used to create WebView2 Environment. +/// +[uuid(7c7ecf51-e918-5caf-853c-e9a2bcc27775), object, pointer_default(unique)] +interface ICoreWebView2EnvironmentOptions8 : IUnknown { + /// Gets the `ScrollBarStyle` property. + [propget] HRESULT ScrollBarStyle([out, retval] COREWEBVIEW2_SCROLLBAR_STYLE* value); + + + /// The ScrollBar style being set on the WebView2 Environment. + /// The default value is `COREWEBVIEW2_SCROLLBAR_STYLE_DEFAULT` + /// which specifies the default browser ScrollBar style. + /// The `color-scheme` CSS property needs to be set on the corresponding page + /// to allow ScrollBar to follow light or dark theme. Please see + /// [color-scheme](https://developer.mozilla.org/docs/Web/CSS/color-scheme#declaring_color_scheme_preferences) + /// for how `color-scheme` can be set. + /// CSS styles that modify the ScrollBar applied on top of native ScrollBar styling + /// that is selected with `ScrollBarStyle`. + /// + [propput] HRESULT ScrollBarStyle([in] COREWEBVIEW2_SCROLLBAR_STYLE value); + + + +} + + + +/// Additional options used to create the WebView2 Environment that support +/// specifying the `ReleaseChannels` and `ChannelSearchKind`. +/// +[uuid(c48d539f-e39f-441c-ae68-1f66e570bdc5), object, pointer_default(unique)] +interface ICoreWebView2EnvironmentOptions7 : IUnknown { + /// Gets the `ChannelSearchKind` property. + [propget] HRESULT ChannelSearchKind([out, retval] COREWEBVIEW2_CHANNEL_SEARCH_KIND* value); + + + /// The `ChannelSearchKind` property is `COREWEBVIEW2_CHANNEL_SEARCH_KIND_MOST_STABLE` + /// by default; environment creation searches for a release channel on the machine + /// from most to least stable using the first channel found. The default search order is: + /// WebView2 Runtime -> Beta -> Dev -> Canary. Set `ChannelSearchKind` to + /// `COREWEBVIEW2_CHANNEL_SEARCH_KIND_LEAST_STABLE` to reverse the search order + /// so that environment creation searches for a channel from least to most stable. If + /// `ReleaseChannels` has been provided, the loader will only search + /// for channels in the set. See `COREWEBVIEW2_RELEASE_CHANNELS` for more details + /// on channels. + /// + /// This property can be overridden by the corresponding + /// registry key `ChannelSearchKind` or the environment variable + /// `WEBVIEW2_CHANNEL_SEARCH_KIND`. Set the value to `1` to set the search kind to + /// `COREWEBVIEW2_CHANNEL_SEARCH_KIND_LEAST_STABLE`. See + /// `CreateCoreWebView2EnvironmentWithOptions` for more details on overrides. + /// + [propput] HRESULT ChannelSearchKind([in] COREWEBVIEW2_CHANNEL_SEARCH_KIND value); + + + /// Gets the `ReleaseChannels` property. + [propget] HRESULT ReleaseChannels([out, retval] COREWEBVIEW2_RELEASE_CHANNELS* value); + + + /// Sets the `ReleaseChannels`, which is a mask of one or more + /// `COREWEBVIEW2_RELEASE_CHANNELS` indicating which channels environment + /// creation should search for. OR operation(s) can be applied to multiple + /// `COREWEBVIEW2_RELEASE_CHANNELS` to create a mask. The default value is a + /// a mask of all the channels. By default, environment creation searches for + /// channels from most to least stable, using the first channel found on the + /// device. When `ReleaseChannels` is provided, environment creation will only + /// search for the channels specified in the set. Set `ChannelSearchKind` to + /// `COREWEBVIEW2_CHANNEL_SEARCH_KIND_LEAST_STABLE` to reverse the search order + /// so environment creation searches for least stable build first. See + /// `COREWEBVIEW2_RELEASE_CHANNELS` for descriptions of each channel. + /// + /// `CreateCoreWebView2EnvironmentWithOptions` fails with + /// `HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)` if environment creation is unable + /// to find any channel from the `ReleaseChannels` installed on the device. + /// Use `GetAvailableCoreWebView2BrowserVersionStringWithOptions` on + /// `ICoreWebView2Environment` to verify which channel is used when this option + /// is set. + /// + /// Examples: + /// + /// | ReleaseChannels | Channel Search Kind: Most Stable (default) | Channel Search Kind: Least Stable | + /// | --- | --- | --- | + /// |COREWEBVIEW2_RELEASE_CHANNELS_BETA \\| COREWEBVIEW2_RELEASE_CHANNELS_STABLE| WebView2 Runtime -> Beta | Beta -> WebView2 Runtime| + /// |COREWEBVIEW2_RELEASE_CHANNELS_CANARY \\| COREWEBVIEW2_RELEASE_CHANNELS_DEV \\| COREWEBVIEW2_RELEASE_CHANNELS_BETA \\| COREWEBVIEW2_RELEASE_CHANNELS_STABLE| WebView2 Runtime -> Beta -> Dev -> Canary | Canary -> Dev -> Beta -> WebView2 Runtime | + /// |COREWEBVIEW2_RELEASE_CHANNELS_CANARY| Canary | Canary | + /// |COREWEBVIEW2_RELEASE_CHANNELS_BETA \\| COREWEBVIEW2_RELEASE_CHANNELS_CANARY \\| COREWEBVIEW2_RELEASE_CHANNELS_STABLE | WebView2 Runtime -> Beta -> Canary | Canary -> Beta -> WebView2 Runtime | + /// + /// If both `BrowserExecutableFolder` and `ReleaseChannels` are provided, the + /// `BrowserExecutableFolder` takes precedence, regardless of whether or not the + /// channel of `BrowserExecutableFolder` is included in the `ReleaseChannels`. + /// `ReleaseChannels` can be overridden by the corresponding registry override + /// `ReleaseChannels` or the environment variable `WEBVIEW2_RELEASE_CHANNELS`. + /// Set the value to a comma-separated string of integers, which map to the + /// following release channel values: Stable (0), Beta (1), Dev (2), and + /// Canary (3). For example, the values "0,2" and "2,0" indicate that environment + /// creation should only search for Dev channel and the WebView2 Runtime, using the + /// order indicated by `ChannelSearchKind`. Environment creation attempts to + /// interpret each integer and treats any invalid entry as Stable channel. See + /// `CreateCoreWebView2EnvironmentWithOptions` for more details on overrides. + /// + [propput] HRESULT ReleaseChannels([in] COREWEBVIEW2_RELEASE_CHANNELS value); + + + +} + + +/// Receives the result of the `CreateCoreWebView2Environment` method. +[uuid(4e8a3389-c9d8-4bd2-b6b5-124fee6cc14d), object, pointer_default(unique)] +interface ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] ICoreWebView2Environment* result); +} +// Skipping ICoreWebView2CreateCoreWebView2EnvironmentWithOptionsCompletedHandler redefinition + + + +/// Creates an evergreen WebView2 Environment using the installed WebView2 +/// Runtime version. This is equivalent to running +/// `CreateCoreWebView2EnvironmentWithOptions` with `nullptr` for +/// `browserExecutableFolder`, `userDataFolder`, `additionalBrowserArguments`. +/// For more information, navigate to +/// `CreateCoreWebView2EnvironmentWithOptions`. +cpp_quote("STDAPI CreateCoreWebView2Environment(ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler* environmentCreatedHandler);") + +/// DLL export to create a WebView2 environment with a custom version of +/// WebView2 Runtime, user data folder, and with or without additional options. +/// +/// When WebView2 experimental APIs are used, make sure to provide a valid `environmentOptions` +/// so that WebView2 runtime knows which version of the SDK that the app is using. Otherwise, +/// WebView2 runtime assumes that the version of the SDK being used is the latest +/// version known to it, which might not be the version of the SDK being used. +/// This wrong SDK version assumption could result in some experimental APIs not being available. +/// +/// The WebView2 environment and all other WebView2 objects are single threaded +/// and have dependencies on Windows components that require COM to be +/// initialized for a single-threaded apartment. The app is expected to run +/// `CoInitializeEx` before running `CreateCoreWebView2EnvironmentWithOptions`. +/// +/// ```text +/// CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); +/// ``` +/// +/// If `CoInitializeEx` did not run or previously ran with +/// `COINIT_MULTITHREADED`, `CreateCoreWebView2EnvironmentWithOptions` fails +/// with one of the following errors. +/// +/// ```text +/// CO_E_NOTINITIALIZED - if CoInitializeEx was not called +/// RPC_E_CHANGED_MODE - if CoInitializeEx was previously called with +/// COINIT_MULTITHREADED +/// ``` +/// +/// +/// Use `browserExecutableFolder` to specify whether WebView2 controls use a +/// fixed or installed version of the WebView2 Runtime that exists on a user +/// machine. To use a fixed version of the WebView2 Runtime, pass the +/// folder path that contains the fixed version of the WebView2 Runtime to +/// `browserExecutableFolder`. BrowserExecutableFolder supports both relative +/// (to the application's executable) and absolute files paths. +/// To create WebView2 controls that use the +/// installed version of the WebView2 Runtime that exists on user machines, +/// pass a `null` or empty string to `browserExecutableFolder`. In this +/// scenario, the API tries to find a compatible version of the WebView2 +/// Runtime that is installed on the user machine (first at the machine level, +/// and then per user) using the selected channel preference. The path of +/// fixed version of the WebView2 Runtime should not contain +/// `\Edge\Application\`. When such a path is used, the API fails +/// with `HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)`. +/// +/// By default, the channel search order is `COREWEBVIEW2_CHANNEL_SEARCH_KIND_MOST_STABLE`, +/// which means that environment creation searches for an installation in the following order: +/// the WebView2 Runtime, Beta, Dev, and Canary. The channel search order is reversed +/// when the `ChannelSearchKind` property on `ICoreWebView2EnvironmentOptions` is set to +/// `COREWEBVIEW2_CHANNEL_SEARCH_KIND_LEAST_STABLE`, or when the corresponding environment +/// variable or registry override is set to `1`. See below for descriptions of overrides. If +/// `ReleaseChannels` on `ICoreWebView2EnvironmentOptions` is provided, environment creation will +/// only consider channels in this set, following the `ChannelSearchKind` order. +/// +/// You may specify the `userDataFolder` to change the default user data +/// folder location for WebView2. The path is either an absolute file path +/// or a relative file path that is interpreted as relative to the compiled +/// code for the current process. For UWP apps, the default user data +/// folder is the app data folder for the package. For non-UWP apps, the +/// default user data (`{Executable File Name}.WebView2`) folder is +/// created in the same directory next to the compiled code for the app. +/// WebView2 creation fails if the compiled code is running in a directory in +/// which the process does not have permission to create a new directory. The +/// app is responsible to clean up the associated user data folder when it +/// is done. +/// +/// \> [!NOTE]\n\> As a browser process may be shared among WebViews, WebView creation fails +/// with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` if the specified options +/// does not match the options of the WebViews that are currently running in +/// the shared browser process. +/// +/// `environmentCreatedHandler` is the handler result to the async operation +/// that contains the `WebView2Environment` that was created. +/// +/// The `browserExecutableFolder`, `channelSearchKind`, `releaseChannels`, +/// `userDataFolder` and `additionalBrowserArguments` of the `environmentOptions` +/// may be overridden by values either specified in environment variables or in +/// the registry. +/// +/// When creating a `WebView2Environment` the following environment variables +/// are verified. +/// +/// ```text +/// WEBVIEW2_BROWSER_EXECUTABLE_FOLDER +/// WEBVIEW2_USER_DATA_FOLDER +/// WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS +/// WEBVIEW2_CHANNEL_SEARCH_KIND +/// WEBVIEW2_RELEASE_CHANNELS +/// ``` +/// +/// If you find an override environment variable, use the +/// `browserExecutableFolder` and `userDataFolder` values as replacements for +/// the corresponding values in `CreateCoreWebView2EnvironmentWithOptions` +/// parameters. If `additionalBrowserArguments` is specified in environment +/// variable or in the registry, it is appended to the corresponding values in +/// `CreateCoreWebView2EnvironmentWithOptions` parameters. See `ReleaseChannels` +/// on `ICoreWebView2EnvironmentOptions` for more details on how to construct the +/// registry key and environment variable values. +/// +/// While not strictly overrides, additional environment variables may be set. +/// +/// ```text +/// WEBVIEW2_WAIT_FOR_SCRIPT_DEBUGGER +/// ``` +/// +/// When found with a non-empty value, this indicates that the WebView is being +/// launched under a script debugger. In this case, the WebView issues a +/// `Page.waitForDebugger` CDP command that runs the script inside the WebView +/// to pause on launch, until a debugger issues a corresponding +/// `Runtime.runIfWaitingForDebugger` CDP command to resume the runtime. +/// +/// \> [!NOTE]\n\> The following environment variable does not have a registry key +/// equivalent: `WEBVIEW2_WAIT_FOR_SCRIPT_DEBUGGER`. +/// +/// When found with a non-empty value, it indicates that the WebView is being +/// launched under a script debugger that also supports host apps that use +/// multiple WebViews. The value is used as the identifier for a named pipe +/// that is opened and written to when a new WebView is created by the host +/// app. The payload should match the payload of the `remote-debugging-port` +/// JSON target and an external debugger may use it to attach to a specific +/// WebView instance. The format of the pipe created by the debugger should be +/// `\\.\pipe\WebView2\Debugger\{app_name}\{pipe_name}`, where the following +/// are true. +/// +/// * `{app_name}` is the host app exe file name, for example, +/// `WebView2Example.exe` +/// * `{pipe_name}` is the value set for `WEBVIEW2_PIPE_FOR_SCRIPT_DEBUGGER` +/// +/// To enable debugging of the targets identified by the JSON, you must set the +/// `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS` environment variable to send +/// `--remote-debugging-port={port_num}`, where the following is true. +/// +/// * `{port_num}` is the port on which the CDP server binds. +/// +/// \> [!WARNING]\n\> If you set both `WEBVIEW2_PIPE_FOR_SCRIPT_DEBUGGER` and +/// `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS` environment variables, the +/// WebViews hosted in your app and associated contents may exposed to 3rd +/// party apps such as debuggers. +/// +/// \> [!NOTE]\n\> The following environment variable does not have a registry key +/// equivalent: `WEBVIEW2_PIPE_FOR_SCRIPT_DEBUGGER`. +/// +/// If none of those environment variables exist, then the registry is examined +/// next. The following registry values are verified. +/// +/// ```text +/// [{Root}]\Software\Policies\Microsoft\Edge\WebView2\BrowserExecutableFolder +/// "{AppId}"="" +/// +/// [{Root}]\Software\Policies\Microsoft\Edge\WebView2\ChannelSearchKind +/// "{AppId}"="" +/// +/// [{Root}]\Software\Policies\Microsoft\Edge\WebView2\ReleaseChannels +/// "{AppId}"="" +/// +/// [{Root}]\Software\Policies\Microsoft\Edge\WebView2\AdditionalBrowserArguments +/// "{AppId}"="" +/// +/// [{Root}]\Software\Policies\Microsoft\Edge\WebView2\UserDataFolder +/// "{AppId}"="" +/// ``` +/// +/// You can use a group policy under **Administrative Templates** > +/// **Microsoft Edge WebView2** to configure `browserExecutableFolder`, +/// `channelSearchKind`, and `releaseChannels`. +/// +/// In the unlikely scenario where some instances of WebView are open during a +/// browser update, the deletion of the previous WebView2 Runtime may be +/// blocked. To avoid running out of disk space, a new WebView creation fails +/// with `HRESULT_FROM_WIN32(ERROR_DISK_FULL)` if it detects that too many +/// previous WebView2 Runtime versions exist. +/// +/// The default maximum number of WebView2 Runtime versions allowed is `20`. +/// To override the maximum number of the previous WebView2 Runtime versions +/// allowed, set the value of the following environment variable. +/// +/// ```text +/// COREWEBVIEW2_MAX_INSTANCES +/// ``` +/// +/// If the Webview depends upon an installed WebView2 Runtime version and it is +/// uninstalled, any subsequent creation fails with +/// `HRESULT_FROM_WIN32(ERROR_PRODUCT_UNINSTALLED)`. +/// +/// First verify with Root as `HKLM` and then `HKCU`. `AppId` is first set to +/// the Application User Model ID of the process, then if no corresponding +/// registry key, the `AppId` is set to the compiled code name of the process, +/// or if that is not a registry key then `*`. A registry setting with `*` as +/// the value name will apply to all WebView2 apps, and cannot be used for the +/// `userDataFolder` option. If an override registry key is found, use the +/// `browserExecutableFolder` and `userDataFolder` registry values as +/// replacements and append `additionalBrowserArguments` registry values for the +/// corresponding values in `CreateCoreWebView2EnvironmentWithOptions` parameters. +/// +/// The following summarizes the possible error values that can be returned from +/// `CreateCoreWebView2EnvironmentWithOptions` and a description of why these +/// errors occur. +/// +/// Error value | Description +/// ----------------------------------------------- | -------------------------- +/// `CO_E_NOTINITIALIZED` | CoInitializeEx was not called. +/// `RPC_E_CHANGED_MODE` | CoInitializeEx was previously called with COINIT_MULTITHREADED. +/// `HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)` | *\\Edge\\Application* path used in browserExecutableFolder. +/// `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` | Specified options do not match the options of the WebViews that are currently running in the shared browser process. +/// `HRESULT_FROM_WIN32(ERROR_DISK_FULL)` | In the unlikely scenario where some instances of WebView are open during a browser update, the deletion of the previous WebView2 Runtime may be blocked. To avoid running out of disk space, a new WebView creation fails with `HRESULT_FROM_WIN32(ERROR_DISK_FULL)` if it detects that too many previous WebView2 Runtime versions exist. +/// `HRESULT_FROM_WIN32(ERROR_PRODUCT_UNINSTALLED)` | If the Webview depends upon an installed WebView2 Runtime version and it is uninstalled. +/// `HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)` | Could not find Edge installation. +/// `HRESULT_FROM_WIN32(ERROR_FILE_EXISTS)` | User data folder cannot be created because a file with the same name already exists. +/// `E_ACCESSDENIED` | Unable to create user data folder, Access Denied. +/// `E_FAIL` | Edge runtime unable to start. +/// +cpp_quote("STDAPI CreateCoreWebView2EnvironmentWithOptions(PCWSTR browserExecutableFolder, PCWSTR userDataFolder, ICoreWebView2EnvironmentOptions* environmentOptions, ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler* environmentCreatedHandler);") + +/// Get the browser version info including channel name if it is not the +/// WebView2 Runtime. Channel names are Beta, Dev, and Canary. +/// If an override exists for the `browserExecutableFolder` or the channel +/// preference, the override is used. If an override is not specified, then +/// the parameter value passed to +/// `GetAvailableCoreWebView2BrowserVersionString` is used. +/// Returns `HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)` if it fails to find an +/// installed WebView2 runtime or non-stable Microsoft Edge installation. +/// +/// The caller must free the returned string with `CoTaskMemFree`. See +/// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). +cpp_quote("STDAPI GetAvailableCoreWebView2BrowserVersionString(PCWSTR browserExecutableFolder, LPWSTR* versionInfo);") + +/// This method is for anyone want to compare version correctly to determine +/// which version is newer, older or same. Use it to determine whether +/// to use webview2 or certain feature based upon version. Sets the value of +/// result to `-1`, `0` or `1` if `version1` is less than, equal or greater +/// than `version2` respectively. Returns `E_INVALIDARG` if it fails to parse +/// any of the version strings or any input parameter is `null`. Directly use +/// the `versionInfo` obtained from +/// `GetAvailableCoreWebView2BrowserVersionString` with input, channel +/// information is ignored. +cpp_quote("STDAPI CompareBrowserVersions(PCWSTR version1, PCWSTR version2, int* result);") + + + + + +/// This function will tell you the browser version info of the release channel +/// used when creating an environment with the same options. Browser version +/// info includes channel name if it is not the WebView2 Runtime. Channel names +/// are Beta, Dev, and Canary. The format of the return string matches the format of +/// `BrowserVersionString` on `ICoreWebView2Environment`. +/// +/// If an override exists for `browserExecutableFolder`, `releaseChannels`, +/// or `ChannelSearchKind`, the override is used. The presence of an override +/// can result in a different channel used than the one expected based on the +/// environment options object. `browserExecutableFolder` takes precedence over +/// the other options, regardless of whether or not its channel is included in +/// the `releaseChannels`. See `CreateCoreWebView2EnvironmentWithOptions` +/// for more details on overrides. If an override is not specified, then the +/// parameters passed to `GetAvailableCoreWebView2BrowserVersionStringWithOptions` +/// are used. Returns `HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)` if it fails to find +/// an installed WebView2 Runtime or non-stable Microsoft Edge installation. Use +/// `GetAvailableCoreWebView2BrowserVersionString` to get the version info without +/// the environment options. +/// +/// The caller must free the returned string with `CoTaskMemFree`. See +/// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). +cpp_quote("STDAPI GetAvailableCoreWebView2BrowserVersionStringWithOptions(PCWSTR browserExecutableFolder, ICoreWebView2EnvironmentOptions* environmentOptions, LPWSTR* versionInfo);") + + + + + +/// Representation of a DOM +/// [File](https://developer.mozilla.org/docs/Web/API/File) object +/// passed via WebMessage. You can use this object to obtain the path of a +/// File dropped on WebView2. +/// \snippet ScenarioDragDrop.cpp DroppedFilePath +/// +[uuid(f2c19559-6bc1-4583-a757-90021be9afec), object, pointer_default(unique)] +interface ICoreWebView2File : IUnknown { + /// Get the absolute file path. + /// + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Path([out, retval] LPWSTR* value); + + + +} + + + +/// Representation of a DOM +/// [FileSystemHandle](https://developer.mozilla.org/docs/Web/API/FileSystemHandle) +/// object. +[uuid(c65100ac-0de2-5551-a362-23d9bd1d0e1f), object, pointer_default(unique)] +interface ICoreWebView2FileSystemHandle : IUnknown { + /// The kind of the FileSystemHandle. It can either be a file or a directory. + [propget] HRESULT Kind([out, retval] COREWEBVIEW2_FILE_SYSTEM_HANDLE_KIND* value); + + + /// The path to the FileSystemHandle. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Path([out, retval] LPWSTR* value); + + + /// The permissions granted to the FileSystemHandle. + [propget] HRESULT Permission([out, retval] COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION* value); + + + +} + + +/// Receives `PermissionRequested` events. +[uuid(845d0edd-8bd8-429b-9915-4821789f23e9), object, pointer_default(unique)] +interface ICoreWebView2FramePermissionRequestedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2Frame* sender, + [in] ICoreWebView2PermissionRequestedEventArgs2* args); +} + + +/// This is an extension of the ICoreWebView2Frame interface that supports PermissionRequested +/// +[uuid(b50d82cc-cc28-481d-9614-cb048895e6a0), object, pointer_default(unique)] +interface ICoreWebView2Frame3 : ICoreWebView2Frame2 { + /// Adds an event handler for the `PermissionRequested` event. + /// Add an event handler for the `PermissionRequested` event. + /// `PermissionRequested` is raised when content in an iframe any of its + /// descendant iframes requests permission to privileged resources. + /// + /// This relates to the `PermissionRequested` event on the `CoreWebView2`. + /// Both these events will be raised in the case of an iframe requesting + /// permission. The `CoreWebView2Frame`'s event handlers will be invoked + /// before the event handlers on the `CoreWebView2`. If the `Handled` property + /// of the `PermissionRequestedEventArgs` is set to TRUE within the + /// `CoreWebView2Frame` event handler, then the event will not be + /// raised on the `CoreWebView2`, and it's event handlers will not be invoked. + /// + /// In the case of nested iframes, the 'PermissionRequested' event will + /// be raised from the top level iframe. + /// + /// If a deferral is not taken on the event args, the subsequent scripts are + /// blocked until the event handler returns. If a deferral is taken, the + /// scripts are blocked until the deferral is completed. + /// + /// \snippet ScenarioIFrameDevicePermission.cpp PermissionRequested0 + /// \snippet ScenarioIFrameDevicePermission.cpp PermissionRequested1 + /// + HRESULT add_PermissionRequested( + [in] ICoreWebView2FramePermissionRequestedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_PermissionRequested`. + HRESULT remove_PermissionRequested( + [in] EventRegistrationToken token); + + +} + + + +/// This is an extension of the ICoreWebView2Frame interface that supports shared buffer based on file mapping. +/// +[uuid(188782dc-92aa-4732-ab3c-fcc59f6f68b9), object, pointer_default(unique)] +interface ICoreWebView2Frame4 : ICoreWebView2Frame3 { + /// Share a shared buffer object with script of the iframe in the WebView. + /// The script will receive a `sharedbufferreceived` event from chrome.webview. + /// The event arg for that event will have the following methods and properties: + /// `getBuffer()`: return an ArrayBuffer object with the backing content from the shared buffer. + /// `additionalData`: an object as the result of parsing `additionalDataAsJson` as JSON string. + /// This property will be `undefined` if `additionalDataAsJson` is nullptr or empty string. + /// `source`: with a value set as `chrome.webview` object. + /// If a string is provided as `additionalDataAsJson` but it is not a valid JSON string, + /// the API will fail with `E_INVALIDARG`. + /// If `access` is COREWEBVIEW2_SHARED_BUFFER_ACCESS_READ_ONLY, the script will only have read access to the buffer. + /// If the script tries to modify the content in a read only buffer, it will cause an access + /// violation in WebView renderer process and crash the renderer process. + /// If the shared buffer is already closed, the API will fail with `RO_E_CLOSED`. + /// + /// The script code should call `chrome.webview.releaseBuffer` with + /// the shared buffer as the parameter to release underlying resources as soon + /// as it does not need access to the shared buffer any more. + /// + /// The application can post the same shared buffer object to multiple web pages or iframes, or + /// post to the same web page or iframe multiple times. Each `PostSharedBufferToScript` will + /// create a separate ArrayBuffer object with its own view of the memory and is separately + /// released. The underlying shared memory will be released when all the views are released. + /// + /// For example, if we want to send data to script for one time read only consumption. + /// + /// \snippet ScenarioSharedBuffer.cpp OneTimeShareBuffer + /// + /// In the HTML document, + /// + /// \snippet assets\ScenarioSharedBuffer.html ShareBufferScriptCode_1 + /// + /// \snippet assets\ScenarioSharedBuffer.html ShareBufferScriptCode_2 + /// + /// Sharing a buffer to script has security risk. You should only share buffer with trusted site. + /// If a buffer is shared to a untrusted site, possible sensitive information could be leaked. + /// If a buffer is shared as modifiable by the script and the script modifies it in an unexpected way, + /// it could result in corrupted data that might even crash the application. + /// + HRESULT PostSharedBufferToScript( + [in] ICoreWebView2SharedBuffer* sharedBuffer, + [in] COREWEBVIEW2_SHARED_BUFFER_ACCESS access, + [in] LPCWSTR additionalDataAsJson + ); + + +} + + + +/// This is an extension of the ICoreWebView2Frame interface that provides the `FrameId` property. +/// +[uuid(99d199c4-7305-11ee-b962-0242ac120002), object, pointer_default(unique)] +interface ICoreWebView2Frame5 : ICoreWebView2Frame4 { + /// The unique identifier of the current frame. It's the same kind of ID as + /// with the `FrameId` in `CoreWebView2` and via `CoreWebView2FrameInfo`. + /// + [propget] HRESULT FrameId([out, retval] UINT32* value); + + + +} + + + +/// Event args for the `FrameCreated` events. +/// +[uuid(4d6e7b5e-9baa-11eb-a8b3-0242ac130003), object, pointer_default(unique)] +interface ICoreWebView2FrameCreatedEventArgs : IUnknown { + /// The frame which was created. + /// + [propget] HRESULT Frame([out, retval] ICoreWebView2Frame** value); + + + +} + + + +/// Provides a set of properties for a frame in the `ICoreWebView2`. +/// +[uuid(da86b8a1-bdf3-4f11-9955-528cefa59727), object, pointer_default(unique)] +interface ICoreWebView2FrameInfo : IUnknown { + /// The value of iframe's window.name property. The default value equals to + /// iframe html tag declaring it, as in ``. + /// The returned string is empty when the frame has no name attribute and + /// no assigned value for window.name. + /// + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Name([out, retval] LPWSTR* value); + + + /// The URI of the document in the frame. + /// + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Source([out, retval] LPWSTR* value); + + + +} + + + +/// Collection of `FrameInfo`s (name and source). Used to list the affected +/// frames' info when a frame-only render process failure occurs in the +/// `ICoreWebView2`. +/// +[uuid(8f834154-d38e-4d90-affb-6800a7272839), object, pointer_default(unique)] +interface ICoreWebView2FrameInfoCollection : IUnknown { + /// Gets an iterator over the collection of `FrameInfo`s. + /// + HRESULT GetIterator( + [out, retval] ICoreWebView2FrameInfoCollectionIterator** value); + + +} + + + +/// Iterator for a collection of `FrameInfo`s. For more info, see +/// `ICoreWebView2ProcessFailedEventArgs2` and +/// `ICoreWebView2FrameInfoCollection`. +/// +[uuid(1bf89e2d-1b2b-4629-b28f-05099b41bb03), object, pointer_default(unique)] +interface ICoreWebView2FrameInfoCollectionIterator : IUnknown { + /// `TRUE` when the iterator has not run out of `FrameInfo`s. If the + /// collection over which the iterator is iterating is empty or if the + /// iterator has gone past the end of the collection, then this is `FALSE`. + /// + [propget] HRESULT HasCurrent([out, retval] BOOL* value); + + + + /// Get the current `ICoreWebView2FrameInfo` of the iterator. + /// Returns `HRESULT_FROM_WIN32(ERROR_INVALID_INDEX)` if HasCurrent is + /// `FALSE`. + /// + HRESULT GetCurrent( + [out, retval] ICoreWebView2FrameInfo** value); + + /// Move the iterator to the next `FrameInfo` in the collection. + /// + HRESULT MoveNext( + [out, retval] BOOL* value); + + +} + + + +/// HTTP request headers. Used to inspect the HTTP request on +/// `WebResourceRequested` event and `NavigationStarting` event. +/// +/// \> [!NOTE]\n\> It is possible to modify the HTTP request from a `WebResourceRequested` +/// event, but not from a `NavigationStarting` event. +/// +[uuid(e86cac0e-5523-465c-b536-8fb9fc8c8c60), object, pointer_default(unique)] +interface ICoreWebView2HttpRequestHeaders : IUnknown { + /// Gets the header value matching the name. + HRESULT GetHeader( + [in] LPCWSTR name + , [out, retval] LPWSTR* value); + + /// Gets the header value matching the name using an iterator. + /// + HRESULT GetHeaders( + [in] LPCWSTR name + , [out, retval] ICoreWebView2HttpHeadersCollectionIterator** value); + + /// Checks whether the headers contain an entry that matches the header name. + HRESULT Contains( + [in] LPCWSTR name + , [out, retval] BOOL* value); + + /// Adds or updates header that matches the name. + HRESULT SetHeader( + [in] LPCWSTR name, + [in] LPCWSTR value + ); + + /// Removes header that matches the name. + HRESULT RemoveHeader( + [in] LPCWSTR name + ); + + /// Gets an iterator over the collection of request headers. + /// + HRESULT GetIterator( + [out, retval] ICoreWebView2HttpHeadersCollectionIterator** value); + + +} + + + +/// HTTP response headers. Used to construct a `WebResourceResponse` for the +/// `WebResourceRequested` event. +/// +[uuid(03c5ff5a-9b45-4a88-881c-89a9f328619c), object, pointer_default(unique)] +interface ICoreWebView2HttpResponseHeaders : IUnknown { + /// Appends header line with name and value. + /// + HRESULT AppendHeader( + [in] LPCWSTR name, + [in] LPCWSTR value + ); + + /// Verifies that the headers contain entries that match the header name. + /// + HRESULT Contains( + [in] LPCWSTR name + , [out, retval] BOOL* value); + + /// Gets the first header value in the collection matching the name. + /// + HRESULT GetHeader( + [in] LPCWSTR name + , [out, retval] LPWSTR* value); + + /// Gets the header values matching the name. + HRESULT GetHeaders( + [in] LPCWSTR name + , [out, retval] ICoreWebView2HttpHeadersCollectionIterator** value); + + /// Gets an iterator over the collection of entire response headers. + /// + HRESULT GetIterator( + [out, retval] ICoreWebView2HttpHeadersCollectionIterator** value); + + +} + + + +/// This is an interface for the StatusCode property of +/// ICoreWebView2NavigationCompletedEventArgs +/// +[uuid(fdf8b738-ee1e-4db2-a329-8d7d7b74d792), object, pointer_default(unique)] +interface ICoreWebView2NavigationCompletedEventArgs2 : ICoreWebView2NavigationCompletedEventArgs { + /// The HTTP status code of the navigation if it involved an HTTP request. + /// For instance, this will usually be 200 if the request was successful, 404 + /// if a page was not found, etc. See + /// https://developer.mozilla.org/docs/Web/HTTP/Status for a list of + /// common status codes. + /// + /// The `HttpStatusCode` property will be 0 in the following cases: + /// * The navigation did not involve an HTTP request. For instance, if it was + /// a navigation to a file:// URL, or if it was a same-document navigation. + /// * The navigation failed before a response was received. For instance, if + /// the hostname was not found, or if there was a network error. + /// + /// In those cases, you can get more information from the `IsSuccess` and + /// `WebErrorStatus` properties. + /// + /// If the navigation receives a successful HTTP response, but the navigated + /// page calls `window.stop()` before it finishes loading, then + /// `HttpStatusCode` may contain a success code like 200, but `IsSuccess` will + /// be FALSE and `WebErrorStatus` will be + /// `COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_ABORTED`. + /// + /// Since WebView2 handles HTTP continuations and redirects automatically, it + /// is unlikely for `HttpStatusCode` to ever be in the 1xx or 3xx ranges. + /// + [propget] HRESULT HttpStatusCode([out, retval] int* value); + + +} + + + +/// The AdditionalAllowedFrameAncestors API that enable developers to provide additional allowed frame ancestors. +/// +[uuid(9086be93-91aa-472d-a7e0-579f2ba006ad), object, pointer_default(unique)] +interface ICoreWebView2NavigationStartingEventArgs2 : ICoreWebView2NavigationStartingEventArgs { + /// Gets the `AdditionalAllowedFrameAncestors` property. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT AdditionalAllowedFrameAncestors([out, retval] LPWSTR* value); + + + /// Additional allowed frame ancestors set by the host app. + /// + /// The app may set this property to allow a frame to be embedded by additional ancestors besides what is allowed by + /// http header [X-Frame-Options](https://developer.mozilla.org/docs/Web/HTTP/Headers/X-Frame-Options) + /// and [Content-Security-Policy frame-ancestors directive](https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors). + /// If set, a frame ancestor is allowed if it is allowed by the additional allowed frame + /// ancestors or original http header from the site. + /// Whether an ancestor is allowed by the additional allowed frame ancestors is done the same way as if the site provided + /// it as the source list of the Content-Security-Policy frame-ancestors directive. + /// For example, if `https://example.com` and `https://www.example.com` are the origins of the top + /// page and intermediate iframes that embed a nested site-embedding iframe, and you fully trust + /// those origins, you should set this property to `https://example.com https://www.example.com`. + /// This property gives the app the ability to use iframe to embed sites that otherwise + /// could not be embedded in an iframe in trusted app pages. + /// This could potentially subject the embedded sites to [Clickjacking](https://en.wikipedia.org/wiki/Clickjacking) + /// attack from the code running in the embedding web page. Therefore, you should only + /// set this property with origins of fully trusted embedding page and any intermediate iframes. + /// Whenever possible, you should use the list of specific origins of the top and intermediate + /// frames instead of wildcard characters for this property. + /// This API is to provide limited support for app scenarios that used to be supported by + /// `` element in other solutions like JavaScript UWP apps and Electron. + /// You should limit the usage of this property to trusted pages, and specific navigation + /// target url, by checking the `Source` of the WebView2, and `Uri` of the event args. + /// + /// This property is ignored for top level document navigation. + /// + /// \snippet ScriptComponent.cpp AdditionalAllowedFrameAncestors_1 + /// + /// \snippet ScriptComponent.cpp AdditionalAllowedFrameAncestors_2 + /// + [propput] HRESULT AdditionalAllowedFrameAncestors([in] LPCWSTR value); + + + +} + + + +/// The NavigationKind API that enables developers to get more information about +/// navigation type. +/// +[uuid(ddffe494-4942-4bd2-ab73-35b8ff40e19f), object, pointer_default(unique)] +interface ICoreWebView2NavigationStartingEventArgs3 : ICoreWebView2NavigationStartingEventArgs2 { + /// Get the navigation kind of this navigation. + /// + /// + [propget] HRESULT NavigationKind([out, retval] COREWEBVIEW2_NAVIGATION_KIND* value); + + + +} + + + +/// This is a continuation of the `ICoreWebView2NewWindowRequestedEventArgs` interface. +/// +[uuid(bbc7baed-74c6-4c92-b63a-7f5aeae03de3), object, pointer_default(unique)] +interface ICoreWebView2NewWindowRequestedEventArgs2 : ICoreWebView2NewWindowRequestedEventArgs { + /// Gets the name of the new window. This window can be created via `window.open(url, windowName)`, + /// where the windowName parameter corresponds to `Name` property. + /// If no windowName is passed to `window.open`, then the `Name` property + /// will be set to an empty string. Additionally, if window is opened through other means, + /// such as `...` or ``, + /// then the `Name` property will be set accordingly. In the case of target=_blank, + /// the `Name` property will be an empty string. + /// Opening a window via ctrl+clicking a link would result in the `Name` property + /// being set to an empty string. + /// + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Name([out, retval] LPWSTR* value); + + + +} + + + +/// This is a continuation of the `ICoreWebView2NewWindowRequestedEventArgs` interface. +/// +[uuid(842bed3c-6ad6-4dd9-b938-28c96667ad66), object, pointer_default(unique)] +interface ICoreWebView2NewWindowRequestedEventArgs3 : ICoreWebView2NewWindowRequestedEventArgs2 { + /// The frame info of the frame where the new window request originated. The + /// `OriginalSourceFrameInfo` is a snapshot of frame information at the time when the + /// new window was requested. + /// + /// See `ICoreWebView2FrameInfo` for details on frame + /// properties. + /// + [propget] HRESULT OriginalSourceFrameInfo([out, retval] ICoreWebView2FrameInfo** value); + + + +} + + + +/// This is the Interface for non-client region change event args. +/// +[uuid(ab71d500-0820-4a52-809c-48db04ff93bf), object, pointer_default(unique)] +interface ICoreWebView2NonClientRegionChangedEventArgs : IUnknown { + /// This property represents the COREWEBVIEW2_NON_CLIENT_REGION_KIND which the + /// region changed event corresponds to. With this property an app can query + /// for a collection of rects which have that region kind by using + /// QueryNonClientRegion on the composition controller. + /// + [propget] HRESULT RegionKind([out, retval] COREWEBVIEW2_NON_CLIENT_REGION_KIND* value); + + + +} + + + +/// A collection of objects. +[uuid(0f36fd87-4f69-4415-98da-888f89fb9a33), object, pointer_default(unique)] +interface ICoreWebView2ObjectCollectionView : IUnknown { + /// Gets the number of objects contained in the `ContextMenuItemCollection`. + [propget] HRESULT Count([out, retval] UINT32* value); + + + + /// Gets the object at the specified index. + HRESULT GetValueAtIndex( + [in] UINT32 index + , [out, retval] IUnknown** value); + + +} + + + +/// This is a continuation of the `ICoreWebView2PermissionRequestedEventArgs` interface. +/// +[uuid(74d7127f-9de6-4200-8734-42d6fb4ff741), object, pointer_default(unique)] +interface ICoreWebView2PermissionRequestedEventArgs2 : ICoreWebView2PermissionRequestedEventArgs { + /// Gets the `Handled` property. + [propget] HRESULT Handled([out, retval] BOOL* value); + + + /// By default, both the `PermissionRequested` event handlers on the + /// `CoreWebView2Frame` and the `CoreWebView2` will be invoked, with the + /// `CoreWebView2Frame` event handlers invoked first. The host may + /// set this flag to `TRUE` within the `CoreWebView2Frame` event handlers + /// to prevent the remaining `CoreWebView2` event handlers from being invoked. + /// + /// If a deferral is taken on the event args, then you must synchronously + /// set `Handled` to TRUE prior to taking your deferral to prevent the + /// `CoreWebView2`s event handlers from being invoked. + /// + [propput] HRESULT Handled([in] BOOL value); + + + +} + + + +/// This is a continuation of the `ICoreWebView2PermissionRequestedEventArgs2` interface. +[uuid(e61670bc-3dce-4177-86d2-c629ae3cb6ac), object, pointer_default(unique)] +interface ICoreWebView2PermissionRequestedEventArgs3 : ICoreWebView2PermissionRequestedEventArgs2 { + /// Gets the `SavesInProfile` property. + [propget] HRESULT SavesInProfile([out, retval] BOOL* value); + + + /// The permission state set from the `PermissionRequested` event is saved in + /// the profile by default; it persists across sessions and becomes the new + /// default behavior for future `PermissionRequested` events. Browser + /// heuristics can affect whether the event continues to be raised when the + /// state is saved in the profile. Set the `SavesInProfile` property to + /// `FALSE` to not persist the state beyond the current request, and to + /// continue to receive `PermissionRequested` + /// events for this origin and permission kind. + /// + [propput] HRESULT SavesInProfile([in] BOOL value); + + + +} + + + +/// Provides a set of properties for a permission setting. +/// +[uuid(792b6eca-5576-421c-9119-74ebb3a4ffb3), object, pointer_default(unique)] +interface ICoreWebView2PermissionSetting : IUnknown { + /// The kind of the permission setting. See `COREWEBVIEW2_PERMISSION_KIND` for + /// more details. + /// + [propget] HRESULT PermissionKind([out, retval] COREWEBVIEW2_PERMISSION_KIND* value); + + + /// The origin of the permission setting. + /// + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT PermissionOrigin([out, retval] LPWSTR* value); + + + /// The state of the permission setting. + /// + [propget] HRESULT PermissionState([out, retval] COREWEBVIEW2_PERMISSION_STATE* value); + + + +} + + + +/// Event args for the `ProcessFailed` event. +/// +[uuid(8155a9a4-1474-4a86-8cae-151b0fa6b8ca), object, pointer_default(unique)] +interface ICoreWebView2ProcessFailedEventArgs : IUnknown { + /// The kind of process failure that has occurred. This is a combination of + /// process kind (for example, browser, renderer, gpu) and failure (exit, + /// unresponsiveness). Renderer processes are further divided in _main frame_ + /// renderer (`RenderProcessExited`, `RenderProcessUnresponsive`) and + /// _subframe_ renderer (`FrameRenderProcessExited`). To learn about the + /// conditions under which each failure kind occurs, see + /// `COREWEBVIEW2_PROCESS_FAILED_KIND`. + /// + [propget] HRESULT ProcessFailedKind([out, retval] COREWEBVIEW2_PROCESS_FAILED_KIND* value); + + + +} + + + +/// A continuation of the ICoreWebView2ProcessFailedEventArgs2 interface +/// fot getting blocked file for code integrity process failures. +/// +[uuid(ab667428-094d-5fd1-b480-8b4c0fdbdf2f), object, pointer_default(unique)] +interface ICoreWebView2ProcessFailedEventArgs3 : ICoreWebView2ProcessFailedEventArgs2 { + /// This property is the full path of the module that caused the + /// crash in cases of Windows Code Integrity failures. + /// [Windows Code Integrity](/mem/intune/user-help/you-need-to-enable-code-integrity) + /// is a feature that verifies the integrity and + /// authenticity of dynamic-link libraries (DLLs) + /// on Windows systems. It ensures that only trusted + /// code can run on the system and prevents unauthorized or + /// malicious modifications. + /// When ProcessFailed occurred due to a failed Code Integrity check, + /// this property returns the full path of the file that was prevented from + /// loading on the system. + /// The webview2 process which tried to load the DLL will fail with + /// exit code STATUS_INVALID_IMAGE_HASH(-1073740760). + /// A file can fail integrity check for various + /// reasons, such as: + /// - It has an invalid or missing signature that does + /// not match the publisher or signer of the file. + /// - It has been tampered with or corrupted by malware or other software. + /// - It has been blocked by an administrator or a security policy. + /// This property always will be the empty string if failure is not caused by + /// STATUS_INVALID_IMAGE_HASH. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT FailureSourceModulePath([out, retval] LPWSTR* value); + + + +} + + +/// Receives the result of the `ClearBrowsingData` method. +[uuid(e9710a06-1d1d-49b2-8234-226f35846ae5), object, pointer_default(unique)] +interface ICoreWebView2ClearBrowsingDataCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode); +} +// Skipping ICoreWebView2ClearBrowsingDataCompletedHandler redefinition + +// Skipping ICoreWebView2ClearBrowsingDataCompletedHandler redefinition + + + +/// Profile2 interface. +/// +/// +[uuid(fa740d4b-5eae-4344-a8ad-74be31925397), object, pointer_default(unique)] +interface ICoreWebView2Profile2 : ICoreWebView2Profile { + /// Clear browsing data based on a data type. This method takes two parameters, + /// the first being a mask of one or more `COREWEBVIEW2_BROWSING_DATA_KINDS`. OR + /// operation(s) can be applied to multiple `COREWEBVIEW2_BROWSING_DATA_KINDS` to + /// create a mask representing those data types. The browsing data kinds that are + /// supported are listed below. These data kinds follow a hierarchical structure in + /// which nested bullet points are included in their parent bullet point's data kind. + /// Ex: All DOM storage is encompassed in all site data which is encompassed in + /// all profile data. + /// * All Profile + /// * All Site Data + /// * All DOM Storage: File Systems, Indexed DB, Local Storage, Web SQL, Cache + /// Storage + /// * Cookies + /// * Disk Cache + /// * Download History + /// * General Autofill + /// * Password Autosave + /// * Browsing History + /// * Settings + /// The completed handler will be invoked when the browsing data has been cleared and + /// will indicate if the specified data was properly cleared. In the case in which + /// the operation is interrupted and the corresponding data is not fully cleared + /// the handler will return `E_ABORT` and otherwise will return `S_OK`. + /// Because this is an asynchronous operation, code that is dependent on the cleared + /// data must be placed in the callback of this operation. + /// If the WebView object is closed before the clear browsing data operation + /// has completed, the handler will be released, but not invoked. In this case + /// the clear browsing data operation may or may not be completed. + /// ClearBrowsingData clears the `dataKinds` regardless of timestamp. + /// + HRESULT ClearBrowsingData( + [in] COREWEBVIEW2_BROWSING_DATA_KINDS dataKinds + , [in] ICoreWebView2ClearBrowsingDataCompletedHandler* handler); + /// ClearBrowsingDataInTimeRange behaves like ClearBrowsingData except that it + /// takes in two additional parameters for the start and end time for which it + /// should clear the data between. The `startTime` and `endTime` + /// parameters correspond to the number of seconds since the UNIX epoch. + /// `startTime` is inclusive while `endTime` is exclusive, therefore the data will + /// be cleared between [startTime, endTime). + /// + HRESULT ClearBrowsingDataInTimeRange( + [in] COREWEBVIEW2_BROWSING_DATA_KINDS dataKinds, + [in] double startTime, + [in] double endTime + , [in] ICoreWebView2ClearBrowsingDataCompletedHandler* handler); + /// ClearBrowsingDataAll behaves like ClearBrowsingData except that it + /// clears the entirety of the data associated with the profile it is called on. + /// It clears the data regardless of timestamp. + /// + /// \snippet AppWindow.cpp ClearBrowsingData + /// + HRESULT ClearBrowsingDataAll( + [in] ICoreWebView2ClearBrowsingDataCompletedHandler* handler); + + +} + + + +/// This is an extension of the ICoreWebView2Profile interface to control levels of tracking prevention. +/// +[uuid(b188e659-5685-4e05-bdba-fc640e0f1992), object, pointer_default(unique)] +interface ICoreWebView2Profile3 : ICoreWebView2Profile2 { + /// Gets the `PreferredTrackingPreventionLevel` property. + [propget] HRESULT PreferredTrackingPreventionLevel([out, retval] COREWEBVIEW2_TRACKING_PREVENTION_LEVEL* value); + + + /// The `PreferredTrackingPreventionLevel` property allows you to control levels of tracking prevention for WebView2 + /// which are associated with a profile. This level would apply to the context of the profile. That is, all WebView2s + /// sharing the same profile will be affected and also the value is persisted in the user data folder. + /// + /// See `COREWEBVIEW2_TRACKING_PREVENTION_LEVEL` for descriptions of levels. + /// + /// If tracking prevention feature is enabled when creating the WebView2 environment, you can also disable tracking + /// prevention later using this property and `COREWEBVIEW2_TRACKING_PREVENTION_LEVEL_NONE` value but that doesn't + /// improves runtime performance. + /// + /// There is `ICoreWebView2EnvironmentOptions5::EnableTrackingPrevention` property to enable/disable tracking prevention feature + /// for all the WebView2's created in the same environment. If enabled, `PreferredTrackingPreventionLevel` is set to + /// `COREWEBVIEW2_TRACKING_PREVENTION_LEVEL_BALANCED` by default for all the WebView2's and profiles created in the same + /// environment or is set to the level whatever value was last changed/persisted to the profile. If disabled + /// `PreferredTrackingPreventionLevel` is not respected by WebView2. If `PreferredTrackingPreventionLevel` is set when the + /// feature is disabled, the property value get changed and persisted but it will takes effect only if + /// `ICoreWebView2EnvironmentOptions5::EnableTrackingPrevention` is true. + /// + /// See `ICoreWebView2EnvironmentOptions5::EnableTrackingPrevention` for more details. + /// \snippet SettingsComponent.cpp SetTrackingPreventionLevel + /// + [propput] HRESULT PreferredTrackingPreventionLevel([in] COREWEBVIEW2_TRACKING_PREVENTION_LEVEL value); + + + +} + + +/// Receives the result of the `SetPermissionState` method. +[uuid(fc77fb30-9c9e-4076-b8c7-7644a703ca1b), object, pointer_default(unique)] +interface ICoreWebView2SetPermissionStateCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode); +} +/// Receives the result of the `GetNonDefaultPermissionSettings` method. +[uuid(38274481-a15c-4563-94cf-990edc9aeb95), object, pointer_default(unique)] +interface ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] ICoreWebView2PermissionSettingCollectionView* result); +} + + +/// This is the ICoreWebView2Profile interface for the permission management APIs. +/// +[uuid(8f4ae680-192e-4ec8-833a-21cfadaef628), object, pointer_default(unique)] +interface ICoreWebView2Profile4 : ICoreWebView2Profile3 { + /// Sets permission state for the given permission kind and origin + /// asynchronously. The change persists across sessions until it is changed by + /// another call to `SetPermissionState`, or by setting the `State` property + /// in `PermissionRequestedEventArgs`. Setting the state to + /// `COREWEBVIEW2_PERMISSION_STATE_DEFAULT` will erase any state saved in the + /// profile and restore the default behavior. + /// The origin should have a valid scheme and host (e.g. "https://www.example.com"), + /// otherwise the method fails with `E_INVALIDARG`. Additional URI parts like + /// path and fragment are ignored. For example, "https://wwww.example.com/app1/index.html/" + /// is treated the same as "https://wwww.example.com". See the + /// [MDN origin definition](https://developer.mozilla.org/docs/Glossary/Origin) + /// for more details. + /// + /// \snippet ScenarioPermissionManagement.cpp SetPermissionState + /// + HRESULT SetPermissionState( + [in] COREWEBVIEW2_PERMISSION_KIND PermissionKind, + [in] LPCWSTR origin, + [in] COREWEBVIEW2_PERMISSION_STATE State + , [in] ICoreWebView2SetPermissionStateCompletedHandler* handler); + + /// Invokes the handler with a collection of all nondefault permission settings. + /// Use this method to get the permission state set in the current and previous + /// sessions. + /// + /// \snippet ScenarioPermissionManagement.cpp GetNonDefaultPermissionSettings + /// + HRESULT GetNonDefaultPermissionSettings( + [in] ICoreWebView2GetNonDefaultPermissionSettingsCompletedHandler* handler); + + +} + + + +/// This is the ICoreWebView2Profile interface for cookie manager. +/// +[uuid(2ee5b76e-6e80-4df2-bcd3-d4ec3340a01b), object, pointer_default(unique)] +interface ICoreWebView2Profile5 : ICoreWebView2Profile4 { + /// Get the cookie manager for the profile. All CoreWebView2s associated with this + /// profile share the same cookie values. Changes to cookies in this cookie manager apply to all + /// CoreWebView2s associated with this profile. + /// See ICoreWebView2CookieManager. + /// + /// \snippet ScenarioCookieManagement.cpp CookieManagerProfile + /// + [propget] HRESULT CookieManager([out, retval] ICoreWebView2CookieManager** value); + + + +} + + +/// Receives the result of the `AddBrowserExtension` method. +[uuid(df1aab27-82b9-4ab6-aae8-017a49398c14), object, pointer_default(unique)] +interface ICoreWebView2ProfileAddBrowserExtensionCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] ICoreWebView2BrowserExtension* result); +} +/// Receives the result of the `GetBrowserExtensions` method. +[uuid(fce16a1c-f107-4601-8b75-fc4940ae25d0), object, pointer_default(unique)] +interface ICoreWebView2ProfileGetBrowserExtensionsCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] ICoreWebView2BrowserExtensionList* result); +} + +/// A collection of ICoreWebView2BrowserExtension. +[uuid(2ef3d2dc-bd5f-4f4d-90af-fd67798f0c2f), object, pointer_default(unique)] +interface ICoreWebView2BrowserExtensionList : IUnknown { + /// The number of elements contained in the collection. + [propget] HRESULT Count([out, retval] UINT32* value); + + /// Gets the element at the given index. + HRESULT GetValueAtIndex([in] UINT32 index, [out, retval] ICoreWebView2BrowserExtension** value); +} + + +/// Interfaces in profile for managing browser extensions. +/// +[uuid(7b4c7906-a1aa-4cb4-b723-db09f813d541), object, pointer_default(unique)] +interface ICoreWebView2Profile7 : ICoreWebView2Profile6 { + /// Adds the [browser extension](https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions) + /// using the extension path for unpacked extensions from the local device. Extension is + /// running right after installation. + /// The extension folder path is the topmost folder of an unpacked browser extension and + /// contains the browser extension manifest file. + /// If the `extensionFolderPath` is an invalid path or doesn't contain the extension manifest.json + /// file, this function will return `ERROR_FILE_NOT_FOUND` to callers. + /// Installed extension will default `IsEnabled` to true. + /// When `AreBrowserExtensionsEnabled` is `FALSE`, `AddBrowserExtension` will fail and return + /// HRESULT `ERROR_NOT_SUPPORTED`. + /// During installation, the content of the extension is not copied to the user data folder. + /// Once the extension is installed, changing the content of the extension will cause the + /// extension to be removed from the installed profile. + /// When an extension is added the extension is persisted in the corresponding profile. The + /// extension will still be installed the next time you use this profile. + /// When an extension is installed from a folder path, adding the same extension from the same + /// folder path means reinstalling this extension. When two extensions with the same Id are + /// installed, only the later installed extension will be kept. + /// + /// Extensions that are designed to include any UI interactions (e.g. icon, badge, pop up, etc.) + /// can be loaded and used but will have missing UI entry points due to the lack of browser + /// UI elements to host these entry points in WebView2. + /// + /// The following summarizes the possible error values that can be returned from + /// `AddBrowserExtension` and a description of why these errors occur. + /// + /// Error value | Description + /// ----------------------------------------------- | -------------------------- + /// `HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)` | Extensions are disabled. + /// `HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)` | Cannot find `manifest.json` file or it is not a valid extension manifest. + /// `E_ACCESSDENIED` | Cannot load extension with file or directory name starting with \"_\", reserved for use by the system. + /// `E_FAIL` | Extension failed to install with other unknown reasons. + /// + HRESULT AddBrowserExtension( + [in] LPCWSTR extensionFolderPath + , [in] ICoreWebView2ProfileAddBrowserExtensionCompletedHandler* handler); + + /// Gets a snapshot of the set of extensions installed at the time `GetBrowserExtensions` is + /// called. If an extension is installed or uninstalled after `GetBrowserExtensions` completes, + /// the list returned by `GetBrowserExtensions` remains the same. + /// When `AreBrowserExtensionsEnabled` is `FALSE`, `GetBrowserExtensions` won't return any + /// extensions on current user profile. + /// + HRESULT GetBrowserExtensions( + [in] ICoreWebView2ProfileGetBrowserExtensionsCompletedHandler* handler); + + +} + + + +/// A continuation of the ICoreWebView2Settings interface that manages the user agent. +/// +[uuid(ee9a0f68-f46c-4e32-ac23-ef8cac224d2a), object, pointer_default(unique)] +interface ICoreWebView2Settings2 : ICoreWebView2Settings { + /// Gets the `UserAgent` property. + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT UserAgent([out, retval] LPWSTR* value); + + + /// This setting determines the UserAgent of WebView. This property may be overridden if + /// the User-Agent header is set in a request. If the parameter is empty + /// the User Agent will not be updated and the current User Agent will remain. + /// Setting this property may clear User Agent Client Hints headers + /// Sec-CH-UA-* and script values from navigator.userAgentData. Current + /// implementation behavior is subject to change. + /// The User Agent set will also be effective on service workers + /// and shared workers associated with the WebView. If there are + /// multiple WebViews associated with the same service worker or + /// shared worker, the last User Agent set will be used. + /// + /// \snippet SettingsComponent.cpp UserAgent + /// + [propput] HRESULT UserAgent([in] LPCWSTR value); + + + +} + + + +/// A continuation of the ICoreWebView2Settings interface that manages whether +/// browser accelerator keys are enabled. +/// +[uuid(fdb5ab74-af33-4854-84f0-0a631deb5eba), object, pointer_default(unique)] +interface ICoreWebView2Settings3 : ICoreWebView2Settings2 { + /// Gets the `AreBrowserAcceleratorKeysEnabled` property. + [propget] HRESULT AreBrowserAcceleratorKeysEnabled([out, retval] BOOL* value); + + + /// When this setting is set to FALSE, it disables all accelerator keys that + /// access features specific to a web browser, including but not limited to: + /// - Ctrl-F and F3 for Find on Page + /// - Ctrl-P for Print + /// - Ctrl-R and F5 for Reload + /// - Ctrl-Plus and Ctrl-Minus for zooming + /// - Ctrl-Shift-C and F12 for DevTools + /// - Special keys for browser functions, such as Back, Forward, and Search + /// + /// It does not disable accelerator keys related to movement and text editing, + /// such as: + /// - Home, End, Page Up, and Page Down + /// - Ctrl-X, Ctrl-C, Ctrl-V + /// - Ctrl-A for Select All + /// - Ctrl-Z for Undo + /// + /// Those accelerator keys will always be enabled unless they are handled in + /// the `AcceleratorKeyPressed` event. + /// + /// This setting has no effect on the `AcceleratorKeyPressed` event. The event + /// will be fired for all accelerator keys, whether they are enabled or not. + /// + /// The default value for `AreBrowserAcceleratorKeysEnabled` is TRUE. + /// + /// \snippet SettingsComponent.cpp AreBrowserAcceleratorKeysEnabled + /// + [propput] HRESULT AreBrowserAcceleratorKeysEnabled([in] BOOL value); + + + +} + + + +/// A continuation of the ICoreWebView2Settings interface to manage pinch zoom. +/// +[uuid(183e7052-1d03-43a0-ab99-98e043b66b39), object, pointer_default(unique)] +interface ICoreWebView2Settings5 : ICoreWebView2Settings4 { + /// Gets the `IsPinchZoomEnabled` property. + [propget] HRESULT IsPinchZoomEnabled([out, retval] BOOL* value); + + + /// Pinch-zoom, referred to as "Page Scale" zoom, is performed as a post-rendering step, + /// it changes the page scale factor property and scales the surface the web page is + /// rendered onto when user performs a pinch zooming action. It does not change the layout + /// but rather changes the viewport and clips the web content, the content outside of the + /// viewport isn't visible onscreen and users can't reach this content using mouse. + /// + /// The `IsPinchZoomEnabled` property enables or disables the ability of + /// the end user to use a pinching motion on touch input enabled devices + /// to scale the web content in the WebView2. It defaults to `TRUE`. + /// When set to `FALSE`, the end user cannot pinch zoom after the next navigation. + /// Disabling/Enabling `IsPinchZoomEnabled` only affects the end user's ability to use + /// pinch motions and does not change the page scale factor. + /// This API only affects the Page Scale zoom and has no effect on the + /// existing browser zoom properties (`IsZoomControlEnabled` and `ZoomFactor`) + /// or other end user mechanisms for zooming. + /// + /// \snippet SettingsComponent.cpp TogglePinchZoomEnabled + /// + [propput] HRESULT IsPinchZoomEnabled([in] BOOL value); + + + +} + + + +/// A continuation of the ICoreWebView2Settings interface to manage swipe navigation. +/// +[uuid(11cb3acd-9bc8-43b8-83bf-f40753714f87), object, pointer_default(unique)] +interface ICoreWebView2Settings6 : ICoreWebView2Settings5 { + /// Gets the `IsSwipeNavigationEnabled` property. + [propget] HRESULT IsSwipeNavigationEnabled([out, retval] BOOL* value); + + + /// The `IsSwipeNavigationEnabled` property enables or disables the ability of the + /// end user to use swiping gesture on touch input enabled devices to + /// navigate in WebView2. It defaults to `TRUE`. + /// + /// When this property is `TRUE`, then all configured navigation gestures are enabled: + /// 1. Swiping left and right to navigate forward and backward is always configured. + /// 2. Swiping down to refresh is off by default and not exposed via our API currently, + /// it requires the "--pull-to-refresh" option to be included in the additional browser + /// arguments to be configured. (See put_AdditionalBrowserArguments.) + /// + /// When set to `FALSE`, the end user cannot swipe to navigate or pull to refresh. + /// This API only affects the overscrolling navigation functionality and has no + /// effect on the scrolling interaction used to explore the web content shown + /// in WebView2. + /// + /// Disabling/Enabling IsSwipeNavigationEnabled takes effect after the + /// next navigation. + /// + /// \snippet SettingsComponent.cpp ToggleSwipeNavigationEnabled + /// + [propput] HRESULT IsSwipeNavigationEnabled([in] BOOL value); + + + +} + + + +/// A continuation of the ICoreWebView2Settings interface to hide Pdf toolbar items. +/// +[uuid(488dc902-35ef-42d2-bc7d-94b65c4bc49c), object, pointer_default(unique)] +interface ICoreWebView2Settings7 : ICoreWebView2Settings6 { + /// Gets the `HiddenPdfToolbarItems` property. + [propget] HRESULT HiddenPdfToolbarItems([out, retval] COREWEBVIEW2_PDF_TOOLBAR_ITEMS* value); + + + /// `HiddenPdfToolbarItems` is used to customize the PDF toolbar items. By default, it is COREWEBVIEW2_PDF_TOOLBAR_ITEMS_NONE and so it displays all of the items. + /// Changes to this property apply to all CoreWebView2s in the same environment and using the same profile. + /// Changes to this setting apply only after the next navigation. + /// \snippet SettingsComponent.cpp ToggleHidePdfToolbarItems + /// + [propput] HRESULT HiddenPdfToolbarItems([in] COREWEBVIEW2_PDF_TOOLBAR_ITEMS value); + + + +} + + + +/// A continuation of the ICoreWebView2Settings interface to manage smartscreen. +/// +[uuid(9e6b0e8f-86ad-4e81-8147-a9b5edb68650), object, pointer_default(unique)] +interface ICoreWebView2Settings8 : ICoreWebView2Settings7 { + /// Gets the `IsReputationCheckingRequired` property. + [propget] HRESULT IsReputationCheckingRequired([out, retval] BOOL* value); + + + /// SmartScreen helps webviews identify reported phishing and malware websites + /// and also helps users make informed decisions about downloads. + /// `IsReputationCheckingRequired` is used to control whether SmartScreen + /// enabled or not. SmartScreen is enabled or disabled for all CoreWebView2s + /// using the same user data folder. If + /// CoreWebView2Setting.IsReputationCheckingRequired is true for any + /// CoreWebView2 using the same user data folder, then SmartScreen is enabled. + /// If CoreWebView2Setting.IsReputationCheckingRequired is false for all + /// CoreWebView2 using the same user data folder, then SmartScreen is + /// disabled. When it is changed, the change will be applied to all WebViews + /// using the same user data folder on the next navigation or download. The + /// default value for `IsReputationCheckingRequired` is true. If the newly + /// created CoreWebview2 does not set SmartScreen to false, when + /// navigating(Such as Navigate(), LoadDataUrl(), ExecuteScript(), etc.), the + /// default value will be applied to all CoreWebview2 using the same user data + /// folder. + /// SmartScreen of WebView2 apps can be controlled by Windows system setting + /// "SmartScreen for Microsoft Edge", specially, for WebView2 in Windows + /// Store apps, SmartScreen is controlled by another Windows system setting + /// "SmartScreen for Microsoft Store apps". When the Windows setting is enabled, the + /// SmartScreen operates under the control of the `IsReputationCheckingRequired`. + /// When the Windows setting is disabled, the SmartScreen will be disabled + /// regardless of the `IsReputationCheckingRequired` value set in WebView2 apps. + /// In other words, under this circumstance the value of + /// `IsReputationCheckingRequired` will be saved but overridden by system setting. + /// Upon re-enabling the Windows setting, the CoreWebview2 will reference the + /// `IsReputationCheckingRequired` to determine the SmartScreen status. + /// \snippet SettingsComponent.cpp ToggleSmartScreen + /// + [propput] HRESULT IsReputationCheckingRequired([in] BOOL value); + + + +} + + + +/// This is the ICoreWebView2Settings Experimental Interface. +/// +[uuid(0528a73b-e92d-49f4-927a-e547dddaa37d), object, pointer_default(unique)] +interface ICoreWebView2Settings9 : ICoreWebView2Settings8 { + /// Gets the `IsNonClientRegionSupportEnabled` property. + [propget] HRESULT IsNonClientRegionSupportEnabled([out, retval] BOOL* value); + + + /// The `IsNonClientRegionSupportEnabled` property enables web pages to use the + /// `app-region` CSS style. Disabling/Enabling the `IsNonClientRegionSupportEnabled` + /// takes effect after the next navigation. Defaults to `FALSE`. + /// + /// When this property is `TRUE`, then all the non-client region features + /// will be enabled: + /// Draggable Regions will be enabled, they are regions on a webpage that + /// are marked with the CSS attribute `app-region: drag/no-drag`. When set to + /// `drag`, these regions will be treated like the window's title bar, supporting + /// dragging of the entire WebView and its host app window; the system menu shows + /// upon right click, and a double click will trigger maximizing/restoration of the + /// window size. + /// + /// When set to `FALSE`, all non-client region support will be disabled. + /// The `app-region` CSS style will be ignored on web pages. + /// \snippet SettingsComponent.cpp ToggleNonClientRegionSupportEnabled + /// + [propput] HRESULT IsNonClientRegionSupportEnabled([in] BOOL value); + + + +} + + + +/// Event args for the `SourceChanged` event. +/// +[uuid(31e0e545-1dba-4266-8914-f63848a1f7d7), object, pointer_default(unique)] +interface ICoreWebView2SourceChangedEventArgs : IUnknown { + /// `TRUE` if the page being navigated to is a new document. + /// + [propget] HRESULT IsNewDocument([out, retval] BOOL* value); + + + +} + + + +/// Event args for the `WebMessageReceived` event. +/// +[uuid(0f99a40c-e962-4207-9e92-e3d542eff849), object, pointer_default(unique)] +interface ICoreWebView2WebMessageReceivedEventArgs : IUnknown { + /// The URI of the document that sent this web message. + /// + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT Source([out, retval] LPWSTR* value); + + + /// The message posted from the WebView content to the host converted to a + /// JSON string. Run this operation to communicate using JavaScript objects. + /// + /// For example, the following `postMessage` runs result in the following + /// `WebMessageAsJson` values. + /// + /// ```json + /// postMessage({'a': 'b'}) L"{\"a\": \"b\"}" + /// postMessage(1.2) L"1.2" + /// postMessage('example') L"\"example\"" + /// ``` + /// + /// + /// The caller must free the returned string with `CoTaskMemFree`. See + /// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings). + [propget] HRESULT WebMessageAsJson([out, retval] LPWSTR* value); + + + + /// If the message posted from the WebView content to the host is a string + /// type, this method returns the value of that string. If the message + /// posted is some other kind of JavaScript type this method fails with the + /// following error. + /// + /// ```text + /// E_INVALIDARG + /// ``` + /// + /// Run this operation to communicate using simple strings. + /// + /// For example, the following `postMessage` runs result in the following + /// `WebMessageAsString` values. + /// + /// ```json + /// postMessage({'a': 'b'}) E_INVALIDARG + /// postMessage(1.2) E_INVALIDARG + /// postMessage('example') L"example" + /// ``` + /// + HRESULT TryGetWebMessageAsString( + [out, retval] LPWSTR* value); + + +} + + + +/// Extension of WebMessageReceivedEventArgs to provide access to additional +/// WebMessage objects. +/// +[uuid(06fc7ab7-c90c-4297-9389-33ca01cf6d5e), object, pointer_default(unique)] +interface ICoreWebView2WebMessageReceivedEventArgs2 : ICoreWebView2WebMessageReceivedEventArgs { + /// Additional received WebMessage objects. To pass `additionalObjects` via + /// WebMessage to the app, use the + /// `chrome.webview.postMessageWithAdditionalObjects` content API. + /// Any DOM object type that can be natively representable that has been + /// passed in to `additionalObjects` parameter will be accessible here. + /// Currently a WebMessage object can be the `ICoreWebView2File` type. + /// Entries in the collection can be `nullptr` if `null` or `undefined` was + /// passed. + /// + [propget] HRESULT AdditionalObjects([out, retval] ICoreWebView2ObjectCollectionView** value); + + + +} + + + +/// Event args for the `WebResourceRequested` event. +[uuid(9c562c24-b219-4d7f-92f6-b187fbbadd56), object, pointer_default(unique)] +interface ICoreWebView2WebResourceRequestedEventArgs2 : ICoreWebView2WebResourceRequestedEventArgs { + /// The web resource requested source. + [propget] HRESULT RequestedSourceKind([out, retval] COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS* value); + + + +} + + + +/// Event args for the WebResourceResponseReceived event. +/// +[uuid(d1db483d-6796-4b8b-80fc-13712bb716f4), object, pointer_default(unique)] +interface ICoreWebView2WebResourceResponseReceivedEventArgs : IUnknown { + /// The request object for the web resource, as committed. This includes + /// headers added by the network stack that were not be included during the + /// associated WebResourceRequested event, such as Authentication headers. + /// Modifications to this object have no effect on how the request is + /// processed as it has already been sent. + /// + [propget] HRESULT Request([out, retval] ICoreWebView2WebResourceRequest** value); + + + /// View of the response object received for the web resource. + [propget] HRESULT Response([out, retval] ICoreWebView2WebResourceResponseView** value); + + + +} + + +/// Receives `BasicAuthenticationRequested` events. +[uuid(58b4d6c2-18d4-497e-b39b-9a96533fa278), object, pointer_default(unique)] +interface ICoreWebView2BasicAuthenticationRequestedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2BasicAuthenticationRequestedEventArgs* args); +} + + +/// This interface is an extension of `ICoreWebView2_9` that supports +/// BasicAuthenticationRequested event. +/// +[uuid(b1690564-6f5a-4983-8e48-31d1143fecdb), object, pointer_default(unique)] +interface ICoreWebView2_10 : ICoreWebView2_9 { + /// Adds an event handler for the `BasicAuthenticationRequested` event. + /// Add an event handler for the BasicAuthenticationRequested event. + /// BasicAuthenticationRequested event is raised when WebView encounters a + /// Basic HTTP Authentication request as described in + /// https://developer.mozilla.org/docs/Web/HTTP/Authentication, a Digest + /// HTTP Authentication request as described in + /// https://developer.mozilla.org/docs/Web/HTTP/Headers/Authorization#digest, + /// an NTLM authentication or a Proxy Authentication request. + /// + /// The host can provide a response with credentials for the authentication or + /// cancel the request. If the host sets the Cancel property to false but does not + /// provide either UserName or Password properties on the Response property, then + /// WebView2 will show the default authentication challenge dialog prompt to + /// the user. + /// + /// \snippet ScenarioAuthentication.cpp BasicAuthenticationRequested + /// + HRESULT add_BasicAuthenticationRequested( + [in] ICoreWebView2BasicAuthenticationRequestedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_BasicAuthenticationRequested`. + HRESULT remove_BasicAuthenticationRequested( + [in] EventRegistrationToken token); + + +} + + + +/// This interface is an extension of `ICoreWebView2_12` that supports Profile +/// API. +/// +[uuid(f75f09a8-667e-4983-88d6-c8773f315e84), object, pointer_default(unique)] +interface ICoreWebView2_13 : ICoreWebView2_12 { + /// The associated `ICoreWebView2Profile` object. If this CoreWebView2 was created with a + /// CoreWebView2ControllerOptions, the CoreWebView2Profile will match those specified options. + /// Otherwise if this CoreWebView2 was created without a CoreWebView2ControllerOptions, then + /// this will be the default CoreWebView2Profile for the corresponding CoreWebView2Environment. + /// + /// \snippet AppWindow.cpp CoreWebView2Profile + /// + [propget] HRESULT Profile([out, retval] ICoreWebView2Profile** value); + + + +} + + +/// Receives the result of the `ClearServerCertificateErrorActions` method. +[uuid(3b40aac6-acfe-4ffd-8211-f607b96e2d5b), object, pointer_default(unique)] +interface ICoreWebView2ClearServerCertificateErrorActionsCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode); +} + +/// Receives `ServerCertificateErrorDetected` events. +[uuid(969b3a26-d85e-4795-8199-fef57344da22), object, pointer_default(unique)] +interface ICoreWebView2ServerCertificateErrorDetectedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2ServerCertificateErrorDetectedEventArgs* args); +} + + +/// This interface is an extension of `ICoreWebView2_13` that adds +/// ServerCertificate support. +/// +[uuid(6daa4f10-4a90-4753-8898-77c5df534165), object, pointer_default(unique)] +interface ICoreWebView2_14 : ICoreWebView2_13 { + /// Adds an event handler for the `ServerCertificateErrorDetected` event. + /// Add an event handler for the ServerCertificateErrorDetected event. + /// The ServerCertificateErrorDetected event is raised when the WebView2 + /// cannot verify server's digital certificate while loading a web page. + /// + /// This event will raise for all web resources and follows the `WebResourceRequested` event. + /// + /// If you don't handle the event, WebView2 will show the default TLS interstitial error page to the user + /// for navigations, and for non-navigations the web request is cancelled. + /// + /// Note that WebView2 before raising `ServerCertificateErrorDetected` raises a `NavigationCompleted` event + /// with `IsSuccess` as FALSE and any of the below WebErrorStatuses that indicate a certificate failure. + /// + /// - COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_COMMON_NAME_IS_INCORRECT + /// - COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_EXPIRED + /// - COREWEBVIEW2_WEB_ERROR_STATUS_CLIENT_CERTIFICATE_CONTAINS_ERRORS + /// - COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_REVOKED + /// - COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_IS_INVALID + /// + /// For more details see `ICoreWebView2NavigationCompletedEventArgs::get_IsSuccess` and handle + /// ServerCertificateErrorDetected event or show the default TLS interstitial error page to the user + /// according to the app needs. + /// + /// WebView2 caches the response when action is `COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION_ALWAYS_ALLOW` + /// for the RequestUri's host and the server certificate in the session and the `ServerCertificateErrorDetected` + /// event won't be raised again. + /// + /// To raise the event again you must clear the cache using `ClearServerCertificateErrorActions`. + /// + /// \snippet SettingsComponent.cpp ServerCertificateErrorDetected1 + /// + HRESULT add_ServerCertificateErrorDetected( + [in] ICoreWebView2ServerCertificateErrorDetectedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_ServerCertificateErrorDetected`. + HRESULT remove_ServerCertificateErrorDetected( + [in] EventRegistrationToken token); + + + /// Clears all cached decisions to proceed with TLS certificate errors from the + /// ServerCertificateErrorDetected event for all WebView2's sharing the same session. + /// + HRESULT ClearServerCertificateErrorActions( + [in] ICoreWebView2ClearServerCertificateErrorActionsCompletedHandler* handler); + + +} + + + +/// This interface is an extension of `ICoreWebView2_16` that supports shared buffer based on file mapping. +/// +[uuid(702e75d4-fd44-434d-9d70-1a68a6b1192a), object, pointer_default(unique)] +interface ICoreWebView2_17 : ICoreWebView2_16 { + /// Share a shared buffer object with script of the main frame in the WebView. + /// The script will receive a `sharedbufferreceived` event from chrome.webview. + /// The event arg for that event will have the following methods and properties: + /// `getBuffer()`: return an ArrayBuffer object with the backing content from the shared buffer. + /// `additionalData`: an object as the result of parsing `additionalDataAsJson` as JSON string. + /// This property will be `undefined` if `additionalDataAsJson` is nullptr or empty string. + /// `source`: with a value set as `chrome.webview` object. + /// If a string is provided as `additionalDataAsJson` but it is not a valid JSON string, + /// the API will fail with `E_INVALIDARG`. + /// If `access` is COREWEBVIEW2_SHARED_BUFFER_ACCESS_READ_ONLY, the script will only have read access to the buffer. + /// If the script tries to modify the content in a read only buffer, it will cause an access + /// violation in WebView renderer process and crash the renderer process. + /// If the shared buffer is already closed, the API will fail with `RO_E_CLOSED`. + /// + /// The script code should call `chrome.webview.releaseBuffer` with + /// the shared buffer as the parameter to release underlying resources as soon + /// as it does not need access to the shared buffer any more. + /// + /// The application can post the same shared buffer object to multiple web pages or iframes, or + /// post to the same web page or iframe multiple times. Each `PostSharedBufferToScript` will + /// create a separate ArrayBuffer object with its own view of the memory and is separately + /// released. The underlying shared memory will be released when all the views are released. + /// + /// For example, if we want to send data to script for one time read only consumption. + /// + /// \snippet ScenarioSharedBuffer.cpp OneTimeShareBuffer + /// + /// In the HTML document, + /// + /// \snippet assets\ScenarioSharedBuffer.html ShareBufferScriptCode_1 + /// + /// \snippet assets\ScenarioSharedBuffer.html ShareBufferScriptCode_2 + /// + /// Sharing a buffer to script has security risk. You should only share buffer with trusted site. + /// If a buffer is shared to a untrusted site, possible sensitive information could be leaked. + /// If a buffer is shared as modifiable by the script and the script modifies it in an unexpected way, + /// it could result in corrupted data that might even crash the application. + /// + /// + HRESULT PostSharedBufferToScript( + [in] ICoreWebView2SharedBuffer* sharedBuffer, + [in] COREWEBVIEW2_SHARED_BUFFER_ACCESS access, + [in] LPCWSTR additionalDataAsJson + ); + + +} + + +/// Receives `LaunchingExternalUriScheme` events. +[uuid(74f712e0-8165-43a9-a13f-0cce597e75df), object, pointer_default(unique)] +interface ICoreWebView2LaunchingExternalUriSchemeEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2LaunchingExternalUriSchemeEventArgs* args); +} + + +/// This interface is an extension of `ICoreWebView2_17` that manages +/// navigation requests to URI schemes registered with the OS. +/// +[uuid(7a626017-28be-49b2-b865-3ba2b3522d90), object, pointer_default(unique)] +interface ICoreWebView2_18 : ICoreWebView2_17 { + /// Adds an event handler for the `LaunchingExternalUriScheme` event. + /// Add an event handler for the `LaunchingExternalUriScheme` event. + /// The `LaunchingExternalUriScheme` event is raised when a navigation request is made to + /// a URI scheme that is registered with the OS. + /// The `LaunchingExternalUriScheme` event handler may suppress the default dialog + /// or replace the default dialog with a custom dialog. + /// + /// If a deferral is not taken on the event args, the external URI scheme launch is + /// blocked until the event handler returns. If a deferral is taken, the + /// external URI scheme launch is blocked until the deferral is completed. + /// The host also has the option to cancel the URI scheme launch. + /// + /// The `NavigationStarting` and `NavigationCompleted` events will be raised, + /// regardless of whether the `Cancel` property is set to `TRUE` or + /// `FALSE`. The `NavigationCompleted` event will be raised with the `IsSuccess` property + /// set to `FALSE` and the `WebErrorStatus` property set to `ConnectionAborted` regardless of + /// whether the host sets the `Cancel` property on the + /// `ICoreWebView2LaunchingExternalUriSchemeEventArgs`. The `SourceChanged`, `ContentLoading`, + /// and `HistoryChanged` events will not be raised for this navigation to the external URI + /// scheme regardless of the `Cancel` property. + /// The `LaunchingExternalUriScheme` event will be raised after the + /// `NavigationStarting` event and before the `NavigationCompleted` event. + /// The default `CoreWebView2Settings` will also be updated upon navigation to an external + /// URI scheme. If a setting on the `CoreWebView2Settings` interface has been changed, + /// navigating to an external URI scheme will trigger the `CoreWebView2Settings` to update. + /// + /// The WebView2 may not display the default dialog based on user settings, browser settings, + /// and whether the origin is determined as a + /// [trustworthy origin](https://w3c.github.io/webappsec-secure-contexts# + /// potentially-trustworthy-origin); however, the event will still be raised. + /// + /// If the request is initiated by a cross-origin frame without a user gesture, + /// the request will be blocked and the `LaunchingExternalUriScheme` event will not + /// be raised. + /// \snippet SettingsComponent.cpp ToggleLaunchingExternalUriScheme + /// + HRESULT add_LaunchingExternalUriScheme( + [in] ICoreWebView2LaunchingExternalUriSchemeEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_LaunchingExternalUriScheme`. + HRESULT remove_LaunchingExternalUriScheme( + [in] EventRegistrationToken token); + + +} + + + +/// This interface is an extension of `ICoreWebView2_18` that manages memory usage +/// target level. +/// +[uuid(6921f954-79b0-437f-a997-c85811897c68), object, pointer_default(unique)] +interface ICoreWebView2_19 : ICoreWebView2_18 { + /// Gets the `MemoryUsageTargetLevel` property. + [propget] HRESULT MemoryUsageTargetLevel([out, retval] COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL* value); + + + /// An app may set `MemoryUsageTargetLevel` to indicate desired memory + /// consumption level of WebView. Scripts will not be impacted and continue + /// to run. This is useful for inactive apps that still want to run scripts + /// and/or keep network connections alive and therefore could not call + /// `TrySuspend` and `Resume` to reduce memory consumption. These apps can + /// set memory usage target level to `COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL_LOW` + /// when the app becomes inactive, and set back to + /// `COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL_NORMAL` when the app becomes + /// active. It is not necessary to set CoreWebView2Controller's IsVisible + /// property to false when setting the property. + /// It is a best effort operation to change memory usage level, and the + /// API will return before the operation completes. + /// Setting the level to `COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL_LOW` + /// could potentially cause memory for some WebView browser processes to be + /// swapped out to disk in some circumstances. + /// It is a best effort to reduce memory usage as much as possible. If a script + /// runs after its related memory has been swapped out, the memory will be swapped + /// back in to ensure the script can still run, but performance might be impacted. + /// Therefore, the app should set the level back to + /// `COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL_NORMAL` when the app becomes + /// active again. Setting memory usage target level back to normal will not happen + /// automatically. + /// An app should choose to use either the combination of `TrySuspend` and `Resume` + /// or the combination of setting MemoryUsageTargetLevel to low and normal. It is + /// not advisable to mix them. + /// Trying to set `MemoryUsageTargetLevel` while suspended will be ignored. + /// The `TrySuspend` and `Resume` methods will change the `MemoryUsageTargetLevel`. + /// `TrySuspend` will automatically set `MemoryUsageTargetLevel` to low while + /// `Resume` on suspended WebView will automatically set `MemoryUsageTargetLevel` + /// to normal. Calling `Resume` when the WebView is not suspended would not change + /// `MemoryUsageTargetLevel`. + /// + /// \snippet ViewComponent.cpp MemoryUsageTargetLevel + /// + [propput] HRESULT MemoryUsageTargetLevel([in] COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL value); + + + +} + + + +/// This interface is an extension of `ICoreWebView2_19` that provides the `FrameId` property. +/// +[uuid(b4bc1926-7305-11ee-b962-0242ac120002), object, pointer_default(unique)] +interface ICoreWebView2_20 : ICoreWebView2_19 { + /// The unique identifier of the main frame. It's the same kind of ID as + /// with the `FrameId` in `CoreWebView2Frame` and via `CoreWebView2FrameInfo`. + /// Note that `FrameId` may not be valid if `CoreWebView2` has not done + /// any navigation. It's safe to get this value during or after the first + /// `ContentLoading` event. Otherwise, it could return the invalid frame Id 0. + /// + [propget] HRESULT FrameId([out, retval] UINT32* value); + + + +} + + +/// Receives the result of the `ExecuteScriptWithResult` method. +[uuid(1bb5317b-8238-4c67-a7ff-baf6558f289d), object, pointer_default(unique)] +interface ICoreWebView2ExecuteScriptWithResultCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] ICoreWebView2ExecuteScriptResult* result); +} + + +/// This is the interface for getting string and exception with ExecuteScriptWithResult. +/// +[uuid(c4980dea-587b-43b9-8143-3ef3bf552d95), object, pointer_default(unique)] +interface ICoreWebView2_21 : ICoreWebView2_20 { + /// Run JavaScript code from the JavaScript parameter in the current + /// top-level document rendered in the WebView. + /// The result of the execution is returned asynchronously in the CoreWebView2ExecuteScriptResult object + /// which has methods and properties to obtain the successful result of script execution as well as any + /// unhandled JavaScript exceptions. + /// If this method is + /// run after the NavigationStarting event during a navigation, the script + /// runs in the new document when loading it, around the time + /// ContentLoading is run. This operation executes the script even if + /// ICoreWebView2Settings::IsScriptEnabled is set to FALSE. + /// + /// \snippet ScriptComponent.cpp ExecuteScriptWithResult + /// + HRESULT ExecuteScriptWithResult( + [in] LPCWSTR javaScript + , [in] ICoreWebView2ExecuteScriptWithResultCompletedHandler* handler); + + +} + + + +/// This interface is an extension of `ICoreWebView2` that allows to +/// set filters in order to receive WebResourceRequested events for +/// service workers, shared workers and different origin iframes. +/// +[uuid(db75dfc7-a857-4632-a398-6969dde26c0a), object, pointer_default(unique)] +interface ICoreWebView2_22 : ICoreWebView2_21 { + /// A web resource request with a resource context that matches this + /// filter's resource context and a URI that matches this filter's URI + /// wildcard string for corresponding request sources will be raised via + /// the `WebResourceRequested` event. To receive all raised events filters + /// have to be added before main page navigation. + /// + /// The `uri` parameter value is a wildcard string matched against the URI + /// of the web resource request. This is a glob style + /// wildcard string in which a `*` matches zero or more characters and a `?` + /// matches exactly one character. + /// These wildcard characters can be escaped using a backslash just before + /// the wildcard character in order to represent the literal `*` or `?`. + /// + /// The matching occurs over the URI as a whole string and not limiting + /// wildcard matches to particular parts of the URI. + /// The wildcard filter is compared to the URI after the URI has been + /// normalized, any URI fragment has been removed, and non-ASCII hostnames + /// have been converted to punycode. + /// + /// Specifying a `nullptr` for the uri is equivalent to an empty string which + /// matches no URIs. + /// + /// For more information about resource context filters, navigate to + /// [COREWEBVIEW2_WEB_RESOURCE_CONTEXT](/microsoft-edge/webview2/reference/win32/icorewebview2#corewebview2_web_resource_context). + /// + /// The `requestSourceKinds` is a mask of one or more + /// `COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS`. OR operation(s) can be + /// applied to multiple `COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS` to + /// create a mask representing those data types. API returns `E_INVALIDARG` if + /// `requestSourceKinds` equals to zero. For more information about request + /// source kinds, navigate to + /// [COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS](/microsoft-edge/webview2/reference/win32/icorewebview2#corewebview2_web_resource_request_source_kinds). + /// + /// Because service workers and shared workers run separately from any one + /// HTML document their WebResourceRequested will be raised for all + /// CoreWebView2s that have appropriate filters added in the corresponding + /// CoreWebView2Environment. You should only add a WebResourceRequested filter + /// for COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_SERVICE_WORKER or + /// COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_SHARED_WORKER on + /// one CoreWebView2 to avoid handling the same WebResourceRequested + /// event multiple times. + /// + /// | URI Filter String | Request URI | Match | Notes | + /// | ---- | ---- | ---- | ---- | + /// | `*` | `https://contoso.com/a/b/c` | Yes | A single * will match all URIs | + /// | `*://contoso.com/*` | `https://contoso.com/a/b/c` | Yes | Matches everything in contoso.com across all schemes | + /// | `*://contoso.com/*` | `https://example.com/?https://contoso.com/` | Yes | But also matches a URI with just the same text anywhere in the URI | + /// | `example` | `https://contoso.com/example` | No | The filter does not perform partial matches | + /// | `*example` | `https://contoso.com/example` | Yes | The filter matches across URI parts | + /// | `*example` | `https://contoso.com/path/?example` | Yes | The filter matches across URI parts | + /// | `*example` | `https://contoso.com/path/?query#example` | No | The filter is matched against the URI with no fragment | + /// | `*example` | `https://example` | No | The URI is normalized before filter matching so the actual URI used for comparison is `https://example/` | + /// | `*example/` | `https://example` | Yes | Just like above, but this time the filter ends with a / just like the normalized URI | + /// | `https://xn--qei.example/` | `https://❤.example/` | Yes | Non-ASCII hostnames are normalized to punycode before wildcard comparison | + /// | `https://❤.example/` | `https://xn--qei.example/` | No | Non-ASCII hostnames are normalized to punycode before wildcard comparison | + /// + /// \snippet ScenarioSharedWorkerWRR.cpp WebResourceRequested2 + /// + HRESULT AddWebResourceRequestedFilterWithRequestSourceKinds( + [in] LPCWSTR uri, + [in] COREWEBVIEW2_WEB_RESOURCE_CONTEXT ResourceContext, + [in] COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS requestSourceKinds + ); + + /// Removes a matching WebResource filter that was previously added for the + /// `WebResourceRequested` event. If the same filter was added multiple + /// times, then it must be removed as many times as it was added for the + /// removal to be effective. Returns `E_INVALIDARG` for a filter that was + /// not added or is already removed. + /// If the filter was added for multiple requestSourceKinds and removed just for one of them + /// the filter remains for the non-removed requestSourceKinds. + /// + HRESULT RemoveWebResourceRequestedFilterWithRequestSourceKinds( + [in] LPCWSTR uri, + [in] COREWEBVIEW2_WEB_RESOURCE_CONTEXT ResourceContext, + [in] COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS requestSourceKinds + ); + + +} + + +/// Receives the result of the `ShowSaveAsUI` method. +[uuid(e24b07e3-8169-5c34-994a-7f6478946a3c), object, pointer_default(unique)] +interface ICoreWebView2ShowSaveAsUICompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] COREWEBVIEW2_SAVE_AS_UI_RESULT result); +} + +/// Receives `SaveAsUIShowing` events. +[uuid(6baa177e-3a2e-5ccf-9a13-fad676cd0522), object, pointer_default(unique)] +interface ICoreWebView2SaveAsUIShowingEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2SaveAsUIShowingEventArgs* args); +} + + +/// This is the ICoreWebView2_25 interface. +/// +[uuid(b5a86092-df50-5b4f-a17b-6c8f8b40b771), object, pointer_default(unique)] +interface ICoreWebView2_25 : ICoreWebView2_24 { + /// Adds an event handler for the `SaveAsUIShowing` event. + /// This event is raised when save as is triggered, programmatically or manually. + /// + /// \snippet ScenarioSaveAs.cpp ToggleSilent + /// + HRESULT add_SaveAsUIShowing( + [in] ICoreWebView2SaveAsUIShowingEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_SaveAsUIShowing`. + HRESULT remove_SaveAsUIShowing( + [in] EventRegistrationToken token); + + + /// Programmatically trigger a Save As action for the currently loaded document. + /// The `SaveAsUIShowing` event is raised. + /// + /// Opens a system modal dialog by default. If the `SuppressDefaultDialog` property + /// is `TRUE`, the system dialog is not opened. + /// + /// This method returns `COREWEBVIEW2_SAVE_AS_UI_RESULT`. See + /// `COREWEBVIEW2_SAVE_AS_UI_RESULT` for details. + /// + /// \snippet ScenarioSaveAs.cpp ProgrammaticSaveAs + /// + HRESULT ShowSaveAsUI( + [in] ICoreWebView2ShowSaveAsUICompletedHandler* handler); + + +} + + + +/// This is the ICoreWebView_23 interface for +/// PostWebMessageAsJsonWithAdditionalObjects. +/// +[uuid(508f0db5-90c4-5872-90a7-267a91377502), object, pointer_default(unique)] +interface ICoreWebView2_23 : ICoreWebView2_22 { + /// Same as `PostWebMessageAsJson`, but also has support for posting DOM objects + /// to page content. The `additionalObjects` property in the DOM MessageEvent + /// fired on the page content is an array-like list of DOM objects that can + /// be posted to the web content. Currently these can be the following + /// types of objects: + /// + /// | Win32 | DOM type | + /// |-------------------|-------------| + /// | ICoreWebView2FileSystemHandle | [FileSystemHandle](https://developer.mozilla.org/docs/Web/API/FileSystemHandle) | + /// | nullptr | null | + /// + /// The objects are posted to the web content, following the + /// [structured-clone](https://developer.mozilla.org/docs/Web/API/Web_Workers_API/Structured_clone_algorithm) + /// semantics, meaning only objects that can be cloned can be posted. + /// They will also behave as if they had been created by the web content they are + /// posted to. For example, if a FileSystemFileHandle is posted to a web content + /// it can only be re-transferred via postMessage to other web content + /// [with the same origin](https://fs.spec.whatwg.org/#filesystemhandle). + /// Warning: An app needs to be mindful when using this API to post DOM objects + /// as this API provides the web content with unusual access to sensitive Web + /// Platform features such as filesystem access! Similar to PostWebMessageAsJson + /// the app should check the `Source` property of WebView2 right before posting the message + /// to ensure the message and objects will only be sent to the target web content + /// that it expects to receive the DOM objects. Additionally, the order + /// of messages that are posted between `PostWebMessageAsJson` and `PostWebMessageAsJsonWithAdditionalObjects` + /// may not be preserved. + /// \snippet ScenarioFileSystemHandleShare.cpp PostWebMessageWithAdditionalObjects + HRESULT PostWebMessageAsJsonWithAdditionalObjects( + [in] LPCWSTR webMessageAsJson, + [in] ICoreWebView2ObjectCollectionView* additionalObjects + ); + + +} + + +/// Receives `NotificationReceived` events. +[uuid(89c5d598-8788-423b-be97-e6e01c0f9ee3), object, pointer_default(unique)] +interface ICoreWebView2NotificationReceivedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2NotificationReceivedEventArgs* args); +} + + +/// This is the ICoreWebView2_24 interface that manages WebView2 Web +/// Notification functionality. +/// +[uuid(39a7ad55-4287-5cc1-88a1-c6f458593824), object, pointer_default(unique)] +interface ICoreWebView2_24 : ICoreWebView2_23 { + /// Adds an event handler for the `NotificationReceived` event. + /// Add an event handler for the `NotificationReceived` event for + /// non-persistent notifications. + /// + /// If a deferral is not taken on the event args, the subsequent scripts after + /// the DOM notification creation call (i.e. `Notification()`) are blocked + /// until the event handler returns. If a deferral is taken, the scripts are + /// blocked until the deferral is completed. + /// + HRESULT add_NotificationReceived( + [in] ICoreWebView2NotificationReceivedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_NotificationReceived`. + HRESULT remove_NotificationReceived( + [in] EventRegistrationToken token); + + +} + + +/// Receives `ClientCertificateRequested` events. +[uuid(d7175ba2-bcc3-11eb-8529-0242ac130003), object, pointer_default(unique)] +interface ICoreWebView2ClientCertificateRequestedEventHandler : IUnknown { + /// Provides the event args for the corresponding event. + HRESULT Invoke( + [in] ICoreWebView2* sender, + [in] ICoreWebView2ClientCertificateRequestedEventArgs* args); +} + + +/// A continuation of the ICoreWebView2_4 interface to support ClientCertificateRequested +/// event. +/// +[uuid(bedb11b8-d63c-11eb-b8bc-0242ac130003), object, pointer_default(unique)] +interface ICoreWebView2_5 : ICoreWebView2_4 { + /// Adds an event handler for the `ClientCertificateRequested` event. + /// Add an event handler for the ClientCertificateRequested event. + /// The ClientCertificateRequested event is raised when the WebView2 + /// is making a request to an HTTP server that needs a client certificate + /// for HTTP authentication. + /// Read more about HTTP client certificates at + /// [RFC 8446 The Transport Layer Security (TLS) Protocol Version 1.3](https://tools.ietf.org/html/rfc8446). + /// + /// With this event you have several options for responding to client certificate requests: + /// + /// Scenario | Handled | Cancel | SelectedCertificate + /// ---------------------------------------------------------- | ------- | ------ | ------------------- + /// Respond to server with a certificate | True | False | MutuallyTrustedCertificate value + /// Respond to server without certificate | True | False | null + /// Display default client certificate selection dialog prompt | False | False | n/a + /// Cancel the request | n/a | True | n/a + /// + /// If you don't handle the event, WebView2 will + /// show the default client certificate selection dialog prompt to user. + /// + /// \snippet SettingsComponent.cpp ClientCertificateRequested1 + /// \snippet ScenarioClientCertificateRequested.cpp ClientCertificateRequested2 + /// + HRESULT add_ClientCertificateRequested( + [in] ICoreWebView2ClientCertificateRequestedEventHandler* eventHandler, + [out] EventRegistrationToken* token); + + /// Removes an event handler previously added with `add_ClientCertificateRequested`. + HRESULT remove_ClientCertificateRequested( + [in] EventRegistrationToken token); + + +} + + + +/// This interface is an extension of `ICoreWebView2_5` that manages opening +/// the browser task manager window. +/// +[uuid(499aadac-d92c-4589-8a75-111bfc167795), object, pointer_default(unique)] +interface ICoreWebView2_6 : ICoreWebView2_5 { + /// Opens the Browser Task Manager view as a new window in the foreground. + /// If the Browser Task Manager is already open, this will bring it into + /// the foreground. WebView2 currently blocks the Shift+Esc shortcut for + /// opening the task manager. An end user can open the browser task manager + /// manually via the `Browser task manager` entry of the DevTools window's + /// title bar's context menu. + /// + HRESULT OpenTaskManagerWindow( + ); + + +} + + +/// Receives the result of the `PrintToPdf` method. +[uuid(ccf1ef04-fd8e-4d5f-b2de-0983e41b8c36), object, pointer_default(unique)] +interface ICoreWebView2PrintToPdfCompletedHandler : IUnknown { + + /// Provides the result of the corresponding asynchronous method. + HRESULT Invoke([in] HRESULT errorCode, [in] BOOL result); +} + + +/// This interface is an extension of `ICoreWebView2_6` that supports printing +/// to PDF. +/// +[uuid(79c24d83-09a3-45ae-9418-487f32a58740), object, pointer_default(unique)] +interface ICoreWebView2_7 : ICoreWebView2_6 { + /// Print the current page to PDF asynchronously with the provided settings. + /// See `ICoreWebView2PrintSettings` for description of settings. Passing + /// nullptr for `printSettings` results in default print settings used. + /// + /// Use `resultFilePath` to specify the path to the PDF file. The host should + /// provide an absolute path, including file name. If the path + /// points to an existing file, the file will be overwritten. If the path is + /// not valid, the method fails with `E_INVALIDARG`. + /// + /// The async `PrintToPdf` operation completes when the data has been written + /// to the PDF file. At this time the + /// `ICoreWebView2PrintToPdfCompletedHandler` is invoked. If the + /// application exits before printing is complete, the file is not saved. + /// Only one `Printing` operation can be in progress at a time. If + /// `PrintToPdf` is called while a `PrintToPdf` or `PrintToPdfStream` or `Print` or + /// `ShowPrintUI` job is in progress, the completed handler is immediately invoked + /// with `isSuccessful` set to FALSE. + /// + /// \snippet FileComponent.cpp PrintToPdf + /// + HRESULT PrintToPdf( + [in] LPCWSTR ResultFilePath, + [in] ICoreWebView2PrintSettings* printSettings + , [in] ICoreWebView2PrintToPdfCompletedHandler* handler); + + +} + + + +} diff --git a/scripts/latest_version.txt b/scripts/latest_version.txt index 97ac9c8..630fa3d 100644 --- a/scripts/latest_version.txt +++ b/scripts/latest_version.txt @@ -1 +1 @@ -1.0.2592.51 \ No newline at end of file +1.0.2739.15 \ No newline at end of file