如何处理CefSharp Offscreen中的弹出链接

时间:2016-08-24 17:05:47

标签: c# console-application cefsharp

我编写了一个使用CEF屏幕外渲染模式的控制台应用程序,并提供了自己的窗口,其中显示了从CEF渲染引擎返回的图像。 我设法让子窗口打开(和关闭),但我有一个问题与#34;连接AccelAero"功能,如http://reservations.daallo.com/xbe/public/showLogin.action。 在这样的网站中,弹出一个新窗口,允许用户输入他/她的FB凭证。然后弹出窗口关闭,网站让你进入。 在我的实现中,弹出窗口确实出现了,但是一旦被批准它就保持打开而没有内容(使用Dev-Tools测试显示它不再连接),并且在父窗口中没有任何反应。

public class LifeSpanHandler : ILifeSpanHandler
{     
    public void OnAfterCreated(IWebBrowser browserControl, IBrowser browser)
    {

    }

    public bool DoClose(IWebBrowser browserControl, IBrowser browser)
    {
        return false;
    }

    public void OnBeforeClose(IWebBrowser browserControl, IBrowser browser)
    {

    }

    public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
    {
        //var chromiumWebBrowser = (ChromiumWebBrowser)browserControl;
        //var windowX = (windowInfo.X == int.MinValue) ? double.NaN : windowInfo.X;
        //var windowY = (windowInfo.Y == int.MinValue) ? double.NaN : windowInfo.Y;
        //var windowWidth = (windowInfo.Width == int.MinValue) ? double.NaN : windowInfo.Width;
        //var windowHeight = (windowInfo.Height == int.MinValue) ? double.NaN : windowInfo.Height;

        ChromiumWebBrowser chromiumBrowser = null;
        /*
           it is a website which have a scripts that start a new popup 
           on its first page and when I want to grab the handler of the 
           popup window in a new page the scripts of the page understand
           this and reopen a new popup window which I want to grab its 
           handler too.
        */
        chromiumBrowser = new ChromiumWebBrowser(targetUrl);
        chromiumBrowser.SetAsPopup();
        chromiumBrowser.LifeSpanHandler = this;
        newBrowser = chromiumBrowser;
        return true; //Infinite loop
    }
}

通话:

   browser = new ChromiumWebBrowser("http://reservations.daallo.com/xbe/public/showLogin.action");
   browser.LifeSpanHandler = new LifeSpanHandler();

0 个答案:

没有答案