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

This commit is contained in:
Marshall Greenblatt 2023-01-05 14:11:56 -05:00
parent b5acaf4520
commit abbf5d2c20
3 changed files with 47 additions and 3 deletions

View File

@ -388,6 +388,8 @@ patches = [
# https://bitbucket.org/chromiumembedded/cef/issues/1947
#
# Don't initialize PrerenderContents object in StreamsPrivateAPI.
#
# Return nullptr from ExtensionRegistry::Get when extensions are disabled.
'name': 'extensions_1947',
},
{

View File

@ -160,6 +160,37 @@ index fd08f312145a5..1440a3e8246f9 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

View File

@ -1,5 +1,5 @@
diff --git chrome/browser/net/profile_network_context_service.cc chrome/browser/net/profile_network_context_service.cc
index eb8daa2c4d5fe..64f6ac00f4faa 100644
index eb8daa2c4d5fe..254d6e08bffc4 100644
--- chrome/browser/net/profile_network_context_service.cc
+++ chrome/browser/net/profile_network_context_service.cc
@@ -22,6 +22,7 @@
@ -10,7 +10,18 @@ index eb8daa2c4d5fe..64f6ac00f4faa 100644
#include "chrome/browser/browser_features.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_content_browser_client.h"
@@ -796,7 +797,19 @@ void ProfileNetworkContextService::ConfigureNetworkContextParamsInternal(
@@ -304,7 +305,9 @@ ProfileNetworkContextService::ProfileNetworkContextService(Profile* profile)
base::Unretained(this)));
#if BUILDFLAG(ENABLE_EXTENSIONS)
- registry_observation_.Observe(extensions::ExtensionRegistry::Get(profile_));
+ if (auto extension_registry = extensions::ExtensionRegistry::Get(profile_)) {
+ registry_observation_.Observe(extension_registry);
+ }
#endif
}
@@ -796,7 +799,19 @@ void ProfileNetworkContextService::ConfigureNetworkContextParamsInternal(
// Configure on-disk storage for non-OTR profiles. OTR profiles just use
// default behavior (in memory storage, default sizes).
@ -31,7 +42,7 @@ index eb8daa2c4d5fe..64f6ac00f4faa 100644
PrefService* local_state = g_browser_process->local_state();
// Configure the HTTP cache path and size.
base::FilePath base_cache_path;
@@ -809,7 +822,9 @@ void ProfileNetworkContextService::ConfigureNetworkContextParamsInternal(
@@ -809,7 +824,9 @@ void ProfileNetworkContextService::ConfigureNetworkContextParamsInternal(
base_cache_path.Append(chrome::kCacheDirname);
network_context_params->http_cache_max_size =
local_state->GetInteger(prefs::kDiskCacheSize);