Skip to content

Commit 606d9df

Browse files
committed
Core - Add Cef.GetErrorCode
- Get the error code for when Cef.Initialize fails Resolves #4914
1 parent 7306d43 commit 606d9df

File tree

4 files changed

+167
-0
lines changed

4 files changed

+167
-0
lines changed

CefSharp.Core.Runtime.RefAssembly/CefSharp.Core.Runtime.netcore.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public static void AddDisposable(System.IDisposable item) { }
6969
public static void DoMessageLoopWork() { }
7070
public static void EnableWaitForBrowsersToClose() { }
7171
public static int ExecuteProcess() { throw null; }
72+
public static CefSharp.Enums.ResultCode GetExitCode() { throw null; }
7273
public static CefSharp.ICookieManager GetGlobalCookieManager() { throw null; }
7374
public static CefSharp.ICookieManager GetGlobalCookieManager(CefSharp.ICompletionCallback callback) { throw null; }
7475
public static CefSharp.IRequestContext GetGlobalRequestContext() { throw null; }

CefSharp.Core.Runtime/Cef.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,19 @@ namespace CefSharp
523523
return nullptr;
524524
}
525525

526+
/// <summary>
527+
/// This function can optionally be called on the main application thread after
528+
/// CefInitialize to retrieve the initialization exit code. When CefInitialize
529+
/// returns true the exit code will be 0 (ResultCode.NormalExit).
530+
/// Otherwise, see ResultCode for possible exit code values including
531+
/// browser process initialization errors and normal early exit conditions
532+
/// (such as ResultCode.NormalExitProcessNotified for process singleton relaunch behavior).
533+
/// </summary>
534+
static ResultCode GetExitCode()
535+
{
536+
return (ResultCode)CefGetExitCode();
537+
}
538+
526539
/// <summary>
527540
/// Called prior to calling Cef.Shutdown, this diposes of any remaning
528541
/// ChromiumWebBrowser instances. In WPF this is used from Dispatcher.ShutdownStarted

CefSharp.Core/Cef.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
using System;
88
using System.Threading.Tasks;
9+
using CefSharp.Enums;
910
using CefSharp.Internals;
1011

1112
namespace CefSharp
@@ -370,6 +371,19 @@ public static ICookieManager GetGlobalCookieManager(ICompletionCallback callback
370371
return Core.Cef.GetGlobalCookieManager(callback);
371372
}
372373

374+
/// <summary>
375+
/// This function can optionally be called on the main application thread after
376+
/// CefInitialize to retrieve the initialization exit code. When CefInitialize
377+
/// returns true the exit code will be 0 (<see cref="ResultCode.NormalExit"/>).
378+
/// Otherwise, see <see cref="ResultCode"/> for possible exit code values including
379+
/// browser process initialization errors and normal early exit conditions
380+
/// (such as <see cref="ResultCode.NormalExitProcessNotified"/> for process singleton relaunch behavior).
381+
/// </summary>
382+
public static ResultCode GetExitCode()
383+
{
384+
return Core.Cef.GetExitCode();
385+
}
386+
373387
/// <summary>
374388
/// Called prior to calling Cef.Shutdown, this disposes of any remaining
375389
/// ChromiumWebBrowser instances. In WPF this is used from Dispatcher.ShutdownStarted

CefSharp/Enums/ResultCode.cs

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
namespace CefSharp.Enums
2+
{
3+
/// <summary>
4+
/// CEF Exit Codes
5+
/// </summary>
6+
public enum ResultCode
7+
{
8+
// The following values should be kept in sync with Chromium's
9+
// content::ResultCode type.
10+
11+
NormalExit,
12+
13+
/// <summary>
14+
/// Process was killed by user or system.
15+
/// </summary>
16+
Killed,
17+
18+
/// <summary>
19+
/// Process hung.
20+
/// </summary>
21+
Hung,
22+
23+
/// <summary>
24+
/// A bad message caused the process termination.
25+
/// </summary>
26+
KilledBadMessage,
27+
28+
/// <summary>
29+
/// The GPU process exited because initialization failed.
30+
/// </summary>
31+
GpuDeadOnArrival,
32+
33+
// The following values should be kept in sync with Chromium's
34+
// chrome::ResultCode type. Unused chrome values are excluded.
35+
36+
ChromeFirst,
37+
38+
/// <summary>
39+
/// A critical chrome file is missing.
40+
/// </summary>
41+
MissingData = 7,
42+
43+
/// <summary>
44+
/// Command line parameter is not supported.
45+
/// </summary>
46+
UnsupportedParam = 13,
47+
48+
/// <summary>
49+
/// The profile was in use on another host.
50+
/// </summary>
51+
ProfileInUse = 21,
52+
53+
/// <summary>
54+
/// Failed to pack an extension via the command line.
55+
/// </summary>
56+
PackExtensionError = 22,
57+
58+
/// <summary>
59+
/// The browser process exited early by passing the command line to another
60+
/// running browser.
61+
/// </summary>
62+
NormalExitProcessNotified = 24,
63+
64+
/// <summary>
65+
/// A browser process was sandboxed. This should never happen.
66+
/// </summary>
67+
InvalidSandboxState = 31,
68+
69+
/// <summary>
70+
/// Cloud policy enrollment failed or was given up by user.
71+
/// </summary>
72+
CloudPolicyEnrollmentFailed = 32,
73+
74+
/// <summary>
75+
/// The GPU process was terminated due to context lost.
76+
/// </summary>
77+
GpuExitOnContextLost = 34,
78+
79+
/// <summary>
80+
/// An early startup command was executed and the browser must exit.
81+
/// </summary>
82+
NormalExitPackExtensionSuccess = 36,
83+
84+
/// <summary>
85+
/// The browser process exited because system resources are exhausted. The
86+
/// system state can't be recovered and will be unstable.
87+
/// </summary>
88+
SystemResourceExhausted = 37,
89+
90+
ChromeLast = 39,
91+
92+
// The following values should be kept in sync with Chromium's
93+
// sandbox::TerminationCodes type.
94+
95+
SandboxFatalFirst = 7006,
96+
97+
/// <summary>
98+
/// Windows sandbox could not set the integrity level.
99+
/// </summary>
100+
SandboxFatalIntegrity = SandboxFatalFirst,
101+
102+
/// <summary>
103+
/// Windows sandbox could not lower the token.
104+
/// </summary>
105+
SandboxFatalDroptoken,
106+
107+
/// <summary>
108+
/// Windows sandbox failed to flush registry handles.
109+
/// </summary>
110+
SandboxFatalFlushandles,
111+
112+
/// <summary>
113+
/// Windows sandbox failed to forbid HCKU caching.
114+
/// </summary>
115+
SandboxFatalCachedisable,
116+
117+
/// <summary>
118+
/// Windows sandbox failed to close pending handles.
119+
/// </summary>
120+
SandboxFatalClosehandles,
121+
122+
/// <summary>
123+
/// Windows sandbox could not set the mitigation policy.
124+
/// </summary>
125+
SandboxFatalMitigation,
126+
127+
/// <summary>
128+
/// Windows sandbox exceeded the job memory limit.
129+
/// </summary>
130+
SandboxFatalMemoryExceeded,
131+
132+
/// <summary>
133+
/// Windows sandbox failed to warmup.
134+
/// </summary>
135+
SandboxFatalWarmup,
136+
137+
SandboxFatalLast,
138+
}
139+
}

0 commit comments

Comments
 (0)