mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-23 12:15:48 +02:00
Work on abstracting app logic into libraries
This commit is contained in:
parent
12ec8baf5c
commit
51d2ec92ca
Browser
lib/TweetLib.Core/Features
2
Browser/FormBrowser.Designer.cs
generated
2
Browser/FormBrowser.Designer.cs
generated
@ -27,7 +27,7 @@ private void InitializeComponent() {
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = TweetDuck.Browser.TweetDeckBrowser.BackgroundColor;
|
||||
this.BackColor = TweetLib.Core.Features.TweetDeck.TweetDeckBrowser.BackgroundColor;
|
||||
this.ClientSize = new System.Drawing.Size(1008, 730);
|
||||
this.Icon = Properties.Resources.icon;
|
||||
this.Location = TweetDuck.Controls.ControlExtensions.InvisibleLocation;
|
||||
|
@ -1,21 +1,15 @@
|
||||
using CefSharp;
|
||||
using CefSharp.Handler;
|
||||
using TweetLib.Core;
|
||||
using TweetLib.Utils.Static;
|
||||
using TweetLib.Core.Features.Twitter;
|
||||
|
||||
namespace TweetDuck.Browser.Handling {
|
||||
sealed class CustomLifeSpanHandler : LifeSpanHandler {
|
||||
private static bool IsPopupAllowed(string url) {
|
||||
return url.StartsWithOrdinal("https://twitter.com/teams/authorize?") ||
|
||||
url.StartsWithOrdinal("https://accounts.google.com/") ||
|
||||
url.StartsWithOrdinal("https://appleid.apple.com/");
|
||||
}
|
||||
|
||||
public static bool HandleLinkClick(WindowOpenDisposition targetDisposition, string targetUrl) {
|
||||
switch (targetDisposition) {
|
||||
case WindowOpenDisposition.NewBackgroundTab:
|
||||
case WindowOpenDisposition.NewForegroundTab:
|
||||
case WindowOpenDisposition.NewPopup when !IsPopupAllowed(targetUrl):
|
||||
case WindowOpenDisposition.NewPopup when !TwitterUrls.IsAllowedPopupUrl(targetUrl):
|
||||
case WindowOpenDisposition.NewWindow:
|
||||
App.SystemHandler.OpenBrowser(targetUrl);
|
||||
return true;
|
||||
|
@ -17,8 +17,6 @@
|
||||
|
||||
namespace TweetDuck.Browser {
|
||||
sealed class TweetDeckBrowser : IDisposable {
|
||||
public static readonly Color BackgroundColor = Color.FromArgb(28, 99, 153);
|
||||
|
||||
public bool Ready => browserComponent.Ready;
|
||||
|
||||
public bool Enabled {
|
||||
@ -54,7 +52,7 @@ public TweetDeckBrowser(FormBrowser owner, PluginManager pluginManager, ITweetDe
|
||||
};
|
||||
|
||||
// ReSharper disable once PossiblyImpureMethodCallOnReadonlyVariable
|
||||
this.browser.BrowserSettings.BackgroundColor = (uint) BackgroundColor.ToArgb();
|
||||
this.browser.BrowserSettings.BackgroundColor = (uint) TweetDeckBrowserImpl.BackgroundColor.ToArgb();
|
||||
|
||||
var extraContext = new TweetDeckExtraContext();
|
||||
var resourceHandlerRegistry = new CefResourceHandlerRegistry();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using TweetLib.Browser.Base;
|
||||
using TweetLib.Browser.Contexts;
|
||||
using TweetLib.Browser.Events;
|
||||
@ -16,6 +17,8 @@
|
||||
|
||||
namespace TweetLib.Core.Features.TweetDeck {
|
||||
public sealed class TweetDeckBrowser : BaseBrowser<TweetDeckBrowser> {
|
||||
public static readonly Color BackgroundColor = Color.FromArgb(28, 99, 153);
|
||||
|
||||
private const string NamespaceTweetDeck = "tweetdeck";
|
||||
private const string BackgroundColorOverride = "setTimeout(function f(){let h=document.head;if(!h){setTimeout(f,5);return;}let e=document.createElement('style');e.innerHTML='body,body::before{background:#1c6399!important;margin:0}';h.appendChild(e);},1)";
|
||||
|
||||
|
@ -22,6 +22,12 @@ public static bool IsTwitterLogin2Factor(string url) {
|
||||
return url.Contains("://twitter.com/account/login_verification") || url.Contains("://mobile.twitter.com/account/login_verification");
|
||||
}
|
||||
|
||||
public static bool IsAllowedPopupUrl(string url) {
|
||||
return url.StartsWithOrdinal("https://twitter.com/teams/authorize?") ||
|
||||
url.StartsWithOrdinal("https://accounts.google.com/") ||
|
||||
url.StartsWithOrdinal("https://appleid.apple.com/");
|
||||
}
|
||||
|
||||
public static string? GetFileNameFromUrl(string url) {
|
||||
return StringUtils.NullIfEmpty(Path.GetFileName(new Uri(url).AbsolutePath));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user