Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: chrome/app_shim/chrome_main_app_mode_mac.mm

Issue 819133004: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/app_shim/app_mode_loader_mac.mm ('k') | chrome/app_shim/win/app_shim_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 205 }
206 206
207 void AppShimController::CreateChannelAndSendLaunchApp( 207 void AppShimController::CreateChannelAndSendLaunchApp(
208 const base::FilePath& socket_path) { 208 const base::FilePath& socket_path) {
209 IPC::ChannelHandle handle(socket_path.value()); 209 IPC::ChannelHandle handle(socket_path.value());
210 channel_ = IPC::ChannelProxy::Create(handle, 210 channel_ = IPC::ChannelProxy::Create(handle,
211 IPC::Channel::MODE_NAMED_CLIENT, 211 IPC::Channel::MODE_NAMED_CLIENT,
212 this, 212 this,
213 g_io_thread->message_loop_proxy().get()); 213 g_io_thread->message_loop_proxy().get());
214 214
215 bool launched_by_chrome = 215 bool launched_by_chrome = base::CommandLine::ForCurrentProcess()->HasSwitch(
216 CommandLine::ForCurrentProcess()->HasSwitch( 216 app_mode::kLaunchedByChromeProcessId);
217 app_mode::kLaunchedByChromeProcessId);
218 apps::AppShimLaunchType launch_type = launched_by_chrome ? 217 apps::AppShimLaunchType launch_type = launched_by_chrome ?
219 apps::APP_SHIM_LAUNCH_REGISTER_ONLY : apps::APP_SHIM_LAUNCH_NORMAL; 218 apps::APP_SHIM_LAUNCH_REGISTER_ONLY : apps::APP_SHIM_LAUNCH_NORMAL;
220 219
221 [delegate_ setController:this]; 220 [delegate_ setController:this];
222 221
223 std::vector<base::FilePath> files; 222 std::vector<base::FilePath> files;
224 [delegate_ getFilesToOpenAtStartup:&files]; 223 [delegate_ getFilesToOpenAtStartup:&files];
225 224
226 channel_->Send(new AppShimHostMsg_LaunchApp( 225 channel_->Send(new AppShimHostMsg_LaunchApp(
227 g_info->profile_dir, g_info->app_mode_id, launch_type, files)); 226 g_info->profile_dir, g_info->app_mode_id, launch_type, files));
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 extern "C" { 555 extern "C" {
557 556
558 // |ChromeAppModeStart()| is the point of entry into the framework from the app 557 // |ChromeAppModeStart()| is the point of entry into the framework from the app
559 // mode loader. 558 // mode loader.
560 __attribute__((visibility("default"))) 559 __attribute__((visibility("default")))
561 int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info); 560 int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info);
562 561
563 } // extern "C" 562 } // extern "C"
564 563
565 int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info) { 564 int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info) {
566 CommandLine::Init(info->argc, info->argv); 565 base::CommandLine::Init(info->argc, info->argv);
567 566
568 base::mac::ScopedNSAutoreleasePool scoped_pool; 567 base::mac::ScopedNSAutoreleasePool scoped_pool;
569 base::AtExitManager exit_manager; 568 base::AtExitManager exit_manager;
570 chrome::RegisterPathProvider(); 569 chrome::RegisterPathProvider();
571 570
572 if (info->major_version < app_mode::kCurrentChromeAppModeInfoMajorVersion) { 571 if (info->major_version < app_mode::kCurrentChromeAppModeInfoMajorVersion) {
573 RAW_LOG(ERROR, "App Mode Loader too old."); 572 RAW_LOG(ERROR, "App Mode Loader too old.");
574 return 1; 573 return 1;
575 } 574 }
576 if (info->major_version > app_mode::kCurrentChromeAppModeInfoMajorVersion) { 575 if (info->major_version > app_mode::kCurrentChromeAppModeInfoMajorVersion) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 608
610 // Launch the IO thread. 609 // Launch the IO thread.
611 base::Thread::Options io_thread_options; 610 base::Thread::Options io_thread_options;
612 io_thread_options.message_loop_type = base::MessageLoop::TYPE_IO; 611 io_thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
613 base::Thread *io_thread = new base::Thread("CrAppShimIO"); 612 base::Thread *io_thread = new base::Thread("CrAppShimIO");
614 io_thread->StartWithOptions(io_thread_options); 613 io_thread->StartWithOptions(io_thread_options);
615 g_io_thread = io_thread; 614 g_io_thread = io_thread;
616 615
617 // Find already running instances of Chrome. 616 // Find already running instances of Chrome.
618 pid_t pid = -1; 617 pid_t pid = -1;
619 std::string chrome_process_id = CommandLine::ForCurrentProcess()-> 618 std::string chrome_process_id =
620 GetSwitchValueASCII(app_mode::kLaunchedByChromeProcessId); 619 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
620 app_mode::kLaunchedByChromeProcessId);
621 if (!chrome_process_id.empty()) { 621 if (!chrome_process_id.empty()) {
622 if (!base::StringToInt(chrome_process_id, &pid)) 622 if (!base::StringToInt(chrome_process_id, &pid))
623 LOG(FATAL) << "Invalid PID: " << chrome_process_id; 623 LOG(FATAL) << "Invalid PID: " << chrome_process_id;
624 } else { 624 } else {
625 NSString* chrome_bundle_id = [base::mac::OuterBundle() bundleIdentifier]; 625 NSString* chrome_bundle_id = [base::mac::OuterBundle() bundleIdentifier];
626 NSArray* existing_chrome = [NSRunningApplication 626 NSArray* existing_chrome = [NSRunningApplication
627 runningApplicationsWithBundleIdentifier:chrome_bundle_id]; 627 runningApplicationsWithBundleIdentifier:chrome_bundle_id];
628 if ([existing_chrome count] > 0) 628 if ([existing_chrome count] > 0)
629 pid = [[existing_chrome objectAtIndex:0] processIdentifier]; 629 pid = [[existing_chrome objectAtIndex:0] processIdentifier];
630 } 630 }
631 631
632 AppShimController controller; 632 AppShimController controller;
633 base::MessageLoopForUI main_message_loop; 633 base::MessageLoopForUI main_message_loop;
634 main_message_loop.set_thread_name("MainThread"); 634 main_message_loop.set_thread_name("MainThread");
635 base::PlatformThread::SetName("CrAppShimMain"); 635 base::PlatformThread::SetName("CrAppShimMain");
636 636
637 // In tests, launching Chrome does nothing, and we won't get a ping response, 637 // In tests, launching Chrome does nothing, and we won't get a ping response,
638 // so just assume the socket exists. 638 // so just assume the socket exists.
639 if (pid == -1 && 639 if (pid == -1 &&
640 !CommandLine::ForCurrentProcess()->HasSwitch( 640 !base::CommandLine::ForCurrentProcess()->HasSwitch(
641 app_mode::kLaunchedForTest)) { 641 app_mode::kLaunchedForTest)) {
642 // Launch Chrome if it isn't already running. 642 // Launch Chrome if it isn't already running.
643 ProcessSerialNumber psn; 643 ProcessSerialNumber psn;
644 CommandLine command_line(CommandLine::NO_PROGRAM); 644 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
645 command_line.AppendSwitch(switches::kSilentLaunch); 645 command_line.AppendSwitch(switches::kSilentLaunch);
646 646
647 // If the shim is the app launcher, pass --show-app-list when starting a new 647 // If the shim is the app launcher, pass --show-app-list when starting a new
648 // Chrome process to inform startup codepaths and load the correct profile. 648 // Chrome process to inform startup codepaths and load the correct profile.
649 if (info->app_mode_id == app_mode::kAppListModeId) { 649 if (info->app_mode_id == app_mode::kAppListModeId) {
650 command_line.AppendSwitch(switches::kShowAppList); 650 command_line.AppendSwitch(switches::kShowAppList);
651 } else { 651 } else {
652 command_line.AppendSwitchPath(switches::kProfileDirectory, 652 command_line.AppendSwitchPath(switches::kProfileDirectory,
653 info->profile_dir); 653 info->profile_dir);
654 } 654 }
(...skipping 28 matching lines...) Expand all
683 // minute. 683 // minute.
684 main_message_loop.PostTask( 684 main_message_loop.PostTask(
685 FROM_HERE, 685 FROM_HERE,
686 base::Bind(&AppShimController::Init, 686 base::Bind(&AppShimController::Init,
687 base::Unretained(&controller))); 687 base::Unretained(&controller)));
688 } 688 }
689 689
690 main_message_loop.Run(); 690 main_message_loop.Run();
691 return 0; 691 return 0;
692 } 692 }
OLDNEW
« no previous file with comments | « chrome/app_shim/app_mode_loader_mac.mm ('k') | chrome/app_shim/win/app_shim_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698