Browse Source

Allow using current argv for relaunch

Cheng Zhao 9 years ago
parent
commit
8435f1c900
3 changed files with 18 additions and 3 deletions
  1. 15 1
      atom/browser/browser.cc
  2. 2 1
      atom/browser/browser.h
  3. 1 1
      atom/browser/relauncher_win.cc

+ 15 - 1
atom/browser/browser.cc

@@ -34,9 +34,21 @@ Browser* Browser::Get() {
   return AtomBrowserMainParts::Get()->browser();
 }
 
-bool Browser::Relaunch(const base::FilePath& app,
+bool Browser::Relaunch(bool override_argv,
+                       const base::FilePath& app,
                        const relauncher::StringVector& args) {
+  if (!override_argv) {
+#if defined(OS_WIN)
+    const relauncher::StringVector& argv = atom::AtomCommandLine::wargv();
+#else
+    const relauncher::StringVector& argv = atom::AtomCommandLine::argv();
+#endif
+    return relauncher::RelaunchApp(argv);
+  }
+
   relauncher::StringVector argv;
+  argv.reserve(1 + args.size());
+
   if (app.empty()) {
     base::FilePath exe_path;
     PathService::Get(base::FILE_EXE, &exe_path);
@@ -45,6 +57,8 @@ bool Browser::Relaunch(const base::FilePath& app,
     argv.push_back(app.value());
   }
 
+  argv.insert(argv.end(), args.begin(), args.end());
+
   return relauncher::RelaunchApp(argv);
 }
 

+ 2 - 1
atom/browser/browser.h

@@ -55,7 +55,8 @@ class Browser : public WindowListObserver {
   void Shutdown();
 
   // Restart the app.
-  bool Relaunch(const base::FilePath& app,
+  bool Relaunch(bool override_argv,
+                const base::FilePath& app,
                 const relauncher::StringVector& args);
 
   // Focus the application.

+ 1 - 1
atom/browser/relauncher_win.cc

@@ -31,7 +31,7 @@ HANDLE GetParentProcessHandle(base::ProcessHandle handle) {
   }
 
   PROCESS_BASIC_INFORMATION pbi;
-	LONG status = NtQueryInformationProcess(
+  LONG status = NtQueryInformationProcess(
       handle, ProcessBasicInformation,
       &pbi, sizeof(PROCESS_BASIC_INFORMATION), NULL);
   if (!NT_SUCCESS(status)) {