diff options
author | justincohen <justincohen@chromium.org> | 2016-01-08 15:49:43 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-08 23:51:01 +0000 |
commit | b83910dc8dc2457740ad0ef6de03218ae11ddc47 (patch) | |
tree | d49d897db02a019747c0dafd2138e66ce8955489 | |
parent | f1503e37c092083c0efde38f8f64884e5fb852fa (diff) | |
download | chromium_src-b83910dc8dc2457740ad0ef6de03218ae11ddc47.zip chromium_src-b83910dc8dc2457740ad0ef6de03218ae11ddc47.tar.gz chromium_src-b83910dc8dc2457740ad0ef6de03218ae11ddc47.tar.bz2 |
[iOS] Allow overriding icuctl.dat file location.
This allows for iOS to only ship one icuctl.dat file for the main bundle
and for the today extension.
BUG=
Review URL: https://codereview.chromium.org/1568363002
Cr-Commit-Position: refs/heads/master@{#368461}
-rw-r--r-- | base/i18n/icu_util.cc | 10 | ||||
-rw-r--r-- | base/ios/ios_util.h | 9 | ||||
-rw-r--r-- | base/ios/ios_util.mm | 16 |
3 files changed, 35 insertions, 0 deletions
diff --git a/base/i18n/icu_util.cc b/base/i18n/icu_util.cc index d7e45c3..08dbeb3 100644 --- a/base/i18n/icu_util.cc +++ b/base/i18n/icu_util.cc @@ -28,6 +28,10 @@ #include "base/android/apk_assets.h" #endif +#if defined(OS_IOS) +#include "base/ios/ios_util.h" +#endif + #if defined(OS_MACOSX) #include "base/mac/foundation_util.h" #endif @@ -124,6 +128,12 @@ void LazyInitIcuDataFile() { ScopedCFTypeRef<CFStringRef> data_file_name( SysUTF8ToCFStringRef(kIcuDataFileName)); FilePath data_path = mac::PathForFrameworkBundleResource(data_file_name); +#if defined(OS_IOS) + FilePath override_data_path = base::ios::FilePathOfEmbeddedICU(); + if (!override_data_path.empty()) { + data_path = override_data_path; + } +#endif // !defined(OS_IOS) if (data_path.empty()) { LOG(ERROR) << kIcuDataFileName << " not found in bundle"; return; diff --git a/base/ios/ios_util.h b/base/ios/ios_util.h index e677adc..3b276ff 100644 --- a/base/ios/ios_util.h +++ b/base/ios/ios_util.h @@ -8,6 +8,7 @@ #include <stdint.h> #include "base/base_export.h" +#include "base/files/file_path.h" namespace base { namespace ios { @@ -30,6 +31,14 @@ BASE_EXPORT bool IsRunningOnOrLater(int32_t major, // example by using the "RTL Psuedolanguage" option when launching from XCode). BASE_EXPORT bool IsInForcedRTL(); +// Stores the |path| of the ICU dat file in a global to be referenced later by +// FilePathOfICUFile(). This should only be called once. +BASE_EXPORT void OverridePathOfEmbeddedICU(const char* path); + +// Returns the overriden path set by OverridePathOfEmbeddedICU(), otherwise +// returns invalid FilePath. +BASE_EXPORT FilePath FilePathOfEmbeddedICU(); + } // namespace ios } // namespace base diff --git a/base/ios/ios_util.mm b/base/ios/ios_util.mm index 627fb40..bc10d19 100644 --- a/base/ios/ios_util.mm +++ b/base/ios/ios_util.mm @@ -11,6 +11,7 @@ #include "base/sys_info.h" namespace { + // Return a 3 elements array containing the major, minor and bug fix version of // the OS. const int32_t* OSVersionAsArray() { @@ -19,6 +20,9 @@ const int32_t* OSVersionAsArray() { &digits[0], &digits[1], &digits[2]); return digits; } + +std::string* g_icudtl_path_override = nullptr; + } // namespace namespace base { @@ -48,5 +52,17 @@ bool IsInForcedRTL() { return [defaults boolForKey:@"NSForceRightToLeftWritingDirection"]; } +void OverridePathOfEmbeddedICU(const char* path) { + DCHECK(!g_icudtl_path_override); + g_icudtl_path_override = new std::string(path); +} + +FilePath FilePathOfEmbeddedICU() { + if (g_icudtl_path_override) { + return FilePath(*g_icudtl_path_override); + } + return FilePath(); +} + } // namespace ios } // namespace base |