[headless] Prevent page handoff to an existing process.
Handing off pages to an existing Chrome process using the same profile
is the expected behavior for the Headfull Chrome, however, it is
unexpected and undesirable for the Headless Chrome.
This change modifies Native Headless Chrome behavior so that if there is
an existing Chrome process using a profile and a new Native Headless
Chrome process is started using the same profile, the new process is
terminated with the Chrome result chrome::RESULT_CODE_PROFILE_IN_USE
and no page hand off.
Bug: 1278077
Change-Id: Id0e0278203f561d35bc4b8e36a5e381ef7686d91
Cq-Include-Trybots: luci.chromium.try:linux-headless-shell-rel
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3324603
Reviewed-by: Andrey Kosyakov <[email protected]>
Reviewed-by: Lei Zhang <[email protected]>
Commit-Queue: Peter Kvitek <[email protected]>
Cr-Commit-Position: refs/heads/main@{#950351}
diff --git a/chrome/browser/chrome_process_singleton.h b/chrome/browser/chrome_process_singleton.h
index 3a2e52c1..7f33028 100644
--- a/chrome/browser/chrome_process_singleton.h
+++ b/chrome/browser/chrome_process_singleton.h
@@ -39,6 +39,9 @@
// instance. Callers are guaranteed to either have notified an existing
// process or have grabbed the singleton (unless the profile is locked by an
// unreachable process).
+ // The guarantee is a bit different if we're running in Native Headless mode,
+ // in which case an existing process is not notified and this method returns
+ // PROFILE_IN_USE if it happens to use the same profile directory.
ProcessSingleton::NotifyResult NotifyOtherProcessOrCreate();
// Clear any lock state during shutdown.