From cc3d77eec5d8a9f75e574883b87dee39b083d0bf Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 8 Feb 2024 13:41:18 -0500 Subject: [PATCH] chrome: Enforce matching context for new user and incognito profiles Selecting a new user or incognito profile via Chrome UI may result in the creation of a new Profile object. If that occurs, we should find or create a matching CefBrowserContext and CefRequestContext instead of reusing an existing mismatched context (e.g. using the original context for an incognito window would be a mismatch). If a new CefRequestContext will be created the client can now implement CefBrowserProcessHandler::GetDefaultRequestContextHandler() to provide the handler for that context. To test with a new user profile: 1. Click "Profile" icon, select "Add". Now you have 2+ profiles. 2. Click "Profile" icon, select the other user name to create a new window using the other user profile. 3. The new window should launch successfully. To test with a new incognito profile: 1. Select "New Incognito window" from the 3-dot menu. 2. The new window should launch successfully. To test DevTools window creation for the new profile: 1. Right-click in the new window, select Inspect. 2. The DevTools window should launch successfully. --- .../capi/cef_browser_process_handler_capi.h | 25 ++++-- include/cef_api_hash.h | 8 +- include/cef_browser_process_handler.h | 25 ++++-- libcef/browser/browser_context.cc | 35 ++++---- libcef/browser/browser_context.h | 10 ++- .../browser/chrome/chrome_browser_context.cc | 28 ++++++- .../browser/chrome/chrome_browser_context.h | 3 + .../browser/chrome/chrome_browser_delegate.cc | 26 ++++-- .../chrome/chrome_browser_host_impl.cc | 4 + libcef/browser/request_context_impl.cc | 79 +++++++++++++------ libcef/browser/request_context_impl.h | 27 ++++--- .../cpptoc/browser_process_handler_cpptoc.cc | 24 +++++- .../ctocpp/browser_process_handler_ctocpp.cc | 21 ++++- .../ctocpp/browser_process_handler_ctocpp.h | 4 +- 14 files changed, 244 insertions(+), 75 deletions(-) diff --git a/include/capi/cef_browser_process_handler_capi.h b/include/capi/cef_browser_process_handler_capi.h index d99eff1d3..a4edda9d8 100644 --- a/include/capi/cef_browser_process_handler_capi.h +++ b/include/capi/cef_browser_process_handler_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=f844d2a1e39d822129d0733f33c14d27481c36b7$ +// $hash=d958d5bed7f909f6313facef3440fb8ba07a5c01$ // #ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_ @@ -44,6 +44,7 @@ #include "include/capi/cef_client_capi.h" #include "include/capi/cef_command_line_capi.h" #include "include/capi/cef_preference_capi.h" +#include "include/capi/cef_request_context_handler_capi.h" #include "include/capi/cef_values_capi.h" #ifdef __cplusplus @@ -147,14 +148,26 @@ typedef struct _cef_browser_process_handler_t { int64_t delay_ms); /// - /// Return the default client for use with a newly created browser window. If - /// null is returned the browser will be unmanaged (no callbacks will be - /// executed for that browser) and application shutdown will be blocked until - /// the browser window is closed manually. This function is currently only - /// used with the chrome runtime. + /// Return the default client for use with a newly created browser window + /// (cef_browser_t object). If null is returned the cef_browser_t will be + /// unmanaged (no callbacks will be executed for that cef_browser_t) and + /// application shutdown will be blocked until the browser window is closed + /// manually. This function is currently only used with the Chrome runtime + /// when creating new browser windows via Chrome UI. /// struct _cef_client_t*(CEF_CALLBACK* get_default_client)( struct _cef_browser_process_handler_t* self); + + /// + /// Return the default handler for use with a new user or incognito profile + /// (cef_request_context_t object). If null is returned the + /// cef_request_context_t will be unmanaged (no callbacks will be executed for + /// that cef_request_context_t). This function is currently only used with the + /// Chrome runtime when creating new browser windows via Chrome UI. + /// + struct _cef_request_context_handler_t*( + CEF_CALLBACK* get_default_request_context_handler)( + struct _cef_browser_process_handler_t* self); } cef_browser_process_handler_t; #ifdef __cplusplus diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h index cc73b89b3..df6da5bfc 100644 --- a/include/cef_api_hash.h +++ b/include/cef_api_hash.h @@ -42,13 +42,13 @@ // way that may cause binary incompatibility with other builds. The universal // hash value will change if any platform is affected whereas the platform hash // values will change only if that particular platform is affected. -#define CEF_API_HASH_UNIVERSAL "60ecc3c751154b2b2b41e5d3ac0ccbeba588918d" +#define CEF_API_HASH_UNIVERSAL "afb63c581ad6ef9b3d3ebed472cc66f75ce4647f" #if defined(OS_WIN) -#define CEF_API_HASH_PLATFORM "7819cee8508a9b048ccfa80acea7351a5b549c45" +#define CEF_API_HASH_PLATFORM "504dbb53deeebd11a16ea01533c5d9ecfa6be555" #elif defined(OS_MAC) -#define CEF_API_HASH_PLATFORM "f2bb2e5a9d14dcad463fd3fc8ed4af16b6fe6196" +#define CEF_API_HASH_PLATFORM "dc3cf1d007fec844ab287dac384c8b00366d46fc" #elif defined(OS_LINUX) -#define CEF_API_HASH_PLATFORM "bcf76490ddea85c12ea8feeee9190ffe24dedcc6" +#define CEF_API_HASH_PLATFORM "2b47d389c64db81913818b708b78868a22e65b66" #endif #ifdef __cplusplus diff --git a/include/cef_browser_process_handler.h b/include/cef_browser_process_handler.h index 93daf563c..088df8ef9 100644 --- a/include/cef_browser_process_handler.h +++ b/include/cef_browser_process_handler.h @@ -42,6 +42,7 @@ #include "include/cef_client.h" #include "include/cef_command_line.h" #include "include/cef_preference.h" +#include "include/cef_request_context_handler.h" #include "include/cef_values.h" /// @@ -139,14 +140,28 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted { virtual void OnScheduleMessagePumpWork(int64_t delay_ms) {} /// - /// Return the default client for use with a newly created browser window. If - /// null is returned the browser will be unmanaged (no callbacks will be - /// executed for that browser) and application shutdown will be blocked until - /// the browser window is closed manually. This method is currently only used - /// with the chrome runtime. + /// Return the default client for use with a newly created browser window + /// (CefBrowser object). If null is returned the CefBrowser will be unmanaged + /// (no callbacks will be executed for that CefBrowser) and application + /// shutdown will be blocked until the browser window is closed manually. This + /// method is currently only used with the Chrome runtime when creating new + /// browser windows via Chrome UI. /// /*--cef()--*/ virtual CefRefPtr GetDefaultClient() { return nullptr; } + + /// + /// Return the default handler for use with a new user or incognito profile + /// (CefRequestContext object). If null is returned the CefRequestContext will + /// be unmanaged (no callbacks will be executed for that CefRequestContext). + /// This method is currently only used with the Chrome runtime when creating + /// new browser windows via Chrome UI. + /// + /*--cef()--*/ + virtual CefRefPtr + GetDefaultRequestContextHandler() { + return nullptr; + } }; #endif // CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_ diff --git a/libcef/browser/browser_context.cc b/libcef/browser/browser_context.cc index 58b2cd23b..654f8af2c 100644 --- a/libcef/browser/browser_context.cc +++ b/libcef/browser/browser_context.cc @@ -273,22 +273,7 @@ CefBrowserContext* CefBrowserContext::FromBrowserContext( // static CefBrowserContext* CefBrowserContext::FromProfile(const Profile* profile) { - auto* cef_context = FromBrowserContext(profile); - if (cef_context) { - return cef_context; - } - - if (cef::IsChromeRuntimeEnabled()) { - auto* original_profile = profile->GetOriginalProfile(); - if (original_profile != profile) { - // With the Chrome runtime if the user launches an incognito window via - // the UI we might be associated with the original Profile instead of the - // (current) incognito profile. - return FromBrowserContext(original_profile); - } - } - - return nullptr; + return FromBrowserContext(profile); } // static @@ -430,6 +415,24 @@ CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() { return media_router_manager_.get(); } +CefRefPtr CefBrowserContext::GetAnyRequestContext( + bool prefer_no_handler) const { + CEF_REQUIRE_UIT(); + if (request_context_set_.empty()) { + return nullptr; + } + + if (prefer_no_handler) { + for (const auto& request_context : request_context_set_) { + if (!request_context->GetHandler()) { + return request_context; + } + } + } + + return *request_context_set_.begin(); +} + CefBrowserContext::CookieableSchemes CefBrowserContext::GetCookieableSchemes() const { CEF_REQUIRE_UIT(); diff --git a/libcef/browser/browser_context.h b/libcef/browser/browser_context.h index 8da79950f..7d02e17de 100644 --- a/libcef/browser/browser_context.h +++ b/libcef/browser/browser_context.h @@ -104,7 +104,7 @@ class CefBrowserContext { const content::GlobalRenderFrameHostId& global_id, bool require_frame_match); - // Returns the underlying CefBrowserContext if any. + // Returns the underlying CefBrowserContext, if any. static CefBrowserContext* FromBrowserContext( const content::BrowserContext* context); static CefBrowserContext* FromProfile(const Profile* profile); @@ -179,6 +179,14 @@ class CefBrowserContext { CefMediaRouterManager* GetMediaRouterManager(); + // Returns any CefRequestContext associated with this object, or nullptr if + // none exist. If |prefer_no_handler| is true this method will try to return a + // context without an associated CefRequestContextHandler. Use + // CefRequestContextImpl::GetOrCreateForBrowserContext() instead of calling + // this method directly. + CefRefPtr GetAnyRequestContext( + bool prefer_no_handler) const; + using CookieableSchemes = absl::optional>; // Returns the schemes associated with this context specifically, or the diff --git a/libcef/browser/chrome/chrome_browser_context.cc b/libcef/browser/chrome/chrome_browser_context.cc index 3eb9e005d..5c4c138bc 100644 --- a/libcef/browser/chrome/chrome_browser_context.cc +++ b/libcef/browser/chrome/chrome_browser_context.cc @@ -38,6 +38,28 @@ ChromeBrowserContext::ChromeBrowserContext( ChromeBrowserContext::~ChromeBrowserContext() = default; +// static +ChromeBrowserContext* ChromeBrowserContext::GetOrCreateForProfile( + Profile* profile) { + DCHECK(profile); + + if (auto existing_context = FromProfile(profile)) { + return static_cast(existing_context); + } + + CefRequestContextSettings settings; + if (!profile->IsOffTheRecord()) { + // Become the primary context associated with |cache_path|. + CefString(&settings.cache_path) = profile->GetPath().value(); + } + + auto* new_context = new ChromeBrowserContext(settings); + new_context->Initialize(); + new_context->ProfileCreated(Profile::CreateStatus::CREATE_STATUS_INITIALIZED, + profile); + return new_context; +} + content::BrowserContext* ChromeBrowserContext::AsBrowserContext() { CHECK(!destroyed_); return profile_; @@ -146,8 +168,10 @@ void ChromeBrowserContext::ProfileCreated(Profile::CreateStatus status, // exists. profile_ = profile; profile_->AddObserver(this); - profile_keep_alive_ = std::make_unique( - profile_, ProfileKeepAliveOrigin::kAppWindow); + if (!profile_->IsOffTheRecord()) { + profile_keep_alive_ = std::make_unique( + profile_, ProfileKeepAliveOrigin::kAppWindow); + } } if (status == Profile::CreateStatus::CREATE_STATUS_INITIALIZED) { diff --git a/libcef/browser/chrome/chrome_browser_context.h b/libcef/browser/chrome/chrome_browser_context.h index 0bac7fde4..be893a9e4 100644 --- a/libcef/browser/chrome/chrome_browser_context.h +++ b/libcef/browser/chrome/chrome_browser_context.h @@ -23,6 +23,9 @@ class ChromeBrowserContext : public CefBrowserContext, public ProfileObserver { ChromeBrowserContext(const ChromeBrowserContext&) = delete; ChromeBrowserContext& operator=(const ChromeBrowserContext&) = delete; + // Returns a ChromeBrowserContext for the specified |profile|. + static ChromeBrowserContext* GetOrCreateForProfile(Profile* profile); + void InitializeAsync(base::OnceClosure initialized_cb); // CefBrowserContext overrides. diff --git a/libcef/browser/chrome/chrome_browser_delegate.cc b/libcef/browser/chrome/chrome_browser_delegate.cc index 9a3455da8..21e4b8127 100644 --- a/libcef/browser/chrome/chrome_browser_delegate.cc +++ b/libcef/browser/chrome/chrome_browser_delegate.cc @@ -10,6 +10,7 @@ #include "libcef/browser/browser_host_base.h" #include "libcef/browser/browser_info_manager.h" #include "libcef/browser/browser_platform_delegate.h" +#include "libcef/browser/chrome/chrome_browser_context.h" #include "libcef/browser/chrome/chrome_browser_host_impl.h" #include "libcef/browser/chrome/views/chrome_browser_view.h" #include "libcef/browser/chrome/views/chrome_child_window.h" @@ -67,9 +68,7 @@ Browser* ChromeBrowserDelegate::CreateDevToolsBrowser( } // We expect openers and popups to have the same Profile. - CHECK_EQ( - CefRequestContextImpl::GetProfile(opener_browser_host->request_context()), - profile); + CHECK_EQ(opener->profile(), profile); // // 1. Get configuration settings from the user and create the new platform @@ -608,12 +607,25 @@ CefRefPtr ChromeBrowserDelegate::CreateBrowserHost( LOG(WARNING) << "Creating a chrome browser without a client"; } - // Check if chrome and CEF are using the same browser context. - // TODO(chrome-runtime): Verify if/when this might occur. + // Get or create a ChromeBrowserContext for the browser Profile. Creation may + // be necessary when selecting a new or incognito Profile for the first time + // via the Chrome UI. auto chrome_browser_context = - CefBrowserContext::FromBrowserContext(browser_->create_params().profile); + ChromeBrowserContext::GetOrCreateForProfile(browser_->profile()); + + // If the provided CefRequestContext matches the ChromeBrowserContext then use + // the provided one, as it will have the preferred CefRequestContextHandler. + // Otherwise, get or create a CefRequestContext that matches. if (chrome_browser_context != request_context_impl->GetBrowserContext()) { - LOG(WARNING) << "Creating a chrome browser with mismatched context"; + CefRefPtr handler; + if (auto app = CefAppManager::Get()->GetApplication()) { + if (auto bph = app->GetBrowserProcessHandler()) { + handler = bph->GetDefaultRequestContextHandler(); + } + } + + request_context_impl = CefRequestContextImpl::GetOrCreateForBrowserContext( + chrome_browser_context, handler); } // Remains alive until the associated WebContents is destroyed. diff --git a/libcef/browser/chrome/chrome_browser_host_impl.cc b/libcef/browser/chrome/chrome_browser_host_impl.cc index 1f13364c7..7532bc3d3 100644 --- a/libcef/browser/chrome/chrome_browser_host_impl.cc +++ b/libcef/browser/chrome/chrome_browser_host_impl.cc @@ -601,6 +601,10 @@ void ChromeBrowserHostImpl::SetBrowser(Browser* browser) { static_cast(platform_delegate_.get()) ->set_chrome_browser(browser); if (browser_) { + // We expect the Browser and CefRequestContext to have the same Profile. + CHECK_EQ(browser_->profile(), + request_context()->GetBrowserContext()->AsProfile()); + host_window_handle_ = platform_delegate_->GetHostWindowHandle(); } else { host_window_handle_ = kNullWindowHandle; diff --git a/libcef/browser/request_context_impl.cc b/libcef/browser/request_context_impl.cc index 688c8068c..930ed7017 100644 --- a/libcef/browser/request_context_impl.cc +++ b/libcef/browser/request_context_impl.cc @@ -115,7 +115,7 @@ CefRefPtr CefRequestContext::GetGlobalContext() { CefRequestContextImpl::Config config; config.is_global = true; - return CefRequestContextImpl::GetOrCreateRequestContext(config); + return CefRequestContextImpl::GetOrCreateRequestContext(std::move(config)); } // static @@ -132,7 +132,7 @@ CefRefPtr CefRequestContext::CreateContext( config.settings = settings; config.handler = handler; config.unique_id = g_next_id.GetNext(); - return CefRequestContextImpl::GetOrCreateRequestContext(config); + return CefRequestContextImpl::GetOrCreateRequestContext(std::move(config)); } // static @@ -153,7 +153,7 @@ CefRefPtr CefRequestContext::CreateContext( config.other = static_cast(other.get()); config.handler = handler; config.unique_id = g_next_id.GetNext(); - return CefRequestContextImpl::GetOrCreateRequestContext(config); + return CefRequestContextImpl::GetOrCreateRequestContext(std::move(config)); } // CefRequestContextImpl @@ -176,7 +176,8 @@ CefRequestContextImpl::CreateGlobalRequestContext( Config config; config.is_global = true; config.settings = settings; - CefRefPtr impl = new CefRequestContextImpl(config); + CefRefPtr impl = + new CefRequestContextImpl(std::move(config)); impl->Initialize(); return impl; } @@ -193,7 +194,21 @@ CefRequestContextImpl::GetOrCreateForRequestContext( // Use the global context. Config config; config.is_global = true; - return CefRequestContextImpl::GetOrCreateRequestContext(config); + return CefRequestContextImpl::GetOrCreateRequestContext(std::move(config)); +} + +// static +CefRefPtr +CefRequestContextImpl::GetOrCreateForBrowserContext( + CefBrowserContext* browser_context, + CefRefPtr handler) { + DCHECK(browser_context); + + Config config; + config.browser_context = browser_context; + config.handler = handler; + config.unique_id = g_next_id.GetNext(); + return CefRequestContextImpl::GetOrCreateRequestContext(std::move(config)); } content::BrowserContext* CefRequestContextImpl::GetBrowserContext( @@ -241,7 +256,6 @@ void CefRequestContextImpl::ExecuteWhenBrowserContextInitialized( return; } - EnsureBrowserContext(); browser_context()->StoreOrTriggerInitCallback(std::move(callback)); } @@ -638,7 +652,32 @@ void CefRequestContextImpl::OnRenderFrameDeleted( // static CefRefPtr -CefRequestContextImpl::GetOrCreateRequestContext(const Config& config) { +CefRequestContextImpl::GetOrCreateRequestContext(Config&& config) { + if (config.browser_context) { + // CefBrowserContext is only accessed on the UI thread. + CEF_REQUIRE_UIT(); + DCHECK(!config.is_global); + DCHECK(!config.other); + + // Retrieve any request context that currently exists for the browser + // context. If |config.handler| is nullptr, and the returned request context + // does not have a handler, then we can just return that existing context. + // Otherwise, we'll need to create a new request context with + // |config.handler|. + if (auto other = config.browser_context->GetAnyRequestContext( + /*prefer_no_handler=*/!config.handler)) { + if (!config.handler && !other->GetHandler()) { + // Safe to return the existing context. + return other; + } + + // Use the existing request context as a starting point. It may be the + // global context. This is functionally equivalent to calling + // `CefRequestContext::CreateContext(other, handler)`. + config.other = other; + } + } + if (config.is_global || (config.other && config.other->IsGlobal() && !config.handler)) { // Return the singleton global context. @@ -646,8 +685,8 @@ CefRequestContextImpl::GetOrCreateRequestContext(const Config& config) { CefAppManager::Get()->GetGlobalRequestContext().get()); } - // The new context will be initialized later by EnsureBrowserContext(). - CefRefPtr context = new CefRequestContextImpl(config); + CefRefPtr context = + new CefRequestContextImpl(std::move(config)); // Initialize ASAP so that any tasks blocked on initialization will execute. if (CEF_CURRENTLY_ON_UIT()) { @@ -661,8 +700,8 @@ CefRequestContextImpl::GetOrCreateRequestContext(const Config& config) { } CefRequestContextImpl::CefRequestContextImpl( - const CefRequestContextImpl::Config& config) - : config_(config) {} + CefRequestContextImpl::Config&& config) + : config_(std::move(config)) {} void CefRequestContextImpl::Initialize() { CEF_REQUIRE_UIT(); @@ -673,6 +712,9 @@ void CefRequestContextImpl::Initialize() { // Share storage with |config_.other|. browser_context_ = config_.other->browser_context(); CHECK(browser_context_); + } else if (config_.browser_context) { + browser_context_ = config_.browser_context; + config_.browser_context = nullptr; } if (!browser_context_) { @@ -710,9 +752,10 @@ void CefRequestContextImpl::Initialize() { browser_context_->AddCefRequestContext(this); if (config_.other) { - // Clear the reference to |config_.other| after setting - // |request_context_getter_|. This is the reverse order of checks in - // IsSharedWith(). + // Clear the reference to |config_.other| after adding the new assocation + // with |browser_context_| as this may result in |other| being released + // and we don't want the browser context to be destroyed prematurely. + // This is the also the reverse order of checks in IsSharingWith(). config_.other = nullptr; } } @@ -727,14 +770,6 @@ void CefRequestContextImpl::BrowserContextInitialized() { } } -void CefRequestContextImpl::EnsureBrowserContext() { - CEF_REQUIRE_UIT(); - if (!browser_context()) { - Initialize(); - } - DCHECK(browser_context()); -} - void CefRequestContextImpl::ClearCertificateExceptionsInternal( CefRefPtr callback, CefBrowserContext::Getter browser_context_getter) { diff --git a/libcef/browser/request_context_impl.h b/libcef/browser/request_context_impl.h index a035fa984..e4652830a 100644 --- a/libcef/browser/request_context_impl.h +++ b/libcef/browser/request_context_impl.h @@ -38,6 +38,16 @@ class CefRequestContextImpl : public CefRequestContext { static CefRefPtr GetOrCreateForRequestContext( CefRefPtr request_context); + // Returns a CefRequestContextImpl for the specified |browser_context| and + // optional |handler|. If |handler| is nullptr, and a CefRequestContextImpl + // without a handler currently exists for |browser_context|, then that + // existing CefRequestContextImpl will be returned. Otherwise, a new + // CefRequestContextImpl will be created with the specified |handler|. Must be + // called on the UI thread. + static CefRefPtr GetOrCreateForBrowserContext( + CefBrowserContext* browser_context, + CefRefPtr handler); + // Returns the BrowserContext for the specified |request_context|. Will return // the global BrowserContext if |request_context| is NULL. static content::BrowserContext* GetBrowserContext( @@ -145,10 +155,12 @@ class CefRequestContextImpl : public CefRequestContext { // True if wrapping the global context. bool is_global = false; + // Wrap an existing (non-global) browser context. When specifying this value + // GetOrCreateRequestContext() must be called on the UI thread. + CefBrowserContext* browser_context = nullptr; + // |settings| or |other| will be set when creating a new CefRequestContext - // via the API. When wrapping an existing CefBrowserContext* both will be - // empty and Initialize(CefBrowserContext*) will be called immediately after - // CefRequestContextImpl construction. + // via the API. CefRequestContextSettings settings; CefRefPtr other; @@ -156,22 +168,19 @@ class CefRequestContextImpl : public CefRequestContext { CefRefPtr handler; // Used to uniquely identify CefRequestContext objects before an associated - // CefBrowserContext has been created. Should be set when a new + // CefBrowserContext has been created. Should be set when creating a new // CefRequestContext via the API. int unique_id = -1; }; static CefRefPtr GetOrCreateRequestContext( - const Config& config); + Config&& config); - explicit CefRequestContextImpl(const Config& config); + explicit CefRequestContextImpl(Config&& config); void Initialize(); void BrowserContextInitialized(); - // Make sure the browser context exists. Only called on the UI thread. - void EnsureBrowserContext(); - void ClearCertificateExceptionsInternal( CefRefPtr callback, CefBrowserContext::Getter browser_context_getter); diff --git a/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc b/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc index dd24fb740..6c8e76cc8 100644 --- a/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc +++ b/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc @@ -9,11 +9,12 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=11604cc40431cd047990f92e86495c9ccd7ded29$ +// $hash=5703528ee112474079bd5d04f5ca9f2f290238fa$ // #include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h" #include "libcef_dll/cpptoc/client_cpptoc.h" +#include "libcef_dll/cpptoc/request_context_handler_cpptoc.h" #include "libcef_dll/ctocpp/command_line_ctocpp.h" #include "libcef_dll/ctocpp/preference_registrar_ctocpp.h" @@ -138,6 +139,25 @@ struct _cef_client_t* CEF_CALLBACK browser_process_handler_get_default_client( return CefClientCppToC::Wrap(_retval); } +struct _cef_request_context_handler_t* CEF_CALLBACK +browser_process_handler_get_default_request_context_handler( + struct _cef_browser_process_handler_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) { + return NULL; + } + + // Execute + CefRefPtr _retval = + CefBrowserProcessHandlerCppToC::Get(self) + ->GetDefaultRequestContextHandler(); + + // Return type: refptr_same + return CefRequestContextHandlerCppToC::Wrap(_retval); +} + } // namespace // CONSTRUCTOR - Do not edit by hand. @@ -154,6 +174,8 @@ CefBrowserProcessHandlerCppToC::CefBrowserProcessHandlerCppToC() { GetStruct()->on_schedule_message_pump_work = browser_process_handler_on_schedule_message_pump_work; GetStruct()->get_default_client = browser_process_handler_get_default_client; + GetStruct()->get_default_request_context_handler = + browser_process_handler_get_default_request_context_handler; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc b/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc index 8af40f892..2503bd167 100644 --- a/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc +++ b/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc @@ -9,13 +9,14 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=1d072dd56acd042383f193e1986606ebb2bb9ee1$ +// $hash=1487ab43138b7c4bee2b05064a91ed051ff2533e$ // #include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h" #include "libcef_dll/cpptoc/command_line_cpptoc.h" #include "libcef_dll/cpptoc/preference_registrar_cpptoc.h" #include "libcef_dll/ctocpp/client_ctocpp.h" +#include "libcef_dll/ctocpp/request_context_handler_ctocpp.h" // VIRTUAL METHODS - Body may be edited by hand. @@ -136,6 +137,24 @@ CefRefPtr CefBrowserProcessHandlerCToCpp::GetDefaultClient() { return CefClientCToCpp::Wrap(_retval); } +NO_SANITIZE("cfi-icall") +CefRefPtr +CefBrowserProcessHandlerCToCpp::GetDefaultRequestContextHandler() { + cef_browser_process_handler_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_default_request_context_handler)) { + return nullptr; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_request_context_handler_t* _retval = + _struct->get_default_request_context_handler(_struct); + + // Return type: refptr_same + return CefRequestContextHandlerCToCpp::Wrap(_retval); +} + // CONSTRUCTOR - Do not edit by hand. CefBrowserProcessHandlerCToCpp::CefBrowserProcessHandlerCToCpp() {} diff --git a/libcef_dll/ctocpp/browser_process_handler_ctocpp.h b/libcef_dll/ctocpp/browser_process_handler_ctocpp.h index e98d15dc1..8c9c45bd9 100644 --- a/libcef_dll/ctocpp/browser_process_handler_ctocpp.h +++ b/libcef_dll/ctocpp/browser_process_handler_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=adc863edb83f2bb42719a92c410289ee338acb0f$ +// $hash=1212f57d4d21fbb85deba5fc02bfe0a38a6d1a04$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_ @@ -45,6 +45,8 @@ class CefBrowserProcessHandlerCToCpp const CefString& current_directory) override; void OnScheduleMessagePumpWork(int64_t delay_ms) override; CefRefPtr GetDefaultClient() override; + CefRefPtr GetDefaultRequestContextHandler() + override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_