Chromium Embedded Framework (CEF)
126.2.0+g5c56e98+chromium-126.0.6478.62
|
Class for managing multiple resource providers. More...
#include "include/wrapper/cef_resource_manager.h"
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 | |
CefResourceManager & | operator= (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< CefResourceHandler > | GetResourceHandler (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 | |
RefCountedThreadSafe & | operator= (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 | |
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.
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.
using CefResourceManager::RequestList = std::list<scoped_refptr<Request> > |
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.
CefResourceManager::CefResourceManager | ( | ) |
|
delete |
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.
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.
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.
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.
CefRefPtr<CefResourceHandler> CefResourceManager::GetResourceHandler | ( | CefRefPtr< CefBrowser > | browser, |
CefRefPtr< CefFrame > | frame, | ||
CefRefPtr< CefRequest > | request | ||
) |
Called from CefRequestHandler::GetResourceHandler on the browser process IO thread.
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.
|
delete |
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.
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.
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.
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.
|
friend |
|
friend |