Chromium Code Reviews| Index: base/i18n/icu_util.cc |
| diff --git a/base/i18n/icu_util.cc b/base/i18n/icu_util.cc |
| index a9f0b129633cd596934b8cf7d680d1fcca7f7a8a..4cea9d2d6fa99cb3283ec69ef1fc6f1ff4cb1bfd 100644 |
| --- a/base/i18n/icu_util.cc |
| +++ b/base/i18n/icu_util.cc |
| @@ -23,6 +23,10 @@ |
| #include "third_party/icu/source/i18n/unicode/timezone.h" |
| #endif |
| +#if defined(OS_ANDROID) |
| +#include "base/android/apk_assets.h" |
| +#endif |
| + |
| #if defined(OS_MACOSX) |
| #include "base/mac/foundation_util.h" |
| #endif |
| @@ -118,7 +122,16 @@ bool InitializeICU() { |
| #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC) |
| // The ICU data is statically linked. |
| result = true; |
| -#elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE) |
| +#elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE) && OS_ANDROID |
|
Yaron
2015/06/02 14:28:01
defined(OS_ANDROID)
agrieve
2015/06/02 17:24:40
Done.
|
| + base::MemoryMappedFile::Region pak_region; |
| + int pak_fd = base::android::OpenApkAsset(kIcuDataFileName, &pak_region); |
| + CHECK(pak_fd != -1); |
| + |
| +#if !defined(NDEBUG) |
|
Yaron
2015/06/02 14:28:01
Yikes. This is pretty awkward (to be fair this fun
agrieve
2015/06/02 17:24:40
Agree it's awkward :S
InitializeICU is called fro
|
| + g_called_once = false; |
| +#endif |
| + result = InitializeICUWithFileDescriptor(pak_fd, pak_region); |
| +#elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE) && !OS_ANDROID |
|
Yaron
2015/06/02 14:28:01
!defined(OS_ANDROID)
agrieve
2015/06/02 17:24:40
Done.
|
| // If the ICU data directory is set, ICU won't actually load the data until |
| // it is needed. This can fail if the process is sandboxed at that time. |
| // Instead, we map the file in and hand off the data so the sandbox won't |
| @@ -137,8 +150,6 @@ bool InitializeICU() { |
| wcscpy_s(tmp_buffer, data_path.value().c_str()); |
| debug::Alias(tmp_buffer); |
| CHECK(path_ok); // TODO(scottmg): http://crbug.com/445616 |
| -#elif defined(OS_ANDROID) |
| - bool path_ok = PathService::Get(DIR_ANDROID_APP_DATA, &data_path); |
| #else |
| // For now, expect the data file to be alongside the executable. |
| // This is sufficient while we work on unit tests, but will eventually |