OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 Linux, when the user tries to launch a second copy of chrome, we check | 5 // On Linux, when the user tries to launch a second copy of chrome, we check |
6 // for a socket in the user's profile directory. If the socket file is open we | 6 // for a socket in the user's profile directory. If the socket file is open we |
7 // send a message to the first chrome browser process with the current | 7 // send a message to the first chrome browser process with the current |
8 // directory and second process command line flags. The second process then | 8 // directory and second process command line flags. The second process then |
9 // exits. | 9 // exits. |
10 // | 10 // |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 // Send back "SHUTDOWN" message, so that the client process can start up | 634 // Send back "SHUTDOWN" message, so that the client process can start up |
635 // without killing this process. | 635 // without killing this process. |
636 reader->FinishWithACK(kShutdownToken, arraysize(kShutdownToken) - 1); | 636 reader->FinishWithACK(kShutdownToken, arraysize(kShutdownToken) - 1); |
637 return; | 637 return; |
638 } | 638 } |
639 | 639 |
640 CommandLine parsed_command_line(argv); | 640 CommandLine parsed_command_line(argv); |
641 PrefService* prefs = g_browser_process->local_state(); | 641 PrefService* prefs = g_browser_process->local_state(); |
642 DCHECK(prefs); | 642 DCHECK(prefs); |
643 | 643 |
644 Profile* profile = ProfileManager::GetLastUsedProfile(); | |
645 | |
646 if (!profile) { | |
647 // We should only be able to get here if the profile already exists and | |
648 // has been created. | |
649 NOTREACHED(); | |
650 return; | |
651 } | |
652 | |
653 // Ignore the request if the process was passed the --product-version flag. | 644 // Ignore the request if the process was passed the --product-version flag. |
654 // Normally we wouldn't get here if that flag had been passed, but it can | 645 // Normally we wouldn't get here if that flag had been passed, but it can |
655 // happen if it is passed to an older version of chrome. Since newer versions | 646 // happen if it is passed to an older version of chrome. Since newer versions |
656 // of chrome do this in the background, we want to avoid spawning extra | 647 // of chrome do this in the background, we want to avoid spawning extra |
657 // windows. | 648 // windows. |
658 if (parsed_command_line.HasSwitch(switches::kProductVersion)) { | 649 if (parsed_command_line.HasSwitch(switches::kProductVersion)) { |
659 DLOG(WARNING) << "Remote process was passed product version flag, " | 650 DLOG(WARNING) << "Remote process was passed product version flag, " |
660 << "but ignored it. Doing nothing."; | 651 << "but ignored it. Doing nothing."; |
661 } else { | 652 } else { |
662 // Run the browser startup sequence again, with the command line of the | 653 // Run the browser startup sequence again, with the command line of the |
663 // signalling process. | 654 // signalling process. |
664 FilePath current_dir_file_path(current_dir); | 655 BrowserInit::ProcessCommandLineAlreadyRunning( |
665 BrowserInit::ProcessCommandLine(parsed_command_line, current_dir_file_path, | 656 parsed_command_line, FilePath(current_dir)); |
666 false /* not process startup */, profile, | |
667 NULL); | |
668 } | 657 } |
669 | 658 |
670 // Send back "ACK" message to prevent the client process from starting up. | 659 // Send back "ACK" message to prevent the client process from starting up. |
671 reader->FinishWithACK(kACKToken, arraysize(kACKToken) - 1); | 660 reader->FinishWithACK(kACKToken, arraysize(kACKToken) - 1); |
672 } | 661 } |
673 | 662 |
674 void ProcessSingleton::LinuxWatcher::RemoveSocketReader(SocketReader* reader) { | 663 void ProcessSingleton::LinuxWatcher::RemoveSocketReader(SocketReader* reader) { |
675 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 664 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
676 DCHECK(reader); | 665 DCHECK(reader); |
677 readers_.erase(reader); | 666 readers_.erase(reader); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 sock)); | 993 sock)); |
1005 | 994 |
1006 return true; | 995 return true; |
1007 } | 996 } |
1008 | 997 |
1009 void ProcessSingleton::Cleanup() { | 998 void ProcessSingleton::Cleanup() { |
1010 UnlinkPath(socket_path_); | 999 UnlinkPath(socket_path_); |
1011 UnlinkPath(cookie_path_); | 1000 UnlinkPath(cookie_path_); |
1012 UnlinkPath(lock_path_); | 1001 UnlinkPath(lock_path_); |
1013 } | 1002 } |
OLD | NEW |