Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Unified Diff: ash/mus/sysui_application.cc

Issue 1874703003: Load ash_sysui resources with ResourceLoader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for comment. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/mus/sysui_application.cc
diff --git a/ash/mus/sysui_application.cc b/ash/mus/sysui_application.cc
index 92302485d160fb25dfd6b507f008afd9812dc1ea..4b913d47819f50050b99fc7e26a74511fa77cfce 100644
--- a/ash/mus/sysui_application.cc
+++ b/ash/mus/sysui_application.cc
@@ -4,6 +4,11 @@
#include "ash/mus/sysui_application.h"
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+
#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/host/ash_window_tree_host_init_params.h"
#include "ash/host/ash_window_tree_host_platform.h"
@@ -19,6 +24,7 @@
#include "base/path_service.h"
#include "base/threading/sequenced_worker_pool.h"
#include "components/mus/public/cpp/property_type_converters.h"
+#include "components/resource_provider/public/cpp/resource_loader.h"
#include "mash/wm/public/interfaces/ash_window_type.mojom.h"
#include "mash/wm/public/interfaces/container.mojom.h"
#include "ui/aura/env.h"
@@ -45,6 +51,10 @@ namespace sysui {
namespace {
+const char kResourceFileStrings[] = "ash_resources_strings.pak";
+const char kResourceFile100[] = "ash_resources_100_percent.pak";
+const char kResourceFile200[] = "ash_resources_200_percent.pak";
+
// Tries to determine the corresponding mash container from widget init params.
mash::wm::mojom::Container GetContainerId(
const views::Widget::InitParams& params) {
@@ -176,7 +186,6 @@ class AshInit {
public:
AshInit() : worker_pool_(new base::SequencedWorkerPool(2, "AshWorkerPool")) {
ui::RegisterPathProvider();
- InitializeResourceBundle();
}
~AshInit() { worker_pool_->Shutdown(); }
@@ -184,6 +193,7 @@ class AshInit {
aura::Window* root() { return ash::Shell::GetPrimaryRootWindow(); }
void Initialize(mojo::Connector* connector) {
+ InitializeResourceBundle(connector);
aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
views::WindowManagerConnection::Create(connector);
@@ -221,24 +231,29 @@ class AshInit {
SetupWallpaper(SkColorSetARGB(255, 0, 255, 0));
}
- void InitializeResourceBundle() {
+ void InitializeResourceBundle(mojo::Connector* connector) {
+ if (ui::ResourceBundle::HasSharedInstance())
+ return;
+
+ std::set<std::string> resource_paths;
+ resource_paths.insert(kResourceFileStrings);
+ resource_paths.insert(kResourceFile100);
+ resource_paths.insert(kResourceFile200);
+
+ resource_provider::ResourceLoader loader(connector, resource_paths);
+ if (!loader.BlockUntilLoaded())
+ return;
+
// Load ash resources and en-US strings; not 'common' (Chrome) resources.
- // TODO(msw): Do not load 'test' resources (include sys lang; rename paks?).
- // TODO(msw): Use the ResourceProvider interface to load these pak files.
// TODO(msw): Check ResourceBundle::IsScaleFactorSupported; load 300% etc.
- base::FilePath path;
- PathService::Get(base::DIR_MODULE, &path);
- base::FilePath ash_test_strings =
- path.Append(FILE_PATH_LITERAL("ash_test_strings.pak"));
- base::FilePath ash_test_resources_100 =
- path.Append(FILE_PATH_LITERAL("ash_test_resources_100_percent.pak"));
- base::FilePath ash_test_resources_200 =
- path.Append(FILE_PATH_LITERAL("ash_test_resources_200_percent.pak"));
-
- ui::ResourceBundle::InitSharedInstanceWithPakPath(ash_test_strings);
+ ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(
+ loader.ReleaseFile(kResourceFileStrings),
+ base::MemoryMappedFile::Region::kWholeFile);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- rb.AddDataPackFromPath(ash_test_resources_100, ui::SCALE_FACTOR_100P);
- rb.AddDataPackFromPath(ash_test_resources_200, ui::SCALE_FACTOR_200P);
+ rb.AddDataPackFromFile(loader.ReleaseFile(kResourceFile100),
+ ui::SCALE_FACTOR_100P);
+ rb.AddDataPackFromFile(loader.ReleaseFile(kResourceFile200),
+ ui::SCALE_FACTOR_200P);
}
void SetupWallpaper(SkColor color) {

Powered by Google App Engine
This is Rietveld 408576698