From 28384a325c1646d45ef7c367e61871b20c6a4d0c Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Wed, 16 Jun 2010 03:16:23 +0000 Subject: Don't spontaneously open new windows. When users downgrade, they may get a chrome binary that doesn't respect --product-version; don't allow chrome binaries launched with this flag to open new windows in existing chrome processes. BUG=46547 TEST=manual Review URL: http://codereview.chromium.org/2814007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49894 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/process_singleton_linux.cc | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'chrome/browser/process_singleton_linux.cc') diff --git a/chrome/browser/process_singleton_linux.cc b/chrome/browser/process_singleton_linux.cc index 2a1a01c..bfd6539 100644 --- a/chrome/browser/process_singleton_linux.cc +++ b/chrome/browser/process_singleton_linux.cc @@ -325,7 +325,8 @@ bool KillProcessByLockPath(const std::string& path) { int rv = kill(static_cast(pid), SIGKILL); // ESRCH = No Such Process (can happen if the other process is already in // progress of shutting down and finishes before we try to kill it). - DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " << safe_strerror(errno); + DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " + << safe_strerror(errno); return true; } @@ -533,12 +534,22 @@ void ProcessSingleton::LinuxWatcher::HandleMessage( return; } - // Run the browser startup sequence again, with the command line of the - // signalling process. - FilePath current_dir_file_path(current_dir); - BrowserInit::ProcessCommandLine(parsed_command_line, - current_dir_file_path.ToWStringHack(), - false, profile, NULL); + // Ignore the request if the process was passed the --product-version flag. + // Normally we wouldn't get here if that flag had been passed, but it can + // happen if it is passed to an older version of chrome. Since newer versions + // of chrome do this in the background, we want to avoid spawning extra + // windows. + if (parsed_command_line.HasSwitch(switches::kProductVersion)) { + DLOG(WARNING) << "Remote process was passed product version flag, " + << "but ignored it. Doing nothing."; + } else { + // Run the browser startup sequence again, with the command line of the + // signalling process. + FilePath current_dir_file_path(current_dir); + BrowserInit::ProcessCommandLine(parsed_command_line, + current_dir_file_path.ToWStringHack(), + false, profile, NULL); + } // Send back "ACK" message to prevent the client process from starting up. reader->FinishWithACK(kACKToken, arraysize(kACKToken) - 1); -- cgit v1.1