Skip to content

Commit 019883d

Browse files
committed
OutOfProcessChromiumWebBrowser - Cleanup
Start removing unused code
1 parent e19de45 commit 019883d

File tree

1 file changed

+10
-88
lines changed

1 file changed

+10
-88
lines changed

CefSharp.OutOfProcess.BrowserProcess/OutOfProcessChromiumWebBrowser.cs

Lines changed: 10 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ public partial class OutOfProcessChromiumWebBrowser : IWebBrowserInternal
6363
/// </summary>
6464
private IBrowser _browser;
6565

66-
/// <summary>
67-
/// Initial browser load task complection source
68-
/// </summary>
69-
private TaskCompletionSource<LoadUrlAsyncResponse> _initialLoadTaskCompletionSource = new TaskCompletionSource<LoadUrlAsyncResponse>();
70-
71-
/// <summary>
72-
/// Initial browser load action
73-
/// </summary>
74-
private Action<bool?, CefErrorCode?> _initialLoadAction;
75-
7666
/// <summary>
7767
/// Id
7868
/// </summary>
@@ -314,8 +304,6 @@ void IWebBrowserInternal.OnStatusMessage(StatusMessageEventArgs args)
314304
void IWebBrowserInternal.OnLoadError(LoadErrorEventArgs args)
315305
{
316306
LoadError?.Invoke(this, args);
317-
318-
_initialLoadAction?.Invoke(null, args.ErrorCode);
319307
}
320308

321309
/// <summary>
@@ -347,11 +335,10 @@ void IWebBrowserInternal.OnAfterBrowserCreated(IBrowser browser)
347335

348336
this._browser = browser;
349337
BrowserCore = browser;
350-
_initialLoadAction = InitialLoad;
351338
Interlocked.Exchange(ref _browserInitialized, 1);
352339

353340
var host = browser.GetHost();
354-
_outofProcessHostRpc.NotifyBrowserCreated(_id, browser.GetHost().GetWindowHandle());
341+
_outofProcessHostRpc.NotifyBrowserCreated(_id, host.GetWindowHandle());
355342

356343
var observer = new CefSharpDevMessageObserver();
357344
observer.OnDevToolsAgentDetached((b) =>
@@ -395,37 +382,37 @@ void IWebBrowserInternal.OnAfterBrowserCreated(IBrowser browser)
395382
/// <param name="args">The <see cref="LoadingStateChangedEventArgs"/> instance containing the event data.</param>
396383
void IWebBrowserInternal.SetLoadingStateChange(LoadingStateChangedEventArgs args)
397384
{
398-
SetLoadingStateChange(args);
385+
CanGoBack = args.CanGoBack;
386+
CanGoForward = args.CanGoForward;
387+
IsLoading = args.IsLoading;
399388

400-
LoadingStateChanged?.Invoke(this, args);
389+
_outofProcessHostRpc.NotifyLoadingStateChange(_id, args.CanGoBack, args.CanGoForward, args.IsLoading);
401390

402-
_initialLoadAction?.Invoke(args.IsLoading, null);
391+
LoadingStateChanged?.Invoke(this, args);
403392
}
404393

405394
/// <inheritdoc/>
406395
public void LoadUrl(string url)
407396
{
408-
Load(url);
397+
throw new NotImplementedException();
409398
}
410399

411400
/// <inheritdoc/>
412401
public Task<LoadUrlAsyncResponse> LoadUrlAsync(string url)
413402
{
414-
//LoadUrlAsync is actually a static method so that CefSharp.Wpf.HwndHost can reuse the code
415-
return CefSharp.WebBrowserExtensions.LoadUrlAsync(this, url);
403+
throw new NotImplementedException();
416404
}
417405

418406
/// <inheritdoc/>
419407
public Task<WaitForNavigationAsyncResponse> WaitForNavigationAsync(TimeSpan? timeout = null, CancellationToken cancellationToken = default)
420408
{
421-
//WaitForNavigationAsync is actually a static method so that CefSharp.Wpf.HwndHost can reuse the code
422-
return CefSharp.WebBrowserExtensions.WaitForNavigationAsync(this, timeout, cancellationToken);
409+
throw new NotImplementedException();
423410
}
424411

425412
/// <inheritdoc/>
426413
public Task<LoadUrlAsyncResponse> WaitForInitialLoadAsync()
427414
{
428-
return _initialLoadTaskCompletionSource.Task;
415+
throw new NotImplementedException();
429416
}
430417

431418
/// <inheritdoc/>
@@ -460,58 +447,6 @@ public bool TryGetBrowserCoreById(int browserId, out IBrowser browser)
460447
}
461448
}
462449

463-
private void InitialLoad(bool? isLoading, CefErrorCode? errorCode)
464-
{
465-
if (IsDisposed)
466-
{
467-
_initialLoadAction = null;
468-
469-
_initialLoadTaskCompletionSource.TrySetCanceled();
470-
471-
return;
472-
}
473-
474-
if (isLoading.HasValue)
475-
{
476-
if (isLoading.Value)
477-
{
478-
return;
479-
}
480-
481-
_initialLoadAction = null;
482-
483-
var host = _browser?.GetHost();
484-
485-
var navEntry = host?.GetVisibleNavigationEntry();
486-
487-
int statusCode = navEntry?.HttpStatusCode ?? -1;
488-
489-
//By default 0 is some sort of error, we map that to -1
490-
//so that it's clearer that something failed.
491-
if (statusCode == 0)
492-
{
493-
statusCode = -1;
494-
}
495-
496-
_initialLoadTaskCompletionSource.TrySetResultAsync(new LoadUrlAsyncResponse(CefErrorCode.None, statusCode));
497-
}
498-
else if (errorCode.HasValue)
499-
{
500-
//Actions that trigger a download will raise an aborted error.
501-
//Generally speaking Aborted is safe to ignore
502-
if (errorCode == CefErrorCode.Aborted)
503-
{
504-
return;
505-
}
506-
507-
_initialLoadAction = null;
508-
509-
_initialLoadTaskCompletionSource.TrySetResultAsync(new LoadUrlAsyncResponse(errorCode.Value, -1));
510-
}
511-
}
512-
513-
partial void SetLoadingStateChange(LoadingStateChangedEventArgs args);
514-
515450
/// <summary>
516451
/// Sets the handler references to null.
517452
/// Where required also calls Dispose().
@@ -877,19 +812,6 @@ void IWebBrowserInternal.SetAddress(AddressChangedEventArgs args)
877812
_outofProcessHostRpc.NotifyAddressChanged(_id, args.Address);
878813
}
879814

880-
/// <summary>
881-
/// Sets the loading state change.
882-
/// </summary>
883-
/// <param name="args">The <see cref="LoadingStateChangedEventArgs"/> instance containing the event data.</param>
884-
partial void SetLoadingStateChange(LoadingStateChangedEventArgs args)
885-
{
886-
CanGoBack = args.CanGoBack;
887-
CanGoForward = args.CanGoForward;
888-
IsLoading = args.IsLoading;
889-
890-
_outofProcessHostRpc.NotifyLoadingStateChange(_id, args.CanGoBack, args.CanGoForward, args.IsLoading);
891-
}
892-
893815
/// <summary>
894816
/// Sets the title.
895817
/// </summary>

0 commit comments

Comments
 (0)