Any reason to prefer CefSharp over CefGlue (or vice-versa)?

1,175 views
Skip to first unread message

Christian LeMoussel

unread,
Mar 27, 2015, 7:13:19 AM3/27/15
to cefs...@googlegroups.com
Hi,

For decent implementation of the Chromium Embedded Framework (CEF) for .Net, there are two leading options appear to be CefSharp and CefGlue.
I notice that they differ in approach :
  • CefGlue uses P/Invoke to call into the CEF unmanaged code
  • CefSharp uses a mixed-mode C++/CLI wrapper around the CEF libraries

it seems that CefGlue are more functionality (certain events, CLR<>JS interaction etc. ) than CefSharp. All of them supports Mono.

My application (browser off screen rendering) requirements are to get more informations about HTML page & HTTP request  like

  • Http Status code
  • Headers fields
  • redirection Url
  • HTML Source
  • Character Set /  Encoding
  • Content Format
  • JavaScript integration (Insert & Execute JavaScript code in HTML page)

All this is carried out with CefGlue.

But I think CefSharp is more simpler that It has a NuGet bundle (so it is easy to use and update) & supports newer version of WPF (.NET 4+).


For all these all requirements and the most up to date CEF version. Should I go with CEFSharp?

Is there anyone out there with experience with both libraries?

Alex Maitland

unread,
Mar 27, 2015, 8:24:09 AM3/27/15
to cefs...@googlegroups.com
I can't provide an unbiased opinion on the subject as I've never used `CefGlue` and I have invested quite a bit of time into `CefSharp`. So I'll just give you the FYI that our `OffScreen` implementation is the least developed flavor of `CefSharp`, It doesn't get the same attention as the `WinForms` or `WPF` versions.

We do our best to keep things up to date, there aren't that many active contributors, so we're doing our best to build an active community (I think `CefGlue` probably has less contributors, though I could be mistaken).

If you have spare time, feel free to get involved! More the merrier!

Christian LeMoussel

unread,
Mar 27, 2015, 8:35:29 AM3/27/15
to cefs...@googlegroups.com
Alex,

If you have spare time, feel free to get involved! More the merrier!
Why not?

but I am newbie with CEF.
To start that any help / contribution would you need?

Christia.

Alex Maitland

unread,
Mar 27, 2015, 8:55:22 AM3/27/15
to cefs...@googlegroups.com
 but I am newbie with CEF
 
Everyone has to start somewhere :)

I think `CefSharp` is like most open source projects, use it for a while, see what features are missing or what documentation is lacking, then ask what can be done about it? :)

Christian LeMoussel

unread,
Mar 27, 2015, 10:11:02 AM3/27/15
to cefs...@googlegroups.com
Can you tell me if this functionality is implemented in CefSharp

  • Http Status code
  • Response Headers
  • redirection Url
  • HTML Source
    • ChromiumWebBrowser.GetSourceAsync() ?
  • Character Set /  Encoding
  • Content Format
  • JavaScript integration (Insert & Execute JavaScript code in HTML page)
    • ChromiumWebBrowser.ExecuteScriptAsync() ?

Alex Maitland

unread,
Mar 27, 2015, 10:43:13 AM3/27/15
to cefs...@googlegroups.com
Can you provide a little more detail please? A brief usage scenario?

Christian LeMoussel

unread,
Mar 27, 2015, 11:06:33 AM3/27/15
to cefs...@googlegroups.com
I am developing a crawler. For each page found/not found  I need some informations.
The first
version of my crawler uses HttpRequest
. But somes sites use Javascript/Ajax Jquery to render.
Hence the idea of using CEF


So I need all the information in the Http response.
And I have to be able to inject/exute javascript code to explore DOM to find href links.

Alex Maitland

unread,
Mar 27, 2015, 6:15:52 PM3/27/15
to cefs...@googlegroups.com
FrameLoadEnd exposes the HttpStatusCode.

Look at `IRequestHandler`, it will allow you to hook into some of the lower level request mechanics. `OnBeforeBrowse` will likely be very helpful.

Injecting script and getting source should be no problem. `EvaluateScriptAsync` is likely the one I'd use in an offscreen scenario, you can wait for the task to execute. Where `ExecuteScriptAsync` is a fire and forget kinda method.

If there's something `CEF` can do, that's not exposed on `CefSharp`, then for the most part it's relatively easy to implement your typical feature.

I'm not sure what you mean by `Content Format`

Christian LeMoussel

unread,
Mar 28, 2015, 3:04:35 AM3/28/15
to cefs...@googlegroups.com
Hi Alex ,
  • JavaScript integration (Insert & Execute JavaScript code in HTML page)
    • ChromiumWebBrowser.EvaluateScriptAsync()

Does `CefSharp` expose all HTTP-response information (HttpResponse Class)?

Alex Maitland

unread,
Mar 28, 2015, 5:44:37 AM3/28/15
to cefs...@googlegroups.com

Incase you haven't found it already, the `CEF` api doc is quite useful http://magpcss.org/ceforum/apidocs3/index-all.html

`IRequest` is the interface exposed by `CefSharp`, it has most things exposed, what's not there should be easy to implement. The `HttpResponse` class is a `.Net` thing, not used by `CefSharp`.

`CefResourceHandler` is used to when you wish to intercept a request and fulfill the response yourself. Useful for loading files from disk, etc. Is that what your looking for? (This isn't `CefSharp` specific, would be the same in `CefGlue`).

You can use `IRequestHandler.OnBeforeResourceLoad` to perform a redirect if you need to.

`Content-Type` is just a header for which you should be able to derive the encoding.

Alex Maitland

unread,
Mar 28, 2015, 6:11:16 AM3/28/15
to cefs...@googlegroups.com
Was reading over the Redirect code, it was overly complicated (left over from an old version of `CEF`).

So I'm going to simplify it see https://github.com/cefsharp/CefSharp/pull/911

Christian LeMoussel

unread,
Mar 28, 2015, 6:43:22 AM3/28/15
to cefs...@googlegroups.com
OK what you said int this issue "to perform Redirect simply set the IRequest.Url"

bool IRequestHandler.OnBeforeResourceLoad(IWebBrowser browser, IRequest request, bool isMainFrame)
{
  // Redirection
   request.Url = WhatyouDO;
  return false;
}

But how to know if request Url is redirected to another?
I want to knon the request Url & the redirected Url
eg http://httpbin.org/redirect/1 => 302 Redirectd to http://httpbin.org/get

Request Url =
http://httpbin.org/redirect/1
Redirected Url =
http://httpbin.org/get


Rem: Excuse me for these noobs questions. But I started with CefSharp / CEF


Christian.

Message has been deleted

Christian LeMoussel

unread,
Mar 28, 2015, 12:34:20 PM3/28/15
to cefs...@googlegroups.com
`IRequest` is the interface exposed by `CefSharp`, it has most things exposed, what's not there should be easy to implement. The `HttpResponse` class is a `.Net` thing, not used by `CefSharp`.

Do you have some example on how to use IRequest interface?

Alex Maitland

unread,
Mar 29, 2015, 4:20:07 AM3/29/15
to cefs...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages