]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Allow modifying helper app's name
authorCheng Zhao <zcbenz@gmail.com>
Tue, 14 Apr 2015 05:51:08 +0000 (13:51 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 14 Apr 2015 05:51:08 +0000 (13:51 +0800)
atom/app/atom_main_delegate_mac.mm

index 7232817c94ffff03921da008ec0b8afe3562b837..c158a117164cda1f1ff5bfd5f5b6260368cb7f2f 100644 (file)
@@ -6,7 +6,9 @@
 
 #include "base/mac/bundle_locations.h"
 #include "base/files/file_path.h"
+#include "base/files/file_util.h"
 #include "base/path_service.h"
+#include "brightray/common/application_info.h"
 #include "brightray/common/mac/main_application_bundle.h"
 #include "content/public/common/content_paths.h"
 
@@ -19,6 +21,14 @@ base::FilePath GetFrameworksPath() {
                                                .Append("Frameworks");
 }
 
+base::FilePath GetHeleprAppPath(const base::FilePath& frameworks_path,
+                                const std::string& name) {
+  return frameworks_path.Append(name + " Helper.app")
+                        .Append("Contents")
+                        .Append("MacOS")
+                        .Append(name + " Helper");
+}
+
 }  // namespace
 
 void AtomMainDelegate::OverrideFrameworkBundlePath() {
@@ -27,11 +37,13 @@ void AtomMainDelegate::OverrideFrameworkBundlePath() {
 }
 
 void AtomMainDelegate::OverrideChildProcessPath() {
-  base::FilePath helper_path =
-      GetFrameworksPath().Append(PRODUCT_NAME " Helper.app")
-                         .Append("Contents")
-                         .Append("MacOS")
-                         .Append(PRODUCT_NAME " Helper");
+  base::FilePath frameworks_path = GetFrameworksPath();
+  base::FilePath helper_path = GetHeleprAppPath(frameworks_path, PRODUCT_NAME);
+  if (!base::PathExists(helper_path))
+    helper_path = GetHeleprAppPath(frameworks_path,
+                                   brightray::GetApplicationName());
+  if (!base::PathExists(helper_path))
+    LOG(FATAL) << "Unable to find helper app";
   PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
 }