in libcef/common/alloy/alloy_main_delegate.cc [472:570]
void AlloyMainDelegate::InitializeResourceBundle() {
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
base::FilePath resources_pak_file, chrome_100_percent_pak_file,
chrome_200_percent_pak_file, locales_dir;
base::FilePath resources_dir;
if (command_line->HasSwitch(switches::kResourcesDirPath)) {
resources_dir =
command_line->GetSwitchValuePath(switches::kResourcesDirPath);
}
if (resources_dir.empty())
resources_dir = resource_util::GetResourcesDir();
if (!resources_dir.empty())
base::PathService::Override(chrome::DIR_RESOURCES, resources_dir);
if (!resource_bundle_delegate_.pack_loading_disabled()) {
if (!resources_dir.empty()) {
CHECK(resources_dir.IsAbsolute());
resources_pak_file =
resources_dir.Append(FILE_PATH_LITERAL("resources.pak"));
chrome_100_percent_pak_file =
resources_dir.Append(FILE_PATH_LITERAL("chrome_100_percent.pak"));
chrome_200_percent_pak_file =
resources_dir.Append(FILE_PATH_LITERAL("chrome_200_percent.pak"));
}
if (command_line->HasSwitch(switches::kLocalesDirPath))
locales_dir = command_line->GetSwitchValuePath(switches::kLocalesDirPath);
if (!locales_dir.empty())
base::PathService::Override(ui::DIR_LOCALES, locales_dir);
}
#if defined(OS_WIN)
// From chrome/app/chrome_main_delegate.cc
// Throbber icons and cursors are still stored in chrome.dll,
// this can be killed once those are merged into resources.pak. See
// GlassBrowserFrameView::InitThrobberIcons(), https://crbug.com/368327 and
// https://crbug.com/1178117.
auto module_handle =
::GetModuleHandle(CefAppManager::Get()->GetResourceDllName());
if (!module_handle)
module_handle = ::GetModuleHandle(NULL);
ui::SetResourcesDataDLL(module_handle);
#endif
std::string locale = command_line->GetSwitchValueASCII(switches::kLang);
DCHECK(!locale.empty());
const std::string loaded_locale =
ui::ResourceBundle::InitSharedInstanceWithLocale(
locale, &resource_bundle_delegate_,
ui::ResourceBundle::LOAD_COMMON_RESOURCES);
if (!loaded_locale.empty() && g_browser_process)
g_browser_process->SetApplicationLocale(loaded_locale);
ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance();
if (!resource_bundle_delegate_.pack_loading_disabled()) {
if (loaded_locale.empty())
LOG(ERROR) << "Could not load locale pak for " << locale;
resource_bundle_delegate_.set_allow_pack_file_load(true);
if (base::PathExists(resources_pak_file)) {
resource_bundle.AddDataPackFromPath(resources_pak_file,
ui::kScaleFactorNone);
} else {
LOG(ERROR) << "Could not load resources.pak";
}
// Always load the 1x data pack first as the 2x data pack contains both 1x
// and 2x images. The 1x data pack only has 1x images, thus passes in an
// accurate scale factor to gfx::ImageSkia::AddRepresentation.
if (resource_util::IsScaleFactorSupported(ui::k100Percent)) {
if (base::PathExists(chrome_100_percent_pak_file)) {
resource_bundle.AddDataPackFromPath(chrome_100_percent_pak_file,
ui::k100Percent);
} else {
LOG(ERROR) << "Could not load chrome_100_percent.pak";
}
}
if (resource_util::IsScaleFactorSupported(ui::k200Percent)) {
if (base::PathExists(chrome_200_percent_pak_file)) {
resource_bundle.AddDataPackFromPath(chrome_200_percent_pak_file,
ui::k200Percent);
} else {
LOG(ERROR) << "Could not load chrome_200_percent.pak";
}
}
// Skip the default pak file loading that would otherwise occur in
// ResourceBundle::LoadChromeResources().
resource_bundle_delegate_.set_allow_pack_file_load(false);
}
}