diff --git a/chromium_src/chrome/install_static/brave_user_data_dir_win_unittest.cc b/chromium_src/chrome/install_static/brave_user_data_dir_win_unittest.cc index 310d1b34ee5..e4538c1722d 100644 --- a/chromium_src/chrome/install_static/brave_user_data_dir_win_unittest.cc +++ b/chromium_src/chrome/install_static/brave_user_data_dir_win_unittest.cc @@ -20,14 +20,12 @@ inline bool EndsWith(const std::wstring& value, const std::wstring& ending) { return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); } -#if defined(OFFICIAL_BUILD) const wchar_t kPolicyRegistryKey[] = - L"SOFTWARE\\Policies\\BraveSoftware\\Brave-Browser"; + L"SOFTWARE\\Policies\\BraveSoftware\\Brave"; +#if defined(OFFICIAL_BUILD) const wchar_t kUserDataDirNameSuffix[] = L"\\BraveSoftware\\Brave-Browser\\User Data"; #else -const wchar_t kPolicyRegistryKey[] = - L"SOFTWARE\\Policies\\BraveSoftware\\Brave-Browser-Development"; const wchar_t kUserDataDirNameSuffix[] = L"\\BraveSoftware\\Brave-Browser-Development\\User Data"; #endif diff --git a/chromium_src/chrome/install_static/user_data_dir.cc b/chromium_src/chrome/install_static/user_data_dir.cc new file mode 100644 index 00000000000..3400e1d9fa2 --- /dev/null +++ b/chromium_src/chrome/install_static/user_data_dir.cc @@ -0,0 +1,44 @@ +/* Copyright (c) 2025 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "chrome/install_static/user_data_dir.h" + +#include + +#include "chrome/install_static/install_util.h" + +namespace install_static { + +std::wstring& BraveAppendChromeInstallSubDirectory(const InstallConstants& mode, + bool include_suffix, + std::wstring* path); + +} // namespace install_static + +#define AppendChromeInstallSubDirectory BraveAppendChromeInstallSubDirectory + +#include + +#undef AppendChromeInstallSubDirectory + +namespace install_static { + +std::wstring& BraveAppendChromeInstallSubDirectory(const InstallConstants& mode, + bool include_suffix, + std::wstring* path) { + AppendChromeInstallSubDirectory(mode, include_suffix, path); + // Special case to handle the Policy version of the path for Brave. + // Brave uses `SOFTWARE\Policies\BraveSoftware\Brave` + // instead of `SOFTWARE\Policies\BraveSoftware\Brave-Browser` + if (!include_suffix && path->starts_with(L"SOFTWARE\\Policies\\") && + path->ends_with(kProductPathName)) { + *path = path->substr(0, (path->length() - kProductPathNameLength)); + path->append(L"Brave"); + } + + return *path; +} + +} // namespace install_static