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

Unified Diff: content/shell/app/shell_main_delegate.cc

Issue 1181953002: Load non-locale .pak files directly from the .apk on Android (rather than extracting on start-up). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@raw-paks
Patch Set: yfriedman review comments Created 5 years, 6 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: content/shell/app/shell_main_delegate.cc
diff --git a/content/shell/app/shell_main_delegate.cc b/content/shell/app/shell_main_delegate.cc
index 86b5b04eabf18acf850f8927c128f17a5886c407..bcbba35dc3732f1eee330020e1ea93cfee2aff7b 100644
--- a/content/shell/app/shell_main_delegate.cc
+++ b/content/shell/app/shell_main_delegate.cc
@@ -49,6 +49,7 @@
#endif
#if defined(OS_ANDROID)
+#include "base/android/apk_assets.h"
#include "base/posix/global_descriptors.h"
#include "content/shell/android/shell_descriptors.h"
#endif
@@ -294,35 +295,35 @@ void ShellMainDelegate::InitializeResourceBundle() {
// In the Android case, the renderer runs with a different UID and can never
// access the file system. So we are passed a file descriptor to the
// ResourceBundle pak at launch time.
- int pak_fd =
- base::GlobalDescriptors::GetInstance()->MaybeGet(kShellPakDescriptor);
+ auto global_descriptors = base::GlobalDescriptors::GetInstance();
+ int pak_fd = global_descriptors->MaybeGet(kShellPakDescriptor);
+ base::MemoryMappedFile::Region pak_region;
if (pak_fd >= 0) {
+ pak_region = global_descriptors->GetRegion(kShellPakDescriptor);
// This is clearly wrong. See crbug.com/330930
- ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(
- base::File(pak_fd), base::MemoryMappedFile::Region::kWholeFile);
- ResourceBundle::GetSharedInstance().AddDataPackFromFile(
- base::File(pak_fd), ui::SCALE_FACTOR_100P);
- return;
+ ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(base::File(pak_fd),
+ pak_region);
+ ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion(
+ base::File(pak_fd), pak_region, ui::SCALE_FACTOR_100P);
+ } else {
+ pak_fd =
+ base::android::OpenApkAsset("assets/content_shell.pak", &pak_region);
+ DCHECK_GE(pak_fd, 0);
+ global_descriptors->Set(kShellPakDescriptor, pak_fd, pak_region);
+ ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(base::File(pak_fd),
+ pak_region);
}
-#endif
-
+#else
base::FilePath pak_file;
#if defined(OS_MACOSX)
pak_file = GetResourcesPakFilePath();
#else
base::FilePath pak_dir;
-
-#if defined(OS_ANDROID)
- bool got_path = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_dir);
- DCHECK(got_path);
- pak_dir = pak_dir.Append(FILE_PATH_LITERAL("paks"));
-#else
PathService::Get(base::DIR_MODULE, &pak_dir);
-#endif
-
pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak"));
-#endif
+#endif // defined(OS_MACOSX)
ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
+#endif // defined(OS_ANDROID)
}
ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() {

Powered by Google App Engine
This is Rietveld 408576698