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..14780a88dd62922b003bd4114ac0a9cd0998a704 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,17 +313,25 @@ public class ResourceExtractor { |
| mExtractTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
| } |
| + public static File getAppDataDirFromContext(Context context) { |
| + return new File(PathUtils.getDataDirectory(context.getApplicationContext())); |
| + } |
| + |
| 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.e(LOGTAG, "Unable to remove the icudata " + icudata.getName()); |
|
Andrew Hayden (chromium.org)
2014/02/25 13:52:56
Thanks for adding this. Can we add a comment in he
|
| + } |
| File dir = getOutputDirFromContext(context); |
| if (dir.exists()) { |
| File[] files = dir.listFiles(); |
| for (File file : files) { |
| if (!file.delete()) { |
| - Log.w(LOGTAG, "Unable to remove existing resource " + file.getName()); |
| + Log.e(LOGTAG, "Unable to remove existing resource " + file.getName()); |
| } |
| } |
| } |