chrome: cefclient: Add support for --request-context-per-browser

Wait for the OnRequestContextInitialized callback before using a
non-global CefRequestContext.

Use default handling of --load-extension for Chrome runtime (fixes #3529).
This commit is contained in:
Marshall Greenblatt
2024-02-08 16:29:17 -05:00
parent 70471059cf
commit a79981bf7f
7 changed files with 98 additions and 48 deletions

View File

@@ -96,10 +96,21 @@ class RootWindow
// of this class will be called on the main thread.
class Delegate {
public:
// Called to retrieve the CefRequestContext for browser. Only called for
// non-popup browsers. May return nullptr.
virtual CefRefPtr<CefRequestContext> GetRequestContext(
RootWindow* root_window) = 0;
// Called to synchronously retrieve the CefRequestContext for browser. Only
// called for non-popup browsers. Must be called on the main thread. With
// the Chrome runtime this method is only safe when using the global request
// context.
// TODO: Delete this method and use the async version instead.
virtual CefRefPtr<CefRequestContext> GetRequestContext() = 0;
using RequestContextCallback =
base::OnceCallback<void(CefRefPtr<CefRequestContext>)>;
// Called to asynchronously retrieve the CefRequestContext for browser. Only
// called for non-popup browsers. Save to call on any thread. |callback|
// will be executed on the UI thread after the request context is
// initialized.
virtual void GetRequestContext(RequestContextCallback callback) = 0;
// Returns the ImageCache.
virtual scoped_refptr<ImageCache> GetImageCache() = 0;