OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.preferences.datareduction; | 5 package org.chromium.chrome.browser.preferences.datareduction; |
6 | 6 |
7 import org.chromium.base.ContextUtils; | 7 import org.chromium.base.ContextUtils; |
8 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; | 8 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; |
9 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 9 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
10 import org.chromium.chrome.browser.preferences.PrefServiceBridge.AboutVersionStr ings; | 10 import org.chromium.chrome.browser.preferences.PrefServiceBridge.AboutVersionStr ings; |
(...skipping 18 matching lines...) Expand all Loading... | |
29 | 29 |
30 /** | 30 /** |
31 * Keys used to save whether the infobar promo is shown and the Chrome versi on it was shown in. | 31 * Keys used to save whether the infobar promo is shown and the Chrome versi on it was shown in. |
32 */ | 32 */ |
33 private static final String SHARED_PREF_DISPLAYED_INFOBAR_PROMO = | 33 private static final String SHARED_PREF_DISPLAYED_INFOBAR_PROMO = |
34 "displayed_data_reduction_infobar_promo"; | 34 "displayed_data_reduction_infobar_promo"; |
35 private static final String SHARED_PREF_DISPLAYED_INFOBAR_PROMO_VERSION = | 35 private static final String SHARED_PREF_DISPLAYED_INFOBAR_PROMO_VERSION = |
36 "displayed_data_reduction_infobar_promo_version"; | 36 "displayed_data_reduction_infobar_promo_version"; |
37 | 37 |
38 /** | 38 /** |
39 * Keys used to save the content length when the snackbar promo is shown and save if the user | |
40 * has set the content length on the first upgrade or install to the version that shows the | |
41 * 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
| |
42 */ | |
43 private static final String SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_CONTENT_LEN GTH = | |
44 "displayed_data_reduction_snackbar_promo_content_length"; | |
45 private static final String SHARED_PREF_SNACKBAR_PROMO_INIT_WITH_STARTING_CO NTENT_LENGTH = | |
46 "data_reduction_snackbar_promo_init_with_starting_content_length"; | |
47 | |
48 /** | |
39 * Returns whether any of the data reduction proxy promotions can be display ed. Checks if the | 49 * Returns whether any of the data reduction proxy promotions can be display ed. Checks if the |
40 * proxy is allowed by the DataReductionProxyConfig, already on, or if the u ser is managed. If | 50 * proxy is allowed by the DataReductionProxyConfig, already on, or if the u ser is managed. If |
41 * the data reduction proxy is managed by an administrator's policy, the use r should not be | 51 * the data reduction proxy is managed by an administrator's policy, the use r should not be |
42 * given a promotion to enable it. | 52 * given a promotion to enable it. |
43 * | 53 * |
44 * @return Whether the any data reduction proxy promotion has been displayed . | 54 * @return Whether the any data reduction proxy promotion has been displayed . |
45 */ | 55 */ |
46 public static boolean canShowPromos() { | 56 public static boolean canShowPromos() { |
47 if (!DataReductionProxySettings.getInstance().isDataReductionProxyPromoA llowed()) { | 57 if (!DataReductionProxySettings.getInstance().isDataReductionProxyPromoA llowed()) { |
48 return false; | 58 return false; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 | 142 |
133 /** | 143 /** |
134 * Returns whether the data reduction proxy infobar promo has been displayed before. | 144 * Returns whether the data reduction proxy infobar promo has been displayed before. |
135 * | 145 * |
136 * @return Whether the data reduction proxy infobar promo has been displayed . | 146 * @return Whether the data reduction proxy infobar promo has been displayed . |
137 */ | 147 */ |
138 public static boolean getDisplayedInfoBarPromo() { | 148 public static boolean getDisplayedInfoBarPromo() { |
139 return ContextUtils.getAppSharedPreferences().getBoolean( | 149 return ContextUtils.getAppSharedPreferences().getBoolean( |
140 SHARED_PREF_DISPLAYED_INFOBAR_PROMO, false); | 150 SHARED_PREF_DISPLAYED_INFOBAR_PROMO, false); |
141 } | 151 } |
152 | |
153 /** | |
154 * Saves a shared pref indicating the content length when the last the snack bar 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.
| |
155 * displayed. | |
156 */ | |
157 public static void saveSnackbarPromoDisplayed(long contentLength) { | |
158 ContextUtils.getAppSharedPreferences() | |
159 .edit() | |
160 .putLong(SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_CONTENT_LENGTH, co ntentLength) | |
161 .apply(); | |
162 } | |
163 | |
164 /** | |
165 * Returns the content length from when the last data snackbar promo was dis played. If the promo | |
166 * 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.
| |
167 * | |
168 * @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.
| |
169 */ | |
170 public static long getDisplayedSnackbarPromoContentLength() { | |
171 return ContextUtils.getAppSharedPreferences().getLong( | |
172 SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_CONTENT_LENGTH, -1); | |
173 } | |
174 | |
175 /** | |
176 * Saves a shared pref indicating the content length on the first upgrade or install to the | |
177 * version that shows the snackbar. Also, saves a boolean indicating that th e content length has | |
178 * been initialized. | |
179 */ | |
180 public static void saveSnackbarPromoInitWithStartingContentLength(long conte ntLength) { | |
181 ContextUtils.getAppSharedPreferences() | |
182 .edit() | |
183 .putBoolean(SHARED_PREF_SNACKBAR_PROMO_INIT_WITH_STARTING_CONTEN T_LENGTH, true) | |
184 .putLong(SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_CONTENT_LENGTH, co ntentLength) | |
185 .apply(); | |
186 } | |
187 | |
188 /** | |
189 * Returns a boolean indicating that the content length on the first upgrade or install to the | |
190 * version that shows the snackbar has been initialized. | |
191 * | |
192 * @return Whether that the starting content length has been initialized. | |
193 */ | |
194 public static boolean hasSnackbarPromoBeenInitWithStartingContentLength() { | |
195 return ContextUtils.getAppSharedPreferences().getBoolean( | |
196 SHARED_PREF_SNACKBAR_PROMO_INIT_WITH_STARTING_CONTENT_LENGTH, fa lse); | |
197 } | |
142 } | 198 } |
OLD | NEW |