OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // On Mac, one can't make shortcuts with command-line arguments. Instead, we | 5 // On Mac, one can't make shortcuts with command-line arguments. Instead, we |
6 // produce small app bundles which locate the Chromium framework and load it, | 6 // produce small app bundles which locate the Chromium framework and load it, |
7 // passing the appropriate data. This is the entry point into the framework for | 7 // passing the appropriate data. This is the entry point into the framework for |
8 // those app bundles. | 8 // those app bundles. |
9 | 9 |
10 #import <Cocoa/Cocoa.h> | 10 #import <Cocoa/Cocoa.h> |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 runningApplicationsWithBundleIdentifier:chrome_bundle_id]; | 614 runningApplicationsWithBundleIdentifier:chrome_bundle_id]; |
615 if ([existing_chrome count] > 0) | 615 if ([existing_chrome count] > 0) |
616 pid = [[existing_chrome objectAtIndex:0] processIdentifier]; | 616 pid = [[existing_chrome objectAtIndex:0] processIdentifier]; |
617 } | 617 } |
618 | 618 |
619 AppShimController controller; | 619 AppShimController controller; |
620 base::MessageLoopForUI main_message_loop; | 620 base::MessageLoopForUI main_message_loop; |
621 main_message_loop.set_thread_name("MainThread"); | 621 main_message_loop.set_thread_name("MainThread"); |
622 base::PlatformThread::SetName("CrAppShimMain"); | 622 base::PlatformThread::SetName("CrAppShimMain"); |
623 | 623 |
624 if (pid == -1) { | 624 // In tests, launching Chrome does nothing, and we won't get a ping response, |
| 625 // so just assume the socket exists. |
| 626 if (pid == -1 && |
| 627 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 628 app_mode::kLaunchedForTest)) { |
625 // Launch Chrome if it isn't already running. | 629 // Launch Chrome if it isn't already running. |
626 ProcessSerialNumber psn; | 630 ProcessSerialNumber psn; |
627 CommandLine command_line(CommandLine::NO_PROGRAM); | 631 CommandLine command_line(CommandLine::NO_PROGRAM); |
628 command_line.AppendSwitch(switches::kSilentLaunch); | 632 command_line.AppendSwitch(switches::kSilentLaunch); |
629 | 633 |
630 // If the shim is the app launcher, pass --show-app-list when starting a new | 634 // If the shim is the app launcher, pass --show-app-list when starting a new |
631 // Chrome process to inform startup codepaths and load the correct profile. | 635 // Chrome process to inform startup codepaths and load the correct profile. |
632 if (info->app_mode_id == app_mode::kAppListModeId) { | 636 if (info->app_mode_id == app_mode::kAppListModeId) { |
633 command_line.AppendSwitch(switches::kShowAppList); | 637 command_line.AppendSwitch(switches::kShowAppList); |
634 } else { | 638 } else { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 // minute. | 670 // minute. |
667 main_message_loop.PostTask( | 671 main_message_loop.PostTask( |
668 FROM_HERE, | 672 FROM_HERE, |
669 base::Bind(&AppShimController::Init, | 673 base::Bind(&AppShimController::Init, |
670 base::Unretained(&controller))); | 674 base::Unretained(&controller))); |
671 } | 675 } |
672 | 676 |
673 main_message_loop.Run(); | 677 main_message_loop.Run(); |
674 return 0; | 678 return 0; |
675 } | 679 } |
OLD | NEW |