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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java

Issue 1329083002: Clear webapp storage when site data is cleared (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add initial tests and fix compile Created 5 years, 3 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/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
index 37511a3ccab40c6e2f30e3e24c989cb5a3750a48..29997473d5400c2784dd53e634c167872fdd7132 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
@@ -79,6 +79,18 @@ public class WebappDataStorage {
}
/**
+ * Deletes the data for a webapp by clearing all the information inside the SharedPreference
+ * file. This does NOT delete the file itself but the file is left empty.
+ * NOTE: Package private for use by WebappRegistry
gone 2015/09/08 20:38:13 nit: Remove the NOTE since it's useful. Saying wh
Lalit Maganti 2015/09/09 15:27:46 Done.
+ * @param context The context to read the SharedPreferences file.
+ * @param webappId The ID of the webapp being deleted.
+ */
+ static void delete(final Context context, final String webappId) {
gone 2015/09/08 20:38:13 delete is too vague. Sounds like you're deleting
Lalit Maganti 2015/09/09 15:27:46 Done.
+ assert !ThreadUtils.runningOnUiThread();
+ openSharedPreferences(context, webappId).edit().clear().commit();
+ }
+
+ /**
* Sets the factory used to generate WebappDataStorage objects.
*/
@VisibleForTesting
@@ -86,11 +98,15 @@ public class WebappDataStorage {
sFactory = factory;
}
- protected WebappDataStorage(Context context, String webappId) {
- mPreferences = context.getApplicationContext().getSharedPreferences(
+ private static SharedPreferences openSharedPreferences(Context context, String webappId) {
+ return context.getApplicationContext().getSharedPreferences(
SHARED_PREFS_FILE_PREFIX + webappId, Context.MODE_PRIVATE);
}
+ protected WebappDataStorage(Context context, String webappId) {
+ mPreferences = openSharedPreferences(context, webappId);
+ }
+
/*
* Asynchronously retrieves the splash screen image associated with the
* current web app.

Powered by Google App Engine
This is Rietveld 408576698