mirror of
https://github.com/Alex313031/thorium.git
synced 2025-01-10 11:57:48 -03:00
Change win paths Chromium > Thorium
This commit is contained in:
parent
57df566991
commit
642a7dc18f
2 changed files with 239 additions and 0 deletions
73
chrome/install_static/chromium_install_modes.cc
Normal file
73
chrome/install_static/chromium_install_modes.cc
Normal file
|
@ -0,0 +1,73 @@
|
|||
// Copyright 2022 The Chromium Authors and Alex313031. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Brand-specific constants and install modes for Chromium.
|
||||
|
||||
#include "chrome/install_static/chromium_install_modes.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "chrome/app/chrome_dll_resource.h"
|
||||
#include "chrome/common/chrome_icon_resources_win.h"
|
||||
#include "chrome/install_static/install_modes.h"
|
||||
|
||||
namespace install_static {
|
||||
|
||||
const wchar_t kCompanyPathName[] = L"";
|
||||
|
||||
const wchar_t kProductPathName[] = L"Thorium";
|
||||
|
||||
const size_t kProductPathNameLength = _countof(kProductPathName) - 1;
|
||||
|
||||
const char kSafeBrowsingName[] = "thorium";
|
||||
|
||||
const char kDeviceManagementServerHostName[] = "";
|
||||
|
||||
const InstallConstants kInstallModes[] = {
|
||||
// The primary (and only) install mode for Chromium.
|
||||
{
|
||||
sizeof(kInstallModes[0]),
|
||||
CHROMIUM_INDEX, // The one and only mode for Chromium.
|
||||
"", // No install switch for the primary install mode.
|
||||
L"", // Empty install_suffix for the primary install mode.
|
||||
L"", // No logo suffix for the primary install mode.
|
||||
L"", // Empty app_guid since no integraion with Google Update.
|
||||
L"Thorium", // A distinct base_app_name.
|
||||
L"Thorium", // A distinct base_app_id.
|
||||
L"ThoriumHTM", // ProgID prefix.
|
||||
L"Thorium HTML Document", // ProgID description.
|
||||
L"{7D2B3E1D-D096-4594-9D8F-A6667F12E0AC}", // Active Setup GUID.
|
||||
L"{A2DF06F9-A21A-44A8-8A99-8B9C84F29160}", // CommandExecuteImpl CLSID.
|
||||
{0x635EFA6F,
|
||||
0x08D6,
|
||||
0x4EC9,
|
||||
{0xBD, 0x14, 0x8A, 0x0F, 0xDE, 0x97, 0x51,
|
||||
0x59}}, // Toast Activator CLSID.
|
||||
{0xD133B120,
|
||||
0x6DB4,
|
||||
0x4D6B,
|
||||
{0x8B, 0xFE, 0x83, 0xBF, 0x8C, 0xA1, 0xB1, 0xB0}}, // Elevator CLSID.
|
||||
|
||||
{0xb88c45b9,
|
||||
0x8825,
|
||||
0x4629,
|
||||
{0xb8, 0x3e, 0x77, 0xcc, 0x67, 0xd9, 0xce,
|
||||
0xed}}, // IElevator IID and TypeLib
|
||||
// {B88C45B9-8825-4629-B83E-77CC67D9CEED}.
|
||||
L"", // Empty default channel name since no update integration.
|
||||
ChannelStrategy::UNSUPPORTED,
|
||||
true, // Supports system-level installs.
|
||||
true, // Supports in-product set as default browser UX.
|
||||
false, // Does not support retention experiments.
|
||||
icon_resources::kApplicationIndex, // App icon resource index.
|
||||
IDR_MAINFRAME, // App icon resource id.
|
||||
L"S-1-15-2-3251537155-1984446955-2931258699-841473695-1938553385-"
|
||||
L"924012148-", // App container sid prefix for sandbox.
|
||||
},
|
||||
};
|
||||
|
||||
static_assert(_countof(kInstallModes) == NUM_INSTALL_MODES,
|
||||
"Imbalance between kInstallModes and InstallConstantIndex");
|
||||
|
||||
} // namespace install_static
|
166
chrome/install_static/user_data_dir_win_unittest.cc
Normal file
166
chrome/install_static/user_data_dir_win_unittest.cc
Normal file
|
@ -0,0 +1,166 @@
|
|||
// Copyright 2022 The Chromium Authors and Alex313031. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "base/test/test_reg_util_win.h"
|
||||
#include "build/branding_buildflags.h"
|
||||
#include "chrome/chrome_elf/nt_registry/nt_registry.h"
|
||||
#include "chrome/install_static/install_details.h"
|
||||
#include "chrome/install_static/user_data_dir.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace install_static {
|
||||
namespace {
|
||||
|
||||
inline bool EndsWith(const std::wstring& value, const std::wstring& ending) {
|
||||
if (ending.size() > value.size())
|
||||
return false;
|
||||
return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
|
||||
}
|
||||
|
||||
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
||||
const wchar_t kPolicyRegistryKey[] = L"SOFTWARE\\Policies\\Google\\Chrome";
|
||||
const wchar_t kUserDataDirNameSuffix[] = L"\\Google\\Chrome\\User Data";
|
||||
#else
|
||||
const wchar_t kPolicyRegistryKey[] = L"SOFTWARE\\Policies\\Chromium";
|
||||
const wchar_t kUserDataDirNameSuffix[] = L"\\Thorium\\User Data";
|
||||
#endif
|
||||
|
||||
const wchar_t kUserDataDirRegistryKey[] = L"UserDataDir";
|
||||
|
||||
const InstallConstants kFakeInstallConstants = {
|
||||
sizeof(InstallConstants), 0, "", L"", L"", L"", L""};
|
||||
|
||||
class ScopedNTRegistryTestingOverride {
|
||||
public:
|
||||
ScopedNTRegistryTestingOverride(nt::ROOT_KEY root, const std::wstring& path)
|
||||
: root_(root) {
|
||||
EXPECT_TRUE(nt::SetTestingOverride(root_, path));
|
||||
}
|
||||
~ScopedNTRegistryTestingOverride() {
|
||||
nt::SetTestingOverride(root_, std::wstring());
|
||||
}
|
||||
|
||||
private:
|
||||
nt::ROOT_KEY root_;
|
||||
};
|
||||
|
||||
TEST(UserDataDir, EmptyResultsInDefault) {
|
||||
std::wstring result, invalid;
|
||||
|
||||
install_static::GetUserDataDirectoryImpl(L"", kFakeInstallConstants, &result,
|
||||
&invalid);
|
||||
EXPECT_TRUE(EndsWith(result, kUserDataDirNameSuffix));
|
||||
EXPECT_EQ(std::wstring(), invalid);
|
||||
}
|
||||
|
||||
TEST(UserDataDir, InvalidResultsInDefault) {
|
||||
std::wstring result, invalid;
|
||||
|
||||
install_static::GetUserDataDirectoryImpl(L"<>|:", kFakeInstallConstants,
|
||||
&result, &invalid);
|
||||
EXPECT_TRUE(EndsWith(result, kUserDataDirNameSuffix));
|
||||
EXPECT_EQ(L"<>|:", invalid);
|
||||
}
|
||||
|
||||
TEST(UserDataDir, RegistrySettingsInHKLMOverrides) {
|
||||
std::wstring result, invalid;
|
||||
|
||||
// Override the registry to say one value in HKLM, and confirm it takes
|
||||
// precedence over the command line in both implementations.
|
||||
registry_util::RegistryOverrideManager override_manager;
|
||||
std::wstring temp;
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
override_manager.OverrideRegistry(HKEY_LOCAL_MACHINE, &temp));
|
||||
ScopedNTRegistryTestingOverride nt_override(nt::HKLM, temp);
|
||||
|
||||
base::win::RegKey key(HKEY_LOCAL_MACHINE, kPolicyRegistryKey, KEY_WRITE);
|
||||
LONG rv = key.WriteValue(kUserDataDirRegistryKey, L"yyy");
|
||||
ASSERT_EQ(rv, ERROR_SUCCESS);
|
||||
|
||||
install_static::GetUserDataDirectoryImpl(L"xxx", kFakeInstallConstants,
|
||||
&result, &invalid);
|
||||
|
||||
EXPECT_TRUE(EndsWith(result, L"\\yyy"));
|
||||
EXPECT_EQ(std::wstring(), invalid);
|
||||
}
|
||||
|
||||
TEST(UserDataDir, RegistrySettingsInHKCUOverrides) {
|
||||
std::wstring result, invalid;
|
||||
|
||||
// Override the registry to say one value in HKCU, and confirm it takes
|
||||
// precedence over the command line in both implementations.
|
||||
registry_util::RegistryOverrideManager override_manager;
|
||||
std::wstring temp;
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
override_manager.OverrideRegistry(HKEY_CURRENT_USER, &temp));
|
||||
ScopedNTRegistryTestingOverride nt_override(nt::HKCU, temp);
|
||||
|
||||
base::win::RegKey key(HKEY_CURRENT_USER, kPolicyRegistryKey, KEY_WRITE);
|
||||
LONG rv = key.WriteValue(kUserDataDirRegistryKey, L"yyy");
|
||||
ASSERT_EQ(rv, ERROR_SUCCESS);
|
||||
|
||||
install_static::GetUserDataDirectoryImpl(L"xxx", kFakeInstallConstants,
|
||||
&result, &invalid);
|
||||
|
||||
EXPECT_TRUE(EndsWith(result, L"\\yyy"));
|
||||
EXPECT_EQ(std::wstring(), invalid);
|
||||
}
|
||||
|
||||
TEST(UserDataDir, RegistrySettingsInHKLMTakesPrecedenceOverHKCU) {
|
||||
std::wstring result, invalid;
|
||||
|
||||
// Override the registry in both HKLM and HKCU, and confirm HKLM takes
|
||||
// precedence.
|
||||
registry_util::RegistryOverrideManager override_manager;
|
||||
std::wstring temp;
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
override_manager.OverrideRegistry(HKEY_LOCAL_MACHINE, &temp));
|
||||
ScopedNTRegistryTestingOverride nt_override(nt::HKLM, temp);
|
||||
LONG rv;
|
||||
base::win::RegKey key1(HKEY_LOCAL_MACHINE, kPolicyRegistryKey, KEY_WRITE);
|
||||
rv = key1.WriteValue(kUserDataDirRegistryKey, L"111");
|
||||
ASSERT_EQ(rv, ERROR_SUCCESS);
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
override_manager.OverrideRegistry(HKEY_CURRENT_USER, &temp));
|
||||
ScopedNTRegistryTestingOverride nt_override2(nt::HKCU, temp);
|
||||
base::win::RegKey key2(HKEY_CURRENT_USER, kPolicyRegistryKey, KEY_WRITE);
|
||||
rv = key2.WriteValue(kUserDataDirRegistryKey, L"222");
|
||||
ASSERT_EQ(rv, ERROR_SUCCESS);
|
||||
|
||||
install_static::GetUserDataDirectoryImpl(L"xxx", kFakeInstallConstants,
|
||||
&result, &invalid);
|
||||
|
||||
EXPECT_TRUE(EndsWith(result, L"\\111"));
|
||||
EXPECT_EQ(std::wstring(), invalid);
|
||||
}
|
||||
|
||||
TEST(UserDataDir, RegistrySettingWithPathExpansionHKCU) {
|
||||
std::wstring result, invalid;
|
||||
|
||||
registry_util::RegistryOverrideManager override_manager;
|
||||
std::wstring temp;
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
override_manager.OverrideRegistry(HKEY_CURRENT_USER, &temp));
|
||||
ScopedNTRegistryTestingOverride nt_override(nt::HKCU, temp);
|
||||
base::win::RegKey key(HKEY_CURRENT_USER, kPolicyRegistryKey, KEY_WRITE);
|
||||
LONG rv = key.WriteValue(kUserDataDirRegistryKey, L"${windows}");
|
||||
ASSERT_EQ(rv, ERROR_SUCCESS);
|
||||
|
||||
install_static::GetUserDataDirectoryImpl(L"xxx", kFakeInstallConstants,
|
||||
&result, &invalid);
|
||||
|
||||
EXPECT_EQ(strlen("X:\\WINDOWS"), result.size());
|
||||
EXPECT_EQ(std::wstring::npos, result.find(L"${windows}"));
|
||||
std::wstring upper;
|
||||
std::transform(result.begin(), result.end(), std::back_inserter(upper),
|
||||
toupper);
|
||||
EXPECT_TRUE(EndsWith(upper, L"\\WINDOWS"));
|
||||
EXPECT_EQ(std::wstring(), invalid);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace install_static
|
Loading…
Reference in a new issue