@@ -34,10 +34,10 @@ CHECK_FAILURE(m_webView->add_NavigationStarting(
34
34
wil::com_ptr<ICoreWebView2NavigationStartingEventArgs3 > args3;
35
35
if (SUCCEEDED(args->QueryInterface(IID_PPV_ARGS(&args3))))
36
36
{
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 )
41
41
{
42
42
CHECK_FAILURE(args->put_Cancel(true));
43
43
}
@@ -59,7 +59,7 @@ CHECK_FAILURE(m_webView->add_NavigationStarting(
59
59
// `GoBack` or `GoForward`, it will be canceled.
60
60
void WebView_NavigationStarting(object sender, CoreWebView2NavigationStartingEventArgs e)
61
61
{
62
- if (e.NavigationHistoryChange != CoreWebView2NavigationHistoryChangeKind.Other )
62
+ if (e.NavigationKind == CoreWebView2NavigationKind.BackOrForward )
63
63
{
64
64
e.Cancel = true;
65
65
}
@@ -72,27 +72,25 @@ void WebView_NavigationStarting(object sender, CoreWebView2NavigationStartingEve
72
72
``` c++
73
73
// Enums and structs
74
74
[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;
87
86
88
87
// / Extend `NavigationStartingEventArgs` by adding more information.
89
88
[uuid(39A27807-2365 -470B-AF28-885502121049 ), object, pointer_default(unique)]
90
89
interface ICoreWebView2NavigationStartingEventArgs3 : ICoreWebView2NavigationStartingEventArgs2 {
91
90
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);
96
94
}
97
95
}
98
96
```
@@ -102,11 +100,11 @@ interface ICoreWebView2NavigationStartingEventArgs3 : ICoreWebView2NavigationSta
102
100
``` c# (but really MIDL3)
103
101
namespace Microsoft .Web .WebView2 .Core
104
102
{
105
- enum CoreWebView2NavigationHistoryChangeKind
103
+ enum CoreWebView2NavigationKind
106
104
{
107
- Back = 0 ,
108
- Forward = 1 ,
109
- Other = 2 ,
105
+ Reload = 0 ,
106
+ BackOrForward = 1 ,
107
+ Different = 2 ,
110
108
};
111
109
// ..
112
110
runtimeclass CoreWebView2NavigationStartingEventArgs
@@ -116,7 +114,7 @@ namespace Microsoft.Web.WebView2.Core
116
114
[interface_name (" Microsoft.Web.WebView2.Core.ICoreWebView2NavigationStartingEventArgs3" )]
117
115
{
118
116
// ICoreWebView2NavigationStartingEventArgs3 members
119
- CoreWebView2NavigationHistoryChangeKind NavigationHistoryChange { get; };
117
+ CoreWebView2NavigationKind NavigationKind { get; };
120
118
}
121
119
}
122
120
}
0 commit comments