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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ChromeApplication.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/ChromeApplication.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeApplication.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeApplication.java
index 97036ba16a815a38a3241128411918fcbcc0d682..9d0cc5792c5af61487f7151f3a5d1915e94ecfcf 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeApplication.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeApplication.java
@@ -12,7 +12,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
-import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
@@ -27,6 +26,7 @@ import org.chromium.base.ApplicationStatus.ApplicationStateListener;
import org.chromium.base.BuildInfo;
import org.chromium.base.CommandLine;
import org.chromium.base.CommandLineInitUtil;
+import org.chromium.base.ContextUtils;
import org.chromium.base.ResourceExtractor;
import org.chromium.base.ThreadUtils;
import org.chromium.base.TraceEvent;
@@ -206,6 +206,8 @@ public class ChromeApplication extends ContentApplication {
public void onCreate() {
UmaUtils.recordMainEntryPointTime();
super.onCreate();
+ ContextUtils.initApplicationContext(this);
+
UiUtils.setKeyboardShowingDelegate(new UiUtils.KeyboardShowingDelegate() {
@Override
public boolean disableKeyboardCheck(Context context, View view) {
@@ -596,7 +598,7 @@ public class ChromeApplication extends ContentApplication {
*/
protected void removeSessionCookies() {
long lastKnownBootTimestamp =
- PreferenceManager.getDefaultSharedPreferences(this).getLong(PREF_BOOT_TIMESTAMP, 0);
+ ContextUtils.getAppSharedPreferences().getLong(PREF_BOOT_TIMESTAMP, 0);
long bootTimestamp = System.currentTimeMillis() - SystemClock.uptimeMillis();
long difference = bootTimestamp - lastKnownBootTimestamp;
@@ -604,7 +606,7 @@ public class ChromeApplication extends ContentApplication {
if (Math.abs(difference) > BOOT_TIMESTAMP_MARGIN_MS) {
nativeRemoveSessionCookies();
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = prefs.edit();
editor.putLong(PREF_BOOT_TIMESTAMP, bootTimestamp);
editor.apply();
@@ -815,11 +817,11 @@ public class ChromeApplication extends ContentApplication {
}
private boolean hasLocaleChanged(String newLocale) {
- String previousLocale = PreferenceManager.getDefaultSharedPreferences(this).getString(
+ String previousLocale = ContextUtils.getAppSharedPreferences().getString(
PREF_LOCALE, "");
if (!previousLocale.equals(newLocale)) {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = prefs.edit();
editor.putString(PREF_LOCALE, newLocale);
editor.apply();

Powered by Google App Engine
This is Rietveld 408576698