Chromium Embedded Framework (CEF)  131.2.1+ge081753+chromium-131.0.6778.13
CefResourceManager Class Reference

Class for managing multiple resource providers. More...

#include "include/wrapper/cef_resource_manager.h"

Inheritance diagram for CefResourceManager:
base::RefCountedThreadSafe< CefResourceManager, CefDeleteOnIOThread >

Classes

class  Provider
 Interface implemented by resource providers. More...
 
class  Request
 Object representing a request. More...
 

Public Types

using UrlFilter = base::RepeatingCallback< std::string(const std::string &)>
 Provides an opportunity to modify |url| before it is passed to a provider. More...
 
using MimeTypeResolver = base::RepeatingCallback< std::string(const std::string &)>
 Used to resolve mime types for URLs, usually based on the file extension. More...
 
using RequestList = std::list< scoped_refptr< Request > >
 

Public Member Functions

 CefResourceManager ()
 
 CefResourceManager (const CefResourceManager &)=delete
 
CefResourceManageroperator= (const CefResourceManager &)=delete
 
void AddContentProvider (const std::string &url, const std::string &content, const std::string &mime_type, int order, const std::string &identifier)
 Add a provider that maps requests for |url| to |content|. More...
 
void AddDirectoryProvider (const std::string &url_path, const std::string &directory_path, int order, const std::string &identifier)
 Add a provider that maps requests that start with |url_path| to files under |directory_path|. More...
 
void AddArchiveProvider (const std::string &url_path, const std::string &archive_path, const std::string &password, int order, const std::string &identifier)
 Add a provider that maps requests that start with |url_path| to files stored in the archive file at |archive_path|. More...
 
void AddProvider (Provider *provider, int order, const std::string &identifier)
 Add a provider. More...
 
void RemoveProviders (const std::string &identifier)
 Remove all providers with the specified |identifier| value. More...
 
void RemoveAllProviders ()
 Remove all providers. More...
 
void SetUrlFilter (const UrlFilter &filter)
 Set the url filter. More...
 
void SetMimeTypeResolver (const MimeTypeResolver &resolver)
 Set the mime type resolver. More...
 
cef_return_value_t OnBeforeResourceLoad (CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, CefRefPtr< CefRequest > request, CefRefPtr< CefCallback > callback)
 The below methods should be called from other CEF handlers. More...
 
CefRefPtr< CefResourceHandlerGetResourceHandler (CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, CefRefPtr< CefRequest > request)
 Called from CefRequestHandler::GetResourceHandler on the browser process IO thread. More...
 
- Public Member Functions inherited from base::RefCountedThreadSafe< CefResourceManager, CefDeleteOnIOThread >
 RefCountedThreadSafe ()
 
 RefCountedThreadSafe (const RefCountedThreadSafe &)=delete
 
RefCountedThreadSafeoperator= (const RefCountedThreadSafe &)=delete
 
void AddRef () const
 
void Release () const
 

Friends

struct CefDeleteOnThread< TID_IO >
 
class base::RefCountedThreadSafe< CefResourceManager, CefDeleteOnIOThread >
 

Additional Inherited Members

- Static Public Attributes inherited from base::RefCountedThreadSafe< CefResourceManager, CefDeleteOnIOThread >
static constexpr cef_subtle::StartRefCountFromZeroTag kRefCountPreference
 
- Protected Member Functions inherited from base::RefCountedThreadSafe< CefResourceManager, CefDeleteOnIOThread >
 ~RefCountedThreadSafe ()=default
 

Detailed Description

Class for managing multiple resource providers.

For each resource request providers will be called in order and have the option to (a) handle the request by returning a CefResourceHandler, (b) pass the request to the next provider in order, or (c) stop handling the request. See comments on the Request object for additional usage information. The methods of this class may be called on any browser process thread unless otherwise indicated.

Member Typedef Documentation

◆ MimeTypeResolver

using CefResourceManager::MimeTypeResolver = base::RepeatingCallback<std::string(const std::string& )>

Used to resolve mime types for URLs, usually based on the file extension.

|url| will be fully qualified and may contain query or fragment components.

◆ RequestList

◆ UrlFilter

using CefResourceManager::UrlFilter = base::RepeatingCallback<std::string(const std::string& )>

Provides an opportunity to modify |url| before it is passed to a provider.

For example, the implementation could rewrite |url| to include a default file extension. |url| will be fully qualified and may contain query or fragment components.

Constructor & Destructor Documentation

◆ CefResourceManager() [1/2]

CefResourceManager::CefResourceManager ( )

◆ CefResourceManager() [2/2]

CefResourceManager::CefResourceManager ( const CefResourceManager )
delete

Member Function Documentation

◆ AddArchiveProvider()

void CefResourceManager::AddArchiveProvider ( const std::string &  url_path,
const std::string &  archive_path,
const std::string &  password,
int  order,
const std::string &  identifier 
)

Add a provider that maps requests that start with |url_path| to files stored in the archive file at |archive_path|.

|url_path| should include an origin and optional path component only. The archive file will be loaded when a matching URL is requested for the first time. See comments on AddProvider for usage of the |order| and |identifier| parameters.

◆ AddContentProvider()

void CefResourceManager::AddContentProvider ( const std::string &  url,
const std::string &  content,
const std::string &  mime_type,
int  order,
const std::string &  identifier 
)

Add a provider that maps requests for |url| to |content|.

|url| should be fully qualified but not include a query or fragment component. If |mime_type| is empty the MimeTypeResolver will be used. See comments on AddProvider for usage of the |order| and |identifier| parameters.

◆ AddDirectoryProvider()

void CefResourceManager::AddDirectoryProvider ( const std::string &  url_path,
const std::string &  directory_path,
int  order,
const std::string &  identifier 
)

Add a provider that maps requests that start with |url_path| to files under |directory_path|.

|url_path| should include an origin and optional path component only. Files will be loaded when a matching URL is requested. See comments on AddProvider for usage of the |order| and |identifier| parameters.

◆ AddProvider()

void CefResourceManager::AddProvider ( Provider provider,
int  order,
const std::string &  identifier 
)

Add a provider.

This object takes ownership of |provider|. Providers will be called in ascending order based on the |order| value. Multiple providers sharing the same |order| value will be called in the order that they were added. The |identifier| value, which does not need to be unique, can be used to remove the provider at a later time.

◆ GetResourceHandler()

CefRefPtr<CefResourceHandler> CefResourceManager::GetResourceHandler ( CefRefPtr< CefBrowser browser,
CefRefPtr< CefFrame frame,
CefRefPtr< CefRequest request 
)

Called from CefRequestHandler::GetResourceHandler on the browser process IO thread.

◆ OnBeforeResourceLoad()

cef_return_value_t CefResourceManager::OnBeforeResourceLoad ( CefRefPtr< CefBrowser browser,
CefRefPtr< CefFrame frame,
CefRefPtr< CefRequest request,
CefRefPtr< CefCallback callback 
)

The below methods should be called from other CEF handlers.

They must be called exactly as documented for the manager to function correctly. Called from CefRequestHandler::OnBeforeResourceLoad on the browser process IO thread.

◆ operator=()

CefResourceManager& CefResourceManager::operator= ( const CefResourceManager )
delete

◆ RemoveAllProviders()

void CefResourceManager::RemoveAllProviders ( )

Remove all providers.

If any removed providers have pending requests the Provider::OnRequestCancel method will be called. The removed providers may be deleted immediately or at a later time.

◆ RemoveProviders()

void CefResourceManager::RemoveProviders ( const std::string &  identifier)

Remove all providers with the specified |identifier| value.

If any removed providers have pending requests the Provider::OnRequestCancel method will be called. The removed providers may be deleted immediately or at a later time.

◆ SetMimeTypeResolver()

void CefResourceManager::SetMimeTypeResolver ( const MimeTypeResolver resolver)

Set the mime type resolver.

If not set the default resolver will be used. Changes to this value will not affect currently pending requests.

◆ SetUrlFilter()

void CefResourceManager::SetUrlFilter ( const UrlFilter filter)

Set the url filter.

If not set the default no-op filter will be used. Changes to this value will not affect currently pending requests.

Friends And Related Function Documentation

◆ base::RefCountedThreadSafe< CefResourceManager, CefDeleteOnIOThread >

◆ CefDeleteOnThread< TID_IO >

friend struct CefDeleteOnThread< TID_IO >
friend

The documentation for this class was generated from the following file: