electron/shell/common/electron_command_line.h
Charles Kerr dffe00b232
fix: -Wunsafe-buffer-usage warnings with argc, argv (#44366)
* refactor: move uv_setup_args() calls to startup

* refactor: call base::CommandLine::Init() before ContentMain()

* feat: add ElectronCommandLine::AsUtf8()

* refactor: call base::CommandLine::Init() before NodeMain()

* refactor: use ElectronCommandLine::AsUtf8() in NodeMain()

* fix: -Wunsafe-buffer-usage warning in ElectronCommandLine::Init()

* chore: add a DCHECK to confirm ElectronCommandLine was initialized before AsUtf8() is called

* chore: const correctness in ElectronCommandLine::Init() args

* chore: add ElectronCommandLine to macOS Electron Helper app

* chore: move argc, argvc setup into electron_library_main on macOS

* chore: revert BUILD.gn changes

* fix: WideToUTF8() call in ElectronCommandLine::AsUtf8()

* build: add uv to the include paths for app/electron_main_linux

* build: add uv to the include paths for app/electron_library_main.mm

* chore: revert unrelated changes

these were intended for another branch
2024-10-29 13:23:08 +01:00

39 lines
1.1 KiB
C++

// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_COMMON_ELECTRON_COMMAND_LINE_H_
#define ELECTRON_SHELL_COMMON_ELECTRON_COMMAND_LINE_H_
#include "base/command_line.h"
#include "build/build_config.h"
namespace electron {
// Singleton to remember the original "argc" and "argv".
class ElectronCommandLine {
public:
// disable copy
ElectronCommandLine() = delete;
ElectronCommandLine(const ElectronCommandLine&) = delete;
ElectronCommandLine& operator=(const ElectronCommandLine&) = delete;
static const base::CommandLine::StringVector& argv() { return argv_; }
static std::vector<std::string> AsUtf8();
static void Init(int argc, base::CommandLine::CharType const* const* argv);
#if BUILDFLAG(IS_LINUX)
// On Linux the command line has to be read from base::CommandLine since
// it is using zygote.
static void InitializeFromCommandLine();
#endif
private:
static base::CommandLine::StringVector argv_;
};
} // namespace electron
#endif // ELECTRON_SHELL_COMMON_ELECTRON_COMMAND_LINE_H_