Pluggable MIME filter equivalent

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.

Pluggable MIME filter equivalent

Postby yyankov » Sat May 14, 2011 11:23 am

Hi Marshall,

I need to be able to inspect and modify the data as received from the Internet but prior to it being consumed by the browser. This would be the CEF equivalent of IE's Pluggable MIME Filters. I've been looking around the API but so far I've been unable to figure it out. I'm not posting in the Feature Request forum, because I'm hoping there might be an easy way to do this that I'm overlooking.

So far, I've tried the scheme handler approach, and I also tried grabbing the source HTML in CefHandler::HandleLoadEnd(), modifying it and LoadString()-ing it. Both approaches get me in a mess fast and neither has produced reliable results so far.

I suspect CEF needs to be extended to allow for this (probably somewhere around RequestProxy), but my understanding of CEF's internals and WebKit is not yet sufficiently in-depth. What are your thoughts on this?

Thank you!
yyankov
Techie
 
Posts: 10
Joined: Fri May 21, 2010 12:10 pm

Re: Pluggable MIME filter equivalent

Postby magreenblatt » Sat May 14, 2011 9:01 pm

What kind of filtering do you need to do? You could potentially intercept the load request in HandleBeforeResourceLoad, load the request contents yourself using CefWebURLRequest, and return the filtered results via the |resourceStream| argument.
magreenblatt
Site Admin
 
Posts: 9976
Joined: Fri May 29, 2009 6:57 pm

Re: Pluggable MIME filter equivalent

Postby yyankov » Sun May 15, 2011 3:59 am

What kind of filtering do you need to do?

I need to be able to calculate hash codes/check sums of all downloaded resources. For HTML resources I need to be able to inject and/or replace with some additional HTML in some cases.

You could potentially intercept the load request in HandleBeforeResourceLoad, load the request contents yourself using CefWebURLRequest, and return the filtered results via the |resourceStream| argument.

I have tried this, but forgot to mention it. There are two problems with it:

  • How do I make sure the browser observes HTTP redirects when these take place during the download?
  • CEF expects to have the data fully available in the resource stream when HandleBeforeResourceLoad() returns. That would mean blocking on the IO thread which, unless I'm doing it wrong, turns out to be problematic for CefWebURLRequest for some reason and results in a deadlock. The problem with the scheme handler is similar - when CefSchemeHandler::ReadResponse() is called, CEF expects to have all the data returned at once or it stops reading.
yyankov
Techie
 
Posts: 10
Joined: Fri May 21, 2010 12:10 pm

Re: Pluggable MIME filter equivalent

Postby yyankov » Thu Jun 09, 2011 3:16 am

Just a followup in case anyone else need this. Support for content filtering has been added in r243.
yyankov
Techie
 
Posts: 10
Joined: Fri May 21, 2010 12:10 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 31 guests