Dev Tools in CefSharp sample project

707 views
Skip to first unread message

DenStoreKlinge

unread,
Feb 25, 2013, 8:23:11 PM2/25/13
to cefs...@googlegroups.com
Hi

I downloaded the code/lib today and started playing with it. Looks cool. I noticed that in the Winform example, I can start a Dev Tool application, that fx shows the elements in a waterfall display, when downloading the website (e.g. shows each element as it is downloaded, it's size, download time and so on).

I would like to try build a small console that do something similar, just displays the properties/data as text for now. I assume I neeed to catch some events for each element downloaded, giving me the properties on the element.

Any suggestions on where to start in CefSharp and I would be extremely happy if someone could give me a C# code sample.

Thanks in advance.

Jack O'Connor

unread,
Feb 25, 2013, 10:58:07 PM2/25/13
to cefs...@googlegroups.com
Take a look at the IRequestHandler interface. You can implement that and then supply an instance of your implementation to the corresponding property on the webview you're using.



--
You received this message because you are subscribed to the Google Groups "CefSharp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

DenStoreKlinge

unread,
Feb 26, 2013, 4:36:37 AM2/26/13
to cefs...@googlegroups.com
Hi Jack

Thanks, that got me started. I looked into the samples and tried to construct a class based on what I found. This is what I came up with:

    public class CEFTest : IRequestHandler
    {
        public WebView view;

        public CEFTest(string _URL)
        {
            CefSharp.BrowserSettings browserSettings = new CefSharp.BrowserSettings();
            view = new CefSharp.WinForms.WebView("", browserSettings);
            view.RequestHandler = this;

            if (view.IsBrowserInitialized)
            {
                view.Load(_URL);
            }
        }

        public bool OnBeforeBrowse(IWebBrowser browser, IRequest request, NavigationType naigationvType, bool isRedirect)
        {
            return true;
        }

        public bool OnBeforeResourceLoad(IWebBrowser browser, IRequestResponse requestResponse)
        {
            return true;
        }

        public void OnResourceResponse(IWebBrowser browser, string url, int status, string statusText, string mimeType, System.Net.WebHeaderCollection headers)
        {
        }
    }

When I call the CEFTest constructor from my app, IsBrowserInitialized is always false. If I don't have this check, the Load method fails with "Browser not initialized". If I set the URL into the WebView constructor, this wont make a difference. I guess the WebView is missing some initialize part, which it would probably normally get from an app initialier for added components.
Reply all
Reply to author
Forward
0 new messages