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

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

Issue 1417733008: Java code for fetching variations first run seed after receiving chrome.TOS_ACKED broadcast. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fixes: changed comments and removed unused includes and usings 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
new file mode 100644
index 0000000000000000000000000000000000000000..3a02651b21ab86be70a891139f7dd254c35c3f24
--- /dev/null
+++ b/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java
@@ -0,0 +1,61 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.components.variations.firstrun;
newt (away) 2015/11/06 18:27:14 firstrun could be a confusing package name to othe
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+import android.util.Base64;
+
+import org.chromium.base.annotations.CalledByNative;
+
+/**
+ * VariationsSeedBridge is a class which used to pass variations first run seed that was fetched
+ * before the
Alexei Svitkine (slow) 2015/11/06 16:17:55 Nit: Wrapping is off.
Alexander Agulenko 2015/11/06 19:54:37 Done.
+ * actual Chrome first run to Chromium core. Class provides implementation of methods to store the
newt (away) 2015/11/06 18:27:14 nit: remove "implementation of"
Alexander Agulenko 2015/11/06 19:54:37 Done.
+ * seed in
+ * SharedPreferences and to get the seed from there. To store raw seed data class serializes byte[]
+ * to
+ * Base64 encoded string and decodes this string before passing to C++ side.
+ */
+
Alexei Svitkine (slow) 2015/11/06 16:17:55 Nit: Remove empty line.
Alexander Agulenko 2015/11/06 19:54:37 Done.
+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 String getVariationsFirstRunSeedPref(Context context, String prefName) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ return prefs.getString(prefName, "");
+ }
+
+ public static void setVariationsFirstRunSeed(
newt (away) 2015/11/06 18:27:14 javadoc for public methods
Alexander Agulenko 2015/11/06 19:54:37 Done.
+ Context context, byte[] rawSeed, String signature, String country) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ prefs.edit()
+ .putString(VARIATIONS_FIRST_RUN_SEED_BASE64,
+ Base64.encodeToString(rawSeed, Base64.NO_WRAP))
+ .putString(VARIATIONS_FIRST_RUN_SEED_SIGNATURE, signature)
+ .putString(VARIATIONS_FIRST_RUN_SEED_COUNTRY, country)
+ .apply();
+ }
+
+ @CalledByNative
+ private static byte[] getVariationsFirstRunSeedData(Context context) {
+ return Base64.decode(
+ getVariationsFirstRunSeedPref(context, VARIATIONS_FIRST_RUN_SEED_BASE64),
+ Base64.NO_WRAP);
+ }
+
+ @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);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698