Chromium Code Reviews| Index: apps/app_shim/chrome_main_app_mode_mac.mm |
| diff --git a/apps/app_shim/chrome_main_app_mode_mac.mm b/apps/app_shim/chrome_main_app_mode_mac.mm |
| index ddad52a14822ac15e92c6c9d9c53d1c9b0d91bc0..73a92a36c95a03cd601a1032a2756fe1ec5acc20 100644 |
| --- a/apps/app_shim/chrome_main_app_mode_mac.mm |
| +++ b/apps/app_shim/chrome_main_app_mode_mac.mm |
| @@ -21,6 +21,7 @@ |
| #include "base/mac/scoped_nsobject.h" |
| #include "base/message_loop/message_loop.h" |
| #include "base/path_service.h" |
| +#include "base/strings/string_number_conversions.h" |
| #include "base/strings/sys_string_conversions.h" |
| #include "base/threading/thread.h" |
| #include "chrome/common/chrome_constants.h" |
| @@ -432,15 +433,24 @@ int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info) { |
| g_io_thread = io_thread; |
| // Find already running instances of Chrome. |
| - NSString* chrome_bundle_id = [base::mac::OuterBundle() bundleIdentifier]; |
| - NSArray* existing_chrome = [NSRunningApplication |
| - runningApplicationsWithBundleIdentifier:chrome_bundle_id]; |
| + pid_t pid = -1; |
| + std::string chrome_process_id = CommandLine::ForCurrentProcess()-> |
| + GetSwitchValueASCII(app_mode::kChromeProcessId); |
| + if (!chrome_process_id.empty()) { |
| + if (!base::StringToInt(chrome_process_id, &pid)) |
| + pid = -1; |
|
tapted
2013/08/22 06:17:12
This implies it will try to start a new Chrome.. M
jackhou1
2013/08/22 06:52:53
Done.
|
| + } else { |
| + NSString* chrome_bundle_id = [base::mac::OuterBundle() bundleIdentifier]; |
| + NSArray* existing_chrome = [NSRunningApplication |
| + runningApplicationsWithBundleIdentifier:chrome_bundle_id]; |
| + if ([existing_chrome count] > 0) |
| + pid = [[existing_chrome objectAtIndex:0] processIdentifier]; |
| + } |
| // Launch Chrome if it isn't already running. |
| ProcessSerialNumber psn; |
| - if ([existing_chrome count] > 0) { |
| - OSStatus status = GetProcessForPID( |
| - [[existing_chrome objectAtIndex:0] processIdentifier], &psn); |
| + if (pid > -1) { |
| + OSStatus status = GetProcessForPID(pid, &psn); |
| if (status) |
| return 1; |