OnBeforePopup GMail attachment

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.

OnBeforePopup GMail attachment

Postby ScottV » Wed Jul 02, 2014 9:27 pm

When opening an attachment in GMail, clicking the print button opens a popup window which calls "OnBeforePopup" but the "target_url" argument is NULL.

In the CEF Client application a new windows is opened to the correct URL, but we need to capture the URL so we can open our own window.

Is there any way to capture the URL in the "OnBeforePopup" function when printing attachments from GMail?

Thank you,
Scott
ScottV
Techie
 
Posts: 27
Joined: Thu Mar 27, 2014 1:22 pm

Re: OnBeforePopup GMail attachment

Postby magreenblatt » Wed Jul 02, 2014 10:00 pm

What OS and CEF3 version?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: OnBeforePopup GMail attachment

Postby ScottV » Thu Jul 03, 2014 10:10 am

CEF OS: Windows 32bit

Tested builds -

CEF3 DEV: 2014-07-01 3.2042.1752
CEF3 1916: 2014-06-17 3.1916.1749
CEF3 1750: 2014-06-11 3.1750.1738
CEF3 1650: 2014-03-14 3.1650.1639

Compiled with Visual Studio 2013 Professional on Windows 7 64 bit.

--Scott
ScottV
Techie
 
Posts: 27
Joined: Thu Mar 27, 2014 1:22 pm

Re: OnBeforePopup GMail attachment

Postby magreenblatt » Thu Jul 03, 2014 10:54 am

You can create the popup initially hidden and wait for the call to OnAfterCreated before deciding whether to show or close it. See viewtopic.php?f=6&t=10966.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: OnBeforePopup GMail attachment

Postby ScottV » Thu Jul 03, 2014 12:54 pm

Thank you, I will give it a try.

--Scott
ScottV
Techie
 
Posts: 27
Joined: Thu Mar 27, 2014 1:22 pm

Re: OnBeforePopup GMail attachment

Postby ScottV » Wed Jul 09, 2014 3:55 pm

Thank you magreenblatt, that did the trick.

As a follow up here is what I did.

Because my CEF Client Handler is derived from "CefClient" in the "OnBeforePopup" function in the handler class I set the "client" to the handler (this).

Code: Select all
// ClientHandler implementation.
class ClientHandler : public CefClient,
        public CefContextMenuHandler,
        public CefDisplayHandler,
        public CefDownloadHandler,
        public CefLifeSpanHandler,
        public CefLoadHandler,
        public CefRequestHandler
{
...
}


Code: Select all
bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& target_url, const CefString& target_frame_name, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings, bool* no_javascript_access)
{
        if(browser->GetHost()->IsWindowRenderingDisabled())
        {
                // Cancel popups in off-screen rendering mode.
                return true;
        }

        // set client to this calls to receive the "OnAfterCreate" calls
        client = this;

        // The frame window will be the parent of the browser window
        HWND hWindow = GetParent( browser->GetHost()->GetWindowHandle() );

        // send message
        LPCTSTR lpszURL(target_url.c_str());
        if( ::SendMessage( hWindow, WM_APP_CEF_WINDOW_CHECK, (WPARAM)&popupFeatures, (LPARAM)lpszURL) == S_FALSE )
                return true;

        // send message
        if( ::SendMessage( hWindow, WM_APP_CEF_NEW_WINDOW, (WPARAM)&popupFeatures, (LPARAM)&windowInfo) == S_FALSE )
                return true;

        // call parent
        return CefLifeSpanHandler::OnBeforePopup(browser, frame, target_url, target_frame_name, popupFeatures, windowInfo, client, settings, no_javascript_access);
}


I have updated the sample CEF MFC App to reflect this.
https://code.google.com/p/cef-mfc/

--Scott
ScottV
Techie
 
Posts: 27
Joined: Thu Mar 27, 2014 1:22 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 44 guests