mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-03 05:34:07 +02:00
Fix runtime errors & minor tweaks after updating CefSharp
This commit is contained in:
parent
1e3de31fc3
commit
ad28d2279f
@ -33,7 +33,7 @@ protected virtual bool HandleRawKey(IWebBrowser browserControl, IBrowser browser
|
||||
}
|
||||
|
||||
bool IKeyboardHandler.OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut){
|
||||
if (type == KeyType.RawKeyDown && !browser.FocusedFrame.Url.StartsWith("chrome-devtools://")){
|
||||
if (type == KeyType.RawKeyDown && !browser.FocusedFrame.Url.StartsWith("devtools://")){
|
||||
return HandleRawKey(browserControl, browser, (Keys)windowsKeyCode, modifiers);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,13 @@ public void Dispose(){
|
||||
}
|
||||
|
||||
bool IResourceHandler.Open(IRequest request, out bool handleRequest, ICallback callback){
|
||||
callback.Dispose();
|
||||
handleRequest = true;
|
||||
callback.Continue();
|
||||
|
||||
if (dataIn != null){
|
||||
dataIn.Position = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -48,11 +53,11 @@ bool IResourceHandler.Read(Stream dataOut, out int bytesRead, IResourceReadCallb
|
||||
dataIn.Read(buffer, 0, length);
|
||||
dataOut.Write(buffer, 0, length);
|
||||
bytesRead = length;
|
||||
return true;
|
||||
}catch{ // catch IOException, possibly NullReferenceException if dataIn is null
|
||||
bytesRead = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return bytesRead > 0;
|
||||
}
|
||||
|
||||
bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback){
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Collections.Specialized;
|
||||
using CefSharp;
|
||||
using CefSharp;
|
||||
using TweetDuck.Browser.Handling.Filters;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Features.Twitter;
|
||||
@ -28,9 +27,7 @@ protected override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserContro
|
||||
return CefReturnValue.Cancel;
|
||||
}
|
||||
else if (url.Contains(UrlVendorResource)){
|
||||
NameValueCollection headers = request.Headers;
|
||||
headers["Accept-Encoding"] = "identity";
|
||||
request.Headers = headers;
|
||||
request.SetHeaderByName("Accept-Encoding", "identity", overwrite: true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ protected FormNotificationMain(FormBrowser owner, PluginManager pluginManager, b
|
||||
this.timerBarHeight = BrowserUtils.Scale(4, DpiScale);
|
||||
|
||||
browser.KeyboardHandler = new KeyboardHandlerNotification(this);
|
||||
browser.RegisterAsyncJsObject("$TD", new TweetDeckBridge.Notification(owner, this));
|
||||
browser.RegisterJsBridge("$TD", new TweetDeckBridge.Notification(owner, this));
|
||||
|
||||
browser.LoadingStateChanged += Browser_LoadingStateChanged;
|
||||
browser.FrameLoadEnd += Browser_FrameLoadEnd;
|
||||
|
@ -23,7 +23,7 @@ public FormNotificationScreenshotable(Action callback, FormBrowser owner, Plugin
|
||||
|
||||
int realWidth = BrowserUtils.Scale(width, DpiScale);
|
||||
|
||||
browser.RegisterAsyncJsObject("$TD_NotificationScreenshot", new ScreenshotBridge(this, SetScreenshotHeight, callback));
|
||||
browser.RegisterJsBridge("$TD_NotificationScreenshot", new ScreenshotBridge(this, SetScreenshotHeight, callback));
|
||||
|
||||
browser.LoadingStateChanged += (sender, args) => {
|
||||
if (args.IsLoading){
|
||||
|
@ -74,8 +74,8 @@ public TweetDeckBrowser(FormBrowser owner, PluginManager plugins, TweetDeckBridg
|
||||
this.browser.FrameLoadEnd += browser_FrameLoadEnd;
|
||||
this.browser.LoadError += browser_LoadError;
|
||||
|
||||
this.browser.RegisterAsyncJsObject("$TD", tdBridge);
|
||||
this.browser.RegisterAsyncJsObject("$TDU", updateBridge);
|
||||
this.browser.RegisterJsBridge("$TD", tdBridge);
|
||||
this.browser.RegisterJsBridge("$TDU", updateBridge);
|
||||
|
||||
this.browser.BrowserSettings.BackgroundColor = (uint)TwitterUtils.BackgroundColor.ToArgb();
|
||||
this.browser.Dock = DockStyle.None;
|
||||
|
@ -23,7 +23,6 @@ public TabSettingsNotifications(FormNotificationExample notification){
|
||||
});
|
||||
};
|
||||
|
||||
this.notification.Activated += notification_Activated;
|
||||
this.notification.Show();
|
||||
|
||||
Disposed += (sender, args) => this.notification.Dispose();
|
||||
@ -139,11 +138,6 @@ private void TabSettingsNotifications_ParentChanged(object sender, EventArgs e){
|
||||
}
|
||||
}
|
||||
|
||||
private void notification_Activated(object sender, EventArgs e){
|
||||
notification.Hide();
|
||||
notification.Activated -= notification_Activated;
|
||||
}
|
||||
|
||||
private void notification_Move(object sender, EventArgs e){
|
||||
if (radioLocCustom.Checked && notification.Location != ControlExtensions.InvisibleLocation){
|
||||
Config.CustomNotificationPosition = notification.Location;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using CefSharp;
|
||||
using TweetDuck.Browser.Adapters;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Browser;
|
||||
using TweetLib.Core.Features.Plugins;
|
||||
using TweetLib.Core.Features.Plugins.Events;
|
||||
@ -22,7 +23,7 @@ public PluginDispatcher(IWebBrowser browser, Func<string, bool> executeOnUrl){
|
||||
}
|
||||
|
||||
void IPluginDispatcher.AttachBridge(string name, object bridge){
|
||||
browser.RegisterAsyncJsObject(name, bridge);
|
||||
browser.RegisterJsBridge(name, bridge);
|
||||
}
|
||||
|
||||
private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||
|
@ -27,7 +27,7 @@ public IResourceHandler File(byte[] bytes, string extension){
|
||||
return Status(HttpStatusCode.NoContent, "File is empty."); // FromByteArray crashes CEF internals with no contents
|
||||
}
|
||||
else{
|
||||
return ResourceHandler.FromByteArray(bytes, ResourceHandler.GetMimeType(extension));
|
||||
return ResourceHandler.FromByteArray(bytes, Cef.GetMimeType(extension));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,6 +144,7 @@ private static void Main(){
|
||||
|
||||
if (Arguments.HasFlag(Arguments.ArgUpdated)){
|
||||
WindowsUtils.TryDeleteFolderWhenAble(InstallerPath, 8000);
|
||||
WindowsUtils.TryDeleteFolderWhenAble(Path.Combine(StoragePath, "Service Worker"), 4000);
|
||||
BrowserCache.TryClearNow();
|
||||
}
|
||||
|
||||
@ -161,7 +162,7 @@ private static void Main(){
|
||||
|
||||
CefSettings settings = new CefSettings{
|
||||
UserAgent = BrowserUtils.UserAgentChrome,
|
||||
BrowserSubprocessPath = BrandName + ".Browser.exe",
|
||||
BrowserSubprocessPath = Path.Combine(ProgramPath, BrandName + ".Browser.exe"),
|
||||
CachePath = StoragePath,
|
||||
UserDataPath = CefDataPath,
|
||||
LogFile = ConsoleLogFilePath,
|
||||
|
@ -81,6 +81,11 @@ void UpdateZoomLevel(object sender, EventArgs args){
|
||||
};
|
||||
}
|
||||
|
||||
public static void RegisterJsBridge(this IWebBrowser browserControl, string name, object bridge){
|
||||
CefSharpSettings.LegacyJavascriptBindingEnabled = true;
|
||||
browserControl.JavascriptObjectRepository.Register(name, bridge, isAsync: true, BindingOptions.DefaultBinder);
|
||||
}
|
||||
|
||||
public static void OpenDevToolsCustom(this IWebBrowser browser){
|
||||
var info = new WindowInfo();
|
||||
info.SetAsPopup(IntPtr.Zero, "Dev Tools");
|
||||
|
Loading…
Reference in New Issue
Block a user