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