CEF3: OnBeforeNavigation never detects redirects

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.

CEF3: OnBeforeNavigation never detects redirects

Postby dreijer » Tue Mar 19, 2013 3:06 pm

My CEF3 (1138) browser is navigating to a location that redirects to a different URL (on the same domain). I get the callback for the second navigation in CefRenderProcessHandler::OnBeforeNavigation, but the 'is_redirect' parameter is always false. I see the same behavior in the cefclient test application.

Is this a bug or am I supposed to be looking elsewhere to detect this?
dreijer
Expert
 
Posts: 201
Joined: Mon Apr 11, 2011 10:09 pm

Re: CEF3: OnBeforeNavigation never detects redirects

Postby magreenblatt » Tue Mar 19, 2013 6:49 pm

The OnBeforeNavigation() callback comes from RenderViewImpl::decidePolicyForNavigation(). The |is_redirect| flag originates from WebDataSourceImpl::isRedirect().

Sounds like your problem may be related to https://code.google.com/p/chromiumembed ... ail?id=844.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF3: OnBeforeNavigation never detects redirects

Postby dreijer » Tue Mar 19, 2013 6:59 pm

Uhoh, so there's no way of determining redirects at all currently?
dreijer
Expert
 
Posts: 201
Joined: Mon Apr 11, 2011 10:09 pm

Re: CEF3: OnBeforeNavigation never detects redirects

Postby magreenblatt » Wed Mar 20, 2013 11:54 am

dreijer wrote:Uhoh, so there's no way of determining redirects at all currently?

You should be able to determine them at the network layer via CefRequestHandler::OnResourceRedirect().
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF3: OnBeforeNavigation never detects redirects

Postby dreijer » Fri Mar 22, 2013 12:18 am

magreenblatt wrote:You should be able to determine them at the network layer via CefRequestHandler::OnResourceRedirect().

Hmm, so I'm not sure if that's going to work for me or not. I'm using CefRenderProcessHandler::OnBeforeNavigation to cover the scenario we talked about here: viewtopic.php?f=6&t=10394

Basically, I need to be able to catch the navigation request and determine if it's allowed or not. The redirect flag is a big part of that since in most cases I'm hitting up a preset URL, which I explicitly allow navigation to, and then that redirects me to a different URL that I know nothing about and thus cannot validate, but I know the navigation is allowed because it's simply a redirect from a "trusted" page.

How would I go about achieving this?
dreijer
Expert
 
Posts: 201
Joined: Mon Apr 11, 2011 10:09 pm

Re: CEF3: OnBeforeNavigation never detects redirects

Postby magreenblatt » Fri Mar 22, 2013 9:01 am

Why should a redirect from a "trusted" page to an "untrusted" page be allowed when visiting that "untrusted" page directly from the original "trusted" page would be disallowed? Sounds like faulty logic to me. You should probably either trust the redirect page as well or disallow the redirect.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF3: OnBeforeNavigation never detects redirects

Postby dreijer » Fri Mar 22, 2013 9:12 am

The browser navigates to a trusted page with a predefined URL on our server. Our server then redirects to the actual page I'm supposed to be showing in the browser. I don't know what that actual page is, so I can't explicitly validate it. That is, I just allow the redirect because I know it came from the original navigation I allowed.

On the other hand, I want to explicitly disallow the user from navigating to any page he wants.

So in short, I have a list of allowed URLs and I'm allowing redirects from those pages, but nothing else.
dreijer
Expert
 
Posts: 201
Joined: Mon Apr 11, 2011 10:09 pm

Re: CEF3: OnBeforeNavigation never detects redirects

Postby magreenblatt » Fri Mar 22, 2013 11:01 am

Unfortunately I don't have a great solution for you. You'll have to track the redirect state in your application somehow. Maybe if you're lucky the 'Referer' header will be set correctly on the redirect requests.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF3: OnBeforeNavigation never detects redirects

Postby dreijer » Fri Mar 22, 2013 11:20 am

magreenblatt wrote:Unfortunately I don't have a great solution for you. You'll have to track the redirect state in your application somehow. Maybe if you're lucky the 'Referer' header will be set correctly on the redirect requests.

Yeah, that's what I thought. :( I really just need the actual Chromium bug fix for the redirect parameter to be set properly. Do you know if it's anywhere on anybody's radar over at Chromium HQ? Or who I can give a big kiss to fix it? :P
dreijer
Expert
 
Posts: 201
Joined: Mon Apr 11, 2011 10:09 pm

Re: CEF3: OnBeforeNavigation never detects redirects

Postby magreenblatt » Fri Mar 22, 2013 11:30 am

You can submit a patch for the WebKit issue. That's about it.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

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