Commit 498fee7c authored by John Z Wu's avatar John Z Wu Committed by Commit Bot

Load scalable resources in //ios/web_view.

These resources were only bundled but not yet loaded.

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I2bf6ed5d04a12bc5a03dfc001061eb032941d8f3
Reviewed-on: https://chromium-review.googlesource.com/1058346Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Commit-Queue: John Wu <jzw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558792}
parent 0bcc7e1c
......@@ -26,6 +26,11 @@ class WebViewWebMainParts : public web::WebMainParts {
void PostMainMessageLoopRun() override;
void PostDestroyThreads() override;
// Loads resources that are not scaled. f.e. javascript files.
void LoadNonScalableResources();
// Loads resources that can be scaled. f.e. png images for @1x, @2x, and @3x.
void LoadScalableResources();
DISALLOW_COPY_AND_ASSIGN(WebViewWebMainParts);
};
......
......@@ -28,12 +28,8 @@ void WebViewWebMainParts::PreMainMessageLoopStart() {
l10n_util::OverrideLocaleWithCocoaLocale();
ui::ResourceBundle::InitSharedInstanceWithLocale(
std::string(), nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
base::FilePath pak_file;
base::PathService::Get(base::DIR_MODULE, &pak_file);
pak_file = pak_file.Append(FILE_PATH_LITERAL("web_view_resources.pak"));
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
pak_file, ui::SCALE_FACTOR_NONE);
LoadNonScalableResources();
LoadScalableResources();
}
void WebViewWebMainParts::PreCreateThreads() {
......@@ -63,4 +59,39 @@ void WebViewWebMainParts::PostDestroyThreads() {
ApplicationContext::GetInstance()->PostDestroyThreads();
}
void WebViewWebMainParts::LoadNonScalableResources() {
base::FilePath pak_file;
base::PathService::Get(base::DIR_MODULE, &pak_file);
pak_file = pak_file.Append(FILE_PATH_LITERAL("web_view_resources.pak"));
ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance();
resource_bundle.AddDataPackFromPath(pak_file, ui::SCALE_FACTOR_NONE);
}
void WebViewWebMainParts::LoadScalableResources() {
ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance();
if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_100P)) {
base::FilePath pak_file_100;
base::PathService::Get(base::DIR_MODULE, &pak_file_100);
pak_file_100 =
pak_file_100.Append(FILE_PATH_LITERAL("web_view_100_percent.pak"));
resource_bundle.AddDataPackFromPath(pak_file_100, ui::SCALE_FACTOR_100P);
}
if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_200P)) {
base::FilePath pak_file_200;
base::PathService::Get(base::DIR_MODULE, &pak_file_200);
pak_file_200 =
pak_file_200.Append(FILE_PATH_LITERAL("web_view_200_percent.pak"));
resource_bundle.AddDataPackFromPath(pak_file_200, ui::SCALE_FACTOR_200P);
}
if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_300P)) {
base::FilePath pak_file_300;
base::PathService::Get(base::DIR_MODULE, &pak_file_300);
pak_file_300 =
pak_file_300.Append(FILE_PATH_LITERAL("web_view_300_percent.pak"));
resource_bundle.AddDataPackFromPath(pak_file_300, ui::SCALE_FACTOR_300P);
}
}
} // namespace ios_web_view
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