From 483eec6ef82cb27fa2cf04830a4db15e991cf475 Mon Sep 17 00:00:00 2001 From: dbuechel Date: Fri, 18 Jan 2019 09:58:14 +0100 Subject: [PATCH] SEBWIN-106: Fixed loading / rendering issues with favicons and application instance button and enabled popups for default settings. --- .../BrowserApplicationController.cs | 14 +++--- SafeExamBrowser.Client/CompositionRoot.cs | 1 + .../Operations/InitializationOperation.cs | 50 +++++++++++++++++++ .../SafeExamBrowser.Client.csproj | 1 + .../ConfigurationData/DataValues.cs | 1 + SafeExamBrowser.Contracts/I18n/TextKey.cs | 1 + SafeExamBrowser.I18n/Text.xml | 3 ++ .../Controls/ApplicationInstanceButton.xaml | 4 +- 8 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 SafeExamBrowser.Client/Operations/InitializationOperation.cs diff --git a/SafeExamBrowser.Browser/BrowserApplicationController.cs b/SafeExamBrowser.Browser/BrowserApplicationController.cs index c36d6c94..9fbb3223 100644 --- a/SafeExamBrowser.Browser/BrowserApplicationController.cs +++ b/SafeExamBrowser.Browser/BrowserApplicationController.cs @@ -61,11 +61,11 @@ namespace SafeExamBrowser.Browser var cefSettings = InitializeCefSettings(); var success = Cef.Initialize(cefSettings, true, null); - logger.Info("Initialized browser engine."); + logger.Info("Initialized browser."); if (!success) { - throw new Exception("Failed to initialize the browser engine!"); + throw new Exception("Failed to initialize browser!"); } } @@ -92,7 +92,7 @@ namespace SafeExamBrowser.Browser Cef.Shutdown(); - logger.Info("Terminated browser engine."); + logger.Info("Terminated browser."); } private void CreateNewInstance(BrowserSettings custom = null) @@ -127,10 +127,10 @@ namespace SafeExamBrowser.Browser UserAgent = settings.UseCustomUserAgent ? settings.CustomUserAgent : string.Empty }; - logger.Debug($"Browser cache path: {cefSettings.CachePath}"); - logger.Debug($"Browser log file: {cefSettings.LogFile}"); - logger.Debug($"Browser log severity: {cefSettings.LogSeverity}"); - logger.Debug($"Browser engine version: Chromium {Cef.ChromiumVersion}, CEF {Cef.CefVersion}, CefSharp {Cef.CefSharpVersion}"); + logger.Debug($"Cache path: {cefSettings.CachePath}"); + logger.Debug($"Engine version: Chromium {Cef.ChromiumVersion}, CEF {Cef.CefVersion}, CefSharp {Cef.CefSharpVersion}"); + logger.Debug($"Log file: {cefSettings.LogFile}"); + logger.Debug($"Log severity: {cefSettings.LogSeverity}"); return cefSettings; } diff --git a/SafeExamBrowser.Client/CompositionRoot.cs b/SafeExamBrowser.Client/CompositionRoot.cs index 38f12e9a..58cde198 100644 --- a/SafeExamBrowser.Client/CompositionRoot.cs +++ b/SafeExamBrowser.Client/CompositionRoot.cs @@ -95,6 +95,7 @@ namespace SafeExamBrowser.Client var operations = new Queue(); + operations.Enqueue(new InitializationOperation(logger)); operations.Enqueue(new I18nOperation(logger, text, textResource)); operations.Enqueue(new RuntimeConnectionOperation(logger, runtimeProxy, startupToken)); operations.Enqueue(new ConfigurationOperation(configuration, logger, runtimeProxy)); diff --git a/SafeExamBrowser.Client/Operations/InitializationOperation.cs b/SafeExamBrowser.Client/Operations/InitializationOperation.cs new file mode 100644 index 00000000..8bf97478 --- /dev/null +++ b/SafeExamBrowser.Client/Operations/InitializationOperation.cs @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET) + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +using System.Net; +using SafeExamBrowser.Contracts.Core.OperationModel; +using SafeExamBrowser.Contracts.Core.OperationModel.Events; +using SafeExamBrowser.Contracts.I18n; +using SafeExamBrowser.Contracts.Logging; + +namespace SafeExamBrowser.Client.Operations +{ + internal class InitializationOperation : IOperation + { + private ILogger logger; + + public event ActionRequiredEventHandler ActionRequired { add { } remove { } } + public event StatusChangedEventHandler StatusChanged; + + public InitializationOperation(ILogger logger) + { + this.logger = logger; + } + + public OperationResult Perform() + { + logger.Info("Initializing client application..."); + StatusChanged?.Invoke(TextKey.OperationStatus_InitializeClient); + + ConfigureSecurityProtocols(); + + return OperationResult.Success; + } + + public OperationResult Revert() + { + return OperationResult.Success; + } + + private void ConfigureSecurityProtocols() + { + // Enables the security protocols specified below for all web requests which are made during application runtime. + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; + } + } +} diff --git a/SafeExamBrowser.Client/SafeExamBrowser.Client.csproj b/SafeExamBrowser.Client/SafeExamBrowser.Client.csproj index f056f46a..a8b50edf 100644 --- a/SafeExamBrowser.Client/SafeExamBrowser.Client.csproj +++ b/SafeExamBrowser.Client/SafeExamBrowser.Client.csproj @@ -74,6 +74,7 @@ + diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs index 05b8422e..c9049ee8 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs @@ -97,6 +97,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData settings.Browser.AllowDownloads = false; settings.Browser.AllowForwardNavigation = false; settings.Browser.AllowPageZoom = true; + settings.Browser.AllowPopups = true; settings.Browser.AllowReloading = true; settings.Keyboard.AllowAltEsc = false; diff --git a/SafeExamBrowser.Contracts/I18n/TextKey.cs b/SafeExamBrowser.Contracts/I18n/TextKey.cs index c8256c81..72ac5cb8 100644 --- a/SafeExamBrowser.Contracts/I18n/TextKey.cs +++ b/SafeExamBrowser.Contracts/I18n/TextKey.cs @@ -58,6 +58,7 @@ namespace SafeExamBrowser.Contracts.I18n OperationStatus_EmptyClipboard, OperationStatus_FinalizeServiceSession, OperationStatus_InitializeBrowser, + OperationStatus_InitializeClient, OperationStatus_InitializeConfiguration, OperationStatus_InitializeKioskMode, OperationStatus_InitializeProcessMonitoring, diff --git a/SafeExamBrowser.I18n/Text.xml b/SafeExamBrowser.I18n/Text.xml index 034498ac..f3a412cc 100644 --- a/SafeExamBrowser.I18n/Text.xml +++ b/SafeExamBrowser.I18n/Text.xml @@ -126,6 +126,9 @@ Initializing browser + + Initializing client application + Initializing application configuration diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ApplicationInstanceButton.xaml b/SafeExamBrowser.UserInterface.Desktop/Controls/ApplicationInstanceButton.xaml index 089aa8a8..99ed13b9 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ApplicationInstanceButton.xaml +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ApplicationInstanceButton.xaml @@ -16,8 +16,8 @@