OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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; | 5 package org.chromium.chrome.browser.preferences; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.SharedPreferences; | 8 import android.content.SharedPreferences; |
9 | 9 |
10 import org.chromium.base.ContextUtils; | 10 import org.chromium.base.ContextUtils; |
(...skipping 18 matching lines...) Expand all Loading... |
29 private static final String PREF_WEBSITE_SETTINGS_FILTER = "website_settings
_filter"; | 29 private static final String PREF_WEBSITE_SETTINGS_FILTER = "website_settings
_filter"; |
30 private static final String CONTEXTUAL_SEARCH_PROMO_OPEN_COUNT = | 30 private static final String CONTEXTUAL_SEARCH_PROMO_OPEN_COUNT = |
31 "contextual_search_promo_open_count"; | 31 "contextual_search_promo_open_count"; |
32 private static final String CONTEXTUAL_SEARCH_TAP_TRIGGERED_PROMO_COUNT = | 32 private static final String CONTEXTUAL_SEARCH_TAP_TRIGGERED_PROMO_COUNT = |
33 "contextual_search_tap_triggered_promo_count"; | 33 "contextual_search_tap_triggered_promo_count"; |
34 private static final String CONTEXTUAL_SEARCH_TAP_COUNT = "contextual_search
_tap_count"; | 34 private static final String CONTEXTUAL_SEARCH_TAP_COUNT = "contextual_search
_tap_count"; |
35 private static final String CONTEXTUAL_SEARCH_PEEK_PROMO_SHOW_COUNT = | 35 private static final String CONTEXTUAL_SEARCH_PEEK_PROMO_SHOW_COUNT = |
36 "contextual_search_peek_promo_show_count"; | 36 "contextual_search_peek_promo_show_count"; |
37 private static final String CONTEXTUAL_SEARCH_LAST_ANIMATION_TIME = | 37 private static final String CONTEXTUAL_SEARCH_LAST_ANIMATION_TIME = |
38 "contextual_search_last_animation_time"; | 38 "contextual_search_last_animation_time"; |
| 39 private static final String CONTEXTUAL_SEARCH_TAP_QUICK_ANSWER_COUNT = |
| 40 "contextual_search_tap_quick_answer_count"; |
39 private static final String HERB_FLAVOR_KEY = "herb_flavor"; | 41 private static final String HERB_FLAVOR_KEY = "herb_flavor"; |
40 private static final String APP_LINK_KEY = "applink.app_link_enabled"; | 42 private static final String APP_LINK_KEY = "applink.app_link_enabled"; |
41 private static final String CHROME_DEFAULT_BROWSER = "applink.chrome_default
_browser"; | 43 private static final String CHROME_DEFAULT_BROWSER = "applink.chrome_default
_browser"; |
42 | 44 |
43 private static final String SUCCESS_UPLOAD_SUFFIX = "_crash_success_upload"; | 45 private static final String SUCCESS_UPLOAD_SUFFIX = "_crash_success_upload"; |
44 private static final String FAILURE_UPLOAD_SUFFIX = "_crash_failure_upload"; | 46 private static final String FAILURE_UPLOAD_SUFFIX = "_crash_failure_upload"; |
45 | 47 |
46 private static final int SIGNIN_PROMO_CYCLE_IN_DAYS = 120; | 48 private static final int SIGNIN_PROMO_CYCLE_IN_DAYS = 120; |
47 private static final long MILLISECONDS_IN_DAY = 1000 * 60 * 60 * 24; | 49 private static final long MILLISECONDS_IN_DAY = 1000 * 60 * 60 * 24; |
48 | 50 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 * Sets the number of times the promo was triggered to peek by a tap gesture
. | 263 * Sets the number of times the promo was triggered to peek by a tap gesture
. |
262 * Use a negative value to record that the counter has been disabled. | 264 * Use a negative value to record that the counter has been disabled. |
263 * @param count Number of times the promo was triggered by a tap gesture, or
a negative value | 265 * @param count Number of times the promo was triggered by a tap gesture, or
a negative value |
264 * to record that the counter has been disabled. | 266 * to record that the counter has been disabled. |
265 */ | 267 */ |
266 public void setContextualSearchTapTriggeredPromoCount(int count) { | 268 public void setContextualSearchTapTriggeredPromoCount(int count) { |
267 writeInt(CONTEXTUAL_SEARCH_TAP_TRIGGERED_PROMO_COUNT, count); | 269 writeInt(CONTEXTUAL_SEARCH_TAP_TRIGGERED_PROMO_COUNT, count); |
268 } | 270 } |
269 | 271 |
270 /** | 272 /** |
271 * @return Number of tap gestures that have been received when not waiting f
or the promo. | 273 * @return Number of tap gestures that have been received since the last tim
e the panel was |
| 274 * opened. |
272 */ | 275 */ |
273 public int getContextualSearchTapCount() { | 276 public int getContextualSearchTapCount() { |
274 return mSharedPreferences.getInt(CONTEXTUAL_SEARCH_TAP_COUNT, 0); | 277 return mSharedPreferences.getInt(CONTEXTUAL_SEARCH_TAP_COUNT, 0); |
275 } | 278 } |
276 | 279 |
277 /** | 280 /** |
278 * Sets the number of tap gestures that have been received when not waiting
for the promo. | 281 * Sets the number of tap gestures that have been received since the last ti
me the panel was |
279 * @param count Number of taps that have been received when not waiting for
the promo. | 282 * opened. |
| 283 * @param count Number of taps that have been received since the last time t
he panel was opened. |
280 */ | 284 */ |
281 public void setContextualSearchTapCount(int count) { | 285 public void setContextualSearchTapCount(int count) { |
282 writeInt(CONTEXTUAL_SEARCH_TAP_COUNT, count); | 286 writeInt(CONTEXTUAL_SEARCH_TAP_COUNT, count); |
283 } | 287 } |
284 | 288 |
285 /** | 289 /** |
| 290 * @return Number of Tap triggered Quick Answers (that "do answer") that hav
e been shown since |
| 291 * the last time the panel was opened. |
| 292 */ |
| 293 public int getContextualSearchTapQuickAnswerCount() { |
| 294 return mSharedPreferences.getInt(CONTEXTUAL_SEARCH_TAP_QUICK_ANSWER_COUN
T, 0); |
| 295 } |
| 296 |
| 297 /** |
| 298 * Sets the number of tap triggered Quick Answers (that "do answer") that ha
ve been shown since |
| 299 * the last time the panel was opened. |
| 300 * @param count Number of Tap triggered Quick Answers (that "do answer") tha
t have been shown |
| 301 * since the last time the panel was opened. |
| 302 */ |
| 303 public void setContextualSearchTapQuickAnswerCount(int count) { |
| 304 writeInt(CONTEXTUAL_SEARCH_TAP_QUICK_ANSWER_COUNT, count); |
| 305 } |
| 306 |
| 307 /** |
286 * @return Which UI prototype the user is testing. This is cached from nativ
e via | 308 * @return Which UI prototype the user is testing. This is cached from nativ
e via |
287 * {@link FeatureUtilities#cacheHerbFlavor}. | 309 * {@link FeatureUtilities#cacheHerbFlavor}. |
288 */ | 310 */ |
289 public String getCachedHerbFlavor() { | 311 public String getCachedHerbFlavor() { |
290 return mSharedPreferences.getString(HERB_FLAVOR_KEY, ChromeSwitches.HERB
_FLAVOR_DISABLED); | 312 return mSharedPreferences.getString(HERB_FLAVOR_KEY, ChromeSwitches.HERB
_FLAVOR_DISABLED); |
291 } | 313 } |
292 | 314 |
293 /** | 315 /** |
294 * Caches which UI prototype the user is testing. | 316 * Caches which UI prototype the user is testing. |
295 */ | 317 */ |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 * | 358 * |
337 * @param key The name of the preference to modify. | 359 * @param key The name of the preference to modify. |
338 * @param value The new value for the preference. | 360 * @param value The new value for the preference. |
339 */ | 361 */ |
340 private void writeString(String key, String value) { | 362 private void writeString(String key, String value) { |
341 SharedPreferences.Editor ed = mSharedPreferences.edit(); | 363 SharedPreferences.Editor ed = mSharedPreferences.edit(); |
342 ed.putString(key, value); | 364 ed.putString(key, value); |
343 ed.apply(); | 365 ed.apply(); |
344 } | 366 } |
345 } | 367 } |
OLD | NEW |