diff options
author | Andras Becsi <andras.becsi@digia.com> | 2013-07-05 21:58:24 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-07-09 13:47:30 +0200 |
commit | ea1e55ad0f2ae04706c0103e6f613c253cfcb094 (patch) | |
tree | f1335c4310797dd9f412a4bd9fed449b6dab1710 /lib/web_engine_context.cpp | |
parent | 1daab3653e56469868656b32fa87b7f9585ec577 (diff) |
Get rid of or upstream chrome_path patch for zygote
Override base::FILE_EXE in ContentMainDelegateQt::PreSandboxStartup()
with the path to our child process and get rid of the command line
argument and the content::CHILD_PROCESS_EXE override.
This reduces 0001-My-local-fixes.patch to export ContentMainRunner
so the patch can be renamed to better reflect it's purpose.
This hunk is still needed since we need to access ContentMainRunner's
Initialize() to set our ContentMainDelegate.
Change-Id: I808cb114100300a33f8cb1b154c6cde89cbf5d98
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'lib/web_engine_context.cpp')
-rw-r--r-- | lib/web_engine_context.cpp | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/lib/web_engine_context.cpp b/lib/web_engine_context.cpp index 3059bc089..149e580b9 100644 --- a/lib/web_engine_context.cpp +++ b/lib/web_engine_context.cpp @@ -92,15 +92,6 @@ static QByteArray subProcessPath() { return processPath; } -static void initializeBlinkPaths() -{ - static bool initialized = false; - if (initialized) - return; - - PathService::Override(content::CHILD_PROCESS_EXE, base::FilePath(qStringToStringType(QString(subProcessPath())))); -} - // Return a timeout suitable for the glib loop, -1 to block forever, // 0 to return right away, or a timeout in milliseconds from now. int GetTimeIntervalMilliseconds(const base::TimeTicks& from) { @@ -196,7 +187,15 @@ base::MessagePump* messagePumpFactory() class ContentMainDelegateQt : public content::ContentMainDelegate { public: - content::ContentBrowserClient* CreateContentBrowserClient() + + // This is where the embedder puts all of its startup code that needs to run + // before the sandbox is engaged. + void PreSandboxStartup() Q_DECL_OVERRIDE + { + PathService::Override(base::FILE_EXE, base::FilePath(qStringToStringType(subProcessPath()))); + } + + content::ContentBrowserClient* CreateContentBrowserClient() Q_DECL_OVERRIDE { m_browserClient.reset(new ContentBrowserClientQt); return m_browserClient.get(); @@ -214,26 +213,22 @@ WebEngineContext::WebEngineContext() sContext = this; { - QByteArray subProcessPathOption("--browser-subprocess-path="); - subProcessPathOption.append(subProcessPath()); - std::string ua = webkit_glue::BuildUserAgentFromProduct("QtWebEngine/0.1"); - QByteArray userAgentParameter("--user-agent="); userAgentParameter.append(QString::fromStdString(ua).toUtf8()); - const QStringList args = QCoreApplication::arguments(); - const int argc = args.size() + 3; - const char* argv[argc]; - int i = 0; - for(; i < args.size(); ++i) - argv[i] = args.at(i).toLatin1().constData(); - argv[i++] = subProcessPathOption.constData(); - argv[i++] = "--no-sandbox"; - argv[i++] = "--disable-plugins"; - argv[i] = userAgentParameter.constData(); - - CommandLine::Init(argc, argv); + QList<QByteArray> args; + Q_FOREACH (const QString& arg, QCoreApplication::arguments()) + args << arg.toUtf8(); + args << userAgentParameter; + args << QByteArrayLiteral("--no-sandbox"); + args << QByteArrayLiteral("--disable-plugins"); + + const char* argv[args.size()]; + for (int i = 0; i < args.size(); ++i) + argv[i] = args[i].constData(); + + CommandLine::Init(args.size(), argv); } // This needs to be set before the MessageLoop is created by BrowserMainRunner. @@ -245,8 +240,6 @@ WebEngineContext::WebEngineContext() runner->Initialize(0, 0, new ContentMainDelegateQt); } - initializeBlinkPaths(); - static content::BrowserMainRunner *browserRunner = 0; if (!browserRunner) { browserRunner = content::BrowserMainRunner::Create(); |