SEBWIN-220: Moved SEB URI schemes to global application configuration.
This commit is contained in:
parent
72425f0d6c
commit
02d69005c0
5 changed files with 28 additions and 6 deletions
|
@ -59,7 +59,7 @@ namespace SafeExamBrowser.Browser
|
||||||
Id = Guid.NewGuid();
|
Id = Guid.NewGuid();
|
||||||
downloadHandler.ConfigurationDownloadRequested += (fileName, args) => ConfigurationDownloadRequested?.Invoke(fileName, args);
|
downloadHandler.ConfigurationDownloadRequested += (fileName, args) => ConfigurationDownloadRequested?.Invoke(fileName, args);
|
||||||
|
|
||||||
control = new BrowserControl(settings, text);
|
control = new BrowserControl(appConfig, settings, text);
|
||||||
control.AddressChanged += Control_AddressChanged;
|
control.AddressChanged += Control_AddressChanged;
|
||||||
control.LoadingStateChanged += Control_LoadingStateChanged;
|
control.LoadingStateChanged += Control_LoadingStateChanged;
|
||||||
control.TitleChanged += Control_TitleChanged;
|
control.TitleChanged += Control_TitleChanged;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
using System;
|
using System;
|
||||||
using CefSharp.WinForms;
|
using CefSharp.WinForms;
|
||||||
using SafeExamBrowser.Browser.Handlers;
|
using SafeExamBrowser.Browser.Handlers;
|
||||||
|
using SafeExamBrowser.Contracts.Configuration;
|
||||||
using SafeExamBrowser.Contracts.I18n;
|
using SafeExamBrowser.Contracts.I18n;
|
||||||
using SafeExamBrowser.Contracts.UserInterface.Browser;
|
using SafeExamBrowser.Contracts.UserInterface.Browser;
|
||||||
using SafeExamBrowser.Contracts.UserInterface.Browser.Events;
|
using SafeExamBrowser.Contracts.UserInterface.Browser.Events;
|
||||||
|
@ -18,6 +19,7 @@ namespace SafeExamBrowser.Browser
|
||||||
{
|
{
|
||||||
internal class BrowserControl : ChromiumWebBrowser, IBrowserControl
|
internal class BrowserControl : ChromiumWebBrowser, IBrowserControl
|
||||||
{
|
{
|
||||||
|
private AppConfig appConfig;
|
||||||
private BrowserSettings settings;
|
private BrowserSettings settings;
|
||||||
private IText text;
|
private IText text;
|
||||||
|
|
||||||
|
@ -43,8 +45,9 @@ namespace SafeExamBrowser.Browser
|
||||||
remove { titleChanged -= value; }
|
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.settings = settings;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +60,7 @@ namespace SafeExamBrowser.Browser
|
||||||
|
|
||||||
KeyboardHandler = new KeyboardHandler(settings);
|
KeyboardHandler = new KeyboardHandler(settings);
|
||||||
MenuHandler = new ContextMenuHandler(settings, text);
|
MenuHandler = new ContextMenuHandler(settings, text);
|
||||||
RequestHandler = new RequestHandler();
|
RequestHandler = new RequestHandler(appConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NavigateBackwards()
|
public void NavigateBackwards()
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
using System;
|
using System;
|
||||||
using CefSharp;
|
using CefSharp;
|
||||||
using CefSharp.Handler;
|
using CefSharp.Handler;
|
||||||
|
using SafeExamBrowser.Contracts.Configuration;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Browser.Handlers
|
namespace SafeExamBrowser.Browser.Handlers
|
||||||
{
|
{
|
||||||
|
@ -17,16 +18,22 @@ namespace SafeExamBrowser.Browser.Handlers
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
internal class RequestHandler : DefaultRequestHandler
|
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)
|
public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
|
||||||
{
|
{
|
||||||
var uri = new Uri(request.Url);
|
var uri = new Uri(request.Url);
|
||||||
|
|
||||||
// TODO: Move to globals -> SafeExamBrowserUriScheme, SafeExamBrowserSecureUriScheme
|
if (uri.Scheme == appConfig.SebUriScheme)
|
||||||
if (uri.Scheme == "seb")
|
|
||||||
{
|
{
|
||||||
request.Url = new UriBuilder(uri) { Scheme = Uri.UriSchemeHttp }.ToString();
|
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();
|
request.Url = new UriBuilder(uri) { Scheme = Uri.UriSchemeHttps }.ToString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,8 @@ namespace SafeExamBrowser.Configuration
|
||||||
appConfig.RuntimeId = Guid.NewGuid();
|
appConfig.RuntimeId = Guid.NewGuid();
|
||||||
appConfig.RuntimeAddress = $"{BASE_ADDRESS}/runtime/{Guid.NewGuid()}";
|
appConfig.RuntimeAddress = $"{BASE_ADDRESS}/runtime/{Guid.NewGuid()}";
|
||||||
appConfig.RuntimeLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Runtime.txt");
|
appConfig.RuntimeLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Runtime.txt");
|
||||||
|
appConfig.SebUriScheme = "seb";
|
||||||
|
appConfig.SebUriSchemeSecure = "sebs";
|
||||||
appConfig.ServiceAddress = $"{BASE_ADDRESS}/service";
|
appConfig.ServiceAddress = $"{BASE_ADDRESS}/service";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,16 @@ namespace SafeExamBrowser.Contracts.Configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string RuntimeLogFile { get; set; }
|
public string RuntimeLogFile { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The URI scheme for SEB resources.
|
||||||
|
/// </summary>
|
||||||
|
public string SebUriScheme { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The URI scheme for secure SEB resources.
|
||||||
|
/// </summary>
|
||||||
|
public string SebUriSchemeSecure { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The communication address of the service component.
|
/// The communication address of the service component.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue