@@ -33,8 +33,15 @@ async protected bool EnsureWebView2RuntimeVersion(string minimalVersionRequired)
3333
3434// For the scenario where the app wants to light up features fast while running with the old version.
3535 {
36+ // We could be running with a WebView2 Runtime version that has or doesn't have some features.
37+ // Therefore, check the version that we are running the WebView2 with, and skip the new feature if running old version.
38+ string currentRunningVersion = webView2Environment .NewBrowserVersionAvailable ;
39+ if (CoreWebView2Environment .CompareBrowserVersions (currentRunningVersion , minimalVersionHasFeartures ) >= 0 ) {
40+ // Light up the app features that make usage of APIs that only works in newer version.
41+ }
42+
3643 .. .
37- // Listen to NewBrowserVersionAvailable to take action .
44+ // Listen to NewBrowserVersionAvailable event to switch to newer version when it is available .
3845 webView2Environment .NewBrowserVersionAvailable += delegate (object sender , object args )
3946 {
4047 // See the NewBrowserVersionAvailable documentation for more information
@@ -44,7 +51,7 @@ async protected bool EnsureWebView2RuntimeVersion(string minimalVersionRequired)
4451 };
4552
4653 // Trigger Edge WebView2 Runtime update, ignore update result and rely on NewBrowserVersionAvailable to take action.
47- EnsureWebView2RuntimeVersion (desiredVersion );
54+ _ = EnsureWebView2RuntimeVersion (desiredVersion );
4855}
4956
5057```
@@ -122,16 +129,19 @@ See [API Details](#api-details) section below for API reference.
122129 /// Runtime is updated successfully and latest version is now installed.
123130 COREWEBVIEW2_UPDATE_RUNTIME_STATUS_LATEST_VERSION_INSTALLED,
124131
132+ /// Edge WebView2 Runtime update is already running, which could be
133+ /// triggered by auto update or by other UpdateRuntime request from some app.
134+ COREWEBVIEW2_UPDATE_RUNTIME_STATUS_INSTALL_ALREADY_RUNNING,
135+
125136 /// Edge WebView2 Runtime update is blocked by group policy.
126137 COREWEBVIEW2_UPDATE_RUNTIME_STATUS_BLOCKED_BY_POLICY,
127138
128139 /// Edge WebView2 Runtime update failed.
129- /// See `UpdateError ` property of UpdateRuntimeResult for more
140+ /// See `ExtendedError ` property of UpdateRuntimeResult for more
130141 /// information about the failure.
131142 COREWEBVIEW2_UPDATE_RUNTIME_STATUS_FAILED,
132143} COREWEBVIEW2_UPDATE_RUNTIME_STATUS;
133144
134-
135145/// The UpdateRuntime operation result.
136146[uuid(DD503E49-AB19-47C0-B2AD-6DDD09CC3E3A), object, pointer_default(unique)]
137147interface ICoreWebView2ExperimentalUpdateRuntimeResult : IUnknown {
@@ -141,12 +151,14 @@ interface ICoreWebView2ExperimentalUpdateRuntimeResult : IUnknown {
141151 [ out, retval ] COREWEBVIEW2_UPDATE_RUNTIME_STATUS * status);
142152
143153 /// The update error happened while trying to update Edge WebView2 Runtime.
144- [propget] HRESULT UpdateError([out, retval] HRESULT* updateError);
154+ /// ExtendedError will be S_OK if Status is not `COREWEBVIEW2_UPDATE_RUNTIME_STATUS_FAILED`
155+ /// or `COREWEBVIEW2_UPDATE_RUNTIME_STATUS_BLOCKED_BY_POLICY`.
156+ [propget] HRESULT ExtendedError([out, retval] HRESULT* error);
145157}
146158
147159/// The caller implements this interface to receive the UpdateRuntime result.
148160[uuid(F1D2D722-3721-499C-87F5-4C405260697A), object, pointer_default(unique)]
149- interface ICoreWebView2ExperimentalUpdateRuntimeCompletedHandler : IUnknown {
161+ interface ICoreWebView2ExperimentalTryUpdateRuntimeCompletedHandler : IUnknown {
150162
151163 /// Provides the result for the UpdateRuntime operation.
152164 /// `errorCode` will be S_OK if the update operation can be performed
@@ -155,7 +167,7 @@ interface ICoreWebView2ExperimentalUpdateRuntimeCompletedHandler : IUnknown {
155167 /// code of that unexpected error would be set as `errorCode`.
156168 /// When update operation can be performed normally, but update resulted in
157169 /// failure, like download failed, the error code would be presented as
158- /// `UpdateError ` property of ICoreWebView2ExperimentalUpdateRuntimeResult.
170+ /// `ExtendedError ` property of ICoreWebView2ExperimentalUpdateRuntimeResult.
159171 HRESULT Invoke([in] HRESULT errorCode,
160172 [in] ICoreWebView2ExperimentalUpdateRuntimeResult * result);
161173}
@@ -172,41 +184,75 @@ interface ICoreWebView2ExperimentalEnvironment3 : IUnknown {
172184 /// UpdateRuntime's completed handler being invoked. Besides the
173185 /// `NewBrowserVersionAvailable` event, there will be no impact to any
174186 /// currently running WebView2s when the update is installed.
187+ /// Even though the Edge WebView2 Runtime update is installed for the machine
188+ /// and available to all users, the update will happen silently and not show
189+ /// elevation prompt.
190+ /// This will not impact Edge browser installation.
175191 /// The latest version can always be queried using the
176192 /// `GetAvailableCoreWebView2BrowserVersionString` API.
177193 /// The UpdateRuntime method is only supported for an installed Edge WebView2
178194 /// Runtime. When running a fixed version Edge WebView2 Runtime or non stable
179195 /// channel Edge browser, this API will return `HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)`.
180- /// There could only be one active UpdateRuntime operation, calling this API
181- /// before completed handler for previous call is invoked will fail with
196+ /// There could only be one active UpdateRuntime operation in an app process,
197+ /// calling this API before completed handler for previous call is invoked will fail with
182198 /// `HRESULT_FROM_WIN32(ERROR_BUSY)`.
183199 /// Calling this API repeatedly in a short period of time, will also fail with
184200 /// `HRESULT_FROM_WIN32(ERROR_BUSY)`. To protect accidental abuse of the update
185201 /// service, the implementation throttles the calls of this API to 3 times within
186- /// 5 minutes in a process.
202+ /// 5 minutes in a process. Throttling limit can change in the future.
187203 /// The UpdateRuntime operation is associated with the CoreWebView2Environment
188204 /// object and any ongoing UpdateRuntime operation will be aborted when the
189205 /// associated CoreWebView2Environment along with the CoreWebView2 objects that
190206 /// are created by the CoreWebView2Environment object are all released. In this
191207 /// case, the completed handler will be invoked with `S_OK` as `errorCode` and a
192208 /// result object with `Status` of COREWEBVIEW2_UPDATE_RUNTIME_STATUS_FAILED and
193- /// `UpdateError` as `E_ABORT`.
194- ///
195- /// \snippet AppWindow.cpp UpdateRuntime
209+ /// `ExtendedError` as `E_ABORT`.
196210 HRESULT UpdateRuntime(
197- [in] ICoreWebView2ExperimentalUpdateRuntimeCompletedHandler *
211+ [in] ICoreWebView2ExperimentalTryUpdateRuntimeCompletedHandler *
198212 handler);
199213}
214+
215+ ```
216+ ## WinRT
217+ ``` c#
218+ namespace Microsoft .Web .WebView2 .Core
219+ {
220+ public enum CoreWebView2UpdateRuntimeStatus
221+ {
222+ LatestVersionInstalled = 0 ,
223+ InstallAlreadyRunning = 1 ,
224+ BlockedByPolicy = 2 ,
225+ Failed = 3 ,
226+ }
227+
228+ public partial class CoreWebView2UpdateRuntimeResult
229+ {
230+ public CoreWebView2UpdateRuntimeStatus Status
231+ {
232+ get ;
233+ }
234+ public Windows.Foundation.HResult ExtendedError
235+ {
236+ get ;
237+ }
238+ }
239+
240+ public partial class CoreWebView2Environment
241+ {
242+ public async Task <CoreWebView2UpdateRuntimeResult > UpdateRuntimeAsync ()
243+ }
244+ }
200245```
201- ## .NET WinRT
246+ ## .NET
202247```c#
203248namespace Microsoft .Web .WebView2 .Core
204249{
205250 public enum CoreWebView2UpdateRuntimeStatus
206251 {
207252 LatestVersionInstalled = 0 ,
208- BlockedByPolicy = 1 ,
209- Failed = 2 ,
253+ InstallAlreadyRunning = 1 ,
254+ BlockedByPolicy = 2 ,
255+ Failed = 3 ,
210256 }
211257
212258 public partial class CoreWebView2UpdateRuntimeResult
@@ -215,7 +261,7 @@ namespace Microsoft.Web.WebView2.Core
215261 {
216262 get ;
217263 }
218- public int UpdateError
264+ public int ExtendedError
219265 {
220266 get ;
221267 }
0 commit comments