Commit 6a570def authored by sadrul's avatar sadrul Committed by Commit bot

chrome/mash: Load resources before running the mus app.

When running 'chrome --mash' on device, all the resource files necessary
for ash, mus etc. apps are already in the resource files used for regular
chrome. So instead of deploying separate resource files for these apps,
just load chrome's resource files, before initializing the app.

BUG=628715, 633656

Review-Url: https://codereview.chromium.org/2387233002
Cr-Commit-Position: refs/heads/master@{#422694}
parent 36651dd8
......@@ -29,6 +29,9 @@
#include "services/shell/public/interfaces/service_factory.mojom.h"
#include "services/shell/runner/common/switches.h"
#include "services/shell/runner/host/child_process_base.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h"
using shell::mojom::ServiceFactory;
......@@ -44,6 +47,16 @@ bool IsChild() {
switches::kProcessType) == kMashChild;
}
void InitializeResources() {
ui::RegisterPathProvider();
const std::string locale =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kLang);
// This loads the Chrome's resources (chrome_100_percent.pak etc.)
ui::ResourceBundle::InitSharedInstanceWithLocale(
locale, nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
}
// Convert the command line program from chrome_mash to chrome. This is
// necessary as the shell will attempt to start chrome_mash. We want chrome.
void ChangeChromeMashToChrome(base::CommandLine* command_line) {
......@@ -120,6 +133,7 @@ void MashRunner::RunMain() {
void MashRunner::RunChild() {
base::i18n::InitializeICU();
InitializeResources();
shell::ChildProcessMainWithCallback(
base::Bind(&MashRunner::StartChildApp, base::Unretained(this)));
}
......
......@@ -55,6 +55,16 @@ AuraInit::AuraInit(shell::Connector* connector,
ui::MaterialDesignController::Initialize();
InitializeResources(connector);
// Initialize the skia font code to go ask fontconfig underneath.
#if defined(OS_LINUX)
font_loader_ = sk_make_sp<font_service::FontLoader>(connector);
SkFontConfigInterface::SetGlobal(font_loader_.get());
#endif
// There is a bunch of static state in gfx::Font, by running this now,
// before any other apps load, we ensure all the state is set up.
gfx::Font();
ui::InitializeInputMethodForTesting();
}
......@@ -71,6 +81,8 @@ AuraInit::~AuraInit() {
}
void AuraInit::InitializeResources(shell::Connector* connector) {
// Resources may have already been initialized (e.g. when 'chrome --mash' is
// used to launch the current app).
if (ui::ResourceBundle::HasSharedInstance())
return;
......@@ -92,16 +104,6 @@ void AuraInit::InitializeResources(shell::Connector* connector) {
if (!resource_file_200_.empty())
ui::ResourceBundle::GetSharedInstance().AddDataPackFromFile(
loader.TakeFile(resource_file_200_), ui::SCALE_FACTOR_200P);
// Initialize the skia font code to go ask fontconfig underneath.
#if defined(OS_LINUX)
font_loader_ = sk_make_sp<font_service::FontLoader>(connector);
SkFontConfigInterface::SetGlobal(font_loader_.get());
#endif
// There is a bunch of static state in gfx::Font, by running this now,
// before any other apps load, we ensure all the state is set up.
gfx::Font();
}
} // namespace views
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment