diff --git chrome/browser/themes/theme_service.cc chrome/browser/themes/theme_service.cc index ca830ceefd5d5..8b3af9620670d 100644 --- chrome/browser/themes/theme_service.cc +++ chrome/browser/themes/theme_service.cc @@ -27,6 +27,7 @@ #include "base/task/thread_pool.h" #include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" +#include "cef/libcef/features/runtime.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" #include "chrome/browser/profiles/profile.h" @@ -59,6 +60,10 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/layout.h" +#if BUILDFLAG(ENABLE_CEF) +#include "cef/libcef/common/extensions/extensions_util.h" +#endif + #if BUILDFLAG(ENABLE_EXTENSIONS) #include "base/scoped_observation.h" #include "extensions/browser/extension_registry_observer.h" @@ -281,11 +286,19 @@ void ThemeService::Init() { // OnExtensionServiceReady. Otherwise, the ThemeObserver won't be // constructed in time to observe the corresponding events. #if BUILDFLAG(ENABLE_EXTENSIONS) +#if BUILDFLAG(ENABLE_CEF) + const bool extensions_disabled = cef::IsAlloyRuntimeEnabled() && + !extensions::ExtensionsEnabled(); +#else + const bool extensions_disabled = false; +#endif + if (!extensions_disabled) { theme_observer_ = std::make_unique(this); extensions::ExtensionSystem::Get(profile_)->ready().Post( FROM_HERE, base::BindOnce(&ThemeService::OnExtensionServiceReady, weak_ptr_factory_.GetWeakPtr())); + } #endif theme_syncable_service_ = std::make_unique(profile_, this); diff --git chrome/browser/themes/theme_service_factory.cc chrome/browser/themes/theme_service_factory.cc index dc2350f0b2443..7f4b9283534f3 100644 --- chrome/browser/themes/theme_service_factory.cc +++ chrome/browser/themes/theme_service_factory.cc @@ -7,6 +7,7 @@ #include "base/no_destructor.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" +#include "cef/libcef/features/runtime.h" #include "chrome/browser/extensions/extension_system_factory.h" #include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/profile.h" @@ -30,6 +31,10 @@ #include "ui/views/linux_ui/linux_ui.h" #endif +#if BUILDFLAG(ENABLE_CEF) +#include "cef/libcef/common/extensions/extensions_util.h" +#endif + namespace { const ThemeHelper& GetThemeHelper() { @@ -73,7 +78,15 @@ ThemeServiceFactory::ThemeServiceFactory() BrowserContextDependencyManager::GetInstance()) { DependsOn(extensions::ExtensionRegistryFactory::GetInstance()); DependsOn(extensions::ExtensionPrefsFactory::GetInstance()); +#if BUILDFLAG(ENABLE_CEF) + const bool extensions_disabled = cef::IsAlloyRuntimeEnabled() && + !extensions::ExtensionsEnabled(); +#else + const bool extensions_disabled = false; +#endif + if (!extensions_disabled) { DependsOn(extensions::ExtensionSystemFactory::GetInstance()); + } } ThemeServiceFactory::~ThemeServiceFactory() {}