Skip to content

Commit 852f9cb

Browse files
committed
support NW_PRE_ARGS environment variable
The value will be prepend to chromium-args
1 parent 2b10d7b commit 852f9cb

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/nw_package.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <vector>
2424

2525
#include "base/command_line.h"
26+
#include "base/environment.h"
2627
#include "base/files/file_util.h"
2728
#include "base/files/scoped_temp_dir.h"
2829
#include "base/json/json_file_value_serializer.h"
@@ -389,6 +390,8 @@ void Package::InitWithDefault() {
389390
// Window should show in center by default.
390391
window->SetString(switches::kmPosition, "center");
391392
root()->Set(switches::kmWindow, std::move(window));
393+
394+
ReadChromiumArgs();
392395
}
393396

394397
bool Package::ExtractPath(const base::FilePath& path_to_extract,
@@ -448,13 +451,18 @@ bool Package::ExtractPackage(const FilePath& zip_file, FilePath* where) {
448451
}
449452

450453
void Package::ReadChromiumArgs() {
451-
if (!root()->HasKey(switches::kmChromiumArgs))
452-
return;
454+
std::string args, env_args;
455+
std::unique_ptr<base::Environment> env(base::Environment::Create());
453456

454-
std::string args;
455-
if (!root()->GetStringASCII(switches::kmChromiumArgs, &args))
457+
bool got_env = env->GetVar("NW_PRE_ARGS", &env_args);
458+
if (!got_env && !root()->HasKey(switches::kmChromiumArgs))
456459
return;
457460

461+
if (!got_env && !root()->GetStringASCII(switches::kmChromiumArgs, &args))
462+
return;
463+
464+
args = env_args + kChromiumArgsSeparator + args;
465+
458466
std::vector<std::string> chromium_args;
459467
base::StringTokenizer tokenizer(args, kChromiumArgsSeparator);
460468
tokenizer.set_quote_chars("\'");

0 commit comments

Comments
 (0)