You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As IsInitialized is set when CefInitialize returns and it appears to be possible the OnContextInitialized is called
before it returns then this exception wasn't going to work.
Testing with Cef.GetGlobalRequestContext and Cef.GetGlobalCookieManager and they both return null if called before Cef.Initialize
So it shouldn't be possible to actually access the cookie manager/RequestContext. Improved the xml doc
Resolves#2600
Copy file name to clipboardExpand all lines: CefSharp.Core/Cef.h
+13-28Lines changed: 13 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -32,8 +32,6 @@ namespace CefSharp
32
32
{
33
33
public ref classCef sealed
34
34
{
35
-
#defineThrowIfCefNotInitialized() if (!_initialized) throw gcnew Exception(__FUNCTION__ + " requires that CefRequestContext be initialized first. The earlier possible place to execute " + __FUNCTION__ + " is in IBrowserProcessHandler.OnContextInitialized. Alternative use the ChromiumWebBrowser BrowserInitialized (OffScreen) or IsBrowserInitializedChanged (WinForms/WPF) events.");
36
-
37
35
private:
38
36
static Object^ _sync;
39
37
@@ -324,8 +322,6 @@ namespace CefSharp
324
322
String^ targetDomain,
325
323
bool allowTargetSubdomains)
326
324
{
327
-
//ThrowIfCefNotInitialized();
328
-
329
325
returnCefAddCrossOriginWhitelistEntry(
330
326
StringUtils::ToNative(sourceOrigin),
331
327
StringUtils::ToNative(targetProtocol),
@@ -350,8 +346,6 @@ namespace CefSharp
350
346
bool allowTargetSubdomains)
351
347
352
348
{
353
-
//ThrowIfCefNotInitialized();
354
-
355
349
returnCefRemoveCrossOriginWhitelistEntry(
356
350
StringUtils::ToNative(sourceOrigin),
357
351
StringUtils::ToNative(targetProtocol),
@@ -366,24 +360,24 @@ namespace CefSharp
366
360
/// </remarks>
367
361
staticboolClearCrossOriginWhitelist()
368
362
{
369
-
//ThrowIfCefNotInitialized();
370
-
371
363
returnCefClearCrossOriginWhitelist();
372
364
}
373
365
374
366
/// <summary>
375
-
/// Returns the global cookie manager.
367
+
/// Returns the global cookie manager. By default data will be stored at CefSettings.CachePath if specified or in memory otherwise.
368
+
/// Using this method is equivalent to calling Cef.GetGlobalRequestContext().GetDefaultCookieManager()
369
+
/// The earlier possible place to access the ICookieManager is in IBrowserProcessHandler.OnContextInitialized.
370
+
/// Alternative use the ChromiumWebBrowser BrowserInitialized (OffScreen) or IsBrowserInitializedChanged (WinForms/WPF) events.
376
371
/// </summary>
377
-
/// <returns>A the global cookie manager</returns>
372
+
/// <returns>A the global cookie manager or null if the RequestContext has not yet been initialized.</returns>
378
373
static ICookieManager^ GetGlobalCookieManager()
379
374
{
380
-
//ThrowIfCefNotInitialized();
381
-
382
375
auto cookieManager = CefCookieManager::GetGlobalManager(NULL);
383
376
if (cookieManager.get())
384
377
{
385
378
return gcnew CookieManager(cookieManager);
386
379
}
380
+
387
381
returnnullptr;
388
382
}
389
383
@@ -398,13 +392,12 @@ namespace CefSharp
398
392
/// <returns>A blocking cookie manager</returns>
399
393
static ICookieManager^ GetBlockingCookieManager()
400
394
{
401
-
//ThrowIfCefNotInitialized();
402
-
403
395
auto cookieManager = CefCookieManager::GetBlockingManager();
404
396
if (cookieManager.get())
405
397
{
406
398
return gcnew CookieManager(cookieManager);
407
399
}
400
+
408
401
returnnullptr;
409
402
}
410
403
@@ -488,13 +481,13 @@ namespace CefSharp
488
481
}
489
482
490
483
/// <summary>
491
-
/// Clear all registered scheme handler factories.
484
+
/// Clear all scheme handler factories registered with the global request context.
485
+
/// Returns false on error. This function may be called on any thread in the browser process.
486
+
/// Using this function is equivalent to calling Cef.GetGlobalRequestContext().ClearSchemeHandlerFactories().
0 commit comments