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

Unified Diff: ui/base/resource/resource_bundle.cc

Issue 1969313005: [headless] Embed pak file into binary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes according to comments. Created 4 years, 7 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
« ui/base/resource/resource_bundle.h ('K') | « ui/base/resource/resource_bundle.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/resource_bundle.cc
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc
index 0f95c9e2e08dfdbeaa388cf67755dbdbc57ca9a6..a856aad266ba9a2d0ae16dee6ddfc433735065ed 100644
--- a/ui/base/resource/resource_bundle.cc
+++ b/ui/base/resource/resource_bundle.cc
@@ -207,6 +207,14 @@ void ResourceBundle::InitSharedInstanceWithPakPath(const base::FilePath& path) {
}
// static
+void ResourceBundle::InitSharedInstanceWithPakBuffer(base::StringPiece buffer) {
+ InitSharedInstance(NULL);
sky 2016/05/19 20:25:54 nullptr
altimin 2016/05/19 23:04:47 Done.
+ g_shared_instance_->LoadTestResourcesFromBuffer(buffer, buffer);
+
+ g_shared_instance_->InitDefaultFontList();
+}
+
+// static
void ResourceBundle::CleanupSharedInstance() {
if (g_shared_instance_) {
delete g_shared_instance_;
@@ -352,6 +360,27 @@ void ResourceBundle::LoadTestResources(const base::FilePath& path,
}
}
+void ResourceBundle::LoadTestResourcesFromBuffer(
+ base::StringPiece data,
+ base::StringPiece locale_data) {
+ // Headless Chromium allows fallback to lower-res images.
+ is_test_resources_ = true;
+
+ DCHECK(!ui::GetSupportedScaleFactors().empty());
+ const ScaleFactor scale_factor(ui::GetSupportedScaleFactors()[0]);
+ // Use the given resource pak for both common and localized resources.
+ std::unique_ptr<DataPack> data_pack(new DataPack(scale_factor));
+ if (data_pack->LoadFromBuffer(data))
+ AddDataPack(data_pack.release());
+
+ data_pack.reset(new DataPack(ui::SCALE_FACTOR_NONE));
+ if (data_pack->LoadFromBuffer(locale_data)) {
+ locale_resources_data_.reset(data_pack.release());
+ } else {
+ locale_resources_data_.reset(new DataPack(ui::SCALE_FACTOR_NONE));
+ }
+}
+
void ResourceBundle::UnloadLocaleResources() {
locale_resources_data_.reset();
}
« ui/base/resource/resource_bundle.h ('K') | « ui/base/resource/resource_bundle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698