1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-29 20:34:04 +02:00

Move general CefSharp implementation to a separate library project

This commit is contained in:
chylex 2022-02-12 16:30:21 +01:00
parent dd6776fef4
commit 09fac63ffc
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
44 changed files with 332 additions and 170 deletions

View File

@ -8,15 +8,19 @@
+ [Editors](#editors) + [Editors](#editors)
+ [Installers](#installers) + [Installers](#installers)
* [Solution Overview](#solution-overview) * [Solution Overview](#solution-overview)
+ [Project: TweetDuck](#project-tweetduck) + [Core Libraries](#core-libraries)
+ [Project: TweetDuck.Browser](#project-tweetduckbrowser) - [TweetLib.Core](#tweetlibcore)
+ [Project: TweetDuck.Video](#project-tweetduckvideo) - [TweetLib.Browser](#tweetlibbrowser)
+ [Project: TweetLib.Core](#project-tweetlibcore) - [TweetLib.Browser.CEF](#tweetlibbrowsercef)
+ [Project: TweetLib.Browser](#project-tweetlibbrowser) + [Windows Projects](#windows-projects)
+ [Project: TweetLib.Browser.CEF](#project-tweetlibbrowsercef) - [TweetDuck](#tweetduck)
+ [Project: TweetLib.Communication](#project-tweetlibcommunication) - [TweetDuck.Browser](#tweetduckbrowser)
+ [Project: TweetLib.Utils](#project-tweetlibutils) - [TweetDuck.Video](#tweetduckvideo)
+ [Projects: TweetTest.*](#projects-tweettest) - [TweetImpl.CefSharp](#tweetimplcefsharp)
+ [Miscellaneous](#miscellaneous)
- [TweetLib.Communication](#tweetlibcommunication)
- [TweetLib.Utils](#tweetlibutils)
- [TweetTest.*](#tweettest)
* [Development](#development) * [Development](#development)
+ [Building](#building) + [Building](#building)
+ [Debugging](#debugging) + [Debugging](#debugging)
@ -71,14 +75,14 @@ Open the solution file `TweetDuck.sln` in an IDE, and use the **Restore NuGet Pa
The solution contains several C# projects for executables and libraries, and F# projects for automated tests. The solution contains several C# projects for executables and libraries, and F# projects for automated tests.
Projects are organized into folders: Projects are organized into folders:
* Windows executables are in the `windows/` folder, and target `.NET Framework 4.7.2` + `C# 8.0` * Windows projects are in the `windows/` folder, and target `.NET Framework 4.7.2` + `C# 8.0`
* Libraries (`TweetLib.*`) are in the `lib/` folder, and target `.NET Standard 2.0` + `C# 9.0` * Libraries (`TweetLib.*`) are in the `lib/` folder, and target `.NET Standard 2.0` + `C# 9.0`
* Tests (`TweetTest.*`) are also in the `lib/` folder, and target `.NET Framework 4.7.2` + `F#` * Tests (`TweetTest.*`) are also in the `lib/` folder, and target `.NET Framework 4.7.2` + `F#`
Here are a few things to keep in mind: Here are a few things to keep in mind:
* Executable projects have their entry points in `Program.cs` * Executable projects have their entry points in `Program.cs`
* Library projects have their assembly information in `Lib.cs` * Library projects targeting `.NET Standard` have their assembly information in `Lib.cs`
* Most projects include a link to the `Version.cs` file in the root of the repository, which allows changing the version of all executables and library files in one place * All non-test projects include a link to the `Version.cs` file in the root of the repository, which allows changing the version of all executables and library files in one place
Web resource files (HTML, CSS, JS) are in the `Resources/` folder: Web resource files (HTML, CSS, JS) are in the `Resources/` folder:
* `Resources/Content/` contains all the core features of TweetDuck injected into the browser components * `Resources/Content/` contains all the core features of TweetDuck injected into the browser components
@ -87,31 +91,19 @@ Web resource files (HTML, CSS, JS) are in the `Resources/` folder:
These resource folders are linked as part of the `TweetLib.Core` project so they can be edited directly within an IDE. Alternatively, you can edit them using [VS Code](https://code.visualstudio.com/) by opening the workspace file `Resources/..code-workspace`. These resource folders are linked as part of the `TweetLib.Core` project so they can be edited directly within an IDE. Alternatively, you can edit them using [VS Code](https://code.visualstudio.com/) by opening the workspace file `Resources/..code-workspace`.
### Project: TweetDuck ### Core Libraries
Main Windows executable. It has a dependency on Windows Forms and [CefSharp](https://github.com/cefsharp/CefSharp/). Here you will mostly find implementations of interfaces from the library projects, and all the Windows and GUI code. #### TweetLib.Core
### Project: TweetDuck.Browser
Windows executable that hosts various Chromium processes. It depends on two specific DLLs from the [CefSharp](https://github.com/cefsharp/CefSharp/) package. After updating [CefSharp](https://github.com/cefsharp/CefSharp/), run the `windows/TweetDuck/Resources/PostCefUpdate.ps1` PowerShell script to update these dependencies to the new version.
### Project: TweetDuck.Video
Windows executable that hosts a video player, which is based on the WMPLib ActiveX component responsible for integrating Windows Media Player into .NET Framework.
By default, [CefSharp](https://github.com/cefsharp/CefSharp/) is not built with support for H.264 video playback due to software patent nonsense, and even though TweetDuck could be moved entirely to Europe where MPEG LA's patent means nothing, it would require building a custom version of Chromium which requires too many resources. Instead, when a Twitter video played, TweetDuck launches this video player process, which uses Windows Media Player to play H.264 videos.
### Project: TweetLib.Core
This library contains the core TweetDuck application and browser logic. It is built around simple dependency injection that makes it independent of any concrete OS, GUI framework, or browser implementation. This library contains the core TweetDuck application and browser logic. It is built around simple dependency injection that makes it independent of any concrete OS, GUI framework, or browser implementation.
To simplify porting to other systems, it is not necessary to implement all interfaces, but some functionality will be missing (for ex. if clipboard-related interfaces are not implemented, then context menus will not contain options to copy text or images to clipboard). To simplify porting to other systems, it is not necessary to implement all interfaces, but some functionality will be missing (for ex. if clipboard-related interfaces are not implemented, then context menus will not contain options to copy text or images to clipboard).
### Project: TweetLib.Browser #### TweetLib.Browser
This library provides a zero-dependency abstraction of browser components and logic. It defines interfaces, events, and container objects that are used by the `TweetLib.Core` library to describe how a browser should behave, while making as few assumptions about the actual browser implementation as possible. This library provides a zero-dependency abstraction of browser components and logic. It defines interfaces, events, and container objects that are used by the `TweetLib.Core` library to describe how a browser should behave, while making as few assumptions about the actual browser implementation as possible.
### Project: TweetLib.Browser.CEF #### TweetLib.Browser.CEF
This library is a partial implementation of `TweetLib.Browser` based on [CEF](https://bitbucket.org/chromiumembedded/cef/) interfaces and conventions. This library is a partial implementation of `TweetLib.Browser` based on [CEF](https://bitbucket.org/chromiumembedded/cef/) interfaces and conventions.
@ -119,15 +111,37 @@ While `TweetLib.Browser` is highly generic, most browser libraries are likely to
Note: The repository contains an experimental `linux` branch, which uses [CefGlue](https://gitlab.com/xiliumhq/chromiumembedded/cefglue) as its browser library instead of [CefSharp](https://github.com/cefsharp/CefSharp/) which only works on Windows. Note: The repository contains an experimental `linux` branch, which uses [CefGlue](https://gitlab.com/xiliumhq/chromiumembedded/cefglue) as its browser library instead of [CefSharp](https://github.com/cefsharp/CefSharp/) which only works on Windows.
### Project: TweetLib.Communication ### Windows Projects
#### TweetDuck
Main Windows executable. It has a dependency on [CefSharp](https://github.com/cefsharp/CefSharp/) and Windows Forms. Here you will find the entry point that bootstraps the main application, as well as code for GUIs and Windows-specific functionality.
#### TweetDuck.Browser
Windows executable that hosts various Chromium processes. It depends on two specific DLLs from the [CefSharp](https://github.com/cefsharp/CefSharp/) package. After updating [CefSharp](https://github.com/cefsharp/CefSharp/), run the `windows/TweetDuck/Resources/PostCefUpdate.ps1` PowerShell script to update these dependencies to the new version.
#### TweetDuck.Video
Windows executable that hosts a video player, which is based on the WMPLib ActiveX component responsible for integrating Windows Media Player into .NET Framework.
By default, [CefSharp](https://github.com/cefsharp/CefSharp/) is not built with support for H.264 video playback due to software patent nonsense, and even though TweetDuck could be moved entirely to Europe where MPEG LA's patent means nothing, it would require building a custom version of Chromium which requires too many resources. Instead, when a Twitter video played, TweetDuck launches this video player process, which uses Windows Media Player to play H.264 videos.
#### TweetImpl.CefSharp
Windows library that implements `TweetLib.Browser.CEF` using the [CefSharp](https://github.com/cefsharp/CefSharp/) library and Windows Forms.
### Miscellaneous
#### TweetLib.Communication
This library provides a `DuplexPipe` class for two-way communication between processes. This library provides a `DuplexPipe` class for two-way communication between processes.
### Project: TweetLib.Utils #### TweetLib.Utils
This library contains various utilities that fill some very specific holes in the .NET standard library. This library contains various utilities that fill some very specific holes in the .NET standard library.
### Projects: TweetTest.* #### TweetTest.*
These are F# projects with automated tests. These are F# projects with automated tests.

View File

@ -8,6 +8,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweetDuck.Browser", "window
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweetDuck.Video", "windows\TweetDuck.Video\TweetDuck.Video.csproj", "{278B2D11-402D-44B6-B6A1-8FA67DB65565}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweetDuck.Video", "windows\TweetDuck.Video\TweetDuck.Video.csproj", "{278B2D11-402D-44B6-B6A1-8FA67DB65565}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweetImpl.CefSharp", "windows\TweetImpl.CefSharp\TweetImpl.CefSharp.csproj", "{44DF3E2E-F465-4A31-8B43-F40FFFB018BA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweetLib.Communication", "lib\TweetLib.Communication\TweetLib.Communication.csproj", "{72473763-4B9D-4FB6-A923-9364B2680F06}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweetLib.Communication", "lib\TweetLib.Communication\TweetLib.Communication.csproj", "{72473763-4B9D-4FB6-A923-9364B2680F06}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweetLib.Core", "lib\TweetLib.Core\TweetLib.Core.csproj", "{93BA3CB4-A812-4949-B07D-8D393FB38937}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweetLib.Core", "lib\TweetLib.Core\TweetLib.Core.csproj", "{93BA3CB4-A812-4949-B07D-8D393FB38937}"
@ -42,6 +44,10 @@ Global
{278B2D11-402D-44B6-B6A1-8FA67DB65565}.Debug|x86.Build.0 = Debug|x86 {278B2D11-402D-44B6-B6A1-8FA67DB65565}.Debug|x86.Build.0 = Debug|x86
{278B2D11-402D-44B6-B6A1-8FA67DB65565}.Release|x86.ActiveCfg = Release|x86 {278B2D11-402D-44B6-B6A1-8FA67DB65565}.Release|x86.ActiveCfg = Release|x86
{278B2D11-402D-44B6-B6A1-8FA67DB65565}.Release|x86.Build.0 = Release|x86 {278B2D11-402D-44B6-B6A1-8FA67DB65565}.Release|x86.Build.0 = Release|x86
{44DF3E2E-F465-4A31-8B43-F40FFFB018BA}.Debug|x86.ActiveCfg = Debug|x86
{44DF3E2E-F465-4A31-8B43-F40FFFB018BA}.Debug|x86.Build.0 = Debug|x86
{44DF3E2E-F465-4A31-8B43-F40FFFB018BA}.Release|x86.ActiveCfg = Release|x86
{44DF3E2E-F465-4A31-8B43-F40FFFB018BA}.Release|x86.Build.0 = Release|x86
{72473763-4B9D-4FB6-A923-9364B2680F06}.Debug|x86.ActiveCfg = Debug|x86 {72473763-4B9D-4FB6-A923-9364B2680F06}.Debug|x86.ActiveCfg = Debug|x86
{72473763-4B9D-4FB6-A923-9364B2680F06}.Debug|x86.Build.0 = Debug|x86 {72473763-4B9D-4FB6-A923-9364B2680F06}.Debug|x86.Build.0 = Debug|x86
{72473763-4B9D-4FB6-A923-9364B2680F06}.Release|x86.ActiveCfg = Release|x86 {72473763-4B9D-4FB6-A923-9364B2680F06}.Release|x86.ActiveCfg = Release|x86

View File

@ -45,6 +45,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
[Files] [Files]
Source: "..\windows\TweetDuck\bin\x86\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion Source: "..\windows\TweetDuck\bin\x86\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\windows\TweetDuck\bin\x86\Release\TweetDuck.*"; DestDir: "{app}"; Flags: ignoreversion Source: "..\windows\TweetDuck\bin\x86\Release\TweetDuck.*"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\windows\TweetDuck\bin\x86\Release\TweetImpl.*"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\windows\TweetDuck\bin\x86\Release\TweetLib.*"; DestDir: "{app}"; Flags: ignoreversion Source: "..\windows\TweetDuck\bin\x86\Release\TweetLib.*"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\windows\TweetDuck\bin\x86\Release\guide\*.*"; DestDir: "{app}\guide"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\windows\TweetDuck\bin\x86\Release\guide\*.*"; DestDir: "{app}\guide"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "..\windows\TweetDuck\bin\x86\Release\resources\*.*"; DestDir: "{app}\resources"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\windows\TweetDuck\bin\x86\Release\resources\*.*"; DestDir: "{app}\resources"; Flags: ignoreversion recursesubdirs createallsubdirs

View File

@ -3,7 +3,7 @@
using CefSharp; using CefSharp;
using TweetDuck.Configuration; using TweetDuck.Configuration;
namespace TweetDuck.Browser.Handling { namespace TweetDuck.Browser.Base {
sealed class BrowserProcessHandler : IBrowserProcessHandler { sealed class BrowserProcessHandler : IBrowserProcessHandler {
public static Task UpdatePrefs() { public static Task UpdatePrefs() {
return Cef.UIThreadTaskFactory.StartNew(UpdatePrefsInternal); return Cef.UIThreadTaskFactory.StartNew(UpdatePrefsInternal);

View File

@ -1,72 +1,23 @@
using CefSharp;
using CefSharp.WinForms; using CefSharp.WinForms;
using TweetDuck.Browser.Handling;
using TweetDuck.Management;
using TweetDuck.Utils; using TweetDuck.Utils;
using TweetImpl.CefSharp.Component;
using TweetLib.Browser.Base; using TweetLib.Browser.Base;
using TweetLib.Browser.CEF.Component; using TweetLib.Browser.CEF.Utils;
using TweetLib.Browser.CEF.Data; using TweetLib.Core;
using IContextMenuHandler = TweetLib.Browser.Interfaces.IContextMenuHandler;
namespace TweetDuck.Browser.Base { namespace TweetDuck.Browser.Base {
sealed class CefBrowserComponent : BrowserComponent<IFrame, IRequest> { sealed class CefBrowserComponent : BrowserComponentBase {
public delegate ContextMenuBase CreateContextMenu(IContextMenuHandler handler);
private static readonly CreateContextMenu DefaultContextMenuFactory = handler => new ContextMenuBase(handler); private static readonly CreateContextMenu DefaultContextMenuFactory = handler => new ContextMenuBase(handler);
public override string CacheFolder => BrowserCache.CacheFolder; public override string CacheFolder => CefUtils.GetCacheFolder(App.StoragePath);
public ResourceHandlerRegistry<IResourceHandler> ResourceHandlerRegistry { get; } = new ResourceHandlerRegistry<IResourceHandler>(CefResourceHandlerFactory.Instance); public CefBrowserComponent(ChromiumWebBrowser browser, CreateContextMenu createContextMenu = null, bool autoReload = true) : base(browser, createContextMenu ?? DefaultContextMenuFactory, PopupHandler.Instance, autoReload) {
browser.SetupZoomEvents();
private readonly ChromiumWebBrowser browser;
private readonly bool autoReload;
private CreateContextMenu createContextMenu;
public CefBrowserComponent(ChromiumWebBrowser browser, CreateContextMenu createContextMenu = null, bool autoReload = true) : base(new CefBrowserAdapter(browser), CefAdapter.Instance, CefFrameAdapter.Instance, CefRequestAdapter.Instance) {
this.browser = browser;
this.browser.LoadingStateChanged += OnLoadingStateChanged;
this.browser.LoadError += OnLoadError;
this.browser.FrameLoadStart += OnFrameLoadStart;
this.browser.FrameLoadEnd += OnFrameLoadEnd;
this.browser.SetupZoomEvents();
this.createContextMenu = createContextMenu ?? DefaultContextMenuFactory;
this.autoReload = autoReload;
} }
public override void Setup(BrowserSetup setup) { public override void Setup(BrowserSetup setup) {
var lifeSpanHandler = new CefLifeSpanHandler(PopupHandler.Instance); base.Setup(setup);
var requestHandler = new CefRequestHandler(lifeSpanHandler, autoReload);
browser.DragHandler = new CefDragHandler(requestHandler, this);
browser.JsDialogHandler = new CustomJsDialogHandler(); browser.JsDialogHandler = new CustomJsDialogHandler();
browser.LifeSpanHandler = lifeSpanHandler;
browser.MenuHandler = createContextMenu(setup.ContextMenuHandler);
browser.RequestHandler = requestHandler;
browser.ResourceRequestHandlerFactory = new CefResourceRequestHandlerFactory(setup.ResourceRequestHandler, ResourceHandlerRegistry);
createContextMenu = null;
}
public override void AttachBridgeObject(string name, object bridge) {
browser.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true;
browser.JavascriptObjectRepository.Register(name, bridge, isAsync: true, BindingOptions.DefaultBinder);
}
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs e) {
base.OnLoadingStateChanged(e.IsLoading);
}
private void OnLoadError(object sender, LoadErrorEventArgs e) {
base.OnLoadError(e.FailedUrl, e.ErrorCode, CefErrorCodeAdapter.Instance);
}
private void OnFrameLoadStart(object sender, FrameLoadStartEventArgs e) {
base.OnFrameLoadStart(e.Url, e.Frame);
}
private void OnFrameLoadEnd(object sender, FrameLoadEndEventArgs e) {
base.OnFrameLoadEnd(e.Url, e.Frame);
} }
} }
} }

View File

@ -1,14 +1,14 @@
using System.Drawing; using System.Drawing;
using CefSharp; using CefSharp;
using TweetDuck.Browser.Base;
using TweetDuck.Configuration; using TweetDuck.Configuration;
using TweetDuck.Utils; using TweetDuck.Utils;
using TweetImpl.CefSharp.Handlers;
using TweetLib.Browser.Contexts; using TweetLib.Browser.Contexts;
using TweetLib.Core.Features.TweetDeck; using TweetLib.Core.Features.TweetDeck;
using TweetLib.Core.Features.Twitter; using TweetLib.Core.Features.Twitter;
using IContextMenuHandler = TweetLib.Browser.Interfaces.IContextMenuHandler; using IContextMenuHandler = TweetLib.Browser.Interfaces.IContextMenuHandler;
namespace TweetDuck.Browser.Handling { namespace TweetDuck.Browser.Base {
class ContextMenuBase : CefContextMenuHandler { class ContextMenuBase : CefContextMenuHandler {
private const CefMenuCommand MenuOpenDevTools = (CefMenuCommand) 26500; private const CefMenuCommand MenuOpenDevTools = (CefMenuCommand) 26500;

View File

@ -7,7 +7,7 @@
using TweetLib.Core.Systems.Configuration; using TweetLib.Core.Systems.Configuration;
using IContextMenuHandler = TweetLib.Browser.Interfaces.IContextMenuHandler; using IContextMenuHandler = TweetLib.Browser.Interfaces.IContextMenuHandler;
namespace TweetDuck.Browser.Handling { namespace TweetDuck.Browser.Base {
sealed class ContextMenuBrowser : ContextMenuBase { sealed class ContextMenuBrowser : ContextMenuBase {
private const CefMenuCommand MenuGlobal = (CefMenuCommand) 26600; private const CefMenuCommand MenuGlobal = (CefMenuCommand) 26600;
private const CefMenuCommand MenuMute = (CefMenuCommand) 26601; private const CefMenuCommand MenuMute = (CefMenuCommand) 26601;

View File

@ -4,7 +4,7 @@
using TweetLib.Browser.Contexts; using TweetLib.Browser.Contexts;
using IContextMenuHandler = TweetLib.Browser.Interfaces.IContextMenuHandler; using IContextMenuHandler = TweetLib.Browser.Interfaces.IContextMenuHandler;
namespace TweetDuck.Browser.Handling { namespace TweetDuck.Browser.Base {
sealed class ContextMenuNotification : ContextMenuBase { sealed class ContextMenuNotification : ContextMenuBase {
private readonly FormNotificationBase form; private readonly FormNotificationBase form;

View File

@ -6,7 +6,7 @@
using TweetDuck.Dialogs; using TweetDuck.Dialogs;
using TweetDuck.Utils; using TweetDuck.Utils;
namespace TweetDuck.Browser.Handling { namespace TweetDuck.Browser.Base {
sealed class CustomJsDialogHandler : IJsDialogHandler { sealed class CustomJsDialogHandler : IJsDialogHandler {
private static FormMessage CreateMessageForm(string caption, string text) { private static FormMessage CreateMessageForm(string caption, string text) {
MessageBoxIcon icon = MessageBoxIcon.None; MessageBoxIcon icon = MessageBoxIcon.None;

View File

@ -3,7 +3,7 @@
using TweetDuck.Utils; using TweetDuck.Utils;
using TweetLib.Utils.Static; using TweetLib.Utils.Static;
namespace TweetDuck.Browser.Handling { namespace TweetDuck.Browser.Base {
sealed class CustomKeyboardHandler : IKeyboardHandler { sealed class CustomKeyboardHandler : IKeyboardHandler {
private readonly IBrowserKeyHandler handler; private readonly IBrowserKeyHandler handler;

View File

@ -7,7 +7,7 @@
using TweetLib.Core; using TweetLib.Core;
using TweetLib.Utils.Static; using TweetLib.Utils.Static;
namespace TweetDuck.Browser.Handling { namespace TweetDuck.Browser.Base {
sealed class FileDialogHandler : IDialogHandler { sealed class FileDialogHandler : IDialogHandler {
public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, CefFileDialogFlags flags, string title, string defaultFilePath, List<string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) { public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, CefFileDialogFlags flags, string title, string defaultFilePath, List<string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) {
if (mode == CefFileDialogMode.Open || mode == CefFileDialogMode.OpenMultiple) { if (mode == CefFileDialogMode.Open || mode == CefFileDialogMode.OpenMultiple) {

View File

@ -2,7 +2,7 @@
using TweetLib.Core; using TweetLib.Core;
using TweetLib.Core.Features.Twitter; using TweetLib.Core.Features.Twitter;
namespace TweetDuck.Browser.Handling { namespace TweetDuck.Browser.Base {
sealed class PopupHandler : IPopupHandler { sealed class PopupHandler : IPopupHandler {
public static PopupHandler Instance { get; } = new PopupHandler(); public static PopupHandler Instance { get; } = new PopupHandler();

View File

@ -6,7 +6,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using CefSharp; using CefSharp;
using TweetDuck.Browser.Handling; using TweetDuck.Browser.Base;
using TweetDuck.Browser.Notification; using TweetDuck.Browser.Notification;
using TweetDuck.Browser.Notification.Screenshot; using TweetDuck.Browser.Notification.Screenshot;
using TweetDuck.Configuration; using TweetDuck.Configuration;

View File

@ -4,10 +4,10 @@
using System.Windows.Forms; using System.Windows.Forms;
using CefSharp.WinForms; using CefSharp.WinForms;
using TweetDuck.Browser.Base; using TweetDuck.Browser.Base;
using TweetDuck.Browser.Handling;
using TweetDuck.Configuration; using TweetDuck.Configuration;
using TweetDuck.Controls; using TweetDuck.Controls;
using TweetDuck.Utils; using TweetDuck.Utils;
using TweetImpl.CefSharp.Handlers;
using TweetLib.Browser.CEF.Data; using TweetLib.Browser.CEF.Data;
using TweetLib.Browser.Interfaces; using TweetLib.Browser.Interfaces;
using TweetLib.Core.Features.Notifications; using TweetLib.Core.Features.Notifications;

View File

@ -2,7 +2,7 @@
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using CefSharp; using CefSharp;
using TweetDuck.Browser.Handling; using TweetDuck.Browser.Base;
using TweetDuck.Controls; using TweetDuck.Controls;
using TweetDuck.Utils; using TweetDuck.Utils;
using TweetLib.Core.Features.Notifications; using TweetLib.Core.Features.Notifications;

View File

@ -3,7 +3,6 @@
using CefSharp; using CefSharp;
using CefSharp.WinForms; using CefSharp.WinForms;
using TweetDuck.Browser.Base; using TweetDuck.Browser.Base;
using TweetDuck.Browser.Handling;
using TweetDuck.Browser.Notification; using TweetDuck.Browser.Notification;
using TweetDuck.Configuration; using TweetDuck.Configuration;
using TweetDuck.Utils; using TweetDuck.Utils;

View File

@ -3,7 +3,6 @@
using CefSharp.WinForms; using CefSharp.WinForms;
using TweetDuck.Browser; using TweetDuck.Browser;
using TweetDuck.Browser.Base; using TweetDuck.Browser.Base;
using TweetDuck.Browser.Handling;
using TweetDuck.Controls; using TweetDuck.Controls;
using TweetDuck.Management; using TweetDuck.Management;
using TweetDuck.Utils; using TweetDuck.Utils;

View File

@ -3,7 +3,7 @@
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Browser; using TweetDuck.Browser;
using TweetDuck.Browser.Handling; using TweetDuck.Browser.Base;
using TweetDuck.Browser.Notification; using TweetDuck.Browser.Notification;
using TweetDuck.Configuration; using TweetDuck.Configuration;
using TweetDuck.Controls; using TweetDuck.Controls;

View File

@ -2,7 +2,7 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Browser.Handling; using TweetDuck.Browser.Base;
using TweetDuck.Controls; using TweetDuck.Controls;
using TweetDuck.Utils; using TweetDuck.Utils;
using TweetLib.Core; using TweetLib.Core;

View File

@ -6,12 +6,12 @@
using TweetDuck.Application; using TweetDuck.Application;
using TweetDuck.Browser; using TweetDuck.Browser;
using TweetDuck.Browser.Base; using TweetDuck.Browser.Base;
using TweetDuck.Browser.Handling;
using TweetDuck.Configuration; using TweetDuck.Configuration;
using TweetDuck.Dialogs; using TweetDuck.Dialogs;
using TweetDuck.Management; using TweetDuck.Management;
using TweetDuck.Updates; using TweetDuck.Updates;
using TweetDuck.Utils; using TweetDuck.Utils;
using TweetImpl.CefSharp.Handlers;
using TweetLib.Browser.CEF.Utils; using TweetLib.Browser.CEF.Utils;
using TweetLib.Core; using TweetLib.Core;
using TweetLib.Core.Application; using TweetLib.Core.Application;

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\CefSharp.Common.96.0.180\build\CefSharp.Common.props" Condition="Exists('..\..\packages\CefSharp.Common.96.0.180\build\CefSharp.Common.props')" /> <Import Project="..\..\packages\CefSharp.Common.96.0.180\build\CefSharp.Common.props" Condition="Exists('..\..\packages\CefSharp.Common.96.0.180\build\CefSharp.Common.props')" />
<Import Project="..\..\packages\cef.redist.x86.96.0.18\build\cef.redist.x86.props" Condition="Exists('..\..\packages\cef.redist.x86.96.0.18\build\cef.redist.x86.props')" /> <Import Project="..\..\packages\cef.redist.x86.96.0.18\build\cef.redist.x86.props" Condition="Exists('..\..\packages\cef.redist.x86.96.0.18\build\cef.redist.x86.props')" />
<Import Project="..\..\packages\cef.redist.x64.96.0.18\build\cef.redist.x64.props" Condition="Exists('..\..\packages\cef.redist.x64.96.0.18\build\cef.redist.x64.props')" /> <Import Project="..\..\packages\cef.redist.x64.96.0.18\build\cef.redist.x64.props" Condition="Exists('..\..\packages\cef.redist.x64.96.0.18\build\cef.redist.x64.props')" />
@ -45,13 +45,13 @@
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="CefSharp, Version=96.0.180.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL"> <Reference Include="CefSharp, Version=96.0.180.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138">
<HintPath>..\..\packages\CefSharp.Common.96.0.180\lib\net452\CefSharp.dll</HintPath> <HintPath>..\..\packages\CefSharp.Common.96.0.180\lib\net452\CefSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="CefSharp.Core, Version=96.0.180.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL"> <Reference Include="CefSharp.Core, Version=96.0.180.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138">
<HintPath>..\..\packages\CefSharp.Common.96.0.180\lib\net452\CefSharp.Core.dll</HintPath> <HintPath>..\..\packages\CefSharp.Common.96.0.180\lib\net452\CefSharp.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="CefSharp.WinForms, Version=96.0.180.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL"> <Reference Include="CefSharp.WinForms, Version=96.0.180.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138">
<HintPath>..\..\packages\CefSharp.WinForms.96.0.180\lib\net462\CefSharp.WinForms.dll</HintPath> <HintPath>..\..\packages\CefSharp.WinForms.96.0.180\lib\net462\CefSharp.WinForms.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
@ -90,39 +90,24 @@
<Project>{72473763-4b9d-4fb6-a923-9364b2680f06}</Project> <Project>{72473763-4b9d-4fb6-a923-9364b2680f06}</Project>
<Name>TweetLib.Communication</Name> <Name>TweetLib.Communication</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\TweetImpl.CefSharp\TweetImpl.CefSharp.csproj">
<Project>{44df3e2e-f465-4a31-8b43-f40fffb018ba}</Project>
<Name>TweetImpl.CefSharp</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Application\FileDialogs.cs" /> <Compile Include="Application\FileDialogs.cs" />
<Compile Include="Application\MessageDialogs.cs" /> <Compile Include="Application\MessageDialogs.cs" />
<Compile Include="Application\SystemHandler.cs" /> <Compile Include="Application\SystemHandler.cs" />
<Compile Include="Browser\Base\CefAdapter.cs" /> <Compile Include="Browser\Base\BrowserProcessHandler.cs" />
<Compile Include="Browser\Base\CefBrowserAdapter.cs" />
<Compile Include="Browser\Base\CefBrowserComponent.cs" /> <Compile Include="Browser\Base\CefBrowserComponent.cs" />
<Compile Include="Browser\Base\CefContextMenuHandler.cs" /> <Compile Include="Browser\Base\ContextMenuBase.cs" />
<Compile Include="Browser\Base\CefDownloadRequestClient.cs" /> <Compile Include="Browser\Base\ContextMenuBrowser.cs" />
<Compile Include="Browser\Base\CefDragDataAdapter.cs" /> <Compile Include="Browser\Base\ContextMenuNotification.cs" />
<Compile Include="Browser\Base\CefDragHandler.cs" /> <Compile Include="Browser\Base\CustomKeyboardHandler.cs" />
<Compile Include="Browser\Base\CefErrorCodeAdapter.cs" /> <Compile Include="Browser\Base\FileDialogHandler.cs" />
<Compile Include="Browser\Base\CefFrameAdapter.cs" /> <Compile Include="Browser\Base\CustomJsDialogHandler.cs" />
<Compile Include="Browser\Base\CefLifeSpanHandler.cs" /> <Compile Include="Browser\Base\PopupHandler.cs" />
<Compile Include="Browser\Base\CefMenuModelAdapter.cs" />
<Compile Include="Browser\Base\CefRequestAdapter.cs" />
<Compile Include="Browser\Base\CefRequestHandler.cs" />
<Compile Include="Browser\Base\CefResourceHandlerFactory.cs" />
<Compile Include="Browser\Base\CefByteArrayResourceHandler.cs" />
<Compile Include="Browser\Base\CefResourceRequestHandlerFactory.cs" />
<Compile Include="Browser\Base\CefResourceRequestHandler.cs" />
<Compile Include="Browser\Base\CefResponseAdapter.cs" />
<Compile Include="Browser\Base\CefResponseFilter.cs" />
<Compile Include="Browser\Base\CefSchemeHandlerFactory.cs" />
<Compile Include="Browser\Handling\BrowserProcessHandler.cs" />
<Compile Include="Browser\Handling\ContextMenuBase.cs" />
<Compile Include="Browser\Handling\ContextMenuBrowser.cs" />
<Compile Include="Browser\Handling\ContextMenuNotification.cs" />
<Compile Include="Browser\Handling\CustomKeyboardHandler.cs" />
<Compile Include="Browser\Handling\FileDialogHandler.cs" />
<Compile Include="Browser\Handling\CustomJsDialogHandler.cs" />
<Compile Include="Browser\Handling\PopupHandler.cs" />
<Compile Include="Browser\Notification\FormNotificationExample.cs"> <Compile Include="Browser\Notification\FormNotificationExample.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>

View File

@ -2,7 +2,7 @@
using CefSharp; using CefSharp;
using TweetLib.Browser.CEF.Interfaces; using TweetLib.Browser.CEF.Interfaces;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Adapters {
sealed class CefAdapter : ICefAdapter { sealed class CefAdapter : ICefAdapter {
public static CefAdapter Instance { get; } = new CefAdapter(); public static CefAdapter Instance { get; } = new CefAdapter();

View File

@ -1,9 +1,10 @@
using CefSharp; using CefSharp;
using CefSharp.WinForms; using CefSharp.WinForms;
using TweetImpl.CefSharp.Handlers;
using TweetLib.Browser.CEF.Data; using TweetLib.Browser.CEF.Data;
using TweetLib.Browser.CEF.Interfaces; using TweetLib.Browser.CEF.Interfaces;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Adapters {
sealed class CefBrowserAdapter : IBrowserWrapper<IFrame, IRequest> { sealed class CefBrowserAdapter : IBrowserWrapper<IFrame, IRequest> {
public string Url => browser.Address; public string Url => browser.Address;
public IFrame MainFrame => browser.GetMainFrame(); public IFrame MainFrame => browser.GetMainFrame();

View File

@ -1,7 +1,7 @@
using CefSharp; using CefSharp;
using TweetLib.Browser.CEF.Interfaces; using TweetLib.Browser.CEF.Interfaces;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Adapters {
sealed class CefDragDataAdapter : IDragDataAdapter<IDragData> { sealed class CefDragDataAdapter : IDragDataAdapter<IDragData> {
public static CefDragDataAdapter Instance { get; } = new CefDragDataAdapter(); public static CefDragDataAdapter Instance { get; } = new CefDragDataAdapter();

View File

@ -2,7 +2,7 @@
using CefSharp; using CefSharp;
using TweetLib.Browser.CEF.Interfaces; using TweetLib.Browser.CEF.Interfaces;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Adapters {
sealed class CefErrorCodeAdapter : IErrorCodeAdapter<CefErrorCode> { sealed class CefErrorCodeAdapter : IErrorCodeAdapter<CefErrorCode> {
public static CefErrorCodeAdapter Instance { get; } = new CefErrorCodeAdapter(); public static CefErrorCodeAdapter Instance { get; } = new CefErrorCodeAdapter();

View File

@ -1,7 +1,7 @@
using CefSharp; using CefSharp;
using TweetLib.Browser.CEF.Interfaces; using TweetLib.Browser.CEF.Interfaces;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Adapters {
sealed class CefFrameAdapter : IFrameAdapter<IFrame> { sealed class CefFrameAdapter : IFrameAdapter<IFrame> {
public static CefFrameAdapter Instance { get; } = new CefFrameAdapter(); public static CefFrameAdapter Instance { get; } = new CefFrameAdapter();

View File

@ -1,7 +1,7 @@
using CefSharp; using CefSharp;
using TweetLib.Browser.CEF.Interfaces; using TweetLib.Browser.CEF.Interfaces;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Adapters {
sealed class CefMenuModelAdapter : IMenuModelAdapter<IMenuModel> { sealed class CefMenuModelAdapter : IMenuModelAdapter<IMenuModel> {
public static CefMenuModelAdapter Instance { get; } = new CefMenuModelAdapter(); public static CefMenuModelAdapter Instance { get; } = new CefMenuModelAdapter();

View File

@ -1,8 +1,7 @@
using CefSharp; using CefSharp;
using TweetLib.Browser.CEF.Interfaces; using TweetLib.Browser.CEF.Interfaces;
using ResourceType = TweetLib.Browser.Request.ResourceType;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Adapters {
sealed class CefRequestAdapter : IRequestAdapter<IRequest> { sealed class CefRequestAdapter : IRequestAdapter<IRequest> {
public static CefRequestAdapter Instance { get; } = new CefRequestAdapter(); public static CefRequestAdapter Instance { get; } = new CefRequestAdapter();
@ -29,17 +28,17 @@ public bool IsTransitionForwardBack(IRequest request) {
} }
public bool IsCspReport(IRequest request) { public bool IsCspReport(IRequest request) {
return request.ResourceType == CefSharp.ResourceType.CspReport; return request.ResourceType == ResourceType.CspReport;
} }
public ResourceType GetResourceType(IRequest request) { public TweetLib.Browser.Request.ResourceType GetResourceType(IRequest request) {
return request.ResourceType switch { return request.ResourceType switch {
CefSharp.ResourceType.MainFrame => ResourceType.MainFrame, ResourceType.MainFrame => TweetLib.Browser.Request.ResourceType.MainFrame,
CefSharp.ResourceType.Script => ResourceType.Script, ResourceType.Script => TweetLib.Browser.Request.ResourceType.Script,
CefSharp.ResourceType.Stylesheet => ResourceType.Stylesheet, ResourceType.Stylesheet => TweetLib.Browser.Request.ResourceType.Stylesheet,
CefSharp.ResourceType.Xhr => ResourceType.Xhr, ResourceType.Xhr => TweetLib.Browser.Request.ResourceType.Xhr,
CefSharp.ResourceType.Image => ResourceType.Image, ResourceType.Image => TweetLib.Browser.Request.ResourceType.Image,
_ => ResourceType.Unknown _ => TweetLib.Browser.Request.ResourceType.Unknown
}; };
} }

View File

@ -1,7 +1,7 @@
using CefSharp; using CefSharp;
using TweetLib.Browser.CEF.Interfaces; using TweetLib.Browser.CEF.Interfaces;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Adapters {
sealed class CefResponseAdapter : IResponseAdapter<IResponse> { sealed class CefResponseAdapter : IResponseAdapter<IResponse> {
public static CefResponseAdapter Instance { get; } = new CefResponseAdapter(); public static CefResponseAdapter Instance { get; } = new CefResponseAdapter();

View File

@ -0,0 +1,65 @@
using CefSharp;
using CefSharp.WinForms;
using TweetImpl.CefSharp.Adapters;
using TweetImpl.CefSharp.Handlers;
using TweetLib.Browser.Base;
using TweetLib.Browser.CEF.Component;
using TweetLib.Browser.CEF.Data;
using TweetLib.Browser.CEF.Interfaces;
using IContextMenuHandler = TweetLib.Browser.Interfaces.IContextMenuHandler;
namespace TweetImpl.CefSharp.Component {
public abstract class BrowserComponentBase : BrowserComponent<IFrame, IRequest> {
public delegate CefContextMenuHandler CreateContextMenu(IContextMenuHandler handler);
public ResourceHandlerRegistry<IResourceHandler> ResourceHandlerRegistry { get; } = new ResourceHandlerRegistry<IResourceHandler>(CefResourceHandlerFactory.Instance);
protected readonly ChromiumWebBrowser browser;
private readonly CreateContextMenu createContextMenu;
private readonly IPopupHandler popupHandler;
private readonly bool autoReload;
protected BrowserComponentBase(ChromiumWebBrowser browser, CreateContextMenu createContextMenu, IPopupHandler popupHandler, bool autoReload) : base(new CefBrowserAdapter(browser), CefAdapter.Instance, CefFrameAdapter.Instance, CefRequestAdapter.Instance) {
this.browser = browser;
this.browser.LoadingStateChanged += OnLoadingStateChanged;
this.browser.LoadError += OnLoadError;
this.browser.FrameLoadStart += OnFrameLoadStart;
this.browser.FrameLoadEnd += OnFrameLoadEnd;
this.createContextMenu = createContextMenu;
this.popupHandler = popupHandler;
this.autoReload = autoReload;
}
public override void Setup(BrowserSetup setup) {
var lifeSpanHandler = new CefLifeSpanHandler(popupHandler);
var requestHandler = new CefRequestHandler(lifeSpanHandler, autoReload);
browser.DragHandler = new CefDragHandler(requestHandler, this);
browser.LifeSpanHandler = lifeSpanHandler;
browser.MenuHandler = createContextMenu(setup.ContextMenuHandler);
browser.RequestHandler = requestHandler;
browser.ResourceRequestHandlerFactory = new CefResourceRequestHandlerFactory(setup.ResourceRequestHandler, ResourceHandlerRegistry);
}
public override void AttachBridgeObject(string name, object bridge) {
browser.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true;
browser.JavascriptObjectRepository.Register(name, bridge, isAsync: true, BindingOptions.DefaultBinder);
}
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs e) {
base.OnLoadingStateChanged(e.IsLoading);
}
private void OnLoadError(object sender, LoadErrorEventArgs e) {
base.OnLoadError(e.FailedUrl, e.ErrorCode, CefErrorCodeAdapter.Instance);
}
private void OnFrameLoadStart(object sender, FrameLoadStartEventArgs e) {
base.OnFrameLoadStart(e.Url, e.Frame);
}
private void OnFrameLoadEnd(object sender, FrameLoadEndEventArgs e) {
base.OnFrameLoadEnd(e.Url, e.Frame);
}
}
}

View File

@ -2,11 +2,12 @@
using System.IO; using System.IO;
using CefSharp; using CefSharp;
using CefSharp.Callback; using CefSharp.Callback;
using TweetImpl.CefSharp.Adapters;
using TweetLib.Browser.CEF.Data; using TweetLib.Browser.CEF.Data;
using TweetLib.Browser.CEF.Logic; using TweetLib.Browser.CEF.Logic;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Handlers {
sealed class CefByteArrayResourceHandler : IResourceHandler { public sealed class CefByteArrayResourceHandler : IResourceHandler {
private static readonly ByteArrayResourceHandlerLogic.WriteToOut<Stream> WriteToOut = delegate (Stream dataOut, byte[] dataIn, int position, int length) { private static readonly ByteArrayResourceHandlerLogic.WriteToOut<Stream> WriteToOut = delegate (Stream dataOut, byte[] dataIn, int position, int length) {
dataOut.Write(dataIn, position, length); dataOut.Write(dataIn, position, length);
}; };
@ -17,7 +18,7 @@ public CefByteArrayResourceHandler() {
SetResource(new ByteArrayResource(Array.Empty<byte>())); SetResource(new ByteArrayResource(Array.Empty<byte>()));
} }
public CefByteArrayResourceHandler(ByteArrayResource resource) { internal CefByteArrayResourceHandler(ByteArrayResource resource) {
SetResource(resource); SetResource(resource);
} }

View File

@ -1,9 +1,10 @@
using CefSharp; using CefSharp;
using TweetImpl.CefSharp.Adapters;
using TweetLib.Browser.CEF.Logic; using TweetLib.Browser.CEF.Logic;
using TweetLib.Browser.Contexts; using TweetLib.Browser.Contexts;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Handlers {
abstract class CefContextMenuHandler : IContextMenuHandler { public abstract class CefContextMenuHandler : IContextMenuHandler {
private readonly ContextMenuLogic<IMenuModel> logic; private readonly ContextMenuLogic<IMenuModel> logic;
protected CefContextMenuHandler(TweetLib.Browser.Interfaces.IContextMenuHandler handler) { protected CefContextMenuHandler(TweetLib.Browser.Interfaces.IContextMenuHandler handler) {

View File

@ -4,7 +4,7 @@
using TweetLib.Browser.CEF.Logic; using TweetLib.Browser.CEF.Logic;
using static TweetLib.Browser.CEF.Logic.DownloadRequestClientLogic.RequestStatus; using static TweetLib.Browser.CEF.Logic.DownloadRequestClientLogic.RequestStatus;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Handlers {
sealed class CefDownloadRequestClient : UrlRequestClient { sealed class CefDownloadRequestClient : UrlRequestClient {
private readonly DownloadRequestClientLogic logic; private readonly DownloadRequestClientLogic logic;

View File

@ -1,10 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using CefSharp; using CefSharp;
using CefSharp.Enums; using CefSharp.Enums;
using TweetImpl.CefSharp.Adapters;
using TweetLib.Browser.CEF.Logic; using TweetLib.Browser.CEF.Logic;
using TweetLib.Browser.Interfaces; using TweetLib.Browser.Interfaces;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Handlers {
sealed class CefDragHandler : IDragHandler { sealed class CefDragHandler : IDragHandler {
private readonly DragHandlerLogic<IDragData, IRequest> logic; private readonly DragHandlerLogic<IDragData, IRequest> logic;

View File

@ -4,7 +4,7 @@
using TweetLib.Browser.CEF.Logic; using TweetLib.Browser.CEF.Logic;
using static TweetLib.Browser.CEF.Logic.LifeSpanHandlerLogic.TargetDisposition; using static TweetLib.Browser.CEF.Logic.LifeSpanHandlerLogic.TargetDisposition;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Handlers {
sealed class CefLifeSpanHandler : LifeSpanHandler { sealed class CefLifeSpanHandler : LifeSpanHandler {
public LifeSpanHandlerLogic Logic { get; } public LifeSpanHandlerLogic Logic { get; }

View File

@ -1,8 +1,9 @@
using CefSharp; using CefSharp;
using CefSharp.Handler; using CefSharp.Handler;
using TweetImpl.CefSharp.Adapters;
using TweetLib.Browser.CEF.Logic; using TweetLib.Browser.CEF.Logic;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Handlers {
sealed class CefRequestHandler : RequestHandler { sealed class CefRequestHandler : RequestHandler {
public RequestHandlerLogic<IRequest> Logic { get; } public RequestHandlerLogic<IRequest> Logic { get; }

View File

@ -2,7 +2,7 @@
using TweetLib.Browser.CEF.Data; using TweetLib.Browser.CEF.Data;
using TweetLib.Browser.CEF.Interfaces; using TweetLib.Browser.CEF.Interfaces;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Handlers {
sealed class CefResourceHandlerFactory : IResourceHandlerFactory<IResourceHandler> { sealed class CefResourceHandlerFactory : IResourceHandlerFactory<IResourceHandler> {
public static CefResourceHandlerFactory Instance { get; } = new CefResourceHandlerFactory(); public static CefResourceHandlerFactory Instance { get; } = new CefResourceHandlerFactory();

View File

@ -1,10 +1,11 @@
using CefSharp; using CefSharp;
using CefSharp.Handler; using CefSharp.Handler;
using TweetImpl.CefSharp.Adapters;
using TweetLib.Browser.CEF.Data; using TweetLib.Browser.CEF.Data;
using TweetLib.Browser.CEF.Logic; using TweetLib.Browser.CEF.Logic;
using IResourceRequestHandler = TweetLib.Browser.Interfaces.IResourceRequestHandler; using IResourceRequestHandler = TweetLib.Browser.Interfaces.IResourceRequestHandler;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Handlers {
sealed class CefResourceRequestHandler : ResourceRequestHandler { sealed class CefResourceRequestHandler : ResourceRequestHandler {
private readonly ResourceRequestHandlerLogic<IRequest, IResponse, IResourceHandler> logic; private readonly ResourceRequestHandlerLogic<IRequest, IResponse, IResourceHandler> logic;

View File

@ -1,10 +1,11 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using CefSharp; using CefSharp;
using TweetImpl.CefSharp.Adapters;
using TweetLib.Browser.CEF.Data; using TweetLib.Browser.CEF.Data;
using TweetLib.Browser.CEF.Logic; using TweetLib.Browser.CEF.Logic;
using IResourceRequestHandler = TweetLib.Browser.Interfaces.IResourceRequestHandler; using IResourceRequestHandler = TweetLib.Browser.Interfaces.IResourceRequestHandler;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Handlers {
sealed class CefResourceRequestHandlerFactory : IResourceRequestHandlerFactory { sealed class CefResourceRequestHandlerFactory : IResourceRequestHandlerFactory {
bool IResourceRequestHandlerFactory.HasHandlers => true; bool IResourceRequestHandlerFactory.HasHandlers => true;
@ -15,7 +16,7 @@ public CefResourceRequestHandlerFactory(IResourceRequestHandler resourceRequestH
} }
[SuppressMessage("ReSharper", "RedundantAssignment")] [SuppressMessage("ReSharper", "RedundantAssignment")]
CefSharp.IResourceRequestHandler IResourceRequestHandlerFactory.GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling) { global::CefSharp.IResourceRequestHandler IResourceRequestHandlerFactory.GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling) {
return logic.GetResourceRequestHandler(request, ref disableDefaultHandling); return logic.GetResourceRequestHandler(request, ref disableDefaultHandling);
} }
} }

View File

@ -3,7 +3,7 @@
using CefSharp; using CefSharp;
using TweetLib.Browser.CEF.Logic; using TweetLib.Browser.CEF.Logic;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Handlers {
sealed class CefResponseFilter : IResponseFilter { sealed class CefResponseFilter : IResponseFilter {
public static CefResponseFilter Create(ResponseFilterLogic logic) { public static CefResponseFilter Create(ResponseFilterLogic logic) {
return logic == null ? null : new CefResponseFilter(logic); return logic == null ? null : new CefResponseFilter(logic);

View File

@ -1,10 +1,11 @@
using CefSharp; using CefSharp;
using CefSharp.WinForms; using CefSharp.WinForms;
using TweetImpl.CefSharp.Adapters;
using TweetLib.Browser.CEF.Logic; using TweetLib.Browser.CEF.Logic;
using TweetLib.Browser.Interfaces; using TweetLib.Browser.Interfaces;
namespace TweetDuck.Browser.Base { namespace TweetImpl.CefSharp.Handlers {
sealed class CefSchemeHandlerFactory : ISchemeHandlerFactory { public sealed class CefSchemeHandlerFactory : ISchemeHandlerFactory {
public static void Register(CefSettings settings, ICustomSchemeHandler handler) { public static void Register(CefSettings settings, ICustomSchemeHandler handler) {
settings.RegisterScheme(new CefCustomScheme { settings.RegisterScheme(new CefCustomScheme {
SchemeName = handler.Protocol, SchemeName = handler.Protocol,

View File

@ -0,0 +1,22 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TweetDuck CefSharp Implementation")]
[assembly: AssemblyDescription("TweetDuck CefSharp Implementation")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TweetImpl.CefSharp")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c97d4cf0-0bf2-4ec2-b450-dacd6bea56d8")]

View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\CefSharp.Common.96.0.180\build\CefSharp.Common.props" Condition="Exists('..\..\packages\CefSharp.Common.96.0.180\build\CefSharp.Common.props')" />
<Import Project="..\..\packages\cef.redist.x86.96.0.18\build\cef.redist.x86.props" Condition="Exists('..\..\packages\cef.redist.x86.96.0.18\build\cef.redist.x86.props')" />
<Import Project="..\..\packages\cef.redist.x64.96.0.18\build\cef.redist.x64.props" Condition="Exists('..\..\packages\cef.redist.x64.96.0.18\build\cef.redist.x64.props')" />
<Import Project="..\..\packages\CefSharp.WinForms.92.0.260\build\CefSharp.WinForms.props" Condition="Exists('..\..\packages\CefSharp.WinForms.92.0.260\build\CefSharp.WinForms.props')" />
<Import Project="..\..\packages\Microsoft.Net.Compilers.3.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\..\packages\Microsoft.Net.Compilers.3.0.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{44DF3E2E-F465-4A31-8B43-F40FFFB018BA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TweetImpl.CefSharp</RootNamespace>
<AssemblyName>TweetImpl.CefSharp</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<LangVersion>8.0</LangVersion>
<FileAlignment>512</FileAlignment>
<UseVSHostingProcess>false</UseVSHostingProcess>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\x86\Release\</OutputPath>
<Optimize>true</Optimize>
<PlatformTarget>x86</PlatformTarget>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="CefSharp, Version=96.0.180.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138">
<HintPath>..\..\packages\CefSharp.Common.96.0.180\lib\net452\CefSharp.dll</HintPath>
</Reference>
<Reference Include="CefSharp.Core, Version=96.0.180.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138">
<HintPath>..\..\packages\CefSharp.Common.96.0.180\lib\net452\CefSharp.Core.dll</HintPath>
</Reference>
<Reference Include="CefSharp.WinForms, Version=96.0.180.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138">
<HintPath>..\..\packages\CefSharp.WinForms.96.0.180\lib\net462\CefSharp.WinForms.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\lib\TweetLib.Browser.CEF\TweetLib.Browser.CEF.csproj">
<Project>{1b7793c6-9002-483e-9bd7-897fe6cd18fb}</Project>
<Name>TweetLib.Browser.CEF</Name>
</ProjectReference>
<ProjectReference Include="..\..\lib\TweetLib.Browser\TweetLib.Browser.csproj">
<Project>{eefb1f37-7cad-46bd-8042-66e7b502ab02}</Project>
<Name>TweetLib.Browser</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Version.cs" Link="Version.cs" />
<Compile Include="Adapters\CefAdapter.cs" />
<Compile Include="Adapters\CefBrowserAdapter.cs" />
<Compile Include="Adapters\CefDragDataAdapter.cs" />
<Compile Include="Adapters\CefErrorCodeAdapter.cs" />
<Compile Include="Adapters\CefFrameAdapter.cs" />
<Compile Include="Adapters\CefMenuModelAdapter.cs" />
<Compile Include="Adapters\CefRequestAdapter.cs" />
<Compile Include="Adapters\CefResponseAdapter.cs" />
<Compile Include="Component\BrowserComponentBase.cs" />
<Compile Include="Handlers\CefByteArrayResourceHandler.cs" />
<Compile Include="Handlers\CefContextMenuHandler.cs" />
<Compile Include="Handlers\CefDownloadRequestClient.cs" />
<Compile Include="Handlers\CefDragHandler.cs" />
<Compile Include="Handlers\CefLifeSpanHandler.cs" />
<Compile Include="Handlers\CefRequestHandler.cs" />
<Compile Include="Handlers\CefResourceHandlerFactory.cs" />
<Compile Include="Handlers\CefResourceRequestHandler.cs" />
<Compile Include="Handlers\CefResourceRequestHandlerFactory.cs" />
<Compile Include="Handlers\CefResponseFilter.cs" />
<Compile Include="Handlers\CefSchemeHandlerFactory.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<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\Microsoft.Net.Compilers.3.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Net.Compilers.3.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\..\packages\cef.redist.x64.96.0.18\build\cef.redist.x64.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\cef.redist.x64.96.0.18\build\cef.redist.x64.props'))" />
<Error Condition="!Exists('..\..\packages\cef.redist.x86.96.0.18\build\cef.redist.x86.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\cef.redist.x86.96.0.18\build\cef.redist.x86.props'))" />
<Error Condition="!Exists('..\..\packages\CefSharp.Common.96.0.180\build\CefSharp.Common.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\CefSharp.Common.96.0.180\build\CefSharp.Common.props'))" />
<Error Condition="!Exists('..\..\packages\CefSharp.Common.96.0.180\build\CefSharp.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\CefSharp.Common.96.0.180\build\CefSharp.Common.targets'))" />
</Target>
<Import Project="..\..\packages\CefSharp.Common.96.0.180\build\CefSharp.Common.targets" Condition="Exists('..\..\packages\CefSharp.Common.96.0.180\build\CefSharp.Common.targets')" />
</Project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="cef.redist.x64" version="96.0.18" targetFramework="net472" />
<package id="cef.redist.x86" version="96.0.18" targetFramework="net472" />
<package id="CefSharp.Common" version="96.0.180" targetFramework="net472" />
<package id="CefSharp.WinForms" version="96.0.180" targetFramework="net472" />
<package id="Microsoft.Net.Compilers" version="3.0.0" targetFramework="net472" developmentDependency="true" />
</packages>