How exactly is examples/resource_manager expected to behave

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 exactly is examples/resource_manager expected to behave

Postby Tonygeek » Mon Jan 13, 2020 8:14 pm

Complete newbie here.
When I run resource_manager example I end up looking at 404 response from "https://example.com/" and that's it.
The breakpoint in OnRequest doesn't get hit:

Code: Select all
 bool OnRequest(scoped_refptr<CefResourceManager::Request> request) OVERRIDE {
    CEF_REQUIRE_IO_THREAD();

    const std::string& url = request->url(); // breakpoint here
    if (url != url_) {
      // Not handled by this provider.
      return false;
    }
 . . .


My expectation was that OnRequest gets called before any request to "https://example.com/" gets sent over the wire, IOW no external site gets hit with any request.
What am I truing to do? I want to feed local filesystem data in response to submitting a request to some nonexistent URL.
Tonygeek
Techie
 
Posts: 16
Joined: Mon Jan 13, 2020 7:39 pm

Re: How exactly is examples/resource_manager expected to beh

Postby magreenblatt » Tue Jan 14, 2020 4:13 am

You should see the CEF logo and the text "This HTML file and the above logo image were loaded using CefResourceManager." Did you follow the build instructions from https://bitbucket.org/chromiumembedded/cef-project?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How exactly is examples/resource_manager expected to beh

Postby Tonygeek » Tue Jan 14, 2020 11:00 am

I take that back, sorry.
I just rebuilt the whole package from scratch, following the instructions at the link, and resource manager example behaves as you described.
What is not working is my attempt to use it. That is, I copied implementation from resource_manager example into my CEF client (a separate app that I created and which otherwise works fine) but I must have messed up something.
Tonygeek
Techie
 
Posts: 16
Joined: Mon Jan 13, 2020 7:39 pm

Re: How exactly is examples/resource_manager expected to beh

Postby Tonygeek » Thu Jan 16, 2020 2:17 pm

I am having some conceptual difficulties here that I am unable to resolve by walking through the code in debugger.

When I run resource_manager example it behaves as described above.

However, if in debugger I skip over the code to add BinaryResourceProvider
( adding only the DumpResourceProvider) I also end up hitting https://examples.com website.

Code: Select all
// Add example Providers to the CefResourceManager.
void SetupResourceManager(CefRefPtr<CefResourceManager> resource_manager) {
  if (!CefCurrentlyOn(TID_IO)) {
    // Execute on the browser IO thread.
    CefPostTask(TID_IO, base::Bind(SetupResourceManager, resource_manager));
    return;
  }

  const std::string& test_origin = shared::kTestOrigin;

  // Add the Provider for dumping request contents.
  resource_manager->AddProvider(
      new RequestDumpResourceProvider(test_origin + "request.html"), 0,
      std::string());

// Add the Provider for bundled resource files.
#if defined(OS_WIN)
  // Read BINARY resources from the executable.   // !!!! I don't execute this code via moving the next step in debugger !!!
  resource_manager->AddProvider(
      shared::CreateBinaryResourceProvider(test_origin), 100, std::string());


But that is exactly what I want to do in my separate app. I don't care about serving any binary resources embedded in my app. I only want to intercept and modify the response from the specific fake URL, so that I can return the response that I want, in my case coming from the local file system, not from embedded resources.

Do I absolutely need to add binary resource provider on top of dump resource provider?

What am I missing?
Tonygeek
Techie
 
Posts: 16
Joined: Mon Jan 13, 2020 7:39 pm

Re: How exactly is examples/resource_manager expected to beh

Postby Tonygeek » Thu Jan 16, 2020 8:48 pm

What I was missing is this code in my client:

Code: Select all
 CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE { return this; }


I know, pretty bad, but here in the hope that it may help someone copy/pasting resource manager example into his app.
Tonygeek
Techie
 
Posts: 16
Joined: Mon Jan 13, 2020 7:39 pm


Return to Support Forum

Who is online

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