@@ -124,15 +124,26 @@ HRESULT AppWindow::OnCreateCoreWebView2ControllerCompleted(HRESULT result, ICore
124124
125125```csharp
126126CoreWebView2Environment _webViewEnvironment;
127- public CreateWebView2ControllerWithOptions(IntPtr parentWindow, string profileName, bool isInPrivate)
127+ WebViewCreationOptions _creationOptions;
128+ public CreateWebView2Controller(IntPtr parentWindow)
128129{
129- CoreWebView2ControllerOptions options = _webViewEnvironment.CreateCoreWebView2ControllerOptions ();
130- options .ProfileName = profileName;
131- options .IsInPrivateModeEnabled = isInPrivate ;
130+ CoreWebView2ControllerOptions controllerOptions = new CoreWebView2ControllerOptions ();
131+ controllerOptions .ProfileName = _creationOptions. profileName;
132+ controllerOptions .IsInPrivateModeEnabled = _creationOptions.IsInPrivateModeEnabled ;
132133
133- CoreWebView2Controller webView2Controller = await _webViewEnvironment.CreateCoreWebView2ControllerWithOptionsAsync(parentWindow, options);
134- string profileName = webView2Controller.CoreWebView2.Profile.ProfileName;
135- bool inPrivate = webView2Controller.CoreWebView2.Profile.IsInPrivateModeEnabled;
134+ CoreWebView2Controller controller = null;
135+
136+ if (_creationOptions.entry == WebViewCreateEntry.CREATE_WITH_OPTION)
137+ {
138+ controller = await _webViewEnvironment.CreateCoreWebView2ControllerAsync(parentWindow, options);
139+ }
140+ else
141+ {
142+ controller = await _webViewEnvironment.CreateCoreWebView2ControllerAsync(parentWindow);
143+ }
144+
145+ string profileName = controller.CoreWebView2.Profile.ProfileName;
146+ bool inPrivate = controller.CoreWebView2.Profile.IsInPrivateModeEnabled;
136147
137148 // update window title with profileName
138149 UpdateAppTitle(profileName);
@@ -260,14 +271,14 @@ namespace Microsoft.Web.WebView2.Core
260271 // ...
261272
262273 CoreWebView2ControllerOptions CreateCoreWebView2ControllerOptions ();
263-
274+
264275 Windows .Foundation .IAsyncOperation < CoreWebView2Controller >
265- CreateCoreWebView2ControllerWithOptionsAsync (
276+ CreateCoreWebView2ControllerAsync (
266277 CoreWebView2ControllerWindowReference ParentWindow ,
267278 CoreWebView2ControllerOptions options );
268279
269280 Windows .Foundation .IAsyncOperation < CoreWebView2CompositionController >
270- CreateCoreWebView2CompositionControllerWithOptionsAsync (
281+ CreateCoreWebView2CompositionControllerAsync (
271282 CoreWebView2ControllerWindowReference ParentWindow ,
272283 CoreWebView2ControllerOptions options );
273284 }
0 commit comments