Close second browser and return control to first browser

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

Moderator: fddima

Close second browser and return control to first browser

Postby Artem » Sat Jul 21, 2018 12:09 pm

Hello

1. I create a first browser with OSR rendering and load page
2. Next I find a link on page and click it with CefBrowserHost->SendMouseClickEvent()
3. Link has a target=blank attribute and implement CefLifeSpanHandler for catching OnBeforePopup event and create second browser windowless too.
4. When second browser page loaded I register CefV8Handler and execute some JS code for finding buttons on page and click with CefBrowserHost->SendMouseClickEvent()
5. After that I call CefBrowserHost->CloseBrowser(true)

How to return control to first CefBrowser?

I try to implement CefRenderProcessHandler->OnBrowserCreated and OnBrowserDestroyed

OnBrowserCreated called twice, with browser identifier 1 and after creating second browser with identifier 2, but OnBrowserDestroyed not called.

CefFocusHandler how I understand used for page inputs and controls focus, not for browser tabs

Also I tried to save reference to first CefBrowser in global object, but in second browser I get null reference.
Artem
Newbie
 
Posts: 5
Joined: Fri May 18, 2018 9:20 am

Re: Close second browser and return control to first browser

Postby magreenblatt » Sat Jul 21, 2018 1:59 pm

What do you mean by "return control to first CefBrowser"? Do you mean focus some control in the first browser?
magreenblatt
Site Admin
 
Posts: 9831
Joined: Fri May 29, 2009 6:57 pm

Re: Close second browser and return control to first browser

Postby Artem » Sat Jul 21, 2018 2:23 pm

I want to execute JS in first browser, after closing second browser.
Artem
Newbie
 
Posts: 5
Joined: Fri May 18, 2018 9:20 am

Re: Close second browser and return control to first browser

Postby magreenblatt » Sat Jul 21, 2018 7:27 pm

You can use the ExecuteJavaScript method. See https://bitbucket.org/chromiumembedded/ ... gration.md
magreenblatt
Site Admin
 
Posts: 9831
Joined: Fri May 29, 2009 6:57 pm

Re: Close second browser and return control to first browser

Postby Artem » Sun Jul 22, 2018 1:03 am

I don't understand how I can use this method.

For example, in second browser
Code: Select all
internal class SecondBrowserCefClient : CefClient
{
        protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
        {
            if (message.Name == "CLOSE_BROWSER")
            {
                browser.GetHost().CloseBrowser(true);
            }

            return false;
        }
}


This code close second browser, where I can call ExecuteJavaScript for first browser?
Artem
Newbie
 
Posts: 5
Joined: Fri May 18, 2018 9:20 am


Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 1 guest

cron