Fix crash in ThemeService with --disable-extensions (fixes issue #2852)

This commit is contained in:
Marshall Greenblatt 2020-07-21 13:09:26 -04:00
parent a3919cb0ec
commit ef7e98c616
1 changed files with 57 additions and 12 deletions

View File

@ -1,37 +1,82 @@
diff --git chrome/browser/themes/theme_service.cc chrome/browser/themes/theme_service.cc
index 2a6df8119a44..dffe87df9c54 100644
--- chrome/browser/themes/theme_service.cc
+++ chrome/browser/themes/theme_service.cc
@@ -25,6 +25,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/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/theme_installed_infobar_delegate.h"
@@ -54,6 +55,10 @@
#include "extensions/common/extension_set.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_observer.h"
#include "extensions/browser/extension_registry_observer.h"
@@ -270,11 +275,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<ThemeObserver>(this);
extensions::ExtensionSystem::Get(profile_)->ready().Post(
FROM_HERE, base::Bind(&ThemeService::OnExtensionServiceReady,
weak_ptr_factory_.GetWeakPtr()));
+ }
#endif
theme_syncable_service_.reset(new ThemeSyncableService(profile_, this));
diff --git chrome/browser/themes/theme_service_factory.cc chrome/browser/themes/theme_service_factory.cc diff --git chrome/browser/themes/theme_service_factory.cc chrome/browser/themes/theme_service_factory.cc
index caec77bbe3ba..1640307eef65 100644 index caec77bbe3ba..92a813acc008 100644
--- chrome/browser/themes/theme_service_factory.cc --- chrome/browser/themes/theme_service_factory.cc
+++ chrome/browser/themes/theme_service_factory.cc +++ chrome/browser/themes/theme_service_factory.cc
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "build/build_config.h" #include "build/build_config.h"
+#include "cef/libcef/features/features.h" +#include "cef/libcef/features/runtime.h"
#include "chrome/browser/extensions/extension_system_factory.h" #include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
@@ -41,6 +42,10 @@ const ThemeHelper& GetThemeHelper() { @@ -27,6 +28,10 @@
#include "ui/views/linux_ui/linux_ui.h"
} // namespace #endif
+#if BUILDFLAG(ENABLE_CEF) +#if BUILDFLAG(ENABLE_CEF)
+#include "cef/libcef/common/extensions/extensions_util.h" +#include "cef/libcef/common/extensions/extensions_util.h"
+#endif +#endif
+ +
// static namespace {
ThemeService* ThemeServiceFactory::GetForProfile(Profile* profile) {
return static_cast<ThemeService*>( const ThemeHelper& GetThemeHelper() {
@@ -70,7 +75,13 @@ ThemeServiceFactory::ThemeServiceFactory() @@ -70,7 +75,15 @@ ThemeServiceFactory::ThemeServiceFactory()
BrowserContextDependencyManager::GetInstance()) { BrowserContextDependencyManager::GetInstance()) {
DependsOn(extensions::ExtensionRegistryFactory::GetInstance()); DependsOn(extensions::ExtensionRegistryFactory::GetInstance());
DependsOn(extensions::ExtensionPrefsFactory::GetInstance()); DependsOn(extensions::ExtensionPrefsFactory::GetInstance());
+#if BUILDFLAG(ENABLE_CEF) +#if BUILDFLAG(ENABLE_CEF)
+ if (extensions::ExtensionsEnabled()) { + const bool extensions_disabled = cef::IsAlloyRuntimeEnabled() &&
+ !extensions::ExtensionsEnabled();
+#else
+ const bool extensions_disabled = false;
+#endif +#endif
+ if (!extensions_disabled) {
DependsOn(extensions::ExtensionSystemFactory::GetInstance()); DependsOn(extensions::ExtensionSystemFactory::GetInstance());
+#if BUILDFLAG(ENABLE_CEF)
+ } + }
+#endif
} }
ThemeServiceFactory::~ThemeServiceFactory() {} ThemeServiceFactory::~ThemeServiceFactory() {}