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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java

Issue 1417503010: Variations seed is pulled from the Java application on the first launch of Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes according to code review and lint comments Created 5 years, 2 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/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();
}

Powered by Google App Engine
This is Rietveld 408576698