Chromium Code Reviews| 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 58580716660ad72d2ce604cfbfd726bc2ca8166b..905c4bb2e5a09d3ee8d9de918e82fb86fbd46846 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 |
| @@ -298,35 +299,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); |
|
Yaron
2015/06/17 14:12:28
Why does webview have to fallback to loading from
agrieve
2015/06/17 14:35:40
Likely for tests (where files are put there by iso
|
| + 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() { |