mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
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.
This commit is contained in:
@@ -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<CefRequestContextImpl> 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();
|
||||
|
Reference in New Issue
Block a user