This is normal.
From include/cef_request_handler.h
- Code: Select all
class CefRequestHandler : public virtual CefBaseRefCounted {
...
///
// Called on the UI thread before browser navigation. Return true to cancel
// the navigation or false to allow the navigation to proceed. The |request|
// object cannot be modified in this callback.
// CefLoadHandler::OnLoadingStateChange will be called twice in all cases.
// If the navigation is allowed CefLoadHandler::OnLoadStart and
// CefLoadHandler::OnLoadEnd will be called. If the navigation is canceled
// CefLoadHandler::OnLoadError will be called with an |errorCode| value of
// ERR_ABORTED. The |user_gesture| value will be true if the browser
// navigated via explicit user gesture (e.g. clicking a link) or false if it
// navigated automatically (e.g. via the DomContentLoaded event).
///
/*--cef()--*/
virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
bool user_gesture,
bool is_redirect) {
return false;
}
So:
1. The |request| object cannot be modified in this callback.
2. If the navigation is canceledCefLoadHandler::OnLoadError will be called with an |errorCode| value of ERR_ABORTED.
I'd try using OnOpenURLFromTab instead. Although the implementation ends with a comment which is not encouraging.
libcef/browser/browser_host_impl.cc
- Code: Select all
// |source| may be NULL if the navigation originates from a guest view via
// CefContentBrowserClient::CanCreateWindow.
content::WebContents* CefBrowserHostImpl::OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) {
bool cancel = false;
if (client_.get()) {
CefRefPtr<CefRequestHandler> handler = client_->GetRequestHandler();
if (handler.get()) {
cancel = handler->OnOpenURLFromTab(
this, GetFrame(params.frame_tree_node_id), params.url.spec(),
static_cast<cef_window_open_disposition_t>(params.disposition),
params.user_gesture);
}
}
if (!cancel) {
// Start a navigation in the current browser that will result in the
// creation of a new render process.
LoadURL(CefFrameHostImpl::kMainFrameId, params.url.spec(), params.referrer,
params.transition, params.extra_headers);
return source;
}
// We don't know where the navigation, if any, will occur.
return nullptr;
}