diff --git a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs
index 57925e13..3374ffdf 100644
--- a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs
+++ b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs
@@ -59,7 +59,7 @@ namespace SafeExamBrowser.Browser
Id = Guid.NewGuid();
downloadHandler.ConfigurationDownloadRequested += (fileName, args) => ConfigurationDownloadRequested?.Invoke(fileName, args);
- control = new BrowserControl(settings, text);
+ control = new BrowserControl(appConfig, settings, text);
control.AddressChanged += Control_AddressChanged;
control.LoadingStateChanged += Control_LoadingStateChanged;
control.TitleChanged += Control_TitleChanged;
diff --git a/SafeExamBrowser.Browser/BrowserControl.cs b/SafeExamBrowser.Browser/BrowserControl.cs
index d8a2fc0a..f11bfcfc 100644
--- a/SafeExamBrowser.Browser/BrowserControl.cs
+++ b/SafeExamBrowser.Browser/BrowserControl.cs
@@ -9,6 +9,7 @@
using System;
using CefSharp.WinForms;
using SafeExamBrowser.Browser.Handlers;
+using SafeExamBrowser.Contracts.Configuration;
using SafeExamBrowser.Contracts.I18n;
using SafeExamBrowser.Contracts.UserInterface.Browser;
using SafeExamBrowser.Contracts.UserInterface.Browser.Events;
@@ -18,6 +19,7 @@ namespace SafeExamBrowser.Browser
{
internal class BrowserControl : ChromiumWebBrowser, IBrowserControl
{
+ private AppConfig appConfig;
private BrowserSettings settings;
private IText text;
@@ -43,8 +45,9 @@ namespace SafeExamBrowser.Browser
remove { titleChanged -= value; }
}
- public BrowserControl(BrowserSettings settings, IText text) : base(settings.StartUrl)
+ public BrowserControl(AppConfig appConfig, BrowserSettings settings, IText text) : base(settings.StartUrl)
{
+ this.appConfig = appConfig;
this.settings = settings;
this.text = text;
}
@@ -57,7 +60,7 @@ namespace SafeExamBrowser.Browser
KeyboardHandler = new KeyboardHandler(settings);
MenuHandler = new ContextMenuHandler(settings, text);
- RequestHandler = new RequestHandler();
+ RequestHandler = new RequestHandler(appConfig);
}
public void NavigateBackwards()
diff --git a/SafeExamBrowser.Browser/Handlers/RequestHandler.cs b/SafeExamBrowser.Browser/Handlers/RequestHandler.cs
index 6386b61a..bcd75dec 100644
--- a/SafeExamBrowser.Browser/Handlers/RequestHandler.cs
+++ b/SafeExamBrowser.Browser/Handlers/RequestHandler.cs
@@ -9,6 +9,7 @@
using System;
using CefSharp;
using CefSharp.Handler;
+using SafeExamBrowser.Contracts.Configuration;
namespace SafeExamBrowser.Browser.Handlers
{
@@ -17,16 +18,22 @@ namespace SafeExamBrowser.Browser.Handlers
///
internal class RequestHandler : DefaultRequestHandler
{
+ private AppConfig appConfig;
+
+ internal RequestHandler(AppConfig appConfig)
+ {
+ this.appConfig = appConfig;
+ }
+
public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
var uri = new Uri(request.Url);
- // TODO: Move to globals -> SafeExamBrowserUriScheme, SafeExamBrowserSecureUriScheme
- if (uri.Scheme == "seb")
+ if (uri.Scheme == appConfig.SebUriScheme)
{
request.Url = new UriBuilder(uri) { Scheme = Uri.UriSchemeHttp }.ToString();
}
- else if (uri.Scheme == "sebs")
+ else if (uri.Scheme == appConfig.SebUriSchemeSecure)
{
request.Url = new UriBuilder(uri) { Scheme = Uri.UriSchemeHttps }.ToString();
}
diff --git a/SafeExamBrowser.Configuration/ConfigurationRepository.cs b/SafeExamBrowser.Configuration/ConfigurationRepository.cs
index 1139d8d5..87c36702 100644
--- a/SafeExamBrowser.Configuration/ConfigurationRepository.cs
+++ b/SafeExamBrowser.Configuration/ConfigurationRepository.cs
@@ -123,6 +123,8 @@ namespace SafeExamBrowser.Configuration
appConfig.RuntimeId = Guid.NewGuid();
appConfig.RuntimeAddress = $"{BASE_ADDRESS}/runtime/{Guid.NewGuid()}";
appConfig.RuntimeLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Runtime.txt");
+ appConfig.SebUriScheme = "seb";
+ appConfig.SebUriSchemeSecure = "sebs";
appConfig.ServiceAddress = $"{BASE_ADDRESS}/service";
}
diff --git a/SafeExamBrowser.Contracts/Configuration/AppConfig.cs b/SafeExamBrowser.Contracts/Configuration/AppConfig.cs
index 8ac71cd7..73c81271 100644
--- a/SafeExamBrowser.Contracts/Configuration/AppConfig.cs
+++ b/SafeExamBrowser.Contracts/Configuration/AppConfig.cs
@@ -106,6 +106,16 @@ namespace SafeExamBrowser.Contracts.Configuration
///
public string RuntimeLogFile { get; set; }
+ ///
+ /// The URI scheme for SEB resources.
+ ///
+ public string SebUriScheme { get; set; }
+
+ ///
+ /// The URI scheme for secure SEB resources.
+ ///
+ public string SebUriSchemeSecure { get; set; }
+
///
/// The communication address of the service component.
///