From 42eccef5651ccb2cdd1be6ff34512fa9d8b7c9ce Mon Sep 17 00:00:00 2001 From: dbuechel Date: Wed, 18 Dec 2019 08:24:55 +0100 Subject: [PATCH] Cleaned and restructured browser settings namespace. --- .../Filters/IRequestFilter.cs | 2 +- .../Filters/IRule.cs | 2 +- .../Filters/IRuleFactory.cs | 2 +- .../Filters/RequestFilterTests.cs | 2 +- .../Filters/RuleFactoryTests.cs | 2 +- .../Filters/Rules/RegexRuleTests.cs | 2 +- .../Filters/Rules/SimplifiedRuleTests.cs | 2 +- SafeExamBrowser.Browser/BrowserApplication.cs | 1 + .../BrowserApplicationInstance.cs | 3 +- .../Filters/RequestFilter.cs | 2 +- .../Filters/RuleFactory.cs | 2 +- .../Filters/Rules/RegexRule.cs | 2 +- .../Filters/Rules/SimplifiedRule.cs | 2 +- .../Handlers/RequestHandler.cs | 2 +- .../Handlers/ResourceHandler.cs | 5 +- .../ConfigurationData/DataMapper.Browser.cs | 22 ++++---- .../ConfigurationData/DataValues.cs | 3 +- .../Browser/BrowserProxySettings.cs | 56 ------------------- .../Browser/BrowserSettings.cs | 16 +++--- .../Browser/{ => Filter}/FilterResult.cs | 2 +- .../{ => Filter}/FilterRuleSettings.cs | 2 +- .../Browser/{ => Filter}/FilterRuleType.cs | 2 +- ...serFilterSettings.cs => FilterSettings.cs} | 5 +- .../Browser/Proxy/ProxyConfiguration.cs | 49 ++++++++++++++++ .../Browser/{ => Proxy}/ProxyPolicy.cs | 6 +- .../Browser/{ => Proxy}/ProxyProtocol.cs | 2 +- .../Browser/ProxySettings.cs | 34 ++++++----- ...serWindowPosition.cs => WindowPosition.cs} | 2 +- ...serWindowSettings.cs => WindowSettings.cs} | 4 +- .../SafeExamBrowser.Settings.csproj | 18 +++--- .../BrowserWindow.xaml.cs | 8 +-- .../BrowserWindow.xaml.cs | 8 +-- 32 files changed, 140 insertions(+), 132 deletions(-) delete mode 100644 SafeExamBrowser.Settings/Browser/BrowserProxySettings.cs rename SafeExamBrowser.Settings/Browser/{ => Filter}/FilterResult.cs (92%) rename SafeExamBrowser.Settings/Browser/{ => Filter}/FilterRuleSettings.cs (94%) rename SafeExamBrowser.Settings/Browser/{ => Filter}/FilterRuleType.cs (92%) rename SafeExamBrowser.Settings/Browser/{BrowserFilterSettings.cs => FilterSettings.cs} (91%) create mode 100644 SafeExamBrowser.Settings/Browser/Proxy/ProxyConfiguration.cs rename SafeExamBrowser.Settings/Browser/{ => Proxy}/ProxyPolicy.cs (74%) rename SafeExamBrowser.Settings/Browser/{ => Proxy}/ProxyProtocol.cs (90%) rename SafeExamBrowser.Settings/Browser/{BrowserWindowPosition.cs => WindowPosition.cs} (92%) rename SafeExamBrowser.Settings/Browser/{BrowserWindowSettings.cs => WindowSettings.cs} (96%) diff --git a/SafeExamBrowser.Browser.Contracts/Filters/IRequestFilter.cs b/SafeExamBrowser.Browser.Contracts/Filters/IRequestFilter.cs index 4f5f0592..fd9eb5e6 100644 --- a/SafeExamBrowser.Browser.Contracts/Filters/IRequestFilter.cs +++ b/SafeExamBrowser.Browser.Contracts/Filters/IRequestFilter.cs @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; namespace SafeExamBrowser.Browser.Contracts.Filters { diff --git a/SafeExamBrowser.Browser.Contracts/Filters/IRule.cs b/SafeExamBrowser.Browser.Contracts/Filters/IRule.cs index 636c9734..95a99120 100644 --- a/SafeExamBrowser.Browser.Contracts/Filters/IRule.cs +++ b/SafeExamBrowser.Browser.Contracts/Filters/IRule.cs @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; namespace SafeExamBrowser.Browser.Contracts.Filters { diff --git a/SafeExamBrowser.Browser.Contracts/Filters/IRuleFactory.cs b/SafeExamBrowser.Browser.Contracts/Filters/IRuleFactory.cs index 8f7cd076..ddc824d3 100644 --- a/SafeExamBrowser.Browser.Contracts/Filters/IRuleFactory.cs +++ b/SafeExamBrowser.Browser.Contracts/Filters/IRuleFactory.cs @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; namespace SafeExamBrowser.Browser.Contracts.Filters { diff --git a/SafeExamBrowser.Browser.UnitTests/Filters/RequestFilterTests.cs b/SafeExamBrowser.Browser.UnitTests/Filters/RequestFilterTests.cs index 7c35734f..9b2f7064 100644 --- a/SafeExamBrowser.Browser.UnitTests/Filters/RequestFilterTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Filters/RequestFilterTests.cs @@ -11,7 +11,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using SafeExamBrowser.Browser.Contracts.Filters; using SafeExamBrowser.Browser.Filters; -using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; namespace SafeExamBrowser.Browser.UnitTests.Filters { diff --git a/SafeExamBrowser.Browser.UnitTests/Filters/RuleFactoryTests.cs b/SafeExamBrowser.Browser.UnitTests/Filters/RuleFactoryTests.cs index 1373e800..268f1052 100644 --- a/SafeExamBrowser.Browser.UnitTests/Filters/RuleFactoryTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Filters/RuleFactoryTests.cs @@ -10,7 +10,7 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using SafeExamBrowser.Browser.Filters; using SafeExamBrowser.Browser.Filters.Rules; -using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; namespace SafeExamBrowser.Browser.UnitTests.Filters { diff --git a/SafeExamBrowser.Browser.UnitTests/Filters/Rules/RegexRuleTests.cs b/SafeExamBrowser.Browser.UnitTests/Filters/Rules/RegexRuleTests.cs index d16d84df..7b6ee630 100644 --- a/SafeExamBrowser.Browser.UnitTests/Filters/Rules/RegexRuleTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Filters/Rules/RegexRuleTests.cs @@ -11,7 +11,7 @@ using System.Text.RegularExpressions; using Microsoft.VisualStudio.TestTools.UnitTesting; using SafeExamBrowser.Browser.Contracts.Filters; using SafeExamBrowser.Browser.Filters.Rules; -using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; namespace SafeExamBrowser.Browser.UnitTests.Filters.Rules { diff --git a/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs b/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs index e88952d6..e1c43dea 100644 --- a/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs @@ -11,7 +11,7 @@ using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using SafeExamBrowser.Browser.Contracts.Filters; using SafeExamBrowser.Browser.Filters.Rules; -using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; namespace SafeExamBrowser.Browser.UnitTests.Filters.Rules { diff --git a/SafeExamBrowser.Browser/BrowserApplication.cs b/SafeExamBrowser.Browser/BrowserApplication.cs index d3f8bad6..0b18ecf9 100644 --- a/SafeExamBrowser.Browser/BrowserApplication.cs +++ b/SafeExamBrowser.Browser/BrowserApplication.cs @@ -21,6 +21,7 @@ using SafeExamBrowser.Configuration.Contracts; using SafeExamBrowser.I18n.Contracts; using SafeExamBrowser.Logging.Contracts; using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Proxy; using SafeExamBrowser.Settings.Logging; using SafeExamBrowser.UserInterface.Contracts; using SafeExamBrowser.UserInterface.Contracts.MessageBox; diff --git a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs index 669780d9..b3dc3e78 100644 --- a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs +++ b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs @@ -21,6 +21,7 @@ using SafeExamBrowser.Configuration.Contracts; using SafeExamBrowser.I18n.Contracts; using SafeExamBrowser.Logging.Contracts; using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; using SafeExamBrowser.UserInterface.Contracts; using SafeExamBrowser.UserInterface.Contracts.Browser; using SafeExamBrowser.UserInterface.Contracts.MessageBox; @@ -44,7 +45,7 @@ namespace SafeExamBrowser.Browser private string url; private double zoomLevel; - private BrowserWindowSettings WindowSettings + private WindowSettings WindowSettings { get { return isMainInstance ? settings.MainWindow : settings.AdditionalWindow; } } diff --git a/SafeExamBrowser.Browser/Filters/RequestFilter.cs b/SafeExamBrowser.Browser/Filters/RequestFilter.cs index 54213545..5dba8fbc 100644 --- a/SafeExamBrowser.Browser/Filters/RequestFilter.cs +++ b/SafeExamBrowser.Browser/Filters/RequestFilter.cs @@ -9,7 +9,7 @@ using System; using System.Collections.Generic; using SafeExamBrowser.Browser.Contracts.Filters; -using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; namespace SafeExamBrowser.Browser.Filters { diff --git a/SafeExamBrowser.Browser/Filters/RuleFactory.cs b/SafeExamBrowser.Browser/Filters/RuleFactory.cs index 73bd2015..b1e43124 100644 --- a/SafeExamBrowser.Browser/Filters/RuleFactory.cs +++ b/SafeExamBrowser.Browser/Filters/RuleFactory.cs @@ -9,7 +9,7 @@ using System; using SafeExamBrowser.Browser.Contracts.Filters; using SafeExamBrowser.Browser.Filters.Rules; -using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; namespace SafeExamBrowser.Browser.Filters { diff --git a/SafeExamBrowser.Browser/Filters/Rules/RegexRule.cs b/SafeExamBrowser.Browser/Filters/Rules/RegexRule.cs index a9a55af5..0ba7aef6 100644 --- a/SafeExamBrowser.Browser/Filters/Rules/RegexRule.cs +++ b/SafeExamBrowser.Browser/Filters/Rules/RegexRule.cs @@ -9,7 +9,7 @@ using System; using System.Text.RegularExpressions; using SafeExamBrowser.Browser.Contracts.Filters; -using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; namespace SafeExamBrowser.Browser.Filters.Rules { diff --git a/SafeExamBrowser.Browser/Filters/Rules/SimplifiedRule.cs b/SafeExamBrowser.Browser/Filters/Rules/SimplifiedRule.cs index a2b886aa..fe5cbb2d 100644 --- a/SafeExamBrowser.Browser/Filters/Rules/SimplifiedRule.cs +++ b/SafeExamBrowser.Browser/Filters/Rules/SimplifiedRule.cs @@ -9,7 +9,7 @@ using System; using System.Text.RegularExpressions; using SafeExamBrowser.Browser.Contracts.Filters; -using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; namespace SafeExamBrowser.Browser.Filters.Rules { diff --git a/SafeExamBrowser.Browser/Handlers/RequestHandler.cs b/SafeExamBrowser.Browser/Handlers/RequestHandler.cs index 25bb15ab..cfbcddd8 100644 --- a/SafeExamBrowser.Browser/Handlers/RequestHandler.cs +++ b/SafeExamBrowser.Browser/Handlers/RequestHandler.cs @@ -13,7 +13,7 @@ using SafeExamBrowser.Browser.Events; using SafeExamBrowser.Configuration.Contracts; using SafeExamBrowser.I18n.Contracts; using SafeExamBrowser.Logging.Contracts; -using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; using BrowserSettings = SafeExamBrowser.Settings.Browser.BrowserSettings; namespace SafeExamBrowser.Browser.Handlers diff --git a/SafeExamBrowser.Browser/Handlers/ResourceHandler.cs b/SafeExamBrowser.Browser/Handlers/ResourceHandler.cs index d936a201..7144afc4 100644 --- a/SafeExamBrowser.Browser/Handlers/ResourceHandler.cs +++ b/SafeExamBrowser.Browser/Handlers/ResourceHandler.cs @@ -17,20 +17,21 @@ using SafeExamBrowser.Configuration.Contracts; using SafeExamBrowser.I18n.Contracts; using SafeExamBrowser.Logging.Contracts; using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; namespace SafeExamBrowser.Browser.Handlers { internal class ResourceHandler : CefSharp.Handler.ResourceRequestHandler { private AppConfig appConfig; - private BrowserFilterSettings settings; + private FilterSettings settings; private ILogger logger; private IRequestFilter filter; private IResourceHandler contentHandler; private IResourceHandler pageHandler; private IText text; - internal ResourceHandler(AppConfig appConfig, BrowserFilterSettings settings, IRequestFilter filter, ILogger logger, IText text) + internal ResourceHandler(AppConfig appConfig, FilterSettings settings, IRequestFilter filter, ILogger logger, IText text) { this.appConfig = appConfig; this.filter = filter; diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Browser.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Browser.cs index fe34111f..bf0e8e4d 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Browser.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.Browser.cs @@ -9,6 +9,8 @@ using System.Collections.Generic; using SafeExamBrowser.Settings; using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Filter; +using SafeExamBrowser.Settings.Browser.Proxy; using SafeExamBrowser.Settings.UserInterface; namespace SafeExamBrowser.Configuration.ConfigurationData @@ -272,7 +274,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData private void MapFtpProxy(AppSettings settings, IDictionary data) { - var proxy = new ProxySettings { Protocol = ProxyProtocol.Ftp }; + var proxy = new ProxyConfiguration { Protocol = ProxyProtocol.Ftp }; if (data.TryGetValue(Keys.Browser.Proxy.Ftp.Host, out var v) && v is string host) { @@ -304,7 +306,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData private void MapHttpProxy(AppSettings settings, IDictionary data) { - var proxy = new ProxySettings { Protocol = ProxyProtocol.Http }; + var proxy = new ProxyConfiguration { Protocol = ProxyProtocol.Http }; if (data.TryGetValue(Keys.Browser.Proxy.Http.Host, out var v) && v is string host) { @@ -336,7 +338,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData private void MapHttpsProxy(AppSettings settings, IDictionary data) { - var proxy = new ProxySettings { Protocol = ProxyProtocol.Https }; + var proxy = new ProxyConfiguration { Protocol = ProxyProtocol.Https }; if (data.TryGetValue(Keys.Browser.Proxy.Https.Host, out var v) && v is string host) { @@ -368,7 +370,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData private void MapSocksProxy(AppSettings settings, IDictionary data) { - var proxy = new ProxySettings { Protocol = ProxyProtocol.Socks }; + var proxy = new ProxyConfiguration { Protocol = ProxyProtocol.Socks }; if (data.TryGetValue(Keys.Browser.Proxy.Socks.Host, out var v) && v is string host) { @@ -458,13 +460,13 @@ namespace SafeExamBrowser.Configuration.ConfigurationData switch (position) { case LEFT: - settings.Browser.AdditionalWindow.Position = BrowserWindowPosition.Left; + settings.Browser.AdditionalWindow.Position = WindowPosition.Left; break; case CENTER: - settings.Browser.AdditionalWindow.Position = BrowserWindowPosition.Center; + settings.Browser.AdditionalWindow.Position = WindowPosition.Center; break; case RIGHT: - settings.Browser.AdditionalWindow.Position = BrowserWindowPosition.Right; + settings.Browser.AdditionalWindow.Position = WindowPosition.Right; break; } } @@ -481,13 +483,13 @@ namespace SafeExamBrowser.Configuration.ConfigurationData switch (position) { case LEFT: - settings.Browser.MainWindow.Position = BrowserWindowPosition.Left; + settings.Browser.MainWindow.Position = WindowPosition.Left; break; case CENTER: - settings.Browser.MainWindow.Position = BrowserWindowPosition.Center; + settings.Browser.MainWindow.Position = WindowPosition.Center; break; case RIGHT: - settings.Browser.MainWindow.Position = BrowserWindowPosition.Right; + settings.Browser.MainWindow.Position = WindowPosition.Right; break; } } diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs index 2b50c14d..ecc1f252 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs @@ -11,6 +11,7 @@ using System.IO; using SafeExamBrowser.Configuration.Contracts; using SafeExamBrowser.Settings; using SafeExamBrowser.Settings.Browser; +using SafeExamBrowser.Settings.Browser.Proxy; using SafeExamBrowser.Settings.Logging; using SafeExamBrowser.Settings.Service; using SafeExamBrowser.Settings.UserInterface; @@ -116,7 +117,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData settings.Browser.AdditionalWindow.AllowForwardNavigation = true; settings.Browser.AdditionalWindow.AllowReloading = true; settings.Browser.AdditionalWindow.FullScreenMode = false; - settings.Browser.AdditionalWindow.Position = BrowserWindowPosition.Right; + settings.Browser.AdditionalWindow.Position = WindowPosition.Right; settings.Browser.AdditionalWindow.RelativeHeight = 100; settings.Browser.AdditionalWindow.RelativeWidth = 50; settings.Browser.AdditionalWindow.ShowReloadWarning = false; diff --git a/SafeExamBrowser.Settings/Browser/BrowserProxySettings.cs b/SafeExamBrowser.Settings/Browser/BrowserProxySettings.cs deleted file mode 100644 index ea7471e3..00000000 --- a/SafeExamBrowser.Settings/Browser/BrowserProxySettings.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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; -using System.Collections.Generic; - -namespace SafeExamBrowser.Settings.Browser -{ - /// - /// Defines the proxy settings for the browser engine. - /// - [Serializable] - public class BrowserProxySettings - { - /// - /// Determines whether proxy auto-configuration should be used. Requires a valid URL defined in . - /// - public bool AutoConfigure { get; set; } - - /// - /// A valid URL to a proxy auto-configuration file (.pac). Is only evaluated if is enabled. - /// - public string AutoConfigureUrl { get; set; } - - /// - /// Forces proxy auto-detection by the browser engine. - /// - public bool AutoDetect { get; set; } - - /// - /// A list of hosts for which all proxy settings should be bypassed. - /// - public IList BypassList { get; set; } - - /// - /// The proxy policy to be used. - /// - public ProxyPolicy Policy { get; set; } - - /// - /// Defines all proxies to be used. - /// - public IList Proxies { get; set; } - - public BrowserProxySettings() - { - BypassList = new List(); - Proxies = new List(); - } - } -} diff --git a/SafeExamBrowser.Settings/Browser/BrowserSettings.cs b/SafeExamBrowser.Settings/Browser/BrowserSettings.cs index 9d6b9c9d..3995efbf 100644 --- a/SafeExamBrowser.Settings/Browser/BrowserSettings.cs +++ b/SafeExamBrowser.Settings/Browser/BrowserSettings.cs @@ -19,7 +19,7 @@ namespace SafeExamBrowser.Settings.Browser /// /// The settings to be used for additional browser windows. /// - public BrowserWindowSettings AdditionalWindow { get; set; } + public WindowSettings AdditionalWindow { get; set; } /// /// Determines whether the user will be allowed to download configuration files. @@ -44,12 +44,12 @@ namespace SafeExamBrowser.Settings.Browser /// /// The settings to be used for the browser request filter. /// - public BrowserFilterSettings Filter { get; set; } + public FilterSettings Filter { get; set; } /// /// The settings to be used for the main browser window. /// - public BrowserWindowSettings MainWindow { get; set; } + public WindowSettings MainWindow { get; set; } /// /// Determines how attempts to open a popup are handled. @@ -59,7 +59,7 @@ namespace SafeExamBrowser.Settings.Browser /// /// Determines the proxy settings to be used by the browser. /// - public BrowserProxySettings Proxy { get; set; } + public ProxySettings Proxy { get; set; } /// /// The URL with which the main browser window will be loaded. @@ -73,10 +73,10 @@ namespace SafeExamBrowser.Settings.Browser public BrowserSettings() { - AdditionalWindow = new BrowserWindowSettings(); - Filter = new BrowserFilterSettings(); - MainWindow = new BrowserWindowSettings(); - Proxy = new BrowserProxySettings(); + AdditionalWindow = new WindowSettings(); + Filter = new FilterSettings(); + MainWindow = new WindowSettings(); + Proxy = new ProxySettings(); } } } diff --git a/SafeExamBrowser.Settings/Browser/FilterResult.cs b/SafeExamBrowser.Settings/Browser/Filter/FilterResult.cs similarity index 92% rename from SafeExamBrowser.Settings/Browser/FilterResult.cs rename to SafeExamBrowser.Settings/Browser/Filter/FilterResult.cs index ee0364b6..e756ee45 100644 --- a/SafeExamBrowser.Settings/Browser/FilterResult.cs +++ b/SafeExamBrowser.Settings/Browser/Filter/FilterResult.cs @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -namespace SafeExamBrowser.Settings.Browser +namespace SafeExamBrowser.Settings.Browser.Filter { /// /// Defines all possible results of a request filter operation. diff --git a/SafeExamBrowser.Settings/Browser/FilterRuleSettings.cs b/SafeExamBrowser.Settings/Browser/Filter/FilterRuleSettings.cs similarity index 94% rename from SafeExamBrowser.Settings/Browser/FilterRuleSettings.cs rename to SafeExamBrowser.Settings/Browser/Filter/FilterRuleSettings.cs index 56d131e8..c6ebe64c 100644 --- a/SafeExamBrowser.Settings/Browser/FilterRuleSettings.cs +++ b/SafeExamBrowser.Settings/Browser/Filter/FilterRuleSettings.cs @@ -8,7 +8,7 @@ using System; -namespace SafeExamBrowser.Settings.Browser +namespace SafeExamBrowser.Settings.Browser.Filter { /// /// Defines the settings for a request filter rule. diff --git a/SafeExamBrowser.Settings/Browser/FilterRuleType.cs b/SafeExamBrowser.Settings/Browser/Filter/FilterRuleType.cs similarity index 92% rename from SafeExamBrowser.Settings/Browser/FilterRuleType.cs rename to SafeExamBrowser.Settings/Browser/Filter/FilterRuleType.cs index 4f2ae216..93c09f16 100644 --- a/SafeExamBrowser.Settings/Browser/FilterRuleType.cs +++ b/SafeExamBrowser.Settings/Browser/Filter/FilterRuleType.cs @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -namespace SafeExamBrowser.Settings.Browser +namespace SafeExamBrowser.Settings.Browser.Filter { /// /// Defines all possible filter rule types. diff --git a/SafeExamBrowser.Settings/Browser/BrowserFilterSettings.cs b/SafeExamBrowser.Settings/Browser/FilterSettings.cs similarity index 91% rename from SafeExamBrowser.Settings/Browser/BrowserFilterSettings.cs rename to SafeExamBrowser.Settings/Browser/FilterSettings.cs index 1c289b25..f7d75bb0 100644 --- a/SafeExamBrowser.Settings/Browser/BrowserFilterSettings.cs +++ b/SafeExamBrowser.Settings/Browser/FilterSettings.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; +using SafeExamBrowser.Settings.Browser.Filter; namespace SafeExamBrowser.Settings.Browser { @@ -15,7 +16,7 @@ namespace SafeExamBrowser.Settings.Browser /// Defines all settings for the request filter of the browser. /// [Serializable] - public class BrowserFilterSettings + public class FilterSettings { /// /// Defines whether content requests for a web page should be filtered according to the defined . @@ -32,7 +33,7 @@ namespace SafeExamBrowser.Settings.Browser /// public IList Rules { get; set; } - public BrowserFilterSettings() + public FilterSettings() { Rules = new List(); } diff --git a/SafeExamBrowser.Settings/Browser/Proxy/ProxyConfiguration.cs b/SafeExamBrowser.Settings/Browser/Proxy/ProxyConfiguration.cs new file mode 100644 index 00000000..f84c60ec --- /dev/null +++ b/SafeExamBrowser.Settings/Browser/Proxy/ProxyConfiguration.cs @@ -0,0 +1,49 @@ +/* + * 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; + +namespace SafeExamBrowser.Settings.Browser.Proxy +{ + /// + /// Defines the configuration of a proxy server. + /// + [Serializable] + public class ProxyConfiguration + { + /// + /// The host name or IP address of the proxy server. + /// + public string Host { get; set; } + + /// + /// The password to be used for authentication. + /// + public string Password { get; set; } + + /// + /// The port of the proxy server. + /// + public int Port { get; set; } + + /// + /// The protocol of the proxy server. + /// + public ProxyProtocol Protocol { get; set; } + + /// + /// Determines whether the proxy server requires authentication. + /// + public bool RequiresAuthentication { get; set; } + + /// + /// The username to be used for authentication. + /// + public string Username { get; set; } + } +} diff --git a/SafeExamBrowser.Settings/Browser/ProxyPolicy.cs b/SafeExamBrowser.Settings/Browser/Proxy/ProxyPolicy.cs similarity index 74% rename from SafeExamBrowser.Settings/Browser/ProxyPolicy.cs rename to SafeExamBrowser.Settings/Browser/Proxy/ProxyPolicy.cs index b0a090a9..ea43f8dc 100644 --- a/SafeExamBrowser.Settings/Browser/ProxyPolicy.cs +++ b/SafeExamBrowser.Settings/Browser/Proxy/ProxyPolicy.cs @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -namespace SafeExamBrowser.Settings.Browser +namespace SafeExamBrowser.Settings.Browser.Proxy { /// /// Defines all currently supported proxy policies for the browser. @@ -14,12 +14,12 @@ namespace SafeExamBrowser.Settings.Browser public enum ProxyPolicy { /// - /// Use custom proxy settings as defined in . + /// Use custom proxy settings as defined in . /// Custom, /// - /// Use the proxy settings of the operating system (i.e. ignore all custom settings defined in ). + /// Use the proxy settings of the operating system (i.e. ignore all custom settings defined in ). /// System } diff --git a/SafeExamBrowser.Settings/Browser/ProxyProtocol.cs b/SafeExamBrowser.Settings/Browser/Proxy/ProxyProtocol.cs similarity index 90% rename from SafeExamBrowser.Settings/Browser/ProxyProtocol.cs rename to SafeExamBrowser.Settings/Browser/Proxy/ProxyProtocol.cs index 2d1d2657..a3e57491 100644 --- a/SafeExamBrowser.Settings/Browser/ProxyProtocol.cs +++ b/SafeExamBrowser.Settings/Browser/Proxy/ProxyProtocol.cs @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -namespace SafeExamBrowser.Settings.Browser +namespace SafeExamBrowser.Settings.Browser.Proxy { /// /// Defines all protocols currently supported for proxies. diff --git a/SafeExamBrowser.Settings/Browser/ProxySettings.cs b/SafeExamBrowser.Settings/Browser/ProxySettings.cs index 420c3d8d..ecbdf183 100644 --- a/SafeExamBrowser.Settings/Browser/ProxySettings.cs +++ b/SafeExamBrowser.Settings/Browser/ProxySettings.cs @@ -7,43 +7,51 @@ */ using System; +using System.Collections.Generic; +using SafeExamBrowser.Settings.Browser.Proxy; namespace SafeExamBrowser.Settings.Browser { /// - /// Defines the settings for a proxy server. + /// Defines the proxy settings for the browser engine. /// [Serializable] public class ProxySettings { /// - /// The host name or IP address of the proxy server. + /// Determines whether proxy auto-configuration should be used. Requires a valid URL defined in . /// - public string Host { get; set; } + public bool AutoConfigure { get; set; } /// - /// The password to be used for authentication. + /// A valid URL to a proxy auto-configuration file (.pac). Is only evaluated if is enabled. /// - public string Password { get; set; } + public string AutoConfigureUrl { get; set; } /// - /// The port of the proxy server. + /// Forces proxy auto-detection by the browser engine. /// - public int Port { get; set; } + public bool AutoDetect { get; set; } /// - /// The protocol of the proxy server. + /// A list of hosts for which all proxy settings should be bypassed. /// - public ProxyProtocol Protocol { get; set; } + public IList BypassList { get; set; } /// - /// Determines whether the proxy server requires authentication. + /// The proxy policy to be used. /// - public bool RequiresAuthentication { get; set; } + public ProxyPolicy Policy { get; set; } /// - /// The username to be used for authentication. + /// Defines all proxies to be used. /// - public string Username { get; set; } + public IList Proxies { get; set; } + + public ProxySettings() + { + BypassList = new List(); + Proxies = new List(); + } } } diff --git a/SafeExamBrowser.Settings/Browser/BrowserWindowPosition.cs b/SafeExamBrowser.Settings/Browser/WindowPosition.cs similarity index 92% rename from SafeExamBrowser.Settings/Browser/BrowserWindowPosition.cs rename to SafeExamBrowser.Settings/Browser/WindowPosition.cs index f1dfce02..31148bb7 100644 --- a/SafeExamBrowser.Settings/Browser/BrowserWindowPosition.cs +++ b/SafeExamBrowser.Settings/Browser/WindowPosition.cs @@ -11,7 +11,7 @@ namespace SafeExamBrowser.Settings.Browser /// /// Defines the initial position of a browser window. /// - public enum BrowserWindowPosition + public enum WindowPosition { Left, Center, diff --git a/SafeExamBrowser.Settings/Browser/BrowserWindowSettings.cs b/SafeExamBrowser.Settings/Browser/WindowSettings.cs similarity index 96% rename from SafeExamBrowser.Settings/Browser/BrowserWindowSettings.cs rename to SafeExamBrowser.Settings/Browser/WindowSettings.cs index c3d8f754..4a23d105 100644 --- a/SafeExamBrowser.Settings/Browser/BrowserWindowSettings.cs +++ b/SafeExamBrowser.Settings/Browser/WindowSettings.cs @@ -14,7 +14,7 @@ namespace SafeExamBrowser.Settings.Browser /// Defines all settings for a window of the browser engine. /// [Serializable] - public class BrowserWindowSettings + public class WindowSettings { /// /// Optionally defines the height of the browser window in physical pixels. @@ -59,7 +59,7 @@ namespace SafeExamBrowser.Settings.Browser /// /// Determines the initial position of the browser window (if it is not maximized). /// - public BrowserWindowPosition Position { get; set; } + public WindowPosition Position { get; set; } /// /// Optionally defines the height of the browser window as percentage of the working area height. diff --git a/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj b/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj index 1103625c..c74a4985 100644 --- a/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj +++ b/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj @@ -57,18 +57,18 @@ - + - - - - - + + + + + - - - + + + diff --git a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs index 5fe6fceb..74caf93f 100644 --- a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs @@ -34,7 +34,7 @@ namespace SafeExamBrowser.UserInterface.Desktop private IText text; private WindowClosingEventHandler closing; - private BrowserWindowSettings WindowSettings + private WindowSettings WindowSettings { get { return isMainWindow ? settings.MainWindow : settings.AdditionalWindow; } } @@ -310,13 +310,13 @@ namespace SafeExamBrowser.UserInterface.Desktop switch (WindowSettings.Position) { - case BrowserWindowPosition.Left: + case WindowPosition.Left: Left = 0; break; - case BrowserWindowPosition.Center: + case WindowPosition.Center: Left = (SystemParameters.WorkArea.Width / 2) - (Width / 2); break; - case BrowserWindowPosition.Right: + case WindowPosition.Right: Left = SystemParameters.WorkArea.Width - Width; break; } diff --git a/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml.cs index 19b5b41b..58caa529 100644 --- a/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/BrowserWindow.xaml.cs @@ -34,7 +34,7 @@ namespace SafeExamBrowser.UserInterface.Mobile private IText text; private WindowClosingEventHandler closing; - private BrowserWindowSettings WindowSettings + private WindowSettings WindowSettings { get { return isMainWindow ? settings.MainWindow : settings.AdditionalWindow; } } @@ -319,13 +319,13 @@ namespace SafeExamBrowser.UserInterface.Mobile switch (WindowSettings.Position) { - case BrowserWindowPosition.Left: + case WindowPosition.Left: Left = 0; break; - case BrowserWindowPosition.Center: + case WindowPosition.Center: Left = (SystemParameters.WorkArea.Width / 2) - (Width / 2); break; - case BrowserWindowPosition.Right: + case WindowPosition.Right: Left = SystemParameters.WorkArea.Width - Width; break; }