Skip to content

Commit

Permalink
Re-introduced favicon as window icon and updated browser engine.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbuechel committed Dec 13, 2022
1 parent 0f7404b commit 8fea79c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 18 deletions.
28 changes: 28 additions & 0 deletions PPA/Handlers/DisplayHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net.Http;
using System.Windows.Forms;
using CefSharp;
using CefSharp.Enums;
Expand All @@ -10,10 +13,12 @@ namespace PPA.Handlers
internal class DisplayHandler : IDisplayHandler
{
private readonly Form form;
private readonly HttpClient httpClient;

internal DisplayHandler(Form form)
{
this.form = form;
this.httpClient = new HttpClient();
}

public void OnAddressChanged(IWebBrowser chromiumWebBrowser, AddressChangedEventArgs addressChangedArgs)
Expand All @@ -37,6 +42,29 @@ public bool OnCursorChange(IWebBrowser chromiumWebBrowser, IBrowser browser, Int

public void OnFaviconUrlChange(IWebBrowser chromiumWebBrowser, IBrowser browser, IList<string> urls)
{
var request = new HttpRequestMessage(HttpMethod.Get, urls.First());
var response = httpClient.SendAsync(request).ContinueWith(task =>
{
if (task.IsCompleted && task.Result.IsSuccessStatusCode)
{
task.Result.Content.ReadAsStreamAsync().ContinueWith(stream =>
{
if (stream.IsCompleted)
{
form.Invoke(new Action(() =>
{
try
{
form.Icon = new Icon(stream.Result);
}
catch
{
}
}));
}
});
}
});
}

public void OnFullscreenModeChange(IWebBrowser chromiumWebBrowser, IBrowser browser, bool fullscreen)
Expand Down
28 changes: 14 additions & 14 deletions PPA/PPA.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\CefSharp.Common.105.3.390\build\CefSharp.Common.props" Condition="Exists('..\packages\CefSharp.Common.105.3.390\build\CefSharp.Common.props')" />
<Import Project="..\packages\cef.redist.x86.105.3.39\build\cef.redist.x86.props" Condition="Exists('..\packages\cef.redist.x86.105.3.39\build\cef.redist.x86.props')" />
<Import Project="..\packages\cef.redist.x64.105.3.39\build\cef.redist.x64.props" Condition="Exists('..\packages\cef.redist.x64.105.3.39\build\cef.redist.x64.props')" />
<Import Project="..\packages\CefSharp.Common.107.1.120\build\CefSharp.Common.props" Condition="Exists('..\packages\CefSharp.Common.107.1.120\build\CefSharp.Common.props')" />
<Import Project="..\packages\cef.redist.x86.107.1.12\build\cef.redist.x86.props" Condition="Exists('..\packages\cef.redist.x86.107.1.12\build\cef.redist.x86.props')" />
<Import Project="..\packages\cef.redist.x64.107.1.12\build\cef.redist.x64.props" Condition="Exists('..\packages\cef.redist.x64.107.1.12\build\cef.redist.x64.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -45,14 +45,14 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="CefSharp, Version=105.3.390.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL">
<HintPath>..\packages\CefSharp.Common.105.3.390\lib\net452\CefSharp.dll</HintPath>
<Reference Include="CefSharp, Version=107.1.120.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL">
<HintPath>..\packages\CefSharp.Common.107.1.120\lib\net452\CefSharp.dll</HintPath>
</Reference>
<Reference Include="CefSharp.Core, Version=105.3.390.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL">
<HintPath>..\packages\CefSharp.Common.105.3.390\lib\net452\CefSharp.Core.dll</HintPath>
<Reference Include="CefSharp.Core, Version=107.1.120.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL">
<HintPath>..\packages\CefSharp.Common.107.1.120\lib\net452\CefSharp.Core.dll</HintPath>
</Reference>
<Reference Include="CefSharp.WinForms, Version=105.3.390.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL">
<HintPath>..\packages\CefSharp.WinForms.105.3.390\lib\net462\CefSharp.WinForms.dll</HintPath>
<Reference Include="CefSharp.WinForms, Version=107.1.120.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL">
<HintPath>..\packages\CefSharp.WinForms.107.1.120\lib\net462\CefSharp.WinForms.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
Expand Down Expand Up @@ -90,10 +90,10 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\cef.redist.x64.105.3.39\build\cef.redist.x64.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.105.3.39\build\cef.redist.x64.props'))" />
<Error Condition="!Exists('..\packages\cef.redist.x86.105.3.39\build\cef.redist.x86.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.105.3.39\build\cef.redist.x86.props'))" />
<Error Condition="!Exists('..\packages\CefSharp.Common.105.3.390\build\CefSharp.Common.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Common.105.3.390\build\CefSharp.Common.props'))" />
<Error Condition="!Exists('..\packages\CefSharp.Common.105.3.390\build\CefSharp.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Common.105.3.390\build\CefSharp.Common.targets'))" />
<Error Condition="!Exists('..\packages\cef.redist.x64.107.1.12\build\cef.redist.x64.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.107.1.12\build\cef.redist.x64.props'))" />
<Error Condition="!Exists('..\packages\cef.redist.x86.107.1.12\build\cef.redist.x86.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.107.1.12\build\cef.redist.x86.props'))" />
<Error Condition="!Exists('..\packages\CefSharp.Common.107.1.120\build\CefSharp.Common.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Common.107.1.120\build\CefSharp.Common.props'))" />
<Error Condition="!Exists('..\packages\CefSharp.Common.107.1.120\build\CefSharp.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Common.107.1.120\build\CefSharp.Common.targets'))" />
</Target>
<Import Project="..\packages\CefSharp.Common.105.3.390\build\CefSharp.Common.targets" Condition="Exists('..\packages\CefSharp.Common.105.3.390\build\CefSharp.Common.targets')" />
<Import Project="..\packages\CefSharp.Common.107.1.120\build\CefSharp.Common.targets" Condition="Exists('..\packages\CefSharp.Common.107.1.120\build\CefSharp.Common.targets')" />
</Project>
8 changes: 4 additions & 4 deletions PPA/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="cef.redist.x64" version="105.3.39" targetFramework="net48" />
<package id="cef.redist.x86" version="105.3.39" targetFramework="net48" />
<package id="CefSharp.Common" version="105.3.390" targetFramework="net48" />
<package id="CefSharp.WinForms" version="105.3.390" targetFramework="net48" />
<package id="cef.redist.x64" version="107.1.12" targetFramework="net48" />
<package id="cef.redist.x86" version="107.1.12" targetFramework="net48" />
<package id="CefSharp.Common" version="107.1.120" targetFramework="net48" />
<package id="CefSharp.WinForms" version="107.1.120" targetFramework="net48" />
</packages>

0 comments on commit 8fea79c

Please sign in to comment.