Initialize required KeyedServiceFactories when extensions are disabled (issue #2359)

This commit is contained in:
Marshall Greenblatt 2018-02-02 17:43:33 -05:00
parent 128fbfb2d6
commit a2f430c6f3
6 changed files with 78 additions and 18 deletions

View File

@ -281,6 +281,8 @@ static_library("libcef_static") {
"libcef/browser/browser_context.h",
"libcef/browser/browser_context_impl.cc",
"libcef/browser/browser_context_impl.h",
"libcef/browser/browser_context_keyed_service_factories.cc",
"libcef/browser/browser_context_keyed_service_factories.h",
"libcef/browser/browser_context_proxy.cc",
"libcef/browser/browser_context_proxy.h",
"libcef/browser/browser_host_impl.cc",
@ -330,8 +332,6 @@ static_library("libcef_static") {
"libcef/browser/extensions/api/storage/sync_value_store_cache.h",
"libcef/browser/extensions/api/tabs/tabs_api.cc",
"libcef/browser/extensions/api/tabs/tabs_api.h",
"libcef/browser/extensions/browser_context_keyed_service_factories.cc",
"libcef/browser/extensions/browser_context_keyed_service_factories.h",
"libcef/browser/extensions/browser_extensions_util.cc",
"libcef/browser/extensions/browser_extensions_util.h",
"libcef/browser/extensions/browser_platform_delegate_background.cc",

View File

@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.
#include "libcef/browser/extensions/browser_context_keyed_service_factories.h"
#include "libcef/browser/browser_context_keyed_service_factories.h"
#include "libcef/common/extensions/extensions_util.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/extensions/api/streams_private/streams_private_api.h"
@ -14,20 +15,21 @@
#include "extensions/browser/api/storage/storage_frontend.h"
#include "extensions/browser/renderer_startup_helper.h"
namespace extensions {
namespace cef {
void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
AlarmManager::GetFactoryInstance();
CookieSettingsFactory::GetInstance();
PluginPrefsFactory::GetInstance();
PrefsTabHelper::GetServiceInstance();
RendererStartupHelperFactory::GetInstance();
SpellcheckServiceFactory::GetInstance();
StorageFrontend::GetFactoryInstance();
StreamsPrivateAPI::GetFactoryInstance();
ThemeServiceFactory::GetInstance();
if (extensions::ExtensionsEnabled()) {
extensions::AlarmManager::GetFactoryInstance();
extensions::RendererStartupHelperFactory::GetInstance();
extensions::StorageFrontend::GetFactoryInstance();
extensions::StreamsPrivateAPI::GetFactoryInstance();
}
}
} // namespace cef
} // namespace extensions

View File

@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
#ifndef CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
#define CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
namespace extensions {
namespace cef {
// Ensures the existence of any BrowserContextKeyedServiceFactory provided by
@ -14,6 +13,5 @@ namespace cef {
void EnsureBrowserContextKeyedServiceFactoriesBuilt();
} // namespace cef
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
#endif // CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_

View File

@ -9,11 +9,11 @@
#include <string>
#include "libcef/browser/browser_context_impl.h"
#include "libcef/browser/browser_context_keyed_service_factories.h"
#include "libcef/browser/browser_message_loop.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h"
#include "libcef/browser/devtools_manager_delegate.h"
#include "libcef/browser/extensions/browser_context_keyed_service_factories.h"
#include "libcef/browser/extensions/extension_system_factory.h"
#include "libcef/browser/extensions/extensions_browser_client.h"
#include "libcef/browser/net/chrome_scheme_handler.h"
@ -126,12 +126,13 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
new extensions::CefExtensionsBrowserClient);
extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
// Register additional KeyedService factories here. See
// ChromeBrowserMainExtraPartsProfiles for details.
extensions::cef::EnsureBrowserContextKeyedServiceFactoriesBuilt();
extensions::CefExtensionSystemFactory::GetInstance();
}
// Register additional KeyedService factories here. See
// ChromeBrowserMainExtraPartsProfiles for details.
cef::EnsureBrowserContextKeyedServiceFactoriesBuilt();
printing::CefPrintingMessageFilter::EnsureShutdownNotifierFactoryBuilt();
CefRequestContextSettings settings;

View File

@ -225,6 +225,11 @@ patches = [
# Support CEF changes in chrome/renderer.
'name': 'chrome_renderer',
},
{
# Don't initialize ExtensionSystemFactory when extensions are disabled.
# https://bitbucket.org/chromiumembedded/cef/issues/2359
'name': 'chrome_browser_content_settings',
},
{
# Make some methods of ProfileManager virtual.
# Allow CEF to intercept GetBrowserContext*InIncognito functions.

View File

@ -0,0 +1,54 @@
diff --git chrome/browser/content_settings/host_content_settings_map_factory.cc chrome/browser/content_settings/host_content_settings_map_factory.cc
index 7bb265a57ba4..6917d09be48a 100644
--- chrome/browser/content_settings/host_content_settings_map_factory.cc
+++ chrome/browser/content_settings/host_content_settings_map_factory.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/feature_list.h"
+#include "cef/libcef/features/features.h"
#include "chrome/browser/profiles/off_the_record_profile_impl.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_features.h"
@@ -16,6 +17,10 @@
#include "content/public/browser/browser_thread.h"
#include "extensions/features/features.h"
+#if BUILDFLAG(ENABLE_CEF)
+#include "cef/libcef/common/extensions/extensions_util.h"
+#endif
+
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/extension_service.h"
#include "extensions/browser/extension_system.h"
@@ -41,8 +46,14 @@ HostContentSettingsMapFactory::HostContentSettingsMapFactory()
DependsOn(SupervisedUserSettingsServiceFactory::GetInstance());
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
+#if BUILDFLAG(ENABLE_CEF)
+ if (extensions::ExtensionsEnabled()) {
+#endif
DependsOn(
extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
+#if BUILDFLAG(ENABLE_CEF)
+ }
+#endif
#endif
}
@@ -88,9 +99,15 @@ scoped_refptr<RefcountedKeyedService>
store_last_modified));
#if BUILDFLAG(ENABLE_EXTENSIONS)
+#if BUILDFLAG(ENABLE_CEF)
+ if (extensions::ExtensionsEnabled()) {
+#endif
// These must be registered before before the HostSettings are passed over to
// the IOThread. Simplest to do this on construction.
ExtensionService::RegisterContentSettings(settings_map.get(), profile);
+#if BUILDFLAG(ENABLE_CEF)
+ }
+#endif
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
SupervisedUserSettingsService* supervised_service =