diff --git a/Wabbajack.Common/Consts.cs b/Wabbajack.Common/Consts.cs index c30fe04c..4a072a48 100644 --- a/Wabbajack.Common/Consts.cs +++ b/Wabbajack.Common/Consts.cs @@ -127,6 +127,8 @@ namespace Wabbajack.Common public static AbsolutePath SettingsFile => LocalAppDataPath.Combine("settings.json"); public static RelativePath SettingsIni = (RelativePath)"settings.ini"; public static byte SettingsVersion => 2; + public static AbsolutePath CefCacheLocation = @"CEF".RelativeTo(LocalAppDataPath); + public static Extension SeqExtension = new Extension(".seq"); public static RelativePath SettingsJson = (RelativePath)"settings.json"; diff --git a/Wabbajack.Lib/LibCefHelpers/Init.cs b/Wabbajack.Lib/LibCefHelpers/Init.cs index 9f3c9985..5976b180 100644 --- a/Wabbajack.Lib/LibCefHelpers/Init.cs +++ b/Wabbajack.Lib/LibCefHelpers/Init.cs @@ -12,6 +12,7 @@ using CefSharp; using CefSharp.OffScreen; using Wabbajack.Common; using Wabbajack.Common.Serialization.Json; +using Cookie = CefSharp.Cookie; namespace Wabbajack.Lib.LibCefHelpers { @@ -89,11 +90,31 @@ namespace Wabbajack.Lib.LibCefHelpers if (Inited) return; Inited = true; CefSettings settings = new CefSettings(); - settings.CachePath = Path.Combine(Consts.LocalAppDataPath + @"\CEF"); + settings.CachePath = Consts.CefCacheLocation.ToString(); Cef.Initialize(settings); } public static bool Inited { get; set; } + + public static void ClearCookies() + { + var manager = Cef.GetGlobalCookieManager(); + var visitor = new CookieDeleter(); + manager.VisitAllCookies(visitor); + } + } + + class CookieDeleter : ICookieVisitor + { + public void Dispose() + { + } + + public bool Visit(Cookie cookie, int count, int total, ref bool deleteCookie) + { + deleteCookie = true; + return true; + } } public static class ModuleInitializer diff --git a/Wabbajack.Lib/WebAutomation/WebAutomation.cs b/Wabbajack.Lib/WebAutomation/WebAutomation.cs index 3ae0276f..85409c4e 100644 --- a/Wabbajack.Lib/WebAutomation/WebAutomation.cs +++ b/Wabbajack.Lib/WebAutomation/WebAutomation.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using System.Windows; using CefSharp; using CefSharp.OffScreen; +using Wabbajack.Lib.LibCefHelpers; namespace Wabbajack.Lib.WebAutomation { @@ -62,5 +63,10 @@ namespace Wabbajack.Lib.WebAutomation { _browser.Dispose(); } + + public static void ClearCache() + { + Helpers.ClearCookies(); + } } } diff --git a/Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml b/Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml index 3b54797d..dbc6ad8f 100644 --- a/Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml +++ b/Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml @@ -38,11 +38,15 @@ FontFamily="Lucida Sans" FontSize="20" FontWeight="Bold" - Text="Modlist Gallery" /> + Text="Misc Settings" /> + + + + - + + diff --git a/Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml.cs b/Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml.cs index f314727f..d9f16a06 100644 --- a/Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml.cs +++ b/Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml.cs @@ -16,6 +16,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using ReactiveUI; using Wabbajack.Common; +using Wabbajack.Lib.WebAutomation; namespace Wabbajack { @@ -33,6 +34,8 @@ namespace Wabbajack // Bind Values this.Bind(this.ViewModel, x => x.IsPersistent, x => x.FilterPersistCheckBox.IsChecked) .DisposeWith(disposable); + + this.ClearCefCache.Click += (sender, args) => {Driver.ClearCache();}; }); } }