@@ -34,10 +34,10 @@ CHECK_FAILURE(m_webView->add_NavigationStarting(
3434 wil::com_ptr<ICoreWebView2NavigationStartingEventArgs3 > args3;
3535 if (SUCCEEDED(args->QueryInterface(IID_PPV_ARGS(&args3))))
3636 {
37- COREWEBVIEW2_NAVIGATION_HISTORY_CHANGE_KIND history_change =
38- COREWEBVIEW2_NAVIGATION_HISTORY_CHANGE_KIND_OTHER ;
39- CHECK_FAILURE(args3->get_NavigationHistoryChange(&history_change));
40- if (history_change != COREWEBVIEW2_NAVIGATION_HISTORY_CHANGE_KIND_OTHER )
37+ COREWEBVIEW2_NAVIGATION_KIND kind;
38+ CHECK_FAILURE(args3->get_NavigationKind(&kind)) ;
39+ // disable navigation if it is back/forward
40+ if (kind == COREWEBVIEW2_NAVIGATION_KIND_BACKORFORWARD )
4141 {
4242 CHECK_FAILURE(args->put_Cancel(true));
4343 }
@@ -59,7 +59,7 @@ CHECK_FAILURE(m_webView->add_NavigationStarting(
5959// `GoBack` or `GoForward`, it will be canceled.
6060void WebView_NavigationStarting(object sender, CoreWebView2NavigationStartingEventArgs e)
6161{
62- if (e.NavigationHistoryChange != CoreWebView2NavigationHistoryChangeKind.Other )
62+ if (e.NavigationKind == CoreWebView2NavigationKind.BackOrForward )
6363 {
6464 e.Cancel = true;
6565 }
@@ -72,27 +72,25 @@ void WebView_NavigationStarting(object sender, CoreWebView2NavigationStartingEve
7272``` c++
7373// Enums and structs
7474[v1_enum]
75- typedef enum COREWEBVIEW2_NAVIGATION_HISTORY_CHANGE_KIND {
76- /// Indicates a navigation that is going back to a previous entry in the navigation history.
77- /// For example, a navigation caused by ` CoreWebView2.GoBack ` or in script ` window.history.go(-1) ` .
78- COREWEBVIEW2_NAVIGATION_HISTORY_CHANGE_KIND_BACK,
79- /// Indicates a navigation that is going forward to a later entry in the navigation history.
80- /// For example, a navigation caused by ` CoreWebView2.GoForward ` or in script ` window.history.go(1) ` .
81- COREWEBVIEW2_NAVIGATION_HISTORY_CHANGE_KIND_FORWARD,
82- /// Indicates a navigation that is not going back or forward to an existing entry in the navigation
83- /// history. For example, a navigation caused by ` CoreWebView2.Navigate ` , or ` CoreWebView2.Reload `
84- /// or in script ` window.location.href = 'https://example.com/' ` .
85- COREWEBVIEW2_NAVIGATION_HISTORY_CHANGE_KIND_OTHER,
86- } COREWEBVIEW2_NAVIGATION_HISTORY_CHANGE_KIND;
75+ typedef enum COREWEBVIEW2_NAVIGATION_KIND {
76+ /// Indicates a navigation that is reloading the current document.
77+ /// For example, a navigation caused by ` CoreWebView2.Reload() ` or in script ` window.history.go() ` .
78+ COREWEBVIEW2_NAVIGATION_KIND_RELOAD,
79+ /// Indicates a navigation that is going back or forward in the navigation history.
80+ /// For example, a navigation caused by ` CoreWebView2.GoBack()/Forward() ` or in script ` window.history.go(-1)/go(1) ` .
81+ COREWEBVIEW2_NAVIGATION_KIND_BACKORFORWARD,
82+ /// Indicates a navigation that is navigating to a different document.
83+ /// For example, a navigation caused by ` CoreWebView2.Navigate() ` , or a link click.
84+ COREWEBVIEW2_NAVIGATION_KIND_DIFFERENT,
85+ } COREWEBVIEW2_NAVIGATION_KIND;
8786
8887// / Extend `NavigationStartingEventArgs` by adding more information.
8988[uuid(39A27807-2365 -470B-AF28-885502121049 ), object, pointer_default(unique)]
9089interface ICoreWebView2NavigationStartingEventArgs3 : ICoreWebView2NavigationStartingEventArgs2 {
9190
92- /// Indicates if this navigation is going back or forward to an existing entry in the navigation
93- /// history.
94- [ propget] HRESULT NavigationHistoryChange(
95- [ out, retval] COREWEBVIEW2_NAVIGATION_HISTORY_CHANGE_KIND* history_change);
91+ /// Indicates if this navigation is reload, back/forward or navigating to a different document
92+ [ propget] HRESULT NavigationHistoryKind(
93+ [ out, retval] COREWEBVIEW2_NAVIGATION_KIND* kind);
9694}
9795}
9896```
@@ -102,11 +100,11 @@ interface ICoreWebView2NavigationStartingEventArgs3 : ICoreWebView2NavigationSta
102100``` c# (but really MIDL3)
103101namespace Microsoft .Web .WebView2 .Core
104102{
105- enum CoreWebView2NavigationHistoryChangeKind
103+ enum CoreWebView2NavigationKind
106104 {
107- Back = 0 ,
108- Forward = 1 ,
109- Other = 2 ,
105+ Reload = 0 ,
106+ BackOrForward = 1 ,
107+ Different = 2 ,
110108 };
111109 // ..
112110 runtimeclass CoreWebView2NavigationStartingEventArgs
@@ -116,7 +114,7 @@ namespace Microsoft.Web.WebView2.Core
116114 [interface_name (" Microsoft.Web.WebView2.Core.ICoreWebView2NavigationStartingEventArgs3" )]
117115 {
118116 // ICoreWebView2NavigationStartingEventArgs3 members
119- CoreWebView2NavigationHistoryChangeKind NavigationHistoryChange { get; };
117+ CoreWebView2NavigationKind NavigationKind { get; };
120118 }
121119 }
122120}
0 commit comments