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.
This commit is contained in:
Marshall Greenblatt 2023-02-17 14:08:00 -05:00
parent 719fe7691b
commit b7ba0b9a66
1 changed files with 4 additions and 0 deletions

View File

@ -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);