1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-08-13 10:16:59 +02:00
Files
.github
.idea
Application
Browser
Adapters
Bridge
Data
Handling
Filters
General
BrowserProcessHandler.cs
CustomLifeSpanHandler.cs
FileDialogHandler.cs
JavaScriptDialogHandler.cs
ContextMenuBase.cs
ContextMenuBrowser.cs
ContextMenuGuide.cs
ContextMenuNotification.cs
DragHandlerBrowser.cs
KeyboardHandlerBase.cs
KeyboardHandlerBrowser.cs
KeyboardHandlerNotification.cs
RequestHandlerBase.cs
RequestHandlerBrowser.cs
ResourceHandlerNotification.cs
ResourceRequestHandler.cs
ResourceRequestHandlerBase.cs
ResourceRequestHandlerBrowser.cs
Notification
FormBrowser.Designer.cs
FormBrowser.cs
FormBrowser.resx
TrayIcon.Designer.cs
TrayIcon.cs
TweetDeckBrowser.cs
Configuration
Controls
Dialogs
Management
Plugins
Properties
Resources
Updates
Utils
bld
lib
subprocess
video
.gitattributes
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDuck.csproj
TweetDuck.sln
TweetDuck.sln.DotSettings
Version.cs
packages.config
TweetDuck/Browser/Handling/General/CustomLifeSpanHandler.cs
2021-12-16 23:31:40 +01:00

36 lines
1.4 KiB
C#

using CefSharp;
using CefSharp.Handler;
using TweetDuck.Controls;
using TweetDuck.Utils;
namespace TweetDuck.Browser.Handling.General {
sealed class CustomLifeSpanHandler : LifeSpanHandler {
private static bool IsPopupAllowed(string url) {
return url.StartsWith("https://twitter.com/teams/authorize?");
}
public static bool HandleLinkClick(IWebBrowser browserControl, WindowOpenDisposition targetDisposition, string targetUrl) {
switch (targetDisposition) {
case WindowOpenDisposition.NewBackgroundTab:
case WindowOpenDisposition.NewForegroundTab:
case WindowOpenDisposition.NewPopup when !IsPopupAllowed(targetUrl):
case WindowOpenDisposition.NewWindow:
browserControl.AsControl().InvokeAsyncSafe(() => BrowserUtils.OpenExternalBrowser(targetUrl));
return true;
default:
return false;
}
}
protected override bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser) {
newBrowser = null;
return HandleLinkClick(browserControl, targetDisposition, targetUrl);
}
protected override bool DoClose(IWebBrowser browserControl, IBrowser browser) {
return false;
}
}
}