From 1926ed7124a6ebd3af08a110c6c8bc4e25627662 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 21 Mar 2016 13:53:48 +0100 Subject: Add CommandLine::CreateEmpty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a static function to create the CommandLine object for the current process without initializing it. Rationale: on Windows we need to initialize the CommandLine differently than Chromium intends. Esp. we want to pass our own arguments instead of relying on GetCommandLineW(). Task-number: QTBUG-51971 Change-Id: I0d1f0aa4eabad470d730f4f0a76cd1535f8f23ce Reviewed-by: Kai Koehne Reviewed-by: Michael BrĂ¼ning --- chromium/base/command_line.cc | 10 +++++++++- chromium/base/command_line.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'chromium/base') diff --git a/chromium/base/command_line.cc b/chromium/base/command_line.cc index 92f45f5f9da..c0e5eda59dd 100644 --- a/chromium/base/command_line.cc +++ b/chromium/base/command_line.cc @@ -207,7 +207,7 @@ void CommandLine::InitUsingArgvForTesting(int argc, const char* const* argv) { #endif // defined(OS_WIN) // static -bool CommandLine::Init(int argc, const char* const* argv) { +bool CommandLine::CreateEmpty() { if (current_process_commandline_) { // If this is intentional, Reset() must be called first. If we are using // the shared build mode, we have to share a single object across multiple @@ -216,6 +216,14 @@ bool CommandLine::Init(int argc, const char* const* argv) { } current_process_commandline_ = new CommandLine(NO_PROGRAM); + return true; +} + +// static +bool CommandLine::Init(int argc, const char* const* argv) { + if (!CreateEmpty()) + return false; + #if defined(OS_WIN) current_process_commandline_->ParseFromString(::GetCommandLineW()); #elif defined(OS_POSIX) || defined(OS_FUCHSIA) diff --git a/chromium/base/command_line.h b/chromium/base/command_line.h index 6927e3e3413..afa0fdc5c09 100644 --- a/chromium/base/command_line.h +++ b/chromium/base/command_line.h @@ -77,6 +77,8 @@ class BASE_EXPORT CommandLine { static void InitUsingArgvForTesting(int argc, const char* const* argv); #endif + static bool CreateEmpty(); + // Initialize the current process CommandLine singleton. On Windows, ignores // its arguments (we instead parse GetCommandLineW() directly) because we // don't trust the CRT's parsing of the command line, but it still must be -- cgit v1.2.1