@@ -28,13 +28,11 @@ namespace CefSharp.OutOfProcess.Wpf.HwndHost
2828 /// and https://stackoverflow.com/questions/6500336/custom-dwm-drawn-window-frame-flickers-on-resizing-if-the-window-contains-a-hwnd/17471534#17471534
2929 public class ChromiumWebBrowser : System . Windows . Interop . HwndHost , IChromiumWebBrowserInternal
3030 {
31- public const string BrowserNotInitializedExceptionErrorMessage =
31+ private const string BrowserNotInitializedExceptionErrorMessage =
3232 "The ChromiumWebBrowser instance creates the underlying Chromium Embedded Framework (CEF) browser instance in an async fashion. " +
3333 "The undelying CefBrowser instance is not yet initialized. Use the IsBrowserInitializedChanged event and check " +
3434 "the IsBrowserInitialized property to determine when the browser has been initialized." ;
3535
36- private static string _defaultHostProcessPath ;
37-
3836 private const int WS_CHILD = 0x40000000 ,
3937 WS_VISIBLE = 0x10000000 ,
4038 LBS_NOTIFY = 0x00000001 ,
@@ -275,21 +273,18 @@ public bool IsDisposed
275273 /// <value>The redo command.</value>
276274 public ICommand RedoCommand { get ; private set ; }
277275
278- /// <summary>
279- /// Initializes a new instance of the <see cref="ChromiumWebBrowser"/> instance.
280- /// </summary>
281- public ChromiumWebBrowser ( ) : this ( null , null )
282- {
283-
284- }
285-
286276 /// <summary>
287277 /// Initializes a new instance of the <see cref="ChromiumWebBrowser"/> instance.
288278 /// </summary>
289279 /// <param name="host">Out of process host</param>
290280 /// <param name="initialAddress">address to load initially</param>
291- public ChromiumWebBrowser ( OutOfProcessHost host , string initialAddress )
281+ public ChromiumWebBrowser ( OutOfProcessHost host , string initialAddress = null )
292282 {
283+ if ( host == null )
284+ {
285+ throw new ArgumentNullException ( nameof ( host ) ) ;
286+ }
287+
293288 _host = host ;
294289 _initialAddress = initialAddress ;
295290
@@ -323,15 +318,6 @@ public ChromiumWebBrowser(OutOfProcessHost host, string initialAddress)
323318 UseLayoutRounding = true ;
324319 }
325320
326- /// <summary>
327- /// Used when control is created through xaml or using default constructor
328- /// </summary>
329- /// <param name="path"></param>
330- public static void SetHostProcessPath ( string path )
331- {
332- _defaultHostProcessPath = path ;
333- }
334-
335321 /// <inheritdoc/>
336322 int IChromiumWebBrowserInternal . Id
337323 {
@@ -505,29 +491,12 @@ protected override HandleRef BuildWindowCore(HandleRef hwndParent)
505491 0 ) ;
506492 }
507493
508- if ( _host == null )
509- {
510- _ = OutOfProcessHost . CreateAsync ( _defaultHostProcessPath ) . ContinueWith ( ( t ) =>
511- {
512- _host = t . Result ;
513-
514- _host . CreateBrowser ( this , _hwndHost , url : _initialAddress , out _id ) ;
515-
516- _devToolsContextConnectionTransport = new OutOfProcessConnectionTransport ( _id , _host ) ;
517-
518- var connection = DevToolsConnection . Attach ( _devToolsContextConnectionTransport ) ;
519- _devToolsContext = Puppeteer . DevToolsContext . CreateForOutOfProcess ( connection ) ;
520- } , TaskScheduler . Default ) ;
521- }
522- else
523- {
524- _host . CreateBrowser ( this , _hwndHost , url : _initialAddress , out _id ) ;
494+ _host . CreateBrowser ( this , _hwndHost , url : _initialAddress , out _id ) ;
525495
526- _devToolsContextConnectionTransport = new OutOfProcessConnectionTransport ( _id , _host ) ;
496+ _devToolsContextConnectionTransport = new OutOfProcessConnectionTransport ( _id , _host ) ;
527497
528- var connection = DevToolsConnection . Attach ( _devToolsContextConnectionTransport ) ;
529- _devToolsContext = Puppeteer . DevToolsContext . CreateForOutOfProcess ( connection ) ;
530- }
498+ var connection = DevToolsConnection . Attach ( _devToolsContextConnectionTransport ) ;
499+ _devToolsContext = Puppeteer . DevToolsContext . CreateForOutOfProcess ( connection ) ;
531500
532501 return new HandleRef ( null , _hwndHost ) ;
533502 }
0 commit comments