2023-11-29 02:33:44 +01:00
|
|
|
diff --git chrome/browser/ui/startup/startup_browser_creator.cc chrome/browser/ui/startup/startup_browser_creator.cc
|
2024-09-27 16:15:44 +02:00
|
|
|
index c484e98959a22..db58381c66dc0 100644
|
2023-11-29 02:33:44 +01:00
|
|
|
--- chrome/browser/ui/startup/startup_browser_creator.cc
|
|
|
|
+++ chrome/browser/ui/startup/startup_browser_creator.cc
|
2024-09-27 16:15:44 +02:00
|
|
|
@@ -604,6 +604,13 @@ std::optional<ash::KioskAppId> GetAppId(const base::CommandLine& command_line,
|
2023-11-29 02:33:44 +01:00
|
|
|
}
|
2024-03-19 22:11:42 +01:00
|
|
|
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
|
|
|
|
2023-11-29 02:33:44 +01:00
|
|
|
+StartupBrowserCreator::ProcessCommandLineCallback*
|
|
|
|
+GetProcessCommandLineCallback() {
|
|
|
|
+ static base::NoDestructor<StartupBrowserCreator::ProcessCommandLineCallback>
|
|
|
|
+ callback;
|
|
|
|
+ return callback.get();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
StartupProfileMode StartupProfileModeFromReason(
|
2024-09-27 16:15:44 +02:00
|
|
|
@@ -1492,6 +1499,12 @@ void StartupBrowserCreator::ProcessCommandLineWithProfile(
|
2023-11-29 02:33:44 +01:00
|
|
|
{profile, mode}, last_opened_profiles);
|
|
|
|
}
|
|
|
|
|
|
|
|
+// static
|
|
|
|
+void StartupBrowserCreator::RegisterProcessCommandLineCallback(
|
|
|
|
+ ProcessCommandLineCallback cb) {
|
|
|
|
+ *GetProcessCommandLineCallback() = cb;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
// static
|
|
|
|
void StartupBrowserCreator::ProcessCommandLineAlreadyRunning(
|
|
|
|
const base::CommandLine& command_line,
|
2024-09-27 16:15:44 +02:00
|
|
|
@@ -1501,6 +1514,11 @@ void StartupBrowserCreator::ProcessCommandLineAlreadyRunning(
|
2023-11-29 02:33:44 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ auto* cb = GetProcessCommandLineCallback();
|
|
|
|
+ if (!cb->is_null() && cb->Run(command_line, cur_dir)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
Profile* profile = nullptr;
|
|
|
|
StartupProfileMode mode =
|
|
|
|
StartupProfileModeFromReason(profile_path_info.reason);
|
|
|
|
diff --git chrome/browser/ui/startup/startup_browser_creator.h chrome/browser/ui/startup/startup_browser_creator.h
|
2024-09-27 16:15:44 +02:00
|
|
|
index 919bae5ccfeae..5c2dfbf955723 100644
|
2023-11-29 02:33:44 +01:00
|
|
|
--- chrome/browser/ui/startup/startup_browser_creator.h
|
|
|
|
+++ chrome/browser/ui/startup/startup_browser_creator.h
|
|
|
|
@@ -9,6 +9,7 @@
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "base/files/file_path.h"
|
|
|
|
+#include "base/functional/callback.h"
|
|
|
|
#include "base/gtest_prod_util.h"
|
|
|
|
#include "base/memory/raw_ptr.h"
|
|
|
|
#include "build/build_config.h"
|
2024-09-27 16:15:44 +02:00
|
|
|
@@ -135,6 +136,13 @@ class StartupBrowserCreator {
|
2023-11-29 02:33:44 +01:00
|
|
|
StartupProfileInfo profile_info,
|
|
|
|
const Profiles& last_opened_profiles);
|
|
|
|
|
|
|
|
+ // Registers a callback that will be executed each time
|
|
|
|
+ // ProcessCommandLineAlreadyRunning is called.
|
|
|
|
+ using ProcessCommandLineCallback = base::RepeatingCallback<bool(
|
|
|
|
+ const base::CommandLine& command_line,
|
|
|
|
+ const base::FilePath& cur_dir)>;
|
|
|
|
+ static void RegisterProcessCommandLineCallback(ProcessCommandLineCallback cb);
|
|
|
|
+
|
|
|
|
// This function performs command-line handling and is invoked only after
|
|
|
|
// start up (for example when we get a start request for another process).
|
|
|
|
// |command_line| holds the command line we need to process.
|