Popup CefWebBrowser in new tab!

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.

Moderator: fddima

Popup CefWebBrowser in new tab!

Postby Doberman28 » Tue Mar 26, 2013 1:20 pm

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 ---//
}

}));
};
//////////////////////////////////////////////////////
Doberman28
Newbie
 
Posts: 1
Joined: Thu Feb 21, 2013 6:12 am

Re: Popup CefWebBrowser in new tab!

Postby fddima » Tue Mar 26, 2013 3:40 pm

fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: Popup CefWebBrowser in new tab!

Postby wy7980 » Sat Dec 13, 2014 2:03 am

but I want to know where should I add the codes:
browser.BeforePopup += (s, e) =>
{
BeginInvoke(new Action(() =>
{
var url = e.Url;
if (url != null)
{
_AddTab(url);
}
else
{
//---- Here is empty url ---//
}

}));
};

I tried to add those in cefglue.demo.winforms mainviewimpls.cs, but I'm afraid it's not right
wy7980
Newbie
 
Posts: 1
Joined: Fri Dec 12, 2014 10:39 am


Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 12 guests