mac: Always use "Atom" as name when find helper process. Fixes #89.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 12 Sep 2013 07:42:36 +0000 (15:42 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 12 Sep 2013 07:42:36 +0000 (15:42 +0800)
app/atom_main_delegate.cc

index 9eb81ba..f868e27 100644 (file)
 #include "content/public/common/content_switches.h"
 #include "renderer/atom_renderer_client.h"
 
+#if defined(OS_MACOSX)
+
+#include "base/mac/bundle_locations.h"
+#include "base/path_service.h"
+#include "content/public/common/content_paths.h"
+
+namespace brightray {
+base::FilePath MainApplicationBundlePath();
+}
+
+namespace {
+
+base::FilePath GetFrameworksPath() {
+  return brightray::MainApplicationBundlePath().Append("Contents")
+                                               .Append("Frameworks");
+}
+
+}  // namespace
+
+#endif  // defined(OS_MACOSX)
+
 namespace atom {
 
 AtomMainDelegate::AtomMainDelegate() {
@@ -40,6 +61,16 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
 void AtomMainDelegate::PreSandboxStartup() {
   brightray::MainDelegate::PreSandboxStartup();
 
+#if defined(OS_MACOSX)
+  // Override the path to helper process, since third party users may want to
+  // change the application name.
+  base::FilePath helper_path = GetFrameworksPath().Append("Atom Helper.app")
+                                                  .Append("Contents")
+                                                  .Append("MacOS")
+                                                  .Append("Atom Helper");
+  PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
+#endif  // defined(OS_MACOSX)
+
   // Disable renderer sandbox for most of node's functions.
   CommandLine* command_line = CommandLine::ForCurrentProcess();
   command_line->AppendSwitch(switches::kNoSandbox);