From 73082fd2ced94905ba0c2125e5da581d1a7a0466 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Fri, 17 Feb 2023 14:08:00 -0500 Subject: [PATCH] chrome: Make primary user profile the default global context (see issue #3444) Chrome is always loading the primary user profile by default, so with this change the CEF behavior more accurately reflects reality. Incognito contexts can still be created explicitly via CefRequestContext::CreateContext. Prior to this change, the default for the global context was an Incognito profile based on the primary user profile. That caused request interception to be bypassed in WillCreateURLLoaderFactory for profiles associated with the "New window" and "New incognito window" commands. Those profiles, while also being (or based on) the primary user profile, did not match the specific Incognito profile assigned to the default global context. After this change, the "New window" and "New incognito window" commands will match the default global context when executed on a browser that was created using the primary user profile. --- libcef/browser/chrome/chrome_browser_main_extra_parts_cef.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libcef/browser/chrome/chrome_browser_main_extra_parts_cef.cc b/libcef/browser/chrome/chrome_browser_main_extra_parts_cef.cc index a069d7aa4..87aa49fa5 100644 --- a/libcef/browser/chrome/chrome_browser_main_extra_parts_cef.cc +++ b/libcef/browser/chrome/chrome_browser_main_extra_parts_cef.cc @@ -11,6 +11,7 @@ #include "libcef/browser/permission_prompt.h" #include "base/task/thread_pool.h" +#include "chrome/browser/profiles/profile.h" ChromeBrowserMainExtraPartsCef::ChromeBrowserMainExtraPartsCef() = default; @@ -25,6 +26,9 @@ void ChromeBrowserMainExtraPartsCef::PostProfileInit(Profile* profile, CefRequestContextSettings settings; CefContext::Get()->PopulateGlobalRequestContextSettings(&settings); + // Use the existing path for the initial profile. + CefString(&settings.cache_path) = profile->GetPath().value(); + // Create the global RequestContext. global_request_context_ = CefRequestContextImpl::CreateGlobalRequestContext(settings);