diff options
author | agrieve <agrieve@chromium.org> | 2015-06-19 14:20:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-19 21:21:24 +0000 |
commit | f30e04470453ccd7e6a9abf586185b991d174902 (patch) | |
tree | 6294dd378c05275f7f142c8665d3f83b455c4e84 | |
parent | e33731cd7108536b56e18e722af5c9d425c47d55 (diff) | |
download | chromium_src-f30e04470453ccd7e6a9abf586185b991d174902.zip chromium_src-f30e04470453ccd7e6a9abf586185b991d174902.tar.gz chromium_src-f30e04470453ccd7e6a9abf586185b991d174902.tar.bz2 |
Android: Store language .pak files in res/raw rather than assets
This is a prerequisite for having them live within APK splits.
Although pak files need to be renamed to be stored under res/raw,
ResourceExtractor restores their original name during extraction (so no
change to native code).
All sub-locales are stored and extracted together, just as before.
BUG=371610
Review URL: https://codereview.chromium.org/1158053005
Cr-Commit-Position: refs/heads/master@{#335350}
16 files changed, 342 insertions, 188 deletions
diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java index 5ef433e..96ca680 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java @@ -232,7 +232,7 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { // We don't need to extract any paks because for WebView, they are // in the system image. - ResourceExtractor.setMandatoryPaksToExtract(""); + ResourceExtractor.setMandatoryPaksToExtract(0); try { LibraryLoader.get(LibraryProcessType.PROCESS_WEBVIEW).ensureInitialized(); diff --git a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java index 986785e..f6dc9a5 100644 --- a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java +++ b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java @@ -46,8 +46,7 @@ public class AwShellApplication extends ContentApplication { @Override protected void initializeLibraryDependencies() { - ResourceExtractor.setMandatoryPaksToExtract(""); - ResourceExtractor.setExtractImplicitLocaleForTesting(false); + ResourceExtractor.setMandatoryPaksToExtract(0); } @Override diff --git a/base/android/java/src/org/chromium/base/ResourceExtractor.java b/base/android/java/src/org/chromium/base/ResourceExtractor.java index dd654ff..584dfae 100644 --- a/base/android/java/src/org/chromium/base/ResourceExtractor.java +++ b/base/android/java/src/org/chromium/base/ResourceExtractor.java @@ -6,16 +6,16 @@ package org.chromium.base; import android.annotation.TargetApi; import android.content.Context; -import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.res.AssetManager; +import android.content.res.Resources; +import android.content.res.TypedArray; import android.os.AsyncTask; import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.Trace; -import android.preference.PreferenceManager; import android.util.Log; import java.io.File; @@ -26,9 +26,9 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; -import java.util.regex.Pattern; /** * Handles extracting the necessary resources bundled in an APK and moving them to a location on @@ -37,23 +37,24 @@ import java.util.regex.Pattern; public class ResourceExtractor { private static final String LOGTAG = "ResourceExtractor"; - private static final String LAST_LANGUAGE = "Last language"; - private static final String PAK_FILENAMES_LEGACY_NOREUSE = "Pak filenames"; private static final String ICU_DATA_FILENAME = "icudtl.dat"; private static final String V8_NATIVES_DATA_FILENAME = "natives_blob.bin"; private static final String V8_SNAPSHOT_DATA_FILENAME = "snapshot_blob.bin"; private static String[] sMandatoryPaks = null; + private static int sLocalePaksResId = -1; - // By default, we attempt to extract a pak file for the users - // current device locale. Use setExtractImplicitLocale() to - // change this behavior. - private static boolean sExtractImplicitLocalePak = true; - - private static boolean isAppDataFile(String file) { - return ICU_DATA_FILENAME.equals(file) - || V8_NATIVES_DATA_FILENAME.equals(file) - || V8_SNAPSHOT_DATA_FILENAME.equals(file); + /** + * Applies the reverse mapping done by locale_pak_resources.py. + */ + private static String toChromeLocaleName(String srcFileName) { + String[] parts = srcFileName.split("_"); + if (parts.length > 1) { + int dotIdx = parts[1].indexOf('.'); + return parts[0] + "-" + parts[1].substring(0, dotIdx).toUpperCase(Locale.ENGLISH) + + parts[1].substring(dotIdx); + } + return srcFileName; } private class ExtractTask extends AsyncTask<Void, Void, Void> { @@ -61,12 +62,38 @@ public class ResourceExtractor { private final List<Runnable> mCompletionCallbacks = new ArrayList<Runnable>(); - public ExtractTask() { + private void extractResourceHelper(InputStream is, File outFile, byte[] buffer) + throws IOException { + OutputStream os = null; + try { + os = new FileOutputStream(outFile); + Log.i(LOGTAG, "Extracting resource " + outFile); + + int count = 0; + while ((count = is.read(buffer, 0, BUFFER_SIZE)) != -1) { + os.write(buffer, 0, count); + } + os.flush(); + + // Ensure something reasonable was written. + if (outFile.length() == 0) { + throw new IOException(outFile + " extracted with 0 length!"); + } + } finally { + try { + if (is != null) { + is.close(); + } + } finally { + if (os != null) { + os.close(); + } + } + } } private void doInBackgroundImpl() { final File outputDir = getOutputDir(); - final File appDataDir = getAppDataDir(); if (!outputDir.exists() && !outputDir.mkdirs()) { Log.e(LOGTAG, "Unable to create pak resources directory!"); return; @@ -83,97 +110,50 @@ public class ResourceExtractor { deleteFiles(); } - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); - String currentLocale = LocaleUtils.getDefaultLocale(); - String currentLanguage = currentLocale.split("-", 2)[0]; - // If everything we need is already there (and the locale hasn't - // changed), quick exit. - if (prefs.getString(LAST_LANGUAGE, "").equals(currentLanguage)) { - boolean filesPresent = true; - for (String file : sMandatoryPaks) { - File directory = isAppDataFile(file) ? appDataDir : outputDir; - if (!new File(directory, file).exists()) { - filesPresent = false; - break; - } - } - if (filesPresent) return; - } else { - prefs.edit().putString(LAST_LANGUAGE, currentLanguage).apply(); - } - - StringBuilder p = new StringBuilder(); - for (String mandatoryPak : sMandatoryPaks) { - if (p.length() > 0) p.append('|'); - p.append("\\Q" + mandatoryPak + "\\E"); - } - - if (sExtractImplicitLocalePak) { - if (p.length() > 0) p.append('|'); - // As well as the minimum required set of .paks above, we'll - // also add all .paks that we have for the user's currently - // selected language. - p.append(currentLanguage); - p.append("(-\\w+)?\\.pak"); - } - - Pattern paksToInstall = Pattern.compile(p.toString()); - - AssetManager manager = mContext.getResources().getAssets(); beginTraceSection("WalkAssets"); + AssetManager assetManager = mContext.getAssets(); + byte[] buffer = new byte[BUFFER_SIZE]; try { - // Loop through every asset file that we have in the APK, and look for the - // ones that we need to extract by trying to match the Patterns that we - // created above. - byte[] buffer = null; - String[] files = manager.list(""); - for (String file : files) { - if (!paksToInstall.matcher(file).matches()) { - continue; - } - File output = new File(isAppDataFile(file) ? appDataDir : outputDir, file); + // Extract all files that don't already exist. + for (String fileName : sMandatoryPaks) { + File output = new File(outputDir, fileName); if (output.exists()) { continue; } - - InputStream is = null; - OutputStream os = null; beginTraceSection("ExtractResource"); + InputStream inputStream = assetManager.open(fileName); try { - is = manager.open(file); - os = new FileOutputStream(output); - Log.i(LOGTAG, "Extracting resource " + file); - if (buffer == null) { - buffer = new byte[BUFFER_SIZE]; - } - - int count = 0; - while ((count = is.read(buffer, 0, BUFFER_SIZE)) != -1) { - os.write(buffer, 0, count); - } - os.flush(); - - // Ensure something reasonable was written. - if (output.length() == 0) { - throw new IOException(file + " extracted with 0 length!"); - } - - if (isAppDataFile(file)) { - // icu and V8 data need to be accessed by a renderer - // process. - output.setReadable(true, false); - } + extractResourceHelper(inputStream, output, buffer); } finally { - try { - if (is != null) { - is.close(); + endTraceSection(); // ExtractResource + } + } + + if (sLocalePaksResId != 0) { + // locale_paks yields the current language's pak file paths. + Resources resources = mContext.getResources(); + TypedArray resIds = resources.obtainTypedArray(sLocalePaksResId); + try { + int len = resIds.length(); + for (int i = 0; i < len; ++i) { + int resId = resIds.getResourceId(i, 0); + String resPath = resources.getString(resId); + String srcBaseName = new File(resPath).getName(); + String dstBaseName = toChromeLocaleName(srcBaseName); + File output = new File(outputDir, dstBaseName); + if (output.exists()) { + continue; } - } finally { - if (os != null) { - os.close(); + beginTraceSection("ExtractResource"); + InputStream inputStream = resources.openRawResource(resId); + try { + extractResourceHelper(inputStream, output, buffer); + } finally { + endTraceSection(); // ExtractResource } - endTraceSection(); // ExtractResource } + } finally { + resIds.recycle(); } } } catch (IOException e) { @@ -303,32 +283,18 @@ public class ResourceExtractor { } /** - * Specifies the .pak files that should be extracted from the APK's asset resources directory + * Specifies the files that should be extracted from the APK. * and moved to {@link #getOutputDirFromContext(Context)}. - * @param mandatoryPaks The list of pak files to be loaded. If no pak files are - * required, pass a single empty string. + * @param localePaksResId Resource ID for the locale_paks string array. Pass + * in 0 to disable locale pak extraction. + * @param paths The list of paths to be extracted. */ - public static void setMandatoryPaksToExtract(String... mandatoryPaks) { + public static void setMandatoryPaksToExtract(int localePaksResId, String... paths) { // TODO(agrieve): Remove the need to call this once all files are loaded from the apk. assert (sInstance == null || sInstance.mExtractTask == null) : "Must be called before startExtractingResources is called"; - sMandatoryPaks = mandatoryPaks; - - } - - /** - * By default the ResourceExtractor will attempt to extract a pak resource for the users - * currently specified locale. This behavior can be changed with this function and is - * only needed by tests. - * @param extract False if we should not attempt to extract a pak file for - * the users currently selected locale and try to extract only the - * pak files specified in sMandatoryPaks. - */ - @VisibleForTesting - public static void setExtractImplicitLocaleForTesting(boolean extract) { - assert (sInstance == null || sInstance.mExtractTask == null) - : "Must be called before startExtractingResources is called"; - sExtractImplicitLocalePak = extract; + sLocalePaksResId = localePaksResId; + sMandatoryPaks = paths; } /** @@ -347,7 +313,7 @@ public class ResourceExtractor { } catch (IOException e) { Log.w(LOGTAG, "Exception while accessing assets: " + e.getMessage(), e); } - setMandatoryPaksToExtract(pakAndSnapshotFileAssets.toArray( + setMandatoryPaksToExtract(0, pakAndSnapshotFileAssets.toArray( new String[pakAndSnapshotFileAssets.size()])); } @@ -420,6 +386,10 @@ public class ResourceExtractor { return; } + // If a previous release extracted resources, and the current release does not, + // deleteFiles() will not run and some files will be left. This currently + // can happen for ContentShell, but not for Chrome proper, since we always extract + // locale pak files. if (shouldSkipPakExtraction()) { return; } @@ -472,12 +442,11 @@ public class ResourceExtractor { } /** - * Pak extraction not necessarily required by the embedder; we allow them to skip - * this process if they call setMandatoryPaksToExtract with a single empty String. + * Pak extraction not necessarily required by the embedder. */ private static boolean shouldSkipPakExtraction() { - // Must call setMandatoryPaksToExtract before beginning resource extraction. - assert sMandatoryPaks != null; - return sMandatoryPaks.length == 1 && "".equals(sMandatoryPaks[0]); + assert (sLocalePaksResId != -1 && sMandatoryPaks != null) + : "setMandatoryPaksToExtract() must be called before startExtractingResources()"; + return sMandatoryPaks.length == 0 && sLocalePaksResId == 0; } } diff --git a/build/android/gyp/locale_pak_resources.py b/build/android/gyp/locale_pak_resources.py new file mode 100755 index 0000000..8bf9218 --- /dev/null +++ b/build/android/gyp/locale_pak_resources.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python +# +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +"""Creates a resources.zip for locale .pak files. + +Places the locale.pak files into appropriate resource configs +(e.g. en-GB.pak -> res/raw-en/en_gb.pak). Also generates a locale_paks +TypedArray so that resource files can be enumerated at runtime. +""" + +import collections +import optparse +import os +import sys +import zipfile + +from util import build_utils + + +# This should stay in sync with: +# base/android/java/src/org/chromium/base/LocaleUtils.java +_CHROME_TO_ANDROID_LOCALE_MAP = { + 'he': 'iw', + 'id': 'in', + 'fil': 'tl', +} + + +def CreateLocalePaksXml(names): + """Creates the contents for the locale-paks.xml files.""" + VALUES_FILE_TEMPLATE = '''<?xml version="1.0" encoding="utf-8"?> +<resources> + <array name="locale_paks">%s + </array> +</resources> +''' + VALUES_ITEM_TEMPLATE = ''' + <item>@raw/%s</item>''' + + res_names = (os.path.splitext(name)[0] for name in names) + items = ''.join((VALUES_ITEM_TEMPLATE % name for name in res_names)) + return VALUES_FILE_TEMPLATE % items + + +def main(): + parser = optparse.OptionParser() + build_utils.AddDepfileOption(parser) + parser.add_option('--locale-paks', help='List of files for res/raw-LOCALE') + parser.add_option('--resources-zip', help='Path to output resources.zip') + + options, _ = parser.parse_args() + build_utils.CheckOptions(options, parser, + required=['locale_paks', 'resources_zip']) + + sources = build_utils.ParseGypList(options.locale_paks) + + if options.depfile: + deps = sources + build_utils.GetPythonDependencies() + build_utils.WriteDepfile(options.depfile, deps) + + with zipfile.ZipFile(options.resources_zip, 'w', zipfile.ZIP_STORED) as out: + # e.g. "en" -> ["en_gb.pak"] + lang_to_locale_map = collections.defaultdict(list) + for src_path in sources: + basename = os.path.basename(src_path) + name = os.path.splitext(basename)[0] + # Resources file names must consist of [a-z0-9_.]. + res_compatible_name = basename.replace('-', '_').lower() + if name == 'en-US': + dest_dir = 'raw' + else: + # Chrome uses different region mapping logic from Android, so include + # all regions for each language. + android_locale = _CHROME_TO_ANDROID_LOCALE_MAP.get(name, name) + lang = android_locale[0:2] + dest_dir = 'raw-' + lang + lang_to_locale_map[lang].append(res_compatible_name) + out.write(src_path, os.path.join(dest_dir, res_compatible_name)) + + # Create a String Arrays resource so ResourceExtractor can enumerate files. + def WriteValuesFile(lang, names): + dest_dir = 'values' + if lang: + dest_dir += '-' + lang + # Always extract en-US.pak since it's the fallback. + xml = CreateLocalePaksXml(names + ['en_us.pak']) + out.writestr(os.path.join(dest_dir, 'locale-paks.xml'), xml) + + for lang, names in lang_to_locale_map.iteritems(): + WriteValuesFile(lang, names) + WriteValuesFile(None, []) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/build/android/locale_pak_resources.gypi b/build/android/locale_pak_resources.gypi new file mode 100644 index 0000000..6f8e56f8 --- /dev/null +++ b/build/android/locale_pak_resources.gypi @@ -0,0 +1,52 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Creates a resources.zip with locale.pak files placed into appropriate +# resource configs (e.g. en-GB.pak -> res/raw-en/en_gb.pak). Also generates +# a locale_paks TypedArray so that resource files can be enumerated at runtime. +# +# If this target is included in the deps of an android resources/library/apk, +# the resources will be included with that target. +# +# Variables: +# locale_pak_files - List of .pak files to process. +# Names must be of the form "en.pak" or "en-US.pak". +# +# Example +# { +# 'target_name': 'my_locale_resources', +# 'type': 'none', +# 'variables': { +# 'locale_paks_files': ['path1/fr.pak'], +# }, +# 'includes': [ '../build/android/locale_pak_resources.gypi' ], +# }, +# +{ + 'variables': { + 'resources_zip_path': '<(PRODUCT_DIR)/res.java/<(_target_name).zip', + }, + 'all_dependent_settings': { + 'variables': { + 'additional_input_paths': ['<(resources_zip_path)'], + 'dependencies_res_zip_paths': ['<(resources_zip_path)'], + }, + }, + 'actions': [{ + 'action_name': '<(_target_name)_locale_pak_resources', + 'inputs': [ + '<(DEPTH)/build/android/gyp/util/build_utils.py', + '<(DEPTH)/build/android/gyp/locale_pak_resources.py', + '<@(locale_pak_files)', + ], + 'outputs': [ + '<(resources_zip_path)', + ], + 'action': [ + 'python', '<(DEPTH)/build/android/gyp/locale_pak_resources.py', + '--locale-paks', '<(locale_pak_files)', + '--resources-zip', '<(resources_zip_path)', + ], + }], +} diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni index 4c22fac..96cbe44 100644 --- a/build/config/android/rules.gni +++ b/build/config/android/rules.gni @@ -544,6 +544,63 @@ template("jinja_template_resources") { } } +# Creates a resources.zip with locale.pak files placed into appropriate +# resource configs (e.g. en-GB.pak -> res/raw-en/en_gb.pak). Also generates +# a locale_paks TypedArray so that resource files can be enumerated at runtime. +# +# If this target is included in the deps of an android resources/library/apk, +# the resources will be included with that target. +# +# Variables: +# sources: List of .pak files. Names must be of the form "en.pak" or +# "en-US.pak". +# +# Example +# locale_pak_resources("locale_paks") { +# sources = [ "path/en-US.pak", "path/fr.pak", ... ] +# } +template("locale_pak_resources") { + set_sources_assignment_filter([]) + assert(defined(invoker.sources)) + + _base_path = "$target_gen_dir/$target_name" + _resources_zip = _base_path + ".resources.zip" + _build_config = _base_path + ".build_config" + + write_build_config("${target_name}__build_config") { + build_config = _build_config + resources_zip = _resources_zip + type = "android_resources" + } + + action("${target_name}__create_resources_zip") { + sources = invoker.sources + script = "//build/android/gyp/locale_pak_resources.py" + depfile = "$target_gen_dir/$target_name.d" + + outputs = [ + depfile, + _resources_zip, + ] + + _rebased_sources = rebase_path(invoker.sources, root_build_dir) + args = [ + "--locale-paks=${_rebased_sources}", + "--resources-zip", + rebase_path(_resources_zip, root_build_dir), + "--depfile", + rebase_path(depfile, root_build_dir), + ] + } + + group(target_name) { + deps = [ + ":${target_name}__build_config", + ":${target_name}__create_resources_zip", + ] + } +} + # Declare an Android resources target # # This creates a resources zip file that will be used when building an Android diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn index 52e65d5..e820241 100644 --- a/chrome/android/BUILD.gn +++ b/chrome/android/BUILD.gn @@ -24,6 +24,19 @@ jinja_variables = [ "configuration_policy=$configuration_policy", ] +chrome_android_paks_gypi = + exec_script("//build/gypi_to_gn.py", + [ + rebase_path("//chrome/chrome_android_paks.gypi"), + "--replace=<(PRODUCT_DIR)=$root_out_dir", + ], + "scope", + [ "//chrome/chrome_android_paks.gypi" ]) + +locale_pak_resources("chrome_locale_paks") { + sources = chrome_android_paks_gypi.chrome_android_pak_locale_resources +} + # GYP: //chrome/chrome.gyp:chrome_java (resources part) android_resources("chrome_java_resources") { resource_dirs = [ @@ -31,6 +44,7 @@ android_resources("chrome_java_resources") { "java/res_default", ] deps = [ + ":chrome_locale_paks", ":chrome_strings_grd", "//content/public/android:content_java_resources", "//chrome/app:java_strings_grd", @@ -242,6 +256,7 @@ android_library("chrome_shell_java") { deps = [ ":chrome_shell_resources", ":chrome_java", + ":chrome_java_resources", "//base:base_java", "//content/public/android:content_java", "//components/dom_distiller/android:dom_distiller_content_java", @@ -717,18 +732,10 @@ static_library("chrome_staging") { chrome_public_apk_assets_dir = "$root_build_dir/chrome_public_apk_assets" -chrome_android_paks_gypi = - exec_script("//build/gypi_to_gn.py", - [ rebase_path("//chrome/chrome_android_paks.gypi") ], - "scope", - [ "//chrome/chrome_android_paks.gypi" ]) - copy_ex("chrome_public_apk_assets") { clear_dir = true dest = chrome_public_apk_assets_dir - gypi_sources = chrome_android_paks_gypi.chrome_android_pak_input_resources - cleaned_sources = rebase_path(gypi_sources, "<(PRODUCT_DIR)") - sources = rebase_path(cleaned_sources, ".", root_out_dir) + sources = chrome_android_paks_gypi.chrome_android_pak_input_resources if (icu_use_data_file) { sources += [ "$root_build_dir/icudtl.dat" ] } diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/ChromeMobileApplication.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/ChromeMobileApplication.java index 35b1446..1ac9afb 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/ChromeMobileApplication.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/ChromeMobileApplication.java @@ -24,6 +24,7 @@ import org.chromium.base.ResourceExtractor; import org.chromium.base.ThreadUtils; import org.chromium.base.VisibleForTesting; import org.chromium.base.annotations.SuppressFBWarnings; +import org.chromium.chrome.R; import org.chromium.chrome.browser.accessibility.FontSizePrefs; import org.chromium.chrome.browser.banners.AppBannerManager; import org.chromium.chrome.browser.banners.AppDetailsDelegate; @@ -127,7 +128,8 @@ public class ChromeMobileApplication extends ChromiumApplication { } private static final String[] CHROME_MANDATORY_PAKS = { - "en-US.pak", "resources.pak", "chrome_100_percent.pak", + "resources.pak", + "chrome_100_percent.pak", }; private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "chrome"; private static final String DEV_TOOLS_SERVER_SOCKET_PREFIX = "chrome"; @@ -196,7 +198,7 @@ public class ChromeMobileApplication extends ChromiumApplication { protected void initializeLibraryDependencies() { // The ResourceExtractor is only needed by the browser process, but this will have no // impact on the renderer process construction. - ResourceExtractor.setMandatoryPaksToExtract(CHROME_MANDATORY_PAKS); + ResourceExtractor.setMandatoryPaksToExtract(R.array.locale_paks, CHROME_MANDATORY_PAKS); PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, this); } diff --git a/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellApplication.java b/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellApplication.java index 042e2c7..d75ec52 100644 --- a/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellApplication.java +++ b/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellApplication.java @@ -9,6 +9,7 @@ import android.content.Intent; import org.chromium.base.CommandLine; import org.chromium.base.PathUtils; import org.chromium.base.ResourceExtractor; +import org.chromium.chrome.R; import org.chromium.chrome.browser.ChromiumApplication; import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory; import org.chromium.chrome.browser.identity.UuidBasedUniqueIdentificationGenerator; @@ -29,7 +30,6 @@ public class ChromeShellApplication extends ChromiumApplication { private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "chromeshell"; private static final String[] CHROME_MANDATORY_PAKS = { - "en-US.pak", "resources.pak", "chrome_100_percent.pak", }; @@ -62,7 +62,7 @@ public class ChromeShellApplication extends ChromiumApplication { @Override protected void initializeLibraryDependencies() { - ResourceExtractor.setMandatoryPaksToExtract(CHROME_MANDATORY_PAKS); + ResourceExtractor.setMandatoryPaksToExtract(R.array.locale_paks, CHROME_MANDATORY_PAKS); PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, this); } diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 73fadf8..e8c7a75 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -573,6 +573,7 @@ 'type': 'none', 'dependencies': [ 'activity_type_ids_java', + 'chrome_locale_paks', 'chrome_resources.gyp:chrome_strings', 'chrome_strings_grd', 'chrome_version_java', @@ -642,6 +643,18 @@ ], }, { + # GN: //chrome/android:chrome_locale_paks + 'target_name': 'chrome_locale_paks', + 'type': 'none', + 'variables': { + 'locale_pak_files': [ '<@(chrome_android_pak_locale_resources)' ], + }, + 'includes': [ + 'chrome_android_paks.gypi', + '../build/android/locale_pak_resources.gypi', + ], + }, + { # GN: //chrome:content_setting_javagen 'target_name': 'content_setting_java', 'type': 'none', diff --git a/chrome/chrome_android_paks.gypi b/chrome/chrome_android_paks.gypi index 13f5845..1be60d8 100644 --- a/chrome/chrome_android_paks.gypi +++ b/chrome/chrome_android_paks.gypi @@ -7,6 +7,8 @@ 'chrome_android_pak_input_resources': [ '<(PRODUCT_DIR)/resources.pak', '<(PRODUCT_DIR)/chrome_100_percent.pak', + ], + 'chrome_android_pak_locale_resources': [ '<(PRODUCT_DIR)/locales/am.pak', '<(PRODUCT_DIR)/locales/ar.pak', '<(PRODUCT_DIR)/locales/bg.pak', @@ -55,50 +57,6 @@ 'chrome_android_pak_output_resources': [ '<(chrome_android_pak_output_folder)/resources.pak', '<(chrome_android_pak_output_folder)/chrome_100_percent.pak', - '<(chrome_android_pak_output_folder)/am.pak', - '<(chrome_android_pak_output_folder)/ar.pak', - '<(chrome_android_pak_output_folder)/bg.pak', - '<(chrome_android_pak_output_folder)/ca.pak', - '<(chrome_android_pak_output_folder)/cs.pak', - '<(chrome_android_pak_output_folder)/da.pak', - '<(chrome_android_pak_output_folder)/de.pak', - '<(chrome_android_pak_output_folder)/el.pak', - '<(chrome_android_pak_output_folder)/en-GB.pak', - '<(chrome_android_pak_output_folder)/en-US.pak', - '<(chrome_android_pak_output_folder)/es.pak', - '<(chrome_android_pak_output_folder)/es-419.pak', - '<(chrome_android_pak_output_folder)/fa.pak', - '<(chrome_android_pak_output_folder)/fi.pak', - '<(chrome_android_pak_output_folder)/fil.pak', - '<(chrome_android_pak_output_folder)/fr.pak', - '<(chrome_android_pak_output_folder)/he.pak', - '<(chrome_android_pak_output_folder)/hi.pak', - '<(chrome_android_pak_output_folder)/hr.pak', - '<(chrome_android_pak_output_folder)/hu.pak', - '<(chrome_android_pak_output_folder)/id.pak', - '<(chrome_android_pak_output_folder)/it.pak', - '<(chrome_android_pak_output_folder)/ja.pak', - '<(chrome_android_pak_output_folder)/ko.pak', - '<(chrome_android_pak_output_folder)/lt.pak', - '<(chrome_android_pak_output_folder)/lv.pak', - '<(chrome_android_pak_output_folder)/nb.pak', - '<(chrome_android_pak_output_folder)/nl.pak', - '<(chrome_android_pak_output_folder)/pl.pak', - '<(chrome_android_pak_output_folder)/pt-BR.pak', - '<(chrome_android_pak_output_folder)/pt-PT.pak', - '<(chrome_android_pak_output_folder)/ro.pak', - '<(chrome_android_pak_output_folder)/ru.pak', - '<(chrome_android_pak_output_folder)/sk.pak', - '<(chrome_android_pak_output_folder)/sl.pak', - '<(chrome_android_pak_output_folder)/sr.pak', - '<(chrome_android_pak_output_folder)/sv.pak', - '<(chrome_android_pak_output_folder)/sw.pak', - '<(chrome_android_pak_output_folder)/th.pak', - '<(chrome_android_pak_output_folder)/tr.pak', - '<(chrome_android_pak_output_folder)/uk.pak', - '<(chrome_android_pak_output_folder)/vi.pak', - '<(chrome_android_pak_output_folder)/zh-CN.pak', - '<(chrome_android_pak_output_folder)/zh-TW.pak', ], 'conditions': [ ['icu_use_data_file_flag==1', { diff --git a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastApplication.java b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastApplication.java index 903609f..a9b0c6fc2 100644 --- a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastApplication.java +++ b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastApplication.java @@ -37,7 +37,7 @@ public class CastApplication extends ContentApplication { } public static void initializeApplicationParameters(Context context) { - ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAK_FILES); + ResourceExtractor.setMandatoryPaksToExtract(0, MANDATORY_PAK_FILES); PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, context); } diff --git a/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java b/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java index d1b128e..a8387ce 100644 --- a/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java +++ b/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java @@ -26,7 +26,7 @@ public class ComponentsBrowserTestsApplication extends BaseChromiumApplication { } public static void initializeApplicationParameters(Context context) { - ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAK_FILES); + ResourceExtractor.setMandatoryPaksToExtract(0, MANDATORY_PAK_FILES); PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, context); } } diff --git a/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java b/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java index eeca243..0405e32 100644 --- a/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java +++ b/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java @@ -27,7 +27,7 @@ public class ContentBrowserTestsApplication extends BaseChromiumApplication { } public static void initializeApplicationParameters(Context context) { - ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAK_FILES); + ResourceExtractor.setMandatoryPaksToExtract(0, MANDATORY_PAK_FILES); PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, context); } diff --git a/content/shell/android/linker_test_apk/src/org/chromium/chromium_linker_test_apk/ChromiumLinkerTestApplication.java b/content/shell/android/linker_test_apk/src/org/chromium/chromium_linker_test_apk/ChromiumLinkerTestApplication.java index ab019bb..f482427 100644 --- a/content/shell/android/linker_test_apk/src/org/chromium/chromium_linker_test_apk/ChromiumLinkerTestApplication.java +++ b/content/shell/android/linker_test_apk/src/org/chromium/chromium_linker_test_apk/ChromiumLinkerTestApplication.java @@ -27,7 +27,7 @@ public class ChromiumLinkerTestApplication extends BaseChromiumApplication { } public static void initializeApplicationParameters(Context context) { - ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAK_FILES); + ResourceExtractor.setMandatoryPaksToExtract(0, MANDATORY_PAK_FILES); PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, context); } diff --git a/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java b/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java index d675a0b..f97e6b030 100644 --- a/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java +++ b/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java @@ -28,7 +28,7 @@ public class ContentShellApplication extends ContentApplication { @Override protected void initializeLibraryDependencies() { - ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAK_FILES); + ResourceExtractor.setMandatoryPaksToExtract(0, MANDATORY_PAK_FILES); PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, this); } |