unsolicited popup blocking

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

unsolicited popup blocking

Postby dcaputi » Tue Jan 14, 2014 3:26 pm

Hi,
I'm using CEF for hosting web based ads in my native C++ windows application.
Occasionally, an ad will misbehave and launch an annoying, unwanted and sometimes dangerous (phishing) popup. To stop this behavior I'm simply returning true in the ClientHandler::OnBeforePopup method.
Unfortunately, this is too strict since ALL popups will be disabled including any that are initiated by the user (i.e. after a mouse click)

To work around this problem I'm handling the WM_PARENTNOTIFY message for wParam == WM_LBUTTONDOWN in my window that hosts the CEF browser. The handler records the event and allows popup calls within a one second time window. As a side note, I was unable to make use of any mouse events that are serviced in the CefBrowserHost since this object is not referenced anywhere in my implementation (is that only for off screen rendered content?)

My question is this: Is there a better or more standard way to do this?

Thanks in advance,
-Dan C.
dcaputi
Techie
 
Posts: 20
Joined: Thu Nov 21, 2013 9:38 am

Re: unsolicited popup blocking

Postby magreenblatt » Tue Jan 14, 2014 8:58 pm

You could create the popup window initially hidden (via CefWindowInfo settings in OnBeforePopup) and then wait for OnBeforeBrowse to determine if it should be shown or destroyed. CefRequest::GetTransitionType may allow you to differentiate.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 211 guests