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..51c7d43e09c8c218e3886ede867a2baad2ce12d8 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,32 @@ 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"); |
} |
+ /** |
+ * Pak files (UI strings and other resources) should be updated along with |
+ * Chrome. A version mismatch can lead to a rather broken user experience. |
+ * The ICU data (icudtl.dat) is less version-sensitive, but still can |
+ * lead to malfunction/UX misbehavior. So, we regard failing to update them |
+ * as an error. |
+ */ |
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()); |
+ } |
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()); |
} |
} |
} |