Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2958)

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 1187433006: Load language .pak files directly from the apk when using splits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@locale-res-or-file
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chrome_content_browser_client.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index d5a8247355a9cca09d6396b0aad3c6a52bd06a2e..8b31175b67946ac182cdcdc6707a2c1ed2adedcb 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -157,6 +157,8 @@
#elif defined(OS_LINUX)
#include "chrome/browser/chrome_browser_main_linux.h"
#elif defined(OS_ANDROID)
+#include "base/android/apk_assets.h"
+#include "base/android/build_info.h"
#include "chrome/browser/android/new_tab_page_url_handler.h"
#include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h"
#include "chrome/browser/chrome_browser_main_android.h"
@@ -2224,18 +2226,30 @@ void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
&(*regions)[kAndroidChrome100PercentPakDescriptor]);
mappings->Share(kAndroidChrome100PercentPakDescriptor, fd);
- int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
- const std::string locale = GetApplicationLocale();
- base::FilePath locale_pak = ResourceBundle::GetSharedInstance().
- GetLocaleFilePath(locale, false);
- base::File file(locale_pak, flags);
- DCHECK(file.IsValid());
- mappings->Transfer(kAndroidLocalePakDescriptor,
- base::ScopedFD(file.TakePlatformFile()));
+ if (!locale_pak_fd_.is_valid()) {
+ const std::string locale = GetApplicationLocale();
+ if (ui::GetLocalePaksStoredInApk()) {
+ std::string pak_path = ui::GetPathForAndroidLocalePakWithinApk(locale);
+ locale_pak_fd_.reset(
+ base::android::OpenApkAsset(pak_path, &locale_pak_region_));
+ } else {
+ int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
+ base::FilePath locale_pak = ResourceBundle::GetSharedInstance().
+ GetLocaleFilePath(locale, false);
+ base::File file(locale_pak, flags);
+ locale_pak_fd_.reset(file.TakePlatformFile());
+ locale_pak_region_ = base::MemoryMappedFile::Region::kWholeFile;
+ }
+ DCHECK(locale_pak_fd_.is_valid());
+ }
+ mappings->Share(kAndroidLocalePakDescriptor, locale_pak_fd_.get());
+ regions->insert(
+ std::make_pair(kAndroidLocalePakDescriptor, locale_pak_region_));
if (breakpad::IsCrashReporterEnabled()) {
- file = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile(
- child_process_id);
+ base::File file =
+ breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile(
+ child_process_id);
if (file.IsValid()) {
mappings->Transfer(kAndroidMinidumpDescriptor,
base::ScopedFD(file.TakePlatformFile()));

Powered by Google App Engine
This is Rietveld 408576698