How to properly implement LoadURL(url, referrer) method?

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.

How to properly implement LoadURL(url, referrer) method?

Postby fddima » Mon Mar 13, 2017 2:06 am

Hello.

What's is best practices to properly implement LoadURL(url, referrer) method?

Topic modeled on CEF 57.

Approach #1: Attempt to use LoadRequest

Basically we easily can create request for browser and call Frame::LoadRequest.

Question: What is drawbacks? Do request will be same as browser-generated (in terms of headers)?

Problem: When browser created with "about:blank" starting URL, then call LoadRequest to actual navigating - referrer is not set.
Next LoadRequest call work as expected - referrer is overriden as expected.
If it is bug - then let's fill bug?

Approach #2: Attempt to use OnBeforeResourceLoad

We can intercept request in OnBeforeResourceLoad and set referrer in this method. But this solution turns problem from one to another: now we need to identify correct request which requires referrer override. Also, i think, we loosing referrer policies in that case.

What's is reliable way or best practices to detect correct request here?

Approach #3: Hybrid

Of course it is fairly easily to combine #1 and #2 together (in that case we need handle only first navigation-related resource load) - but feels like dirty workaround.


What's correct way to deal with?
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: How to properly implement LoadURL(url, referrer) method?

Postby magreenblatt » Mon Mar 13, 2017 11:37 am

OnBeforeResourceLoad is the best option currently. LoadRequest/LoadString only work if the renderer process already exists, so cannot be used for the initial navigation. See https://bitbucket.org/chromiumembedded/cef/issues/1587 for another possible solution.
magreenblatt
Site Admin
 
Posts: 12402
Joined: Fri May 29, 2009 6:57 pm

Re: How to properly implement LoadURL(url, referrer) method?

Postby fddima » Mon Mar 13, 2017 12:09 pm

Hm.

I'm create browser and only then try to navigate - so renderer process is actually created and should be reused for any origin. But roots are clear.

But i'm of course are also seen that internally all params exist, so we only mainly miss API call.

So if you accept similar PR as in listed issue in future - then i'm will count on this way resolution.

Thanks!
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am


Return to Support Forum

Who is online

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