Well, I'm answering this question myself.
It turned out that the CefRequest object "HandleBeforeBrowse" is seeing, is created only for the sake of this call. It's destroyed afterwards. Modifications to it are hence lost, and not visible to WebKit.
To workaround this problem, in BrowserWebViewDelegate::decidePolicyForNavigation of browser_webview_delegate.cc of "libcef_static". I added:
- Code: Select all
CefRequest::HeaderMap aftermap;
static_cast<CefRequestImpl*>(req.get())->GetHeaderMap(aftermap);
for (CefRequest::HeaderMap::iterator it = aftermap.begin();
it != aftermap.end(); it++)
((WebURLRequest&)request).setHTTPHeaderField(webkit_glue::StdStringToWebString(WideToUTF8(it->first)),
webkit_glue::StdStringToWebString(WideToUTF8(it->second)));
right after the "HandleBeforeBrowse" call. Though obvious this only took care of the header map.
I noticed that this is probably not a good idea because you have a "const" restriction on the |request| argument. But if HandleBeforeBrowse were to be able to modify something, |request| cannot be const.
I'm using this mechanism to add custom headers to keep track of multi-window situations.