GetResourceRequestHandler with chrome runtime and an extensi

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.

GetResourceRequestHandler with chrome runtime and an extensi

Postby BobM » Tue Jan 31, 2023 10:28 pm

Hi Marshall

In the process of converting to using chrome runtime, I've found that GetResourceRequestHandler is not called when I enable a chrome extension (AdBlock for example). It's working fine without chrome runtime enabled.

I understand this may not yet be fully implemented, or else I'm missing something. Can you please advise.

Thanks
Bob

With an extension enabled (from the chrome://extensions tab in CEF), I see that the call to GetResourceRequestHandler is not made.

This is WITHOUT chrome runtime....

    nbW.exe!client::TNBCefClientHandler::GetResourceRequestHandler(scoped_refptr<CefBrowser> browser={...}, scoped_refptr<CefFrame> frame={...}, scoped_refptr<CefRequest> request={...}, bool is_navigation=true, bool is_download=false, const CefStringBase<CefStringTraitsUTF16> & request_initiator={...}, bool & disable_default_handling=false) Line 2367 C++ Symbols loaded.
    nbW.exe!`anonymous namespace'::request_handler_get_resource_request_handler(_cef_request_handler_t * self, _cef_browser_t * browser=0x2b629e90, _cef_frame_t * frame=0x2b6c1c10, _cef_request_t * request, int is_navigation=1, int is_download=0, const _cef_string_utf16_t * request_initiator, int * disable_default_handling=0x11f9e8cc) Line 144 C++ Symbols loaded.
    libcef.dll!CefRequestHandlerCToCpp::GetResourceRequestHandler(scoped_refptr<CefBrowser> browser={...}, scoped_refptr<CefFrame> frame={...}, scoped_refptr<CefRequest> request={...}, bool is_navigation, bool is_download, const CefStringBase<CefStringTraitsUTF16> & request_initiator={...}, bool & disable_default_handling=false) Line 138 C++ Symbols loaded.
    [Inline Frame] libcef.dll!net_service::`anonymous namespace'::InterceptedRequestHandlerWrapper::GetHandler(int request_id=-3, network::ResourceRequest * request=0x2b6fab38, bool * intercept_only, scoped_refptr<CefRequestImpl> & requestPtr) Line 1167 C++ Symbols loaded.
    libcef.dll!net_service::`anonymous namespace'::InterceptedRequestHandlerWrapper::OnBeforeRequest(int request_id=-3, network::ResourceRequest * request=0x2b6fab38, bool request_was_redirected=false, base::OnceCallback<void (bool, bool)> callback={...}, base::OnceCallback<void (int)> cancel_callback={...}) Line 547 C++ Symbols loaded.
    libcef.dll!net_service::InterceptedRequest::Restart() Line 475 C++ Symbols loaded.
    libcef.dll!net_service::ProxyURLLoaderFactory::CreateLoaderAndStart(mojo::PendingReceiver<network::mojom::URLLoader> receiver={...}, int request_id=-3, unsigned int options=11, const network::ResourceRequest & request={...}, mojo::PendingRemote<network::mojom::URLLoaderClient> client={...}, const net::MutableNetworkTrafficAnnotationTag & traffic_annotation={...}) Line 1351 C++ Symbols loaded.
    libcef.dll!network::mojom::URLLoaderFactoryStubDispatch::Accept(network::mojom::URLLoaderFactory * impl=0x2b6c1f20, mojo::Message * message=0x11f9f470) Line 309 C++ Symbols loaded.
    libcef.dll!network::mojom::URLLoaderFactoryStub<mojo::RawPtrImplRefTraits<network::mojom::URLLoaderFactory>>::Accept(mojo::Message * message=0x11f9f470) Line 140 C++ Symbols loaded.
    [Inline Frame] libcef.dll!base::WeakPtr<mojo::InterfaceEndpointClient>::get() Line 260 C++ Symbols loaded.
    [Inline Frame] libcef.dll!base::WeakPtr<mojo::InterfaceEndpointClient>::operator bool() Line 273 C++ Symbols loaded.
    libcef.dll!mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message * message=0x11f9f470) Line 992 C++ Symbols loaded.
    libcef.dll!mojo::MessageDispatcher::Accept(mojo::Message * message=0x11f9f470) Line 48 C++ Symbols loaded.

This is WITH chrome runtime

    libcef.dll!extensions::WebRequestProxyingURLLoaderFactory::CreateLoaderAndStart(mojo::PendingReceiver<network::mojom::URLLoader> loader_receiver={...}, int request_id=-3, unsigned int options=11, const network::ResourceRequest & request={...}, mojo::PendingRemote<network::mojom::URLLoaderClient> client={...}, const net::MutableNetworkTrafficAnnotationTag & traffic_annotation={...}) Line 1510 C++ Symbols loaded.
    libcef.dll!network::mojom::URLLoaderFactoryStubDispatch::Accept(network::mojom::URLLoaderFactory * impl=0x34f35344, mojo::Message * message=0x043ef4e0) Line 309 C++ Symbols loaded.
    libcef.dll!network::mojom::URLLoaderFactoryStub<mojo::RawPtrImplRefTraits<network::mojom::URLLoaderFactory>>::Accept(mojo::Message * message=0x043ef4e0) Line 140 C++ Symbols loaded.
    [Inline Frame] libcef.dll!base::WeakPtr<mojo::InterfaceEndpointClient>::get() Line 260 C++ Symbols loaded.
    [Inline Frame] libcef.dll!base::WeakPtr<mojo::InterfaceEndpointClient>::operator bool() Line 273 C++ Symbols loaded.
    libcef.dll!mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message * message=0x043ef4e0) Line 992 C++ Symbols loaded.
    libcef.dll!mojo::MessageDispatcher::Accept(mojo::Message * message=0x043ef4e0) Line 48 C++ Symbols loaded.

It does not progress from WebRequestProxyingURLLoaderFactory::CreateLoaderAndStart to the GetResourceRequestHandler methon.
BobM
Mentor
 
Posts: 72
Joined: Wed May 11, 2016 4:28 pm

Re: GetResourceRequestHandler with chrome runtime and an ext

Postby magreenblatt » Tue Jan 31, 2023 10:50 pm

What OS and CEF version? What URL are you trying to intercept? Is the request originating from the extension or from the page content? Is it working/loading as expected, other than not getting the GetResourceRequestHandler callback?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: GetResourceRequestHandler with chrome runtime and an ext

Postby BobM » Wed Feb 01, 2023 8:10 am

CEF 107.1.12+g65b79a6+chromium-107.0.5304.122
Chromium 107.0.5304.122
Command Line "E:\NBDevVC\bin\Unicode Release\nbW.exe" --enable-chrome-runtime --use-native --lang=en-US --disable-features=EnableHangWatcher --enable-media-stream --flag-switches-begin --flag-switches-end

Win 10 Version 10.0.19044 Build 19044

I'm using CefResourceRequestHandler::OnResourceLoadComplete to look for rss mime types, and if found and the page is actually an rss file, replace the page with an html representation of the rss xml data, similar to that which Explorer did. A rss page example is, https://www.smh.com.au/rss/feed.xml

The request originates from the page load.

It does work fine both without chrome runtime, and with chrome runtime without any extensions enabled. But fails if an extension is enabled (from chrome://extensions in my app) with chrome runtime. GetRequestHandler is called correctly in all cases.

Note, in the stack traces above, the one that is "WITH chrome runtime" is when an extension is loaded. In thisl case, WebRequestProxyingURLLoaderFactory::CreateLoaderAndStart is called instead of ProxyURLLoaderFactory::CreateLoaderAndStart, and so it never makes it to a call to GetResourceRequestHandler.


Thanks
BobM
Mentor
 
Posts: 72
Joined: Wed May 11, 2016 4:28 pm

Re: GetResourceRequestHandler with chrome runtime and an ext

Postby magreenblatt » Wed Feb 01, 2023 11:38 am

Code: Select all
WebRequestProxyingURLLoaderFactory::CreateLoaderAndStart is called instead of ProxyURLLoaderFactory::CreateLoaderAndStart, and so it never makes it to a call to GetResourceRequestHandler.

Please add an enhancement request in the CEF issue tracker. We can look at supporting this use case.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm



Return to Support Forum

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 37 guests