Commit dc4af251 authored by Henrique Nakashima's avatar Henrique Nakashima Committed by Commit Bot

Move a SharedPref from ProfileManagerUtils to ChromePreferenceKeys

Register it in ChromePreferenceKeys and use SharedPreferencesManager
consistently instead of SharedPreferences directly.

Bug: 1022108
Change-Id: I809b408ce2d18a725cacfa876b7c906f471e6d2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2028122Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738571}
parent d7ce9650
......@@ -11,6 +11,7 @@ android_library("java") {
"//base:base_java",
"//base:jni_java",
"//chrome/android/public/crypto:java",
"//chrome/browser/preferences:java",
"//content/public/android:content_java",
]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
......
......@@ -4,20 +4,17 @@
package org.chromium.chrome.browser.profiles;
import android.content.SharedPreferences;
import android.os.SystemClock;
import org.chromium.base.ContextUtils;
import org.chromium.base.TraceEvent;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chrome.browser.preferences.ChromePreferenceKeys;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
/**
* A utility class for applying operations on all loaded profiles.
*/
public class ProfileManagerUtils {
// "ChromeMobileApplication" is a relic kept for backward compatibility.
private static final String PREF_BOOT_TIMESTAMP =
"com.google.android.apps.chrome.ChromeMobileApplication.BOOT_TIMESTAMP";
private static final long BOOT_TIMESTAMP_MARGIN_MS = 1000;
/**
......@@ -41,8 +38,9 @@ public class ProfileManagerUtils {
* since the updated timestamp is immediately saved.
*/
public static void removeSessionCookiesForAllProfiles() {
SharedPreferencesManager preferences = SharedPreferencesManager.getInstance();
long lastKnownBootTimestamp =
ContextUtils.getAppSharedPreferences().getLong(PREF_BOOT_TIMESTAMP, 0);
preferences.readLong(ChromePreferenceKeys.PROFILES_BOOT_TIMESTAMP, 0);
long bootTimestamp = System.currentTimeMillis() - SystemClock.uptimeMillis();
long difference = bootTimestamp - lastKnownBootTimestamp;
......@@ -50,10 +48,7 @@ public class ProfileManagerUtils {
if (Math.abs(difference) > BOOT_TIMESTAMP_MARGIN_MS) {
ProfileManagerUtilsJni.get().removeSessionCookiesForAllProfiles();
SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = prefs.edit();
editor.putLong(PREF_BOOT_TIMESTAMP, bootTimestamp);
editor.apply();
preferences.writeLong(ChromePreferenceKeys.PROFILES_BOOT_TIMESTAMP, bootTimestamp);
}
}
......
......@@ -483,6 +483,9 @@ public final class ChromePreferenceKeys {
public static final String PRIVACY_BANDWIDTH_NO_CELLULAR_OLD = "prefetch_bandwidth_no_cellular";
public static final String PRIVACY_ALLOW_PRERENDER_OLD = "allow_prefetch";
public static final String PROFILES_BOOT_TIMESTAMP =
"com.google.android.apps.chrome.ChromeMobileApplication.BOOT_TIMESTAMP";
/**
* Key to cache the enabled bottom toolbar parameter.
*/
......@@ -863,6 +866,7 @@ public final class ChromePreferenceKeys {
PRIVACY_METRICS_IN_SAMPLE,
PRIVACY_METRICS_REPORTING,
PRIVACY_NETWORK_PREDICTIONS,
PROFILES_BOOT_TIMESTAMP,
PROMOS_SKIPPED_ON_FIRST_START,
REACHED_CODE_PROFILER_GROUP,
RLZ_NOTIFIED,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment