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.cpp96
1 files changed, 67 insertions, 29 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index a4ceb3a97..79c093fab 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -49,6 +49,7 @@
#include "base/task/sequence_manager/thread_controller_with_message_pump_impl.h"
#include "base/threading/thread_restrictions.h"
#include "cc/base/switches.h"
+#include "chrome/common/chrome_switches.h"
#if QT_CONFIG(webengine_printing_and_pdf)
#include "chrome/browser/printing/print_job_manager.h"
#include "components/printing/browser/features.h"
@@ -73,6 +74,7 @@
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
+#include "content/public/common/network_service_util.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
#include "media/audio/audio_manager.h"
@@ -182,6 +184,18 @@ void dummyGetPluginCallback(const std::vector<content::WebPluginInfo>&)
namespace QtWebEngineCore {
+#if defined(Q_OS_WIN)
+sandbox::SandboxInterfaceInfo *staticSandboxInterfaceInfo(sandbox::SandboxInterfaceInfo *info)
+{
+ static sandbox::SandboxInterfaceInfo *g_info = nullptr;
+ if (info) {
+ Q_ASSERT(g_info == nullptr);
+ g_info = info;
+ }
+ return g_info;
+}
+#endif
+
extern std::unique_ptr<base::MessagePump> messagePumpFactory();
bool usingSoftwareDynamicGL()
@@ -199,6 +213,21 @@ bool usingSoftwareDynamicGL()
#endif
}
+void setupProxyPac(base::CommandLine *commandLine){
+ if (commandLine->HasSwitch(switches::kProxyPacUrl)) {
+ QUrl pac_url(toQt(commandLine->GetSwitchValueASCII(switches::kProxyPacUrl)));
+ if (pac_url.isValid() && pac_url.isLocalFile()) {
+ QFile file(pac_url.toLocalFile());
+ if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QByteArray ba = file.readAll();
+ commandLine->RemoveSwitch(switches::kProxyPacUrl);
+ commandLine->AppendSwitchASCII(switches::kProxyPacUrl,
+ ba.toBase64().prepend("data:application/x-javascript-config;base64,").toStdString());
+ }
+ }
+ }
+}
+
scoped_refptr<QtWebEngineCore::WebEngineContext> WebEngineContext::m_handle;
bool WebEngineContext::m_destroyed = false;
@@ -248,7 +277,7 @@ void WebEngineContext::destroy()
// Normally the GPU thread is shut down when the GpuProcessHost is destroyed
// on IO thread (triggered by ~BrowserMainRunner). But by that time the UI
// task runner is not working anymore so we need to do this earlier.
- destroyGpuProcess();
+ destroyGpuProcess(m_threadedGpu);
base::MessagePump::Delegate *delegate =
static_cast<base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl *>(
@@ -400,7 +429,8 @@ static void appendToFeatureSwitch(base::CommandLine *commandLine, const char *fe
}
WebEngineContext::WebEngineContext()
- : m_mainDelegate(new ContentMainDelegateQt)
+ : m_threadedGpu(true)
+ , m_mainDelegate(new ContentMainDelegateQt)
, m_globalQObject(new QObject())
{
#if defined(Q_OS_MACOS)
@@ -449,15 +479,13 @@ WebEngineContext::WebEngineContext()
#endif
base::CommandLine* parsedCommandLine = commandLine();
-
+ setupProxyPac(parsedCommandLine);
parsedCommandLine->AppendSwitchPath(switches::kBrowserSubprocessPath, WebEngineLibraryInfo::getPath(content::CHILD_PROCESS_EXE));
// Enable sandboxing on OS X and Linux (Desktop / Embedded) by default.
bool disable_sandbox = qEnvironmentVariableIsSet(kDisableSandboxEnv);
if (!disable_sandbox) {
-#if defined(Q_OS_WIN)
- parsedCommandLine->AppendSwitch(service_manager::switches::kNoSandbox);
-#elif defined(Q_OS_LINUX)
+#if defined(Q_OS_LINUX)
parsedCommandLine->AppendSwitch(service_manager::switches::kDisableSetuidSandbox);
#endif
} else {
@@ -466,20 +494,6 @@ WebEngineContext::WebEngineContext()
}
parsedCommandLine->AppendSwitch(switches::kEnableThreadedCompositing);
- // These are currently only default on OS X, and we don't support them:
- parsedCommandLine->AppendSwitch(switches::kDisableZeroCopy);
- parsedCommandLine->AppendSwitch(switches::kDisableGpuMemoryBufferCompositorResources);
-
- // Enabled on OS X and Linux but currently not working. It worked in 5.7 on OS X.
- parsedCommandLine->AppendSwitch(switches::kDisableGpuMemoryBufferVideoFrames);
-
-#if defined(Q_OS_MACOS)
- // Accelerated decoding currently does not work on macOS due to issues with OpenGL Rectangle
- // texture support. See QTBUG-60002.
- parsedCommandLine->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
- // Same problem with Pepper using OpenGL images.
- parsedCommandLine->AppendSwitch(switches::kDisablePepper3DImageChromium);
-#endif
#if defined(Q_OS_WIN)
// This switch is used in Chromium's gl_context_wgl.cc file to determine whether to create
@@ -505,13 +519,12 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext);
#endif
- bool threadedGpu = true;
#ifndef QT_NO_OPENGL
- threadedGpu = QOpenGLContext::supportsThreadedOpenGL();
+ m_threadedGpu = QOpenGLContext::supportsThreadedOpenGL();
#endif
- threadedGpu = threadedGpu && !qEnvironmentVariableIsSet(kDisableInProcGpuThread);
+ m_threadedGpu = m_threadedGpu && !qEnvironmentVariableIsSet(kDisableInProcGpuThread);
- bool enableViz = ((threadedGpu && !parsedCommandLine->HasSwitch("disable-viz-display-compositor"))
+ bool enableViz = ((m_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");
@@ -529,8 +542,12 @@ WebEngineContext::WebEngineContext()
// The video-capture service is not functioning at this moment (since 69)
appendToFeatureList(disableFeatures, features::kMojoVideoCapture.name);
- // We do not yet support the network-service, but it is enabled by default since 75.
- appendToFeatureList(disableFeatures, network::features::kNetworkService.name);
+ // We do not yet fully support the network-service, but it has been enabled by default since 75.
+ bool enableNetworkService = !parsedCommandLine->HasSwitch("disable-network-service");
+ parsedCommandLine->RemoveSwitch("disable-network-service");
+ if (!enableNetworkService)
+ appendToFeatureList(disableFeatures, network::features::kNetworkService.name);
+
// BlinkGenPropertyTrees is enabled by default in 75, but causes regressions.
appendToFeatureList(disableFeatures, blink::features::kBlinkGenPropertyTrees.name);
@@ -556,6 +573,21 @@ WebEngineContext::WebEngineContext()
}
if (!enableViz) {
+ // These are currently only default on OS X, and we don't support them:
+ parsedCommandLine->AppendSwitch(switches::kDisableZeroCopy);
+ parsedCommandLine->AppendSwitch(switches::kDisableGpuMemoryBufferCompositorResources);
+
+ // Enabled on OS X and Linux but currently not working. It worked in 5.7 on OS X.
+ parsedCommandLine->AppendSwitch(switches::kDisableGpuMemoryBufferVideoFrames);
+
+#if defined(Q_OS_MACOS)
+ // Accelerated decoding currently does not work on macOS due to issues with OpenGL Rectangle
+ // texture support. See QTBUG-60002.
+ parsedCommandLine->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
+ // Same problem with Pepper using OpenGL images.
+ parsedCommandLine->AppendSwitch(switches::kDisablePepper3DImageChromium);
+#endif
+
// 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.
@@ -650,15 +682,18 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kDisableGpu);
}
- registerMainThreadFactories(threadedGpu);
+ registerMainThreadFactories(m_threadedGpu);
SetContentClient(new ContentClientQt);
content::ContentMainParams contentMainParams(m_mainDelegate.get());
#if defined(OS_WIN)
+ contentMainParams.sandbox_info = staticSandboxInterfaceInfo();
sandbox::SandboxInterfaceInfo sandbox_info = {0};
- content::InitializeSandboxInfo(&sandbox_info);
- contentMainParams.sandbox_info = &sandbox_info;
+ if (!contentMainParams.sandbox_info) {
+ content::InitializeSandboxInfo(&sandbox_info);
+ contentMainParams.sandbox_info = &sandbox_info;
+ }
#endif
m_contentRunner->Initialize(contentMainParams);
@@ -677,6 +712,9 @@ WebEngineContext::WebEngineContext()
m_serviceManagerEnvironment = std::make_unique<content::ServiceManagerEnvironment>(content::BrowserTaskExecutor::CreateIOThread());
m_startupData = m_serviceManagerEnvironment->CreateBrowserStartupData();
+ if (base::FeatureList::IsEnabled(network::features::kNetworkService))
+ content::ForceInProcessNetworkService(true);
+
// Once the MessageLoop has been created, attach a top-level RunLoop.
m_runLoop.reset(new base::RunLoop);
m_runLoop->BeforeRun();