1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2024-11-23 17:42:46 +01:00
TweetDuck/windows/TweetImpl.CefSharp/Adapters/CefBrowserAdapter.cs

32 lines
875 B
C#

using CefSharp;
using CefSharp.WinForms;
using TweetImpl.CefSharp.Handlers;
using TweetLib.Browser.CEF.Data;
using TweetLib.Browser.CEF.Interfaces;
namespace TweetImpl.CefSharp.Adapters {
sealed class CefBrowserAdapter : IBrowserWrapper<IFrame, IRequest> {
public string Url => browser.Address;
public IFrame MainFrame => browser.GetMainFrame();
private readonly ChromiumWebBrowser browser;
public CefBrowserAdapter(ChromiumWebBrowser browser) {
this.browser = browser;
}
public void AddWordToDictionary(string word) {
browser.AddWordToDictionary(word);
}
public IRequest CreateGetRequest() {
using var frame = MainFrame;
return frame.CreateRequest(false);
}
public void RequestDownload(IFrame frame, IRequest request, DownloadCallbacks callbacks) {
frame.CreateUrlRequest(request, new CefDownloadRequestClient(callbacks));
}
}
}