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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java

Issue 1874423002: 🍰 Migrate app shared preferences to ContextUtils. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 7 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/physicalweb/UrlManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java
index 5ac519cdd00144b96a6f40116a074ebb3d51d270..fddafeded1efb5b1a42c07a7f995ed150d550195 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java
@@ -18,9 +18,9 @@ import android.os.AsyncTask;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
-import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
+import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.ObserverList;
import org.chromium.base.VisibleForTesting;
@@ -29,7 +29,6 @@ import org.chromium.chrome.browser.ChromeApplication;
import org.chromium.chrome.browser.notifications.NotificationConstants;
import org.chromium.chrome.browser.notifications.NotificationManagerProxy;
import org.chromium.chrome.browser.notifications.NotificationManagerProxyImpl;
-
import org.json.JSONException;
import org.json.JSONObject;
@@ -284,7 +283,7 @@ class UrlManager {
}
private void initSharedPreferences() {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
+ SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
int prefsVersion = prefs.getInt(PREFS_VERSION_KEY, 0);
// Check the version.
@@ -308,7 +307,7 @@ class UrlManager {
private List<UrlInfo> getUrlInfoListFromSharedPreferences(String preferenceName) {
// Check the version.
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
+ SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
List<UrlInfo> urls = new ArrayList<>();
for (String serializedUrl : prefs.getStringSet(preferenceName, new HashSet<String>())) {
try {
@@ -331,8 +330,7 @@ class UrlManager {
}
}
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
- SharedPreferences.Editor editor = prefs.edit();
+ SharedPreferences.Editor editor = ContextUtils.getAppSharedPreferences().edit();
editor.putStringSet(preferenceName, serializedUrls);
editor.apply();
}
@@ -396,7 +394,7 @@ class UrlManager {
* @return the elapsed realtime since the most recent notification update.
*/
public long getTimeSinceNotificationUpdate() {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
+ SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
long timestamp = prefs.getLong(PREFS_NOTIFICATION_UPDATE_TIMESTAMP, 0);
return SystemClock.elapsedRealtime() - timestamp;
}
@@ -405,7 +403,7 @@ class UrlManager {
// Record a timestamp.
// This is useful for tracking whether a notification is pressed soon after an update or
// much later.
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
+ SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = prefs.edit();
editor.putLong(PREFS_NOTIFICATION_UPDATE_TIMESTAMP, SystemClock.elapsedRealtime());
editor.apply();
@@ -542,7 +540,7 @@ class UrlManager {
@VisibleForTesting
static void clearPrefsForTesting(Context context) {
- PreferenceManager.getDefaultSharedPreferences(context).edit()
+ ContextUtils.getAppSharedPreferences().edit()
.remove(PREFS_VERSION_KEY)
.remove(PREFS_NEARBY_URLS_KEY)
.remove(PREFS_RESOLVED_URLS_KEY)

Powered by Google App Engine
This is Rietveld 408576698