diff --git a/SafeExamBrowser.Browser/BrowserApplicationController.cs b/SafeExamBrowser.Browser/BrowserApplicationController.cs
index a38baadc..c7a6884e 100644
--- a/SafeExamBrowser.Browser/BrowserApplicationController.cs
+++ b/SafeExamBrowser.Browser/BrowserApplicationController.cs
@@ -129,7 +129,7 @@ namespace SafeExamBrowser.Browser
CachePath = appConfig.BrowserCachePath,
LogFile = appConfig.BrowserLogFile,
LogSeverity = error ? LogSeverity.Error : (warning ? LogSeverity.Warning : LogSeverity.Info),
- UserAgent = settings.UseCustomUserAgent ? settings.CustomUserAgent : string.Empty
+ UserAgent = InitializeUserAgent()
};
cefSettings.CefCommandLineArgs.Add("touch-events", "enabled");
@@ -165,5 +165,24 @@ namespace SafeExamBrowser.Browser
instances.Remove(instances.FirstOrDefault(i => i.Id == id));
logger.Info($"Browser instance {id} was terminated.");
}
+
+ ///
+ /// TODO: Workaround to correctly set the user agent due to missing support for request interception for requests made by service workers.
+ /// Remove once CEF fully supports service workers and reactivate the functionality in !
+ ///
+ private string InitializeUserAgent()
+ {
+ var osVersion = $"{Environment.OSVersion.Version.Major}.{Environment.OSVersion.Version.Minor}";
+ var sebVersion = $"SEB/{appConfig.ProgramVersion}";
+
+ if (settings.UseCustomUserAgent)
+ {
+ return $"{settings.CustomUserAgent} {sebVersion}";
+ }
+ else
+ {
+ return $"Mozilla/5.0 (Windows NT {osVersion}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{Cef.ChromiumVersion} {sebVersion}";
+ }
+ }
}
}
diff --git a/SafeExamBrowser.Browser/Handlers/ContextMenuHandler.cs b/SafeExamBrowser.Browser/Handlers/ContextMenuHandler.cs
index 39f15716..26e44431 100644
--- a/SafeExamBrowser.Browser/Handlers/ContextMenuHandler.cs
+++ b/SafeExamBrowser.Browser/Handlers/ContextMenuHandler.cs
@@ -13,7 +13,7 @@ using BrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.Browser
namespace SafeExamBrowser.Browser.Handlers
{
///
- /// See https://cefsharp.github.io/api/71.0.0/html/T_CefSharp_IContextMenuHandler.htm.
+ /// See https://cefsharp.github.io/api/73.1.x/html/T_CefSharp_IContextMenuHandler.htm.
///
internal class ContextMenuHandler : IContextMenuHandler
{
diff --git a/SafeExamBrowser.Browser/Handlers/DisplayHandler.cs b/SafeExamBrowser.Browser/Handlers/DisplayHandler.cs
index 40e797d9..169a9d35 100644
--- a/SafeExamBrowser.Browser/Handlers/DisplayHandler.cs
+++ b/SafeExamBrowser.Browser/Handlers/DisplayHandler.cs
@@ -15,7 +15,7 @@ using SafeExamBrowser.Browser.Events;
namespace SafeExamBrowser.Browser.Handlers
{
///
- /// See https://cefsharp.github.io/api/71.0.0/html/T_CefSharp_IDisplayHandler.htm.
+ /// See https://cefsharp.github.io/api/73.1.x/html/T_CefSharp_IDisplayHandler.htm.
///
internal class DisplayHandler : IDisplayHandler
{
diff --git a/SafeExamBrowser.Browser/Handlers/DownloadHandler.cs b/SafeExamBrowser.Browser/Handlers/DownloadHandler.cs
index 5fced235..4ff6a719 100644
--- a/SafeExamBrowser.Browser/Handlers/DownloadHandler.cs
+++ b/SafeExamBrowser.Browser/Handlers/DownloadHandler.cs
@@ -19,7 +19,7 @@ using BrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.Browser
namespace SafeExamBrowser.Browser.Handlers
{
///
- /// See https://cefsharp.github.io/api/71.0.0/html/T_CefSharp_IDownloadHandler.htm.
+ /// See https://cefsharp.github.io/api/73.1.x/html/T_CefSharp_IDownloadHandler.htm.
///
internal class DownloadHandler : IDownloadHandler
{
diff --git a/SafeExamBrowser.Browser/Handlers/KeyboardHandler.cs b/SafeExamBrowser.Browser/Handlers/KeyboardHandler.cs
index a570cbd9..33898547 100644
--- a/SafeExamBrowser.Browser/Handlers/KeyboardHandler.cs
+++ b/SafeExamBrowser.Browser/Handlers/KeyboardHandler.cs
@@ -13,7 +13,7 @@ using SafeExamBrowser.Contracts.UserInterface;
namespace SafeExamBrowser.Browser.Handlers
{
///
- /// See https://cefsharp.github.io/api/71.0.0/html/T_CefSharp_IKeyboardHandler.htm.
+ /// See https://cefsharp.github.io/api/73.1.x/html/T_CefSharp_IKeyboardHandler.htm.
///
internal class KeyboardHandler : IKeyboardHandler
{
diff --git a/SafeExamBrowser.Browser/Handlers/LifeSpanHandler.cs b/SafeExamBrowser.Browser/Handlers/LifeSpanHandler.cs
index cb2be37f..d984448f 100644
--- a/SafeExamBrowser.Browser/Handlers/LifeSpanHandler.cs
+++ b/SafeExamBrowser.Browser/Handlers/LifeSpanHandler.cs
@@ -12,7 +12,7 @@ using SafeExamBrowser.Browser.Events;
namespace SafeExamBrowser.Browser.Handlers
{
///
- /// See https://cefsharp.github.io/api/71.0.0/html/T_CefSharp_ILifeSpanHandler.htm.
+ /// See https://cefsharp.github.io/api/73.1.x/html/T_CefSharp_ILifeSpanHandler.htm.
///
internal class LifeSpanHandler : ILifeSpanHandler
{
diff --git a/SafeExamBrowser.Browser/Handlers/RequestHandler.cs b/SafeExamBrowser.Browser/Handlers/RequestHandler.cs
index f84b725b..8e90a64a 100644
--- a/SafeExamBrowser.Browser/Handlers/RequestHandler.cs
+++ b/SafeExamBrowser.Browser/Handlers/RequestHandler.cs
@@ -28,7 +28,11 @@ namespace SafeExamBrowser.Browser.Handlers
public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
- AppendCustomUserAgent(request);
+ // TODO: CEF does not yet support intercepting requests from service workers, thus the user agent must be statically set at browser
+ // startup for now. Once CEF has full support of service workers, the static user agent should be removed and the method below
+ // reactivated. See https://bitbucket.org/chromiumembedded/cef/issues/2622 for the current status of development.
+ // AppendCustomUserAgent(request);
+
ReplaceCustomScheme(request);
return base.OnBeforeResourceLoad(browserControl, browser, frame, request, callback);