Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/ResourceExtractor.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ResourceExtractor.java b/content/public/android/java/src/org/chromium/content/browser/ResourceExtractor.java |
| index 23aacca28c93749e67b9eb09ac3c5ab44aa938e9..d9d005204322ea1816a23200213ed2adc42c6118 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/ResourceExtractor.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/ResourceExtractor.java |
| @@ -36,6 +36,7 @@ public class ResourceExtractor { |
| private static final String LOGTAG = "ResourceExtractor"; |
| private static final String LAST_LANGUAGE = "Last language"; |
| private static final String PAK_FILENAMES = "Pak filenames"; |
| + private static final String ICU_DATA_FILENAME = "icudtl.dat"; |
| private static String[] sMandatoryPaks = null; |
| @@ -96,6 +97,7 @@ public class ResourceExtractor { |
| p.append(currentLanguage); |
| p.append("(-\\w+)?\\.pak"); |
| } |
| + |
| Pattern paksToInstall = Pattern.compile(p.toString()); |
| AssetManager manager = mContext.getResources().getAssets(); |
| @@ -109,7 +111,8 @@ public class ResourceExtractor { |
| if (!paksToInstall.matcher(file).matches()) { |
| continue; |
| } |
| - File output = new File(mOutputDir, file); |
| + boolean isICUData = file.equals(ICU_DATA_FILENAME); |
| + File output = new File(isICUData ? mAppDataDir : mOutputDir, file); |
| if (output.exists()) { |
| continue; |
| } |
| @@ -135,7 +138,12 @@ public class ResourceExtractor { |
| throw new IOException(file + " extracted with 0 length!"); |
| } |
| - filenames.add(file); |
| + if (!isICUData) { |
| + filenames.add(file); |
| + } else { |
| + // icudata needs to be accessed by a renderer process. |
| + output.setReadable(true, false); |
| + } |
| } finally { |
| try { |
| if (is != null) { |
| @@ -223,6 +231,7 @@ public class ResourceExtractor { |
| private final Context mContext; |
| private ExtractTask mExtractTask; |
| + private final File mAppDataDir; |
| private final File mOutputDir; |
| private static ResourceExtractor sInstance; |
| @@ -263,6 +272,7 @@ public class ResourceExtractor { |
| private ResourceExtractor(Context context) { |
| mContext = context; |
| + mAppDataDir = getAppDataDirFromContext(mContext); |
| mOutputDir = getOutputDirFromContext(mContext); |
| } |
| @@ -303,11 +313,18 @@ public class ResourceExtractor { |
| mExtractTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
| } |
| + public static File getAppDataDirFromContext(Context context) { |
| + return new File(PathUtils.getDataDirectory(context.getApplicationContext())); |
| + } |
|
Yaron
2014/02/20 18:15:01
nit: add ws line after
|
| public static File getOutputDirFromContext(Context context) { |
| - return new File(PathUtils.getDataDirectory(context.getApplicationContext()), "paks"); |
| + return new File(getAppDataDirFromContext(context), "paks"); |
| } |
| public static void deleteFiles(Context context) { |
| + File icudata = new File(getAppDataDirFromContext(context), ICU_DATA_FILENAME); |
| + if (icudata.exists() && !icudata.delete()) { |
| + Log.w(LOGTAG, "Unable to remove the icudata " + icudata.getName()); |
| + } |
| File dir = getOutputDirFromContext(context); |
| if (dir.exists()) { |
| File[] files = dir.listFiles(); |
| @@ -321,8 +338,7 @@ 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. |
| - */ |
| + * this process if they call setMandatoryPaksToExtract with a single empty String */ |
|
benm (inactive)
2014/02/20 14:13:07
nit: add back the period, and */ onto the next lin
|
| private static boolean shouldSkipPakExtraction() { |
| // Must call setMandatoryPaksToExtract before beginning resource extraction. |
| assert sMandatoryPaks != null; |