Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java |
index c5c1564f934cc2c01e0cd420b0881b04861c3966..5d0e4f2f08863733cd050a5fcf8df6b759bef229 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java |
@@ -219,6 +219,42 @@ public final class PrefServiceBridge { |
} |
} |
+ public static final String VARIATIONS_FIRST_RUN_SEED_SIGNATURE = "variations_seed_signature"; |
Alexei Svitkine (slow)
2015/10/29 15:04:12
See Bernhard's suggestion about having a new class
newt (away)
2015/10/30 00:46:36
Yes, please pull this out into a separate class. P
Alexander Agulenko
2015/11/02 22:55:33
Acknowledged.
Bernhard Bauer
2015/11/03 09:44:49
^^^
Bernhard Bauer
2015/11/03 09:45:22
(Or at the very least add a TODO.)
Alexander Agulenko
2015/11/04 08:00:58
Acknowledged.
|
+ public static final String VARIATIONS_FIRST_RUN_SEED_COUNTRY = "variations_seed_country"; |
+ |
+ public static String getVariationsFirstRunSeedPref(Context context, String prefName) { |
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
+ return prefs.getString(prefName, new String()); |
+ } |
+ |
+ public static void setVariationsFirstRunSeedPref( |
+ Context context, String prefName, String data) { |
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
+ prefs.edit().remove(prefName).apply(); |
newt (away)
2015/10/30 00:46:36
There's no need to call remove(). The next line wi
Alexander Agulenko
2015/11/02 22:55:33
Done.
|
+ prefs.edit().putString(prefName, data).apply(); |
+ } |
+ |
+ private static byte[] sVariationsFirstRunSeedData; |
+ |
+ public static void setVariationsFirstRunSeedData(Context context, byte[] rawSeed) { |
+ sVariationsFirstRunSeedData = rawSeed; |
Steven Holte
2015/10/29 21:26:56
Actually, I'm a bit confused here about why we are
newt (away)
2015/10/30 00:46:36
statics should rarely be used in Java. They're glo
Bernhard Bauer
2015/10/30 09:56:08
In addition, what if Chrome is killed _before_ thi
Bernhard Bauer
2015/11/03 09:44:49
^^^
Alexei Svitkine (slow)
2015/11/03 18:44:01
I think we should store the three things in the sa
Alexander Agulenko
2015/11/04 08:00:58
Done.
|
+ } |
+ |
+ @CalledByNative |
+ public static byte[] getVariationsFirstRunSeedData(Context context) { |
newt (away)
2015/10/30 00:46:36
These methods can be private since they're only ca
Alexander Agulenko
2015/11/02 22:55:33
Done.
|
+ return sVariationsFirstRunSeedData; |
+ } |
+ |
+ @CalledByNative |
+ public static String getVariationsFirstRunSeedSignature(Context context) { |
+ return getVariationsFirstRunSeedPref(context, VARIATIONS_FIRST_RUN_SEED_SIGNATURE); |
+ } |
+ |
+ @CalledByNative |
+ public static String getVariationsFirstRunSeedCountry(Context context) { |
+ return getVariationsFirstRunSeedPref(context, VARIATIONS_FIRST_RUN_SEED_COUNTRY); |
+ } |
+ |
public boolean isAcceptCookiesEnabled() { |
return nativeGetAcceptCookiesEnabled(); |
} |