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..f4142be5f6b87f200dd40c07733ed7e06999b38c 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 |
@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.preferences; |
import android.content.Context; |
import android.content.SharedPreferences; |
import android.preference.PreferenceManager; |
+import android.util.Base64; |
import android.util.Log; |
import org.chromium.base.ThreadUtils; |
@@ -219,6 +220,46 @@ public final class PrefServiceBridge { |
} |
} |
+ // TODO(agulenko): Move this piece of code to a separate class. |
newt (away)
2015/11/04 18:10:43
Please remember to do this soon (put it on your pe
Alexander Agulenko
2015/11/05 00:44:21
Acknowledged.
|
+ |
+ private static final String VARIATIONS_FIRST_RUN_SEED = "variations_seed"; |
+ private static final String VARIATIONS_FIRST_RUN_SEED_SIGNATURE = "variations_seed_signature"; |
+ private static final String VARIATIONS_FIRST_RUN_SEED_COUNTRY = "variations_seed_country"; |
+ |
+ private static String getVariationsFirstRunSeedPref(Context context, String prefName) { |
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
+ return prefs.getString(prefName, new String()); |
newt (away)
2015/11/04 18:10:43
s/new String()/""/
(no need to allocate a new Str
Alexander Agulenko
2015/11/05 00:44:22
Done.
|
+ } |
+ |
+ private static void setVariationsFirstRunSeedPref( |
+ Context context, String prefName, String data) { |
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
+ prefs.edit().putString(prefName, data).apply(); |
+ } |
+ |
+ public static void setVariationsFirstRunSeed( |
+ Context context, byte[] rawSeed, String signature, String country) { |
+ setVariationsFirstRunSeedPref( |
newt (away)
2015/11/04 18:10:43
write this as:
SharedPreferences prefs = Prefer
Alexander Agulenko
2015/11/05 00:44:22
Done.
|
+ context, VARIATIONS_FIRST_RUN_SEED, Base64.encodeToString(rawSeed, Base64.NO_WRAP)); |
+ setVariationsFirstRunSeedPref(context, VARIATIONS_FIRST_RUN_SEED_SIGNATURE, signature); |
+ setVariationsFirstRunSeedPref(context, VARIATIONS_FIRST_RUN_SEED_COUNTRY, country); |
+ } |
+ |
+ @CalledByNative |
+ private static String getVariationsFirstRunSeedData(Context context) { |
newt (away)
2015/11/04 18:10:43
Do the base64 decoding here (in Java), and change
Alexander Agulenko
2015/11/05 00:44:22
Done.
|
+ return getVariationsFirstRunSeedPref(context, VARIATIONS_FIRST_RUN_SEED); |
+ } |
+ |
+ @CalledByNative |
+ private static String getVariationsFirstRunSeedSignature(Context context) { |
+ return getVariationsFirstRunSeedPref(context, VARIATIONS_FIRST_RUN_SEED_SIGNATURE); |
+ } |
+ |
+ @CalledByNative |
+ private static String getVariationsFirstRunSeedCountry(Context context) { |
+ return getVariationsFirstRunSeedPref(context, VARIATIONS_FIRST_RUN_SEED_COUNTRY); |
+ } |
+ |
public boolean isAcceptCookiesEnabled() { |
return nativeGetAcceptCookiesEnabled(); |
} |