alloy: Fix crashes when extensions are disabled (fixes issue #3430)

This commit is contained in:
Marshall Greenblatt
2023-01-05 13:55:00 -05:00
parent 8a07a836e1
commit aef474b909
5 changed files with 114 additions and 161 deletions

View File

@@ -160,6 +160,37 @@ index 07be432f365b9..d3800886a5b5c 100644
// A pointer to the current or speculative main frame in `host_contents_`. We
// can't access this frame through the `host_contents_` directly as it does
diff --git extensions/browser/extension_registry.cc extensions/browser/extension_registry.cc
index 10d751cceab73..128af05925e07 100644
--- extensions/browser/extension_registry.cc
+++ extensions/browser/extension_registry.cc
@@ -6,9 +6,14 @@
#include "base/observer_list.h"
#include "base/strings/string_util.h"
+#include "cef/libcef/features/runtime.h"
#include "extensions/browser/extension_registry_factory.h"
#include "extensions/browser/extension_registry_observer.h"
+#if BUILDFLAG(ENABLE_CEF)
+#include "cef/libcef/common/extensions/extensions_util.h"
+#endif
+
namespace extensions {
ExtensionRegistry::ExtensionRegistry(content::BrowserContext* browser_context)
@@ -17,6 +22,11 @@ ExtensionRegistry::~ExtensionRegistry() {}
// static
ExtensionRegistry* ExtensionRegistry::Get(content::BrowserContext* context) {
+#if BUILDFLAG(ENABLE_CEF)
+ if (cef::IsAlloyRuntimeEnabled() && !extensions::ExtensionsEnabled()) {
+ return nullptr;
+ }
+#endif
return ExtensionRegistryFactory::GetForBrowserContext(context);
}
diff --git extensions/browser/extensions_browser_client.h extensions/browser/extensions_browser_client.h
index 028d6b1fec3a0..0829a24eb2879 100644
--- extensions/browser/extensions_browser_client.h
@@ -218,3 +249,16 @@ index aeee5f5a516c4..ca2079ba1b447 100644
host->SetCloseHandler(
base::BindOnce(&ProcessManager::HandleCloseExtensionHost,
weak_ptr_factory_.GetWeakPtr()));
diff --git extensions/common/extensions_client.cc extensions/common/extensions_client.cc
index 53ad0736cfbdf..c252591fa646d 100644
--- extensions/common/extensions_client.cc
+++ extensions/common/extensions_client.cc
@@ -23,7 +23,7 @@ ExtensionsClient* g_client = nullptr;
} // namespace
ExtensionsClient* ExtensionsClient::Get() {
- DCHECK(g_client);
+ // May be nullptr if using CEF Alloy with extensions disabled.
return g_client;
}