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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 runningApplicationsWithBundleIdentifier:chrome_bundle_id]; | 604 runningApplicationsWithBundleIdentifier:chrome_bundle_id]; |
605 if ([existing_chrome count] > 0) | 605 if ([existing_chrome count] > 0) |
606 pid = [[existing_chrome objectAtIndex:0] processIdentifier]; | 606 pid = [[existing_chrome objectAtIndex:0] processIdentifier]; |
607 } | 607 } |
608 | 608 |
609 AppShimController controller; | 609 AppShimController controller; |
610 base::MessageLoopForUI main_message_loop; | 610 base::MessageLoopForUI main_message_loop; |
611 main_message_loop.set_thread_name("MainThread"); | 611 main_message_loop.set_thread_name("MainThread"); |
612 base::PlatformThread::SetName("CrAppShimMain"); | 612 base::PlatformThread::SetName("CrAppShimMain"); |
613 | 613 |
614 if (pid == -1) { | 614 // In tests, launching Chrome does nothing, and we won't get a ping response, |
| 615 // so just assume the socket exists. |
| 616 if (pid == -1 && |
| 617 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 618 app_mode::kLaunchedForTest)) { |
615 // Launch Chrome if it isn't already running. | 619 // Launch Chrome if it isn't already running. |
616 ProcessSerialNumber psn; | 620 ProcessSerialNumber psn; |
617 CommandLine command_line(CommandLine::NO_PROGRAM); | 621 CommandLine command_line(CommandLine::NO_PROGRAM); |
618 command_line.AppendSwitch(switches::kSilentLaunch); | 622 command_line.AppendSwitch(switches::kSilentLaunch); |
619 | 623 |
620 // If the shim is the app launcher, pass --show-app-list when starting a new | 624 // If the shim is the app launcher, pass --show-app-list when starting a new |
621 // Chrome process to inform startup codepaths and load the correct profile. | 625 // Chrome process to inform startup codepaths and load the correct profile. |
622 if (info->app_mode_id == app_mode::kAppListModeId) { | 626 if (info->app_mode_id == app_mode::kAppListModeId) { |
623 command_line.AppendSwitch(switches::kShowAppList); | 627 command_line.AppendSwitch(switches::kShowAppList); |
624 } else { | 628 } else { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 // minute. | 660 // minute. |
657 main_message_loop.PostTask( | 661 main_message_loop.PostTask( |
658 FROM_HERE, | 662 FROM_HERE, |
659 base::Bind(&AppShimController::Init, | 663 base::Bind(&AppShimController::Init, |
660 base::Unretained(&controller))); | 664 base::Unretained(&controller))); |
661 } | 665 } |
662 | 666 |
663 main_message_loop.Run(); | 667 main_message_loop.Run(); |
664 return 0; | 668 return 0; |
665 } | 669 } |
OLD | NEW |