diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/resource/resource_bundle.cc | 7 | ||||
-rw-r--r-- | ui/base/resource/resource_bundle_android.cc | 12 | ||||
-rw-r--r-- | ui/base/resource/resource_bundle_android.h | 4 |
3 files changed, 18 insertions, 5 deletions
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc index f57c321..12b1825 100644 --- a/ui/base/resource/resource_bundle.cc +++ b/ui/base/resource/resource_bundle.cc @@ -198,14 +198,11 @@ ResourceBundle& ResourceBundle::GetSharedInstance() { return *g_shared_instance_; } +#if !defined(OS_ANDROID) bool ResourceBundle::LocaleDataPakExists(const std::string& locale) { -#if defined(OS_ANDROID) - if (!GetPathForAndroidLocalePakWithinApk(locale).empty()) { - return true; - } -#endif return !GetLocaleFilePath(locale, true).empty(); } +#endif // !defined(OS_ANDROID) void ResourceBundle::AddDataPackFromPath(const base::FilePath& path, ScaleFactor scale_factor) { diff --git a/ui/base/resource/resource_bundle_android.cc b/ui/base/resource/resource_bundle_android.cc index a1a4d00..fa72a27 100644 --- a/ui/base/resource/resource_bundle_android.cc +++ b/ui/base/resource/resource_bundle_android.cc @@ -17,6 +17,7 @@ namespace ui { namespace { +bool g_locale_paks_in_apk = false; // It is okay to cache and share these file descriptors since the // ResourceBundle singleton never closes the handles. int g_chrome_100_percent_fd = -1; @@ -60,12 +61,23 @@ void ResourceBundle::LoadCommonResources() { } } +bool ResourceBundle::LocaleDataPakExists(const std::string& locale) { + if (g_locale_paks_in_apk) { + return !GetPathForAndroidLocalePakWithinApk(locale).empty(); + } + return !GetLocaleFilePath(locale, true).empty(); +} + gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { // Flipped image is not used on Android. DCHECK_EQ(rtl, RTL_DISABLED); return GetImageNamed(resource_id); } +void SetLocalePaksStoredInApk(bool value) { + g_locale_paks_in_apk = value; +} + void LoadMainAndroidPackFile(const char* path_within_apk, const base::FilePath& disk_file_path) { if (LoadFromApkOrFile(path_within_apk, diff --git a/ui/base/resource/resource_bundle_android.h b/ui/base/resource/resource_bundle_android.h index 17e1bd2..437c473 100644 --- a/ui/base/resource/resource_bundle_android.h +++ b/ui/base/resource/resource_bundle_android.h @@ -28,6 +28,10 @@ UI_BASE_EXPORT int GetMainAndroidPackFd( UI_BASE_EXPORT int GetCommonResourcesPackFd( base::MemoryMappedFile::Region* out_region); +// Tell ResourceBundle to locate locale pak files via +// GetPathForAndroidLocalePakWithinApk rather than looking for them on disk. +UI_BASE_EXPORT void SetLocalePaksStoredInApk(bool value); + // Returns the path within the apk for the given locale's .pak file, or an // empty string if it doesn't exist. // Only locale paks for the active Android language can be retrieved. |