From ea1e55ad0f2ae04706c0103e6f613c253cfcb094 Mon Sep 17 00:00:00 2001 From: Andras Becsi Date: Fri, 5 Jul 2013 21:58:24 +0200 Subject: 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 --- lib/web_engine_context.cpp | 49 +++++++++++++---------------- patches/0001-Export-ContentMainRunner.patch | 33 +++++++++++++++++++ patches/0001-My-local-fixes.patch | 47 --------------------------- patches/patch-chromium.sh | 2 +- 4 files changed, 55 insertions(+), 76 deletions(-) create mode 100644 patches/0001-Export-ContentMainRunner.patch delete mode 100644 patches/0001-My-local-fixes.patch 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 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(); diff --git a/patches/0001-Export-ContentMainRunner.patch b/patches/0001-Export-ContentMainRunner.patch new file mode 100644 index 000000000..7cd402485 --- /dev/null +++ b/patches/0001-Export-ContentMainRunner.patch @@ -0,0 +1,33 @@ +From 0a3b4029af83089cb313b555a47c5c510dc94cc7 Mon Sep 17 00:00:00 2001 +From: Simon Hausmann +Date: Mon, 29 Apr 2013 11:25:37 +0200 +Subject: Export ContentMainRunner + +--- + content/public/app/content_main_runner.h | 3 ++- + 3 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/content/public/app/content_main_runner.h b/content/public/app/content_main_runner.h +index bed5ff2..992e0d0 100644 +--- a/content/public/app/content_main_runner.h ++++ b/content/public/app/content_main_runner.h +@@ -8,6 +8,7 @@ + #include + + #include "build/build_config.h" ++#include "content/common/content_export.h" + + #if defined(OS_WIN) + #include +@@ -22,7 +23,7 @@ namespace content { + class ContentMainDelegate; + + // This class is responsible for content initialization, running and shutdown. +-class ContentMainRunner { ++class CONTENT_EXPORT ContentMainRunner { + public: + virtual ~ContentMainRunner() {} + +-- +1.8.3 + diff --git a/patches/0001-My-local-fixes.patch b/patches/0001-My-local-fixes.patch deleted file mode 100644 index ab9e927d7..000000000 --- a/patches/0001-My-local-fixes.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 0a3b4029af83089cb313b555a47c5c510dc94cc7 Mon Sep 17 00:00:00 2001 -From: Simon Hausmann -Date: Mon, 29 Apr 2013 11:25:37 +0200 -Subject: [PATCH 1/2] My local fixes - ---- - content/browser/zygote_host/zygote_host_impl_linux.cc | 1 + - content/public/app/content_main_runner.h | 3 ++- - content/public/common/content_client.h | 2 +- - 3 files changed, 4 insertions(+), 2 deletions(-) - -diff --git a/content/browser/zygote_host/zygote_host_impl_linux.cc b/content/browser/zygote_host/zygote_host_impl_linux.cc -index ba7884f8..50eacc8 100644 ---- a/content/browser/zygote_host/zygote_host_impl_linux.cc -+++ b/content/browser/zygote_host/zygote_host_impl_linux.cc -@@ -70,6 +70,7 @@ void ZygoteHostImpl::Init(const std::string& sandbox_cmd) { - - base::FilePath chrome_path; - CHECK(PathService::Get(base::FILE_EXE, &chrome_path)); -+ chrome_path = CommandLine::ForCurrentProcess()->GetSwitchValuePath(switches::kBrowserSubprocessPath); - CommandLine cmd_line(chrome_path); - - cmd_line.AppendSwitchASCII(switches::kProcessType, switches::kZygoteProcess); -diff --git a/content/public/app/content_main_runner.h b/content/public/app/content_main_runner.h -index bed5ff2..992e0d0 100644 ---- a/content/public/app/content_main_runner.h -+++ b/content/public/app/content_main_runner.h -@@ -8,6 +8,7 @@ - #include - - #include "build/build_config.h" -+#include "content/common/content_export.h" - - #if defined(OS_WIN) - #include -@@ -22,7 +23,7 @@ namespace content { - class ContentMainDelegate; - - // This class is responsible for content initialization, running and shutdown. --class ContentMainRunner { -+class CONTENT_EXPORT ContentMainRunner { - public: - virtual ~ContentMainRunner() {} - --- -1.8.3 - diff --git a/patches/patch-chromium.sh b/patches/patch-chromium.sh index 6bc1c5e05..0ffe6860f 100755 --- a/patches/patch-chromium.sh +++ b/patches/patch-chromium.sh @@ -61,7 +61,7 @@ git submodule update --recursive cd $CHROMIUM_SRC_DIR echo "Entering $PWD" -git am $PATCH_DIR/0001-My-local-fixes.patch +git am $PATCH_DIR/0001-Export-ContentMainRunner.patch git am $PATCH_DIR/0002-Add-WebEngineContext-to-RunLoop-s-friends.patch git am $PATCH_DIR/0001-Mac-Use-libc-instead-of-stdlibc.patch git am $PATCH_DIR/0002-Clang-libc-does-not-support-incomplete-types-in-temp.patch -- cgit v1.2.3