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..4512acf60883976f4734f6aa76544d18f9745c5d 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 |
| @@ -36,6 +36,16 @@ public class DataReductionPromoUtils { |
| "displayed_data_reduction_infobar_promo_version"; |
| /** |
| + * Keys used to save the content length when the snackbar promo is shown and save if the user |
| + * has set the content length on the first upgrade or install to the version that shows the |
| + * snackbar. |
|
gone
2016/10/13 01:03:11
Can you clean this sentence up a bit? It's repeat
megjablon
2016/10/24 23:59:00
Done.
Yes. Added a comment. If the finch config s
|
| + */ |
| + private static final String SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_CONTENT_LENGTH = |
| + "displayed_data_reduction_snackbar_promo_content_length"; |
| + private static final String SHARED_PREF_SNACKBAR_PROMO_INIT_WITH_STARTING_CONTENT_LENGTH = |
| + "data_reduction_snackbar_promo_init_with_starting_content_length"; |
| + |
| + /** |
| * Returns whether any of the data reduction proxy promotions can be displayed. Checks if the |
| * proxy is allowed by the DataReductionProxyConfig, already on, or if the user is managed. If |
| * the data reduction proxy is managed by an administrator's policy, the user should not be |
| @@ -139,4 +149,50 @@ public class DataReductionPromoUtils { |
| return ContextUtils.getAppSharedPreferences().getBoolean( |
| SHARED_PREF_DISPLAYED_INFOBAR_PROMO, false); |
| } |
| + |
| + /** |
| + * Saves a shared pref indicating the content length when the last the snackbar promo was |
|
gone
2016/10/13 01:03:11
the last the
You might as well just flesh out the
megjablon
2016/10/24 23:59:00
Done.
|
| + * displayed. |
| + */ |
| + public static void saveSnackbarPromoDisplayed(long contentLength) { |
| + ContextUtils.getAppSharedPreferences() |
| + .edit() |
| + .putLong(SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_CONTENT_LENGTH, contentLength) |
| + .apply(); |
| + } |
| + |
| + /** |
| + * Returns the content length from when the last data snackbar promo was displayed. If the promo |
| + * has not been displayed before, returns -1, |
|
gone
2016/10/13 01:03:11
Maybe
/**
* Returns the content length from when
megjablon
2016/10/24 23:59:00
Done.
|
| + * |
| + * @return The content length when the last the snackbar promo was displayed. |
|
gone
2016/10/13 01:03:11
the last the
megjablon
2016/10/24 23:59:00
Done.
|
| + */ |
| + public static long getDisplayedSnackbarPromoContentLength() { |
| + return ContextUtils.getAppSharedPreferences().getLong( |
| + SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_CONTENT_LENGTH, -1); |
| + } |
| + |
| + /** |
| + * Saves a shared pref indicating the content length on the first upgrade or install to the |
| + * version that shows the snackbar. Also, saves a boolean indicating that the content length has |
| + * been initialized. |
| + */ |
| + public static void saveSnackbarPromoInitWithStartingContentLength(long contentLength) { |
| + ContextUtils.getAppSharedPreferences() |
| + .edit() |
| + .putBoolean(SHARED_PREF_SNACKBAR_PROMO_INIT_WITH_STARTING_CONTENT_LENGTH, true) |
| + .putLong(SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_CONTENT_LENGTH, contentLength) |
| + .apply(); |
| + } |
| + |
| + /** |
| + * Returns a boolean indicating that the content length on the first upgrade or install to the |
| + * version that shows the snackbar has been initialized. |
| + * |
| + * @return Whether that the starting content length has been initialized. |
| + */ |
| + public static boolean hasSnackbarPromoBeenInitWithStartingContentLength() { |
| + return ContextUtils.getAppSharedPreferences().getBoolean( |
| + SHARED_PREF_SNACKBAR_PROMO_INIT_WITH_STARTING_CONTENT_LENGTH, false); |
| + } |
| } |