| 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..bfd563382a4723ae198f81434daa234564252a1e 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);
|
| + 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,25 @@ void ResourceBundle::LoadTestResources(const base::FilePath& path,
|
| }
|
| }
|
|
|
| +void ResourceBundle::LoadTestResourcesFromBuffer(
|
| + base::StringPiece data,
|
| + base::StringPiece locale_data) {
|
| + 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();
|
| }
|
|
|