File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,11 +43,14 @@ const char kNoTimeout[] = "no-timeout";
4343// Display no toolbar
4444const char kNoToolbar [] = " no-toolbar" ;
4545
46+ // Open specified url
47+ const char kUrl [] = " url" ;
48+
4649// Show version and quit
4750const char kVersion [] = " version" ;
4851
49- // Open specified url
50- const char kUrl [] = " url " ;
52+ // Set current working directory
53+ const char kWorkingDirectory [] = " working-directory " ;
5154
5255const char kmMain[] = " main" ;
5356const char kmName[] = " name" ;
Original file line number Diff line number Diff line change @@ -16,8 +16,9 @@ extern const char kDeveloper[];
1616extern const char kDumpRenderTree [];
1717extern const char kNoTimeout [];
1818extern const char kNoToolbar [];
19- extern const char kVersion [];
2019extern const char kUrl [];
20+ extern const char kVersion [];
21+ extern const char kWorkingDirectory [];
2122
2223// Manifest settings
2324extern const char kmMain[];
Original file line number Diff line number Diff line change 2121#include " content/nw/src/renderer/shell_content_renderer_client.h"
2222
2323#include " base/command_line.h"
24+ #include " base/file_path.h"
25+ #include " base/file_util.h"
2426#include " base/logging.h"
2527#include " base/utf_string_conversions.h"
2628#include " content/nw/src/api/dispatcher.h"
@@ -45,6 +47,13 @@ ShellContentRendererClient::~ShellContentRendererClient() {
4547}
4648
4749void ShellContentRendererClient::RenderThreadStarted () {
50+ // Change working directory
51+ CommandLine* command_line = CommandLine::ForCurrentProcess ();
52+ if (command_line->HasSwitch (switches::kWorkingDirectory )) {
53+ file_util::SetCurrentDirectory (
54+ command_line->GetSwitchValuePath (switches::kWorkingDirectory ));
55+ }
56+
4857 // Initialize node after render thread is started
4958 v8::V8::Initialize ();
5059 v8::HandleScope scope;
Original file line number Diff line number Diff line change 2222
2323#include " base/command_line.h"
2424#include " base/file_path.h"
25+ #include " base/file_util.h"
2526#include " content/public/common/content_switches.h"
2627#include " content/public/browser/browser_url_handler.h"
2728#include " content/public/browser/resource_dispatcher_host.h"
@@ -69,8 +70,15 @@ void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
6970 command_line->AppendSwitch (switches::kAllowFileAccessFromFiles );
7071 command_line->AppendSwitch (switches::kDisableWebSecurity );
7172
72- if (nw::GetManifest () && nw::GetUseNode ())
73+ if (nw::GetManifest () && nw::GetUseNode ()) {
74+ // Whether to disable node
7375 command_line->AppendSwitch (switches::kmNodejs);
76+
77+ // Set cwd
78+ FilePath cwd;
79+ file_util::GetCurrentDirectory (&cwd);
80+ command_line->AppendSwitchPath (switches::kWorkingDirectory , cwd);
81+ }
7482}
7583
7684std::string ShellContentBrowserClient::GetApplicationLocale () {
You can’t perform that action at this time.
0 commit comments