What is the right way to block popup and open it in a new Tabitem ???
I have this code, and some links show empty url!
It can try from Gmail if incoming mail have links(any link).
/////////////////////////////////////////////////////////////////////////
internal sealed class CefWebLifeSpanHandler : CefLifeSpanHandler
{
private CefWebBrowser _core;
public CefWebLifeSpanHandler(CefWebBrowser core)
{
_core = core;
}
protected override bool OnBeforePopup(CefBrowser p_browser, CefPopupFeatures p_Features, CefWindowInfo cef_windowInfo, string cef_url, ref CefClient cef_client, CefBrowserSettings cef_settings)
{
_core.OnBeforePopup(p_browser, p_Features,cef_windowInfo, cef_url, ref cef_client, cef_settings);
return true;
}
//////////////////////////////////////////////////////////////////////////////////
public sealed class CefWebBrowser : Control
{
/-------------------------------------------------/
public event EventHandler<BeforePopupEventArgs> BeforePopup;
internal void OnBeforePopup(CefGlue.CefBrowser parentBrowser, CefPopupFeatures popupFeatures, CefWindowInfo cef_windowInfo, string url, ref CefClient client, CefBrowserSettings settings)
{
var handler = BeforePopup;
if (handler != null)
{
handler(this, new BeforePopupEventArgs(parentBrowser, popupFeatures, cef_windowInfo, url, ref client, settings));
}
}
}
//////////////////////////////////////////////////////////////
//This is new EventArgs class--
public sealed class BeforePopupEventArgs : EventArgs
{
private readonly CefBrowser _parentBrowser;
private readonly CefPopupFeatures _popupFeatures;
private readonly string _url;
private readonly CefClient _client;
private readonly CefBrowserSettings _settings;
private readonly CefWindowInfo _cef_windowInfo;
public BeforePopupEventArgs(CefBrowser parentBrowser, CefPopupFeatures popupFeatures, CefWindowInfo cef_windowInfo, string url, ref CefClient client, CefBrowserSettings settings)
{
_parentBrowser = parentBrowser;
_popupFeatures = popupFeatures;
_cef_windowInfo = cef_windowInfo;
_url = url;
_client = client;
_settings = settings;
}
public CefWindowInfo CefWindowInfo
{
get { return _cef_windowInfo; }
}
public CefBrowser ParentBrowser
{
get { return _parentBrowser; }
}
public CefPopupFeatures PopupFeatures
{
get { return _popupFeatures; }
}
public string Url
{
get { return _url; }
}
public CefClient Client
{
get { return _client; }
}
public CefBrowserSettings Settings
{
get { return _settings; }
}
}
//////////////////////////////////////////////////////////////
public partial class MainWindow : Window
{
/--------------------------------------------------------/
browser.BeforePopup += (s, e) =>
{
BeginInvoke(new Action(() =>
{
var url = e.Url;
if (url != null)
{
_AddTab(url);
}
else
{
//---- Here is empty url ---//
}
}));
};
//////////////////////////////////////////////////////