Index: chromecast/app/cast_main_delegate.cc |
diff --git a/chromecast/app/cast_main_delegate.cc b/chromecast/app/cast_main_delegate.cc |
index 12d1a79087ca9379ce988d3f5147d1593c7e2ecd..e7df38e21ff24a6d64c26c34d8f37abd5a9a6d5f 100644 |
--- a/chromecast/app/cast_main_delegate.cc |
+++ b/chromecast/app/cast_main_delegate.cc |
@@ -24,6 +24,7 @@ |
#include "ui/base/resource/resource_bundle.h" |
#if defined(OS_ANDROID) |
+#include "base/android/apk_assets.h" |
#include "chromecast/crash/android/crash_handler.h" |
#endif // defined(OS_ANDROID) |
@@ -129,14 +130,20 @@ void CastMainDelegate::InitializeResourceBundle() { |
#if defined(OS_ANDROID) |
// On Android, the renderer runs with a different UID and can never access |
// the file system. Use the file descriptor passed in at launch time. |
- int pak_fd = |
- base::GlobalDescriptors::GetInstance()->MaybeGet(kAndroidPakDescriptor); |
+ auto global_descriptors = base::GlobalDescriptors::GetInstance(); |
+ int pak_fd = global_descriptors->MaybeGet(kAndroidPakDescriptor); |
+ base::MemoryMappedFile::Region pak_region; |
if (pak_fd >= 0) { |
- ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( |
- base::File(pak_fd), base::MemoryMappedFile::Region::kWholeFile); |
- ui::ResourceBundle::GetSharedInstance().AddDataPackFromFile( |
- base::File(pak_fd), ui::SCALE_FACTOR_100P); |
+ pak_region = global_descriptors->GetRegion(kAndroidPakDescriptor); |
+ ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(base::File(pak_fd), |
+ pak_region); |
+ ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( |
+ base::File(pak_fd), pak_region, ui::SCALE_FACTOR_100P); |
return; |
+ } else { |
+ pak_fd = base::android::OpenApkAsset("assets/cast_shell.pak", &pak_region); |
+ DCHECK_GE(pak_fd, 0); |
+ global_descriptors->Set(kAndroidPakDescriptor, pak_fd, pak_region); |
} |
#endif // defined(OS_ANDROID) |
@@ -148,11 +155,16 @@ void CastMainDelegate::InitializeResourceBundle() { |
resource_delegate_.get(), |
ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); |
+#if defined(OS_ANDROID) |
+ ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( |
+ base::File(pak_fd), pak_region, ui::SCALE_FACTOR_NONE); |
+#else |
base::FilePath pak_file; |
CHECK(PathService::Get(FILE_CAST_PAK, &pak_file)); |
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
pak_file, |
ui::SCALE_FACTOR_NONE); |
+#endif // defined(OS_ANDROID) |
} |
content::ContentBrowserClient* CastMainDelegate::CreateContentBrowserClient() { |