diff options
Diffstat (limited to 'src/core/web_engine_context.cpp')
-rw-r--r-- | src/core/web_engine_context.cpp | 87 |
1 files changed, 71 insertions, 16 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 4bd29dddf..6da80e94d 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. ** @@ -11,24 +11,27 @@ ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** Foundation and appearing in the file LICENSE.LGPL3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -45,6 +48,9 @@ #include "base/run_loop.h" #include "base/threading/thread_restrictions.h" #include "cc/base/switches.h" +#if defined(ENABLE_BASIC_PRINTING) +#include "chrome/browser/printing/print_job_manager.h" +#endif // defined(ENABLE_BASIC_PRINTING) #include "content/browser/gpu/gpu_process_host.h" #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/utility_process_host_impl.h" @@ -52,6 +58,8 @@ #include "content/public/app/content_main.h" #include "content/public/app/content_main_runner.h" #include "content/public/browser/browser_main_runner.h" +#include "content/public/browser/plugin_service.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/common/content_paths.h" #include "content/public/common/content_switches.h" #include "content/public/common/main_function_params.h" @@ -63,7 +71,7 @@ #include "ui/gl/gl_switches.h" #if defined(OS_WIN) #include "sandbox/win/src/sandbox_types.h" -#include "content/public/app/startup_helper_win.h" +#include "content/public/app/sandbox_helper_win.h" #endif // OS_WIN #include "browser_context_adapter.h" @@ -91,7 +99,7 @@ QT_END_NAMESPACE namespace { -scoped_refptr<WebEngineContext> sContext; +scoped_refptr<QtWebEngineCore::WebEngineContext> sContext; void destroyContext() { @@ -144,8 +152,16 @@ bool usingQtQuick2DRenderer() return device == QLatin1String("softwarecontext"); } +#if defined(ENABLE_PLUGINS) +void dummyGetPluginCallback(const std::vector<content::WebPluginInfo>&) +{ +} +#endif + } // namespace +namespace QtWebEngineCore { + void WebEngineContext::destroyBrowserContext() { m_defaultBrowserContext.reset(); @@ -217,6 +233,9 @@ WebEngineContext::WebEngineContext() qputenv("force_s3tc_enable", "true"); #endif + // Allow us to inject javascript like any webview toolkit. + content::RenderFrameHost::AllowInjectingJavaScriptForAndroidWebView(); + #if defined(Q_OS_WIN) // We must initialize the command line with the UTF-16 arguments vector we got from // QCoreApplication. CommandLine::Init ignores its arguments on Windows and calls @@ -240,17 +259,31 @@ WebEngineContext::WebEngineContext() #endif parsedCommandLine->AppendSwitchPath(switches::kBrowserSubprocessPath, WebEngineLibraryInfo::getPath(content::CHILD_PROCESS_EXE)); - parsedCommandLine->AppendSwitch(switches::kNoSandbox); - parsedCommandLine->AppendSwitch(switches::kEnableDelegatedRenderer); + + // Enable sandboxing on OS X and Linux (Desktop / Embedded) by default. + bool disable_sandbox = qEnvironmentVariableIsSet("QTWEBENGINE_DISABLE_SANDBOX"); + if (!disable_sandbox) { +#if defined(Q_OS_WIN) + parsedCommandLine->AppendSwitch(switches::kNoSandbox); +#elif defined(Q_OS_LINUX) + parsedCommandLine->AppendSwitch(switches::kDisableSetuidSandbox); +#endif + } else { + parsedCommandLine->AppendSwitch(switches::kNoSandbox); + qInfo() << "Sandboxing disabled by user."; + } + parsedCommandLine->AppendSwitch(switches::kEnableThreadedCompositing); parsedCommandLine->AppendSwitch(switches::kInProcessGPU); + // These are currently only default on OS X, and we don't support them: + parsedCommandLine->AppendSwitch(switches::kDisableZeroCopy); + parsedCommandLine->AppendSwitch(switches::kDisableGpuMemoryBufferCompositorResources); if (useEmbeddedSwitches) { // Inspired by the Android port's default switches parsedCommandLine->AppendSwitch(switches::kEnableOverlayScrollbar); parsedCommandLine->AppendSwitch(switches::kEnablePinch); parsedCommandLine->AppendSwitch(switches::kEnableViewport); - parsedCommandLine->AppendSwitch(switches::kEnableViewportMeta); parsedCommandLine->AppendSwitch(switches::kMainFrameResizesAreOrientationChanges); parsedCommandLine->AppendSwitch(switches::kDisableAcceleratedVideoDecode); parsedCommandLine->AppendSwitch(switches::kDisableGpuShaderDiskCache); @@ -310,4 +343,26 @@ WebEngineContext::WebEngineContext() // thread to avoid a thread check assertion in its constructor when it // first gets referenced on the IO thread. MediaCaptureDevicesDispatcher::GetInstance(); + +#if defined(ENABLE_PLUGINS) + // Creating pepper plugins from the page (which calls PluginService::GetPluginInfoArray) + // might fail unless the page queried the list of available plugins at least once + // (which ends up calling PluginService::GetPlugins). Since the plugins list can only + // be created from the FILE thread, and that GetPluginInfoArray is synchronous, it + // can't loads plugins synchronously from the IO thread to serve the render process' request + // and we need to make sure that it happened beforehand. + content::PluginService::GetInstance()->GetPlugins(base::Bind(&dummyGetPluginCallback)); +#endif + +#if defined(ENABLE_BASIC_PRINTING) + m_printJobManager.reset(new printing::PrintJobManager()); +#endif // defined(ENABLE_BASIC_PRINTING) } + +#if defined(ENABLE_BASIC_PRINTING) +printing::PrintJobManager* WebEngineContext::getPrintJobManager() +{ + return m_printJobManager.get(); +} +#endif // defined(ENABLE_BASIC_PRINTING) +} // namespace |