Block popups in the in-app browser

This commit is contained in:
Timothy Baldridge 2020-02-15 18:53:57 -07:00
parent 3a6aaee06b
commit 9343d38047
2 changed files with 40 additions and 0 deletions

View File

@ -1,5 +1,10 @@
### Changelog ### Changelog
#### Version - 0.9.20.0
* Don't reuse HTTP request objects (#532)
* Block popups in the in-app browser (#535)
#### Version - 0.9.19.0 #### Version - 0.9.19.0
* Disable server-side indexing of all mods from the Nexus * Disable server-side indexing of all mods from the Nexus
* Accept download states from clients and index the mods we haven't seen * Accept download states from clients and index the mods we haven't seen

View File

@ -37,6 +37,7 @@ namespace Wabbajack.Lib.WebAutomation
_browser.LoadingStateChanged += handler; _browser.LoadingStateChanged += handler;
_browser.Load(uri.ToString()); _browser.Load(uri.ToString());
_browser.DownloadHandler = new DownloadHandler(this); _browser.DownloadHandler = new DownloadHandler(this);
_browser.LifeSpanHandler = new PopupBlocker(this);
return tcs.Task; return tcs.Task;
} }
@ -65,6 +66,40 @@ namespace Wabbajack.Lib.WebAutomation
public string Location => _browser.Address; public string Location => _browser.Address;
} }
public class PopupBlocker : ILifeSpanHandler
{
private CefSharpWrapper _wrapper;
public PopupBlocker(CefSharpWrapper cefSharpWrapper)
{
_wrapper = cefSharpWrapper;
}
public bool OnBeforePopup(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string targetUrl,
string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures,
IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
{
// Block popups
newBrowser = null;
return true;
}
public void OnAfterCreated(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
}
public bool DoClose(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
return true;
}
public void OnBeforeClose(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
}
}
public class DownloadHandler : IDownloadHandler public class DownloadHandler : IDownloadHandler
{ {
private CefSharpWrapper _wrapper; private CefSharpWrapper _wrapper;