SEBWIN-358: Implemented user agent suffix.
This commit is contained in:
parent
6ad5d062db
commit
c43df2e712
4 changed files with 27 additions and 2 deletions
|
@ -247,15 +247,23 @@ namespace SafeExamBrowser.Browser
|
||||||
{
|
{
|
||||||
var osVersion = $"{Environment.OSVersion.Version.Major}.{Environment.OSVersion.Version.Minor}";
|
var osVersion = $"{Environment.OSVersion.Version.Major}.{Environment.OSVersion.Version.Minor}";
|
||||||
var sebVersion = $"SEB/{appConfig.ProgramInformationalVersion}";
|
var sebVersion = $"SEB/{appConfig.ProgramInformationalVersion}";
|
||||||
|
var userAgent = default(string);
|
||||||
|
|
||||||
if (settings.UseCustomUserAgent)
|
if (settings.UseCustomUserAgent)
|
||||||
{
|
{
|
||||||
return $"{settings.CustomUserAgent} {sebVersion}";
|
userAgent = $"{settings.CustomUserAgent} {sebVersion}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $"Mozilla/5.0 (Windows NT {osVersion}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{Cef.ChromiumVersion} {sebVersion}";
|
userAgent = $"Mozilla/5.0 (Windows NT {osVersion}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{Cef.ChromiumVersion} {sebVersion}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(settings.UserAgentSuffix))
|
||||||
|
{
|
||||||
|
userAgent = $"{userAgent} {settings.UserAgentSuffix}";
|
||||||
|
}
|
||||||
|
|
||||||
|
return userAgent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ToScheme(ProxyProtocol protocol)
|
private string ToScheme(ProxyProtocol protocol)
|
||||||
|
|
|
@ -126,6 +126,9 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||||
case Keys.Browser.StartUrl:
|
case Keys.Browser.StartUrl:
|
||||||
MapStartUrl(settings, value);
|
MapStartUrl(settings, value);
|
||||||
break;
|
break;
|
||||||
|
case Keys.Browser.UserAgentSuffix:
|
||||||
|
MapUserAgentSuffix(settings, value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,6 +406,14 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MapUserAgentSuffix(AppSettings settings, object value)
|
||||||
|
{
|
||||||
|
if (value is string suffix)
|
||||||
|
{
|
||||||
|
settings.Browser.UserAgentSuffix = suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MapFilterRules(AppSettings settings, object value)
|
private void MapFilterRules(AppSettings settings, object value)
|
||||||
{
|
{
|
||||||
const int ALLOW = 1;
|
const int ALLOW = 1;
|
||||||
|
|
|
@ -64,6 +64,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
internal const string StartUrl = "startURL";
|
internal const string StartUrl = "startURL";
|
||||||
internal const string UserAgentModeDesktop = "browserUserAgentWinDesktopMode";
|
internal const string UserAgentModeDesktop = "browserUserAgentWinDesktopMode";
|
||||||
internal const string UserAgentModeMobile = "browserUserAgentWinTouchMode";
|
internal const string UserAgentModeMobile = "browserUserAgentWinTouchMode";
|
||||||
|
internal const string UserAgentSuffix = "browserUserAgent";
|
||||||
|
|
||||||
internal static class AdditionalWindow
|
internal static class AdditionalWindow
|
||||||
{
|
{
|
||||||
|
|
|
@ -141,6 +141,11 @@ namespace SafeExamBrowser.Settings.Browser
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UseCustomUserAgent { get; set; }
|
public bool UseCustomUserAgent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A custom suffix to be appended to the user agent.
|
||||||
|
/// </summary>
|
||||||
|
public string UserAgentSuffix { get; set; }
|
||||||
|
|
||||||
public BrowserSettings()
|
public BrowserSettings()
|
||||||
{
|
{
|
||||||
AdditionalWindow = new WindowSettings();
|
AdditionalWindow = new WindowSettings();
|
||||||
|
|
Loading…
Reference in a new issue