AJAX request in CEF

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

AJAX request in CEF

Postby punamg » Thu Nov 13, 2014 10:39 pm

Hi,

I am trying to intercept an AJAX request from my CEF side.
Can you please tell me which API should i override in order to intercept the AJAX request. Currently i tried putting break points in ProcessRequest and ReadResponse of my CefWebResourceHandler derived from CefResourceHandler but its failing.

ALso in the logs i can see the following lines
[1113/224423:INFO:CONSOLE(0)] "[blocked] The page at 'https://xxx.com/app?newWindow=true' was loaded over HTTPS, but ran insecure content from 'native://ajax?v=141589876766&cmd=status&data=y': this content should also be loaded over HTTPS.
[1113/224423:VERBOSE1:navigator_impl.cc(192)] Failed Provisional Load: native://ajax?v=141589876766&cmd=status&data=y, error_code: -3, error_description: , showing_repost_interstitial: 0, frame_id: 21

Can you please tell me what am I doing wrong here.

With Regards
Punam
punamg
Techie
 
Posts: 43
Joined: Thu Dec 05, 2013 6:00 am

Re: AJAX request in CEF

Postby magreenblatt » Thu Nov 13, 2014 11:34 pm

You can't load insecure content from https without disabling web security. Try registering your custom scheme handler to use the "https" scheme instead of "native". See http://www.chromium.org/Home/chromium-s ... rabilities for background.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: AJAX request in CEF

Postby punamg » Mon Nov 17, 2014 11:45 pm

Hi Magreen,

I cannot change the scheme handler to "https" from "native". That is beyond the scope of my application. However, I need to intercept this request from my side.
I tried making the following changes in the code .


Code: Select all
var schemeHandler = new MySchemeHandlerFactory();
CefRuntime.RegisterSchemeHandlerFactory("native", "", schemeHandler);


Code: Select all
class MySchemeHandlerFactory : CefSchemeHandlerFactory
    {
        protected override CefResourceHandler Create(CefBrowser browser, CefFrame frame, string schemeName, CefRequest request)
        {
            return new QBCefWebResourceHandler(browser);
        }
    }


Code: Select all
protected override void OnRegisterCustomSchemes(CefSchemeRegistrar registrar)
{
        registrar.AddCustomScheme("native", true, false, false);
}


However, I am unable to get a hit in MySchemeHandlerFactory's CefResourceHandler Create method. I can still see in the logs the blocked message
[1113/224423:INFO:CONSOLE(0)] "[blocked] The page at 'https://xxx.com/app?newWindow=true' was loaded over HTTPS, but ran insecure content from 'native://ajax?v=141589876766&cmd=status&data=y': this content should also be loaded over HTTPS.

Please help me as i am stuck at this point. I want to get this "native" AJAX request and not have it blocked from CEF side.
punamg
Techie
 
Posts: 43
Joined: Thu Dec 05, 2013 6:00 am

Re: AJAX request in CEF

Postby punamg » Wed Nov 19, 2014 2:38 am

Hi,

Please can someone help me on this. I am kinda stuck at this point.

I am repeatedly getting this error
[1113/224423:INFO:CONSOLE(0)] "[blocked] The page at 'https://xxx.com/app?newWindow=true' was loaded over HTTPS, but ran insecure content from
'native://ajax?v=141589876766&cmd=status&data=y': this content should also be loaded over HTTPS.

I need to intercept this AJAX request "native://ajax?v=141589876766&cmd=status&data=y" in my CEF code. Since the page is loading on https and this AJAX request starts with custom scheme "native", i understand that is why it is getting blocked.
But what is the work around for it. There should be some way that CEF doesnt block this request.
I have tried registering the custom scheme handler "native" in my code as shown above, but still it is not working.

Please help. I am unable to proceed further because of this. What am i doing wrong here !!
punamg
Techie
 
Posts: 43
Joined: Thu Dec 05, 2013 6:00 am

Re: AJAX request in CEF

Postby magreenblatt » Wed Nov 19, 2014 10:41 am

Why can't you replace "native" with "https"? Alternately, you can disable web security by passing the `--disable-web-security` flag but that's not recommended for applications that access the internet.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 44 guests