Make CefBrowserContext an abstract base class (see issue #2969)

Existing CefBrowserContext functionality is now split between
CefBrowserContext and AlloyBrowserContext. Runtime implementations of
CefBrowserContext will provide access to the content::BrowserContext and
Profile types via different inheritance paths. For example, the Alloy
runtime uses ChromeProfileAlloy and the Chrome runtime uses ProfileImpl.

This change also renames CefResourceContext to CefIOThreadState to more
accurately represent its purpose as it no longer needs to extend
content::ResourceContext.
This commit is contained in:
Marshall Greenblatt
2020-06-30 20:57:00 -04:00
parent 619f18fea0
commit 48fc0bd220
40 changed files with 1006 additions and 831 deletions

View File

@ -138,7 +138,10 @@ BrowserContext* CefExtensionsBrowserClient::GetOffTheRecordContext(
BrowserContext* CefExtensionsBrowserClient::GetOriginalContext(
BrowserContext* context) {
return CefBrowserContext::GetForContext(context);
auto cef_browser_context = CefBrowserContext::FromBrowserContext(context);
if (cef_browser_context)
return cef_browser_context->AsBrowserContext();
return nullptr;
}
bool CefExtensionsBrowserClient::IsGuestSession(BrowserContext* context) const {
@ -200,7 +203,9 @@ bool CefExtensionsBrowserClient::AllowCrossRendererResourceLoad(
PrefService* CefExtensionsBrowserClient::GetPrefServiceForContext(
BrowserContext* context) {
return static_cast<CefBrowserContext*>(context)->GetPrefs();
return CefBrowserContext::FromBrowserContext(context)
->AsProfile()
->GetPrefs();
}
void CefExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
@ -224,12 +229,12 @@ bool CefExtensionsBrowserClient::CreateBackgroundExtensionHost(
content::BrowserContext* browser_context,
const GURL& url,
ExtensionHost** host) {
CefBrowserContext* browser_context_impl =
CefBrowserContext::GetForContext(browser_context);
auto cef_browser_context =
CefBrowserContext::FromBrowserContext(browser_context);
// A CEF representation should always exist.
CefRefPtr<CefExtension> cef_extension =
browser_context_impl->extension_system()->GetExtension(extension->id());
cef_browser_context->GetExtension(extension->id());
DCHECK(cef_extension);
if (!cef_extension) {
// Cancel the background host creation.