diff options
author | agrieve <agrieve@chromium.org> | 2015-06-25 13:50:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-25 20:50:54 +0000 |
commit | 96cd91843c80fa6074167df51554467806ced58f (patch) | |
tree | f6e571d19c0d0bb488da23ce8081d81a8eca2f92 /ui | |
parent | cfb223e91b728cab46f1f2853141e520af1fe26a (diff) | |
download | chromium_src-96cd91843c80fa6074167df51554467806ced58f.zip chromium_src-96cd91843c80fa6074167df51554467806ced58f.tar.gz chromium_src-96cd91843c80fa6074167df51554467806ced58f.tar.bz2 |
Never look for locale pak files on disk when they are stored within the apk
BUG=371610
Review URL: https://codereview.chromium.org/1184293003
Cr-Commit-Position: refs/heads/master@{#336248}
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. |