Upstream has been moving a lot of code under the `mac` namespace to a new `apple` namespace, and with that files are being moved around. Chromium changes: https://chromium.googlesource.com/chromium/src/+/e80be15ed013b6132ff4bb37c2b79537725961d9 commit e80be15ed013b6132ff4bb37c2b79537725961d9 Author: Avi Drissman <avi@chromium.org> Date: Fri Aug 18 18:34:47 2023 +0000 Remove forwarding headers Now that Crashpad is rolled, remove the forwarding headers. Fixed: 1444927 https://chromium.googlesource.com/chromium/src/+/eac566b06085a41c6910b204bb2afe38752ced4d commit eac566b06085a41c6910b204bb2afe38752ced4d Author: Avi Drissman <avi@chromium.org> Date: Fri Aug 18 02:56:21 2023 +0000 Move foundation_util to base/apple, leave a forwarding header Crashpad is not yet updated for the new location, so leave a forwarding header to be removed later. Skipping trybots. This is a Mac change, and it’s passing all trybots except for android_optional_gpu_tests_rel that is repeatedly failing on an unrelated issue. NOTRY=true Bug: 1444927 https://chromium.googlesource.com/chromium/src/+/a09d7dda2e1278b9ba903c3c5f459ace3cadb87c commit a09d7dda2e1278b9ba903c3c5f459ace3cadb87c Author: Avi Drissman <avi@chromium.org> Date: Thu Aug 17 16:26:58 2023 +0000 Move scoped_cftypreref to base/apple, leave a forwarding header Crashpad is not yet updated for the new location, so leave a forwarding header to be removed later. Bug: 1444927
110 lines
3.5 KiB
C++
110 lines
3.5 KiB
C++
/* Copyright (c) 2019 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 http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "brave/common/resource_bundle_helper.h"
|
|
|
|
#include <string>
|
|
|
|
#include "base/command_line.h"
|
|
#include "base/path_service.h"
|
|
#include "build/build_config.h"
|
|
#include "ui/base/resource/resource_bundle.h"
|
|
|
|
#if !BUILDFLAG(IS_IOS)
|
|
#include "chrome/common/chrome_paths.h"
|
|
#include "content/public/common/content_switches.h"
|
|
#endif
|
|
|
|
#if BUILDFLAG(IS_MAC)
|
|
#include "base/apple/foundation_util.h"
|
|
#include "base/strings/sys_string_conversions.h"
|
|
#endif
|
|
|
|
#if BUILDFLAG(IS_ANDROID)
|
|
#include "ui/base/resource/resource_bundle_android.h"
|
|
#endif
|
|
|
|
namespace {
|
|
|
|
#if !BUILDFLAG(IS_ANDROID)
|
|
base::FilePath GetResourcesPakFilePath() {
|
|
#if BUILDFLAG(IS_MAC)
|
|
return base::apple::PathForFrameworkBundleResource("brave_resources.pak");
|
|
#else
|
|
base::FilePath pak_path;
|
|
base::PathService::Get(base::DIR_ASSETS, &pak_path);
|
|
pak_path = pak_path.AppendASCII("brave_resources.pak");
|
|
return pak_path;
|
|
#endif // OS_MAC
|
|
}
|
|
#endif // OS_ANDROID
|
|
|
|
#if !BUILDFLAG(IS_ANDROID)
|
|
base::FilePath GetScaledResourcesPakFilePath(
|
|
ui::ResourceScaleFactor scale_factor) {
|
|
DCHECK(scale_factor == ui::k100Percent || scale_factor == ui::k200Percent);
|
|
|
|
const char* pak_file = (scale_factor == ui::k100Percent)
|
|
? "brave_100_percent.pak"
|
|
: "brave_200_percent.pak";
|
|
#if BUILDFLAG(IS_MAC)
|
|
return base::apple::PathForFrameworkBundleResource(pak_file);
|
|
#else
|
|
base::FilePath pak_path;
|
|
base::PathService::Get(base::DIR_ASSETS, &pak_path);
|
|
pak_path = pak_path.AppendASCII(pak_file);
|
|
return pak_path;
|
|
#endif // OS_MAC
|
|
}
|
|
#endif // !BUILDFLAG(IS_ANDROID)
|
|
|
|
} // namespace
|
|
|
|
namespace brave {
|
|
|
|
void InitializeResourceBundle() {
|
|
#if BUILDFLAG(IS_ANDROID)
|
|
ui::BraveLoadMainAndroidPackFile("assets/brave_resources.pak",
|
|
base::FilePath());
|
|
// brave_100_percent.pak is excluded now from the Android build because
|
|
// its resources are not used
|
|
#else
|
|
auto& rb = ui::ResourceBundle::GetSharedInstance();
|
|
rb.AddDataPackFromPath(GetResourcesPakFilePath(), ui::kScaleFactorNone);
|
|
rb.AddDataPackFromPath(GetScaledResourcesPakFilePath(ui::k100Percent),
|
|
ui::k100Percent);
|
|
if (ui::IsScaleFactorSupported(ui::k200Percent)) {
|
|
rb.AddDataPackFromPath(GetScaledResourcesPakFilePath(ui::k200Percent),
|
|
ui::k200Percent);
|
|
}
|
|
#endif // OS_ANDROID
|
|
}
|
|
|
|
// Returns true if this subprocess type needs the ResourceBundle initialized
|
|
// and resources loaded.
|
|
bool SubprocessNeedsResourceBundle() {
|
|
auto cmd = *base::CommandLine::ForCurrentProcess();
|
|
#if BUILDFLAG(IS_IOS)
|
|
return false;
|
|
#else
|
|
std::string process_type = cmd.GetSwitchValueASCII(switches::kProcessType);
|
|
return
|
|
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
|
// The zygote process opens the resources for the renderers.
|
|
process_type == switches::kZygoteProcess ||
|
|
#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
|
#if BUILDFLAG(IS_MAC)
|
|
// Mac needs them too for scrollbar related images and for sandbox
|
|
// profiles.
|
|
process_type == switches::kPpapiPluginProcess ||
|
|
process_type == switches::kGpuProcess ||
|
|
#endif // BUILDFLAG(IS_MAC)
|
|
process_type == switches::kRendererProcess ||
|
|
process_type == switches::kUtilityProcess;
|
|
#endif // BUILDFLAG(IS_IOS)
|
|
}
|
|
|
|
} // namespace brave
|