Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoUtils.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoUtils.java |
| index 9866be882a9f1184963f5c2582fb6c23685b9c5f..c6a2c8824ae9160714c3d5c04b343b75497e4131 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoUtils.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoUtils.java |
| @@ -15,25 +15,41 @@ import org.chromium.chrome.browser.preferences.PrefServiceBridge.AboutVersionStr |
| */ |
| public class DataReductionPromoUtils { |
| /** |
| - * Keys used to save whether the first run experience or second run promo screen has been shown, |
| - * the time in milliseconds since epoch it was shown, the Chrome version it was shown in, and |
| - * whether the user opted out of the data reduction proxy in the FRE promo. |
| + * Key used to save whether the first run experience or second run promo screen has been shown. |
| */ |
| private static final String SHARED_PREF_DISPLAYED_FRE_OR_SECOND_RUN_PROMO = |
| "displayed_data_reduction_promo"; |
| + /** |
| + * Key used to save the time in milliseconds since epoch that the first run experience or second |
| + * run promo was shown. |
| + */ |
| private static final String SHARED_PREF_DISPLAYED_FRE_OR_SECOND_PROMO_TIME_MS = |
| "displayed_data_reduction_promo_time_ms"; |
| + /** |
| + * Key used to save the Chrome version the first run experience or second run promo was shown |
| + * in. |
| + */ |
| private static final String SHARED_PREF_DISPLAYED_FRE_OR_SECOND_PROMO_VERSION = |
| "displayed_data_reduction_promo_version"; |
| + /** |
| + * Key used to save whether the user opted out of the data reduction proxy in the FRE promo. |
| + */ |
| private static final String SHARED_PREF_FRE_PROMO_OPT_OUT = "fre_promo_opt_out"; |
| - |
| /** |
| - * Keys used to save whether the infobar promo is shown and the Chrome version it was shown in. |
| + * Key used to save whether the infobar promo has been shown. |
| */ |
| private static final String SHARED_PREF_DISPLAYED_INFOBAR_PROMO = |
| "displayed_data_reduction_infobar_promo"; |
| + /** |
| + * Key used to save the Chrome version the infobar promo was shown in. |
| + */ |
| private static final String SHARED_PREF_DISPLAYED_INFOBAR_PROMO_VERSION = |
| "displayed_data_reduction_infobar_promo_version"; |
| + /** |
| + * Key used to save the saved bytes when the snackbar promo was last shown. |
| + */ |
| + private static final String SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_SAVED_BYTES = |
| + "displayed_data_reduction_snackbar_promo_saved_bytes"; |
| /** |
| * Returns whether any of the data reduction proxy promotions can be displayed. Checks if the |
| @@ -139,4 +155,44 @@ public class DataReductionPromoUtils { |
| return ContextUtils.getAppSharedPreferences().getBoolean( |
| SHARED_PREF_DISPLAYED_INFOBAR_PROMO, false); |
| } |
| + |
| + /** See {@link #SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_SAVED_BYTES}. */ |
| + public static void saveSnackbarPromoDisplayed(long dataSavingInBytes) { |
| + ContextUtils.getAppSharedPreferences() |
| + .edit() |
| + .putLong(SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_SAVED_BYTES, dataSavingInBytes) |
| + .apply(); |
| + } |
| + |
| + /** |
| + * Returns the data saving in bytes from when the promo snackbar was last displayed. |
| + * |
| + * @return The content length, or -1 if the promo has not been displayed before. |
|
tbansal1
2016/10/26 00:09:30
nit: "The content length"
update the comment.
megjablon
2016/10/26 18:22:57
Done.
|
| + */ |
| + public static long getDisplayedSnackbarPromoSavedBytes() { |
| + return ContextUtils.getAppSharedPreferences().getLong( |
| + SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_SAVED_BYTES, -1); |
| + } |
| + |
| + /** |
| + * Saves a shared pref indicating the data saving in bytes on the first upgrade to the version |
| + * that shows the snackbar. |
| + */ |
| + public static void saveSnackbarPromoInitWithStartingSavedBytes(long dataSavingInBytes) { |
| + ContextUtils.getAppSharedPreferences() |
| + .edit() |
| + .putLong(SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_SAVED_BYTES, dataSavingInBytes) |
| + .apply(); |
| + } |
| + |
| + /** |
| + * Returns a boolean indicating that the data savings in bytes on the first upgrade to the |
| + * version that shows the snackbar has been initialized. |
| + * |
| + * @return Whether that the starting saved bytes have been initialized. |
| + */ |
| + public static boolean hasSnackbarPromoBeenInitWithStartingSavedBytes() { |
| + return ContextUtils.getAppSharedPreferences() |
| + .contains(SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_SAVED_BYTES); |
| + } |
| } |