From 8656363a7adbbc7a3aad17eff12f3e4dd2c6afff Mon Sep 17 00:00:00 2001 From: dbuechel Date: Wed, 8 May 2019 13:53:38 +0200 Subject: [PATCH] SEBWIN-325: Only update the favicon if it really exists. --- .../BrowserApplicationInstance.cs | 16 +++++++++++++--- .../SafeExamBrowser.Browser.csproj | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs index f14f20a3..2e7ee6eb 100644 --- a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs +++ b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs @@ -7,6 +7,7 @@ */ using System; +using System.Net.Http; using SafeExamBrowser.Browser.Events; using SafeExamBrowser.Browser.Handlers; using SafeExamBrowser.Contracts.Applications; @@ -28,6 +29,7 @@ namespace SafeExamBrowser.Browser private AppConfig appConfig; private IBrowserControl control; private IBrowserWindow window; + private HttpClient httpClient; private bool isMainInstance; private IMessageBox messageBox; private IModuleLogger logger; @@ -64,6 +66,7 @@ namespace SafeExamBrowser.Browser { this.appConfig = appConfig; this.Id = id; + this.httpClient = new HttpClient(); this.isMainInstance = isMainInstance; this.messageBox = messageBox; this.logger = logger; @@ -133,10 +136,17 @@ namespace SafeExamBrowser.Browser private void DisplayHandler_FaviconChanged(string uri) { - var icon = new BrowserIconResource(uri); + var request = new HttpRequestMessage(HttpMethod.Head, uri); + var response = httpClient.SendAsync(request).ContinueWith(task => + { + if (task.IsCompleted && task.Result.IsSuccessStatusCode) + { + var icon = new BrowserIconResource(uri); - IconChanged?.Invoke(icon); - window.UpdateIcon(icon); + IconChanged?.Invoke(icon); + window.UpdateIcon(icon); + } + }); } private void DownloadHandler_ConfigurationDownloadRequested(string fileName, DownloadEventArgs args) diff --git a/SafeExamBrowser.Browser/SafeExamBrowser.Browser.csproj b/SafeExamBrowser.Browser/SafeExamBrowser.Browser.csproj index c4b7a1a1..580ece37 100644 --- a/SafeExamBrowser.Browser/SafeExamBrowser.Browser.csproj +++ b/SafeExamBrowser.Browser/SafeExamBrowser.Browser.csproj @@ -59,6 +59,7 @@ +