11diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
2- index 681fd3282078c..df6e7d2cbb9e4 100644
2+ index 681fd3282078c..58cb7f8be17df 100644
33--- a/chrome/browser/chrome_browser_main.cc
44+++ b/chrome/browser/chrome_browser_main.cc
55@@ -10 ,6 +10 ,7 @@
@@ -19,7 +19,51 @@ index 681fd3282078c..df6e7d2cbb9e4 100644
1919 browser_creator_->AddFirstRunTabs (master_prefs_->new_tabs );
2020 }
2121
22- @@ -1399 ,6 +1402 ,10 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl () {
22+ @@ -1034 ,6 +1037 ,43 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl () {
23+ }
24+ #endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS)
25+
26+ +#if BUILDFLAG (IS_MAC)
27+ + // Install iCloud Passwords native messaging host manifest.
28+ + //
29+ + // Why this runs on every startup (not just first run):
30+ + // - First-run only would miss existing users upgrading to this version
31+ + // - The "First Run" sentinel already exists for them, so IsChromeFirstRun()
32+ + // returns false and first-run code is skipped entirely
33+ + // - Running every startup also self-heals if the manifest is deleted
34+ + // - The PathExists check makes this cheap (~0.1ms) when file already exists
35+ + {
36+ + base::FilePath native_messaging_dir;
37+ + if (base::PathService::Get (chrome::DIR_USER_NATIVE_MESSAGING,
38+ + &native_messaging_dir)) {
39+ + // Ensure directory exists for users who installed before first-run
40+ + // directory creation was added.
41+ + if (!base::PathExists (native_messaging_dir))
42+ + base::CreateDirectory (native_messaging_dir);
43+ +
44+ + const base::FilePath manifest_path =
45+ + native_messaging_dir.Append (" com.apple.passwordmanager.json" );
46+ + if (!base::PathExists (manifest_path)) {
47+ + constexpr std::string_view kICloudPasswordsManifest = R"( {
48+ + "name": "com.apple.passwordmanager",
49+ + "description": "PasswordManagerBrowserExtensionHelper",
50+ + "path": "/System/Cryptexes/App/System/Library/CoreServices/PasswordManagerBrowserExtensionHelper.app/Contents/MacOS/PasswordManagerBrowserExtensionHelper",
51+ + "type": "stdio",
52+ + "allowed_origins": [
53+ + "chrome-extension://pejdijmoenmkgeppbflobdenhhabjlaj/",
54+ + "chrome-extension://mfbcdcnpokpoajjciilocoachedjkima/"
55+ + ]
56+ +})" ;
57+ + base::WriteFile (manifest_path, kICloudPasswordsManifest );
58+ + }
59+ + }
60+ + }
61+ +#endif // BUILDFLAG(IS_MAC)
62+ +
63+ #if BUILDFLAG(IS_MAC)
64+ #if defined(ARCH_CPU_X86_64)
65+ // The use of Rosetta to run the x64 version of Chromium on Arm is neither
66+ @@ -1399 ,6 +1439 ,10 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl () {
2367 // running.
2468 browser_process_->PreMainMessageLoopRun ();
2569
@@ -30,7 +74,7 @@ index 681fd3282078c..df6e7d2cbb9e4 100644
3074 #if BUILDFLAG(IS_WIN)
3175 // If the command line specifies 'uninstall' then we need to work here
3276 // unless we detect another chrome browser running.
33- @@ -1835 ,6 +1842 ,11 @@ void ChromeBrowserMainParts::PostMainMessageLoopRun () {
77+ @@ -1835 ,6 +1879 ,11 @@ void ChromeBrowserMainParts::PostMainMessageLoopRun () {
3478 for (auto & chrome_extra_part : chrome_extra_parts_)
3579 chrome_extra_part->PostMainMessageLoopRun ();
3680
0 commit comments