summaryrefslogtreecommitdiffstats
path: root/src/core/web_engine_context.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/web_engine_context.cpp')
-rw-r--r--src/core/web_engine_context.cpp107
1 files changed, 80 insertions, 27 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 07e0d3ba8..a4ceb3a97 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -44,19 +44,22 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
-#include "base/message_loop/message_loop_impl.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
+#include "base/task/sequence_manager/thread_controller_with_message_pump_impl.h"
#include "base/threading/thread_restrictions.h"
#include "cc/base/switches.h"
#if QT_CONFIG(webengine_printing_and_pdf)
#include "chrome/browser/printing/print_job_manager.h"
#include "components/printing/browser/features.h"
#endif
+#include "components/discardable_memory/service/discardable_shared_memory_manager.h"
#include "components/viz/common/features.h"
#include "components/web_cache/browser/web_cache_manager.h"
+#include "content/app/service_manager_environment.h"
#include "content/browser/devtools/devtools_http_handler.h"
#include "content/browser/scheduler/browser_task_executor.h"
+#include "content/browser/startup_data_impl.h"
#include "content/browser/startup_helper.h"
#include "content/public/app/content_main.h"
#include "content/public/app/content_main_runner.h"
@@ -72,14 +75,17 @@
#include "content/public/common/main_function_params.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
-#include "gpu/ipc/host/gpu_switches.h"
#include "media/audio/audio_manager.h"
+#include "media/base/media_switches.h"
#include "mojo/core/embedder/embedder.h"
#include "net/base/port_util.h"
#include "ppapi/buildflags/buildflags.h"
+#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/network_switches.h"
#include "services/resource_coordinator/public/cpp/resource_coordinator_features.h"
#include "services/service_manager/sandbox/switches.h"
+#include "services/tracing/public/cpp/tracing_features.h"
+#include "third_party/blink/public/common/features.h"
#include "ui/events/event_switches.h"
#include "ui/native_theme/native_theme_features.h"
#include "ui/gl/gl_switches.h"
@@ -88,6 +94,10 @@
#include "content/public/app/sandbox_helper_win.h"
#endif // OS_WIN
+#if defined(Q_OS_MACOS)
+#include "base/mac/foundation_util.h"
+#endif
+
#ifndef QT_NO_ACCESSIBILITY
#include "accessibility_activation_observer.h"
#endif
@@ -241,7 +251,8 @@ void WebEngineContext::destroy()
destroyGpuProcess();
base::MessagePump::Delegate *delegate =
- static_cast<base::MessageLoopImpl *>(m_runLoop->delegate_);
+ static_cast<base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl *>(
+ m_runLoop->delegate_);
// Flush the UI message loop before quitting.
while (delegate->DoWork()) { }
@@ -274,6 +285,11 @@ void WebEngineContext::destroy()
// Destroy the main runner, this stops main message loop
m_browserRunner.reset();
+ // These would normally be in the content-runner, but we allocated them separately:
+ m_startupData.reset();
+ m_serviceManagerEnvironment.reset();
+ m_discardableSharedMemoryManager.reset();
+
// Destroying content-runner will force Chromium at_exit calls to run, and
// reap child processes.
m_contentRunner.reset();
@@ -387,7 +403,13 @@ WebEngineContext::WebEngineContext()
: m_mainDelegate(new ContentMainDelegateQt)
, m_globalQObject(new QObject())
{
- base::TaskScheduler::Create("Browser");
+#if defined(Q_OS_MACOS)
+ // The bundled handling is currently both completely broken in Chromium,
+ // and unnecessary for us.
+ base::mac::SetOverrideAmIBundled(false);
+#endif
+
+ base::ThreadPoolInstance::Create("Browser");
m_contentRunner.reset(content::ContentMainRunner::Create());
m_browserRunner = content::BrowserMainRunner::Create();
@@ -457,8 +479,6 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
// Same problem with Pepper using OpenGL images.
parsedCommandLine->AppendSwitch(switches::kDisablePepper3DImageChromium);
- // Same problem with select popups.
- parsedCommandLine->AppendSwitch(switches::kDisableNativeGpuMemoryBuffers);
#endif
#if defined(Q_OS_WIN)
@@ -485,6 +505,17 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext);
#endif
+ bool threadedGpu = true;
+#ifndef QT_NO_OPENGL
+ threadedGpu = QOpenGLContext::supportsThreadedOpenGL();
+#endif
+ threadedGpu = threadedGpu && !qEnvironmentVariableIsSet(kDisableInProcGpuThread);
+
+ bool enableViz = ((threadedGpu && !parsedCommandLine->HasSwitch("disable-viz-display-compositor"))
+ || parsedCommandLine->HasSwitch("enable-viz-display-compositor"));
+ parsedCommandLine->RemoveSwitch("disable-viz-display-compositor");
+ parsedCommandLine->RemoveSwitch("enable-viz-display-compositor");
+
std::string disableFeatures;
std::string enableFeatures;
// Needed to allow navigations within pages that were set using setHtml(). One example is
@@ -492,31 +523,45 @@ WebEngineContext::WebEngineContext()
// This is deprecated behavior, and will be removed in a future Chromium version, as per
// upstream Chromium commit ba52f56207a4b9d70b34880fbff2352e71a06422.
appendToFeatureList(enableFeatures, features::kAllowContentInitiatedDataUrlNavigations.name);
- // Surface synchronization breaks our current graphics integration (since 65)
- appendToFeatureList(disableFeatures, features::kEnableSurfaceSynchronization.name);
- // Viz Display Compositor is enabled by default since 73. Doesn't work for us (also implies SurfaceSynchronization)
- appendToFeatureList(disableFeatures, features::kVizDisplayCompositor.name);
+
+ appendToFeatureList(enableFeatures, features::kTracingServiceInProcess.name);
+
// The video-capture service is not functioning at this moment (since 69)
appendToFeatureList(disableFeatures, features::kMojoVideoCapture.name);
- // Breaks WebEngineNewViewRequest.userInitiated API (since 73)
- appendToFeatureList(disableFeatures, features::kUserActivationV2.name);
- appendToFeatureList(disableFeatures, features::kBackgroundFetch.name);
+ // We do not yet support the network-service, but it is enabled by default since 75.
+ appendToFeatureList(disableFeatures, network::features::kNetworkService.name);
+ // BlinkGenPropertyTrees is enabled by default in 75, but causes regressions.
+ appendToFeatureList(disableFeatures, blink::features::kBlinkGenPropertyTrees.name);
#if QT_CONFIG(webengine_printing_and_pdf)
appendToFeatureList(disableFeatures, printing::features::kUsePdfCompositorServiceForPrint.name);
#endif
+ // Explicitly tell Chromium about default-on features we do not support
+ appendToFeatureList(disableFeatures, features::kBackgroundFetch.name);
+ appendToFeatureList(disableFeatures, features::kOriginTrials.name);
+ appendToFeatureList(disableFeatures, features::kSmsReceiver.name);
+ appendToFeatureList(disableFeatures, features::kWebAuth.name);
+ appendToFeatureList(disableFeatures, features::kWebAuthCable.name);
+ appendToFeatureList(disableFeatures, features::kWebPayments.name);
+ appendToFeatureList(disableFeatures, features::kWebUsb.name);
+
if (useEmbeddedSwitches) {
// embedded switches are based on the switches for Android, see content/browser/android/content_startup_flags.cc
appendToFeatureList(enableFeatures, features::kOverlayScrollbar.name);
- if (!parsedCommandLine->HasSwitch(switches::kDisablePinch))
- parsedCommandLine->AppendSwitch(switches::kEnablePinch);
parsedCommandLine->AppendSwitch(switches::kEnableViewport);
parsedCommandLine->AppendSwitch(switches::kMainFrameResizesAreOrientationChanges);
parsedCommandLine->AppendSwitch(cc::switches::kDisableCompositedAntialiasing);
}
+ if (!enableViz) {
+ // Viz Display Compositor is enabled by default since 73. Doesn't work for us (also implies SurfaceSynchronization)
+ appendToFeatureList(disableFeatures, features::kVizDisplayCompositor.name);
+ // VideoSurfaceLayer is enabled by default since 75. We don't support it.
+ appendToFeatureList(disableFeatures, media::kUseSurfaceLayerForVideo.name);
+ }
+
appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, disableFeatures);
appendToFeatureSwitch(parsedCommandLine, switches::kEnableFeatures, enableFeatures);
base::FeatureList::InitializeInstance(
@@ -542,7 +587,7 @@ WebEngineContext::WebEngineContext()
|| usingANGLE())
{
if (qt_gl_global_share_context()->isOpenGLES()) {
- glType = gl::kGLImplementationEGLName;
+ glType = usingANGLE() ? gl::kGLImplementationANGLEName : gl::kGLImplementationEGLName;
} else {
QOpenGLContext context;
QSurfaceFormat format;
@@ -605,20 +650,10 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kDisableGpu);
}
- bool threadedGpu = true;
-#ifndef QT_NO_OPENGL
- threadedGpu = QOpenGLContext::supportsThreadedOpenGL();
-#endif
- threadedGpu = threadedGpu && !qEnvironmentVariableIsSet(kDisableInProcGpuThread);
registerMainThreadFactories(threadedGpu);
SetContentClient(new ContentClientQt);
- content::StartBrowserTaskScheduler();
- content::BrowserTaskExecutor::Create();
-
- mojo::core::Init();
-
content::ContentMainParams contentMainParams(m_mainDelegate.get());
#if defined(OS_WIN)
sandbox::SandboxInterfaceInfo sandbox_info = {0};
@@ -626,12 +661,30 @@ WebEngineContext::WebEngineContext()
contentMainParams.sandbox_info = &sandbox_info;
#endif
m_contentRunner->Initialize(contentMainParams);
- m_browserRunner->Initialize(content::MainFunctionParams(*base::CommandLine::ForCurrentProcess()));
+
+ mojo::core::Configuration mojoConfiguration;
+ mojoConfiguration.is_broker_process = true;
+ mojo::core::Init(mojoConfiguration);
+
+ // This block mirrors ContentMainRunnerImpl::RunServiceManager():
+ m_mainDelegate->PreCreateMainMessageLoop();
+ base::MessagePump::OverrideMessagePumpForUIFactory(messagePumpFactory);
+ content::BrowserTaskExecutor::Create();
+ m_mainDelegate->PostEarlyInitialization(false);
+ content::StartBrowserThreadPool();
+ content::BrowserTaskExecutor::PostFeatureListSetup();
+ m_discardableSharedMemoryManager = std::make_unique<discardable_memory::DiscardableSharedMemoryManager>();
+ m_serviceManagerEnvironment = std::make_unique<content::ServiceManagerEnvironment>(content::BrowserTaskExecutor::CreateIOThread());
+ m_startupData = m_serviceManagerEnvironment->CreateBrowserStartupData();
// Once the MessageLoop has been created, attach a top-level RunLoop.
m_runLoop.reset(new base::RunLoop);
m_runLoop->BeforeRun();
+ content::MainFunctionParams mainParams(*base::CommandLine::ForCurrentProcess());
+ mainParams.startup_data = m_startupData.get();
+ m_browserRunner->Initialize(mainParams);
+
m_devtoolsServer.reset(new DevToolsServerQt());
m_devtoolsServer->start();
// Force the initialization of MediaCaptureDevicesDispatcher on the UI