Chromium Code Reviews| 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(); |
| } |