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

Unified Diff: components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java

Issue 1437833004: Implemented clearing Java prefs after pulling variations first run seed from Java to C++ side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged with CL 1437833002 + fixed some code review comments Created 5 years, 1 month 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: components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java
diff --git a/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java b/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java
index 3af546bf3bf62115b4ff37c4ff207f4c58f6a54d..b6abf0a8642fe080f2d927699b02e8e48ee83a29 100644
--- a/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java
+++ b/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java
@@ -21,6 +21,8 @@ public final class VariationsSeedBridge {
private static final String VARIATIONS_FIRST_RUN_SEED_BASE64 = "variations_seed_base64";
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 final String VARIATIONS_FIRST_RUN_SEED_NATIVE_STORED =
Alexei Svitkine (slow) 2015/11/12 19:03:22 Add a comment above this.
Alexander Agulenko 2015/11/12 19:50:09 Done.
+ "variations_seed_native_stored";
private static String getVariationsFirstRunSeedPref(Context context, String prefName) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@@ -42,6 +44,38 @@ public final class VariationsSeedBridge {
}
@CalledByNative
+ private static void clearFirstRunPrefs(Context context) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
Alexei Svitkine (slow) 2015/11/12 19:03:22 Nit: Inline this into the line below, given you on
Alexander Agulenko 2015/11/12 19:50:09 Done.
+ prefs.edit()
+ .remove(VARIATIONS_FIRST_RUN_SEED_BASE64)
+ .remove(VARIATIONS_FIRST_RUN_SEED_SIGNATURE)
+ .remove(VARIATIONS_FIRST_RUN_SEED_COUNTRY)
+ .apply();
+ }
+
+ /**
+ * Returns the status of the variations first run fetch: was it successful or not.
+ */
+ public static boolean hasJavaPref(Context context) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ return !prefs.getString(VARIATIONS_FIRST_RUN_SEED_BASE64, "").equals("");
Alexei Svitkine (slow) 2015/11/12 19:03:22 equals("") -> isEmpty()
Alexander Agulenko 2015/11/12 19:50:09 Done.
+ }
+
+ /**
+ * Returns the status of the variations first run fetch: was it successful or not.
Alexei Svitkine (slow) 2015/11/12 19:03:22 Fix comments. Right now the two functions have the
Alexander Agulenko 2015/11/12 19:50:09 Done.
+ */
+ public static boolean hasNativePref(Context context) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ return prefs.getBoolean(VARIATIONS_FIRST_RUN_SEED_NATIVE_STORED, false);
+ }
+
+ @CalledByNative
+ private static void markVariationsSeedAsStored(Context context) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ prefs.edit().putBoolean(VARIATIONS_FIRST_RUN_SEED_NATIVE_STORED, true).apply();
+ }
+
+ @CalledByNative
private static byte[] getVariationsFirstRunSeedData(Context context) {
return Base64.decode(
getVariationsFirstRunSeedPref(context, VARIATIONS_FIRST_RUN_SEED_BASE64),

Powered by Google App Engine
This is Rietveld 408576698