public FormBrowser(PluginSchemeFactory pluginScheme) { InitializeComponent(); Text = Program.BrandName; this.plugins = new PluginManager(Program.Config.Plugins, Program.PluginPath, Program.PluginDataPath); this.plugins.Reloaded += plugins_Reloaded; this.plugins.Executed += plugins_Executed; this.plugins.Reload(); pluginScheme.Setup(plugins); this.notification = new FormNotificationTweet(this, plugins); this.notification.Show(); this.updates = new UpdateHandler(new UpdateCheckClient(Program.InstallerPath), TaskScheduler.FromCurrentSynchronizationContext()); this.updates.CheckFinished += updates_CheckFinished; this.updateBridge = new UpdateBridge(updates, this); this.updateBridge.UpdateAccepted += updateBridge_UpdateAccepted; this.updateBridge.UpdateDismissed += updateBridge_UpdateDismissed; this.browser = new TweetDeckBrowser(this, plugins, new TweetDeckBridge.Browser(this, notification), updateBridge); this.contextMenu = ContextMenuBrowser.CreateMenu(this); Controls.Add(new MenuStrip { Visible = false }); // fixes Alt freezing the program in Win 10 Anniversary Update Disposed += (sender, args) => { Config.MuteToggled -= Config_MuteToggled; Config.TrayBehaviorChanged -= Config_TrayBehaviorChanged; browser.Dispose(); }; Config.MuteToggled += Config_MuteToggled; this.trayIcon.ClickRestore += trayIcon_ClickRestore; this.trayIcon.ClickClose += trayIcon_ClickClose; Config.TrayBehaviorChanged += Config_TrayBehaviorChanged; UpdateTray(); if (Config.MuteNotifications) { UpdateFormIcon(); } if (Config.AllowDataCollection) { analytics = new AnalyticsManager(this, plugins, Program.AnalyticsFilePath); } RestoreWindow(); }
private static void Main() { SetupWinForms(); Cef.EnableHighDPISupport(); WindowRestoreMessage = NativeMethods.RegisterWindowMessage("TweetDuckRestore"); if (!FileUtils.CheckFolderWritePermission(StoragePath)) { FormMessage.Warning("Permission Error", "TweetDuck does not have write permissions to the storage folder: " + StoragePath, FormMessage.OK); return; } if (!LockManager.Lock(Arguments.HasFlag(Arguments.ArgRestart))) { return; } Config.LoadAll(); if (Arguments.HasFlag(Arguments.ArgImportCookies)) { ProfileManager.ImportCookies(); } else if (Arguments.HasFlag(Arguments.ArgDeleteCookies)) { ProfileManager.DeleteCookies(); } if (Arguments.HasFlag(Arguments.ArgUpdated)) { WindowsUtils.TryDeleteFolderWhenAble(InstallerPath, 8000); WindowsUtils.TryDeleteFolderWhenAble(Path.Combine(StoragePath, "Service Worker"), 4000); BrowserCache.TryClearNow(); } try{ ResourceRequestHandlerBase.LoadResourceRewriteRules(Arguments.GetValue(Arguments.ArgFreeze)); }catch (Exception e) { FormMessage.Error("Resource Freeze", "Error parsing resource rewrite rules: " + e.Message, FormMessage.OK); return; } BrowserCache.RefreshTimer(); CefSharpSettings.WcfEnabled = false; CefSharpSettings.LegacyJavascriptBindingEnabled = true; CefSettings settings = new CefSettings { UserAgent = BrowserUtils.UserAgentChrome, BrowserSubprocessPath = Path.Combine(ProgramPath, BrandName + ".Browser.exe"), CachePath = StoragePath, UserDataPath = CefDataPath, LogFile = ConsoleLogFilePath, #if !DEBUG LogSeverity = Arguments.HasFlag(Arguments.ArgLogging) ? LogSeverity.Info : LogSeverity.Disable #endif }; var pluginScheme = new PluginSchemeFactory(); settings.RegisterScheme(new CefCustomScheme { SchemeName = PluginSchemeFactory.Name, IsStandard = false, IsSecure = true, IsCorsEnabled = true, IsCSPBypassing = true, SchemeHandlerFactory = pluginScheme }); CommandLineArgs.ReadCefArguments(Config.User.CustomCefArgs).ToDictionary(settings.CefCommandLineArgs); BrowserUtils.SetupCefArgs(settings.CefCommandLineArgs); Cef.Initialize(settings, false, new BrowserProcessHandler()); Win.Application.ApplicationExit += (sender, args) => ExitCleanup(); FormBrowser mainForm = new FormBrowser(pluginScheme); Resources.Initialize(mainForm); Win.Application.Run(mainForm); if (mainForm.UpdateInstaller != null) { ExitCleanup(); if (mainForm.UpdateInstaller.Launch()) { Win.Application.Exit(); } else { RestartWithArgsInternal(Arguments.GetCurrentClean()); } } }