| 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 26 matching lines...) Expand all Loading... |
| 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 = | 39 private static final String CONTEXTUAL_SEARCH_TAP_QUICK_ANSWER_COUNT = |
| 40 "contextual_search_tap_quick_answer_count"; | 40 "contextual_search_tap_quick_answer_count"; |
| 41 private static final String HERB_FLAVOR_KEY = "herb_flavor"; | 41 private static final String HERB_FLAVOR_KEY = "herb_flavor"; |
| 42 private static final String INSTANT_APPS_KEY = "applink.app_link_enabled"; | 42 private static final String INSTANT_APPS_KEY = "applink.app_link_enabled"; |
| 43 private static final String WEBAPK_RUNTIME_KEY = "webapk.runtime_enabled"; | 43 private static final String WEBAPK_RUNTIME_KEY = "webapk.runtime_enabled"; |
| 44 | 44 |
| 45 private static final String CHROME_DEFAULT_BROWSER = "applink.chrome_default
_browser"; | 45 private static final String CHROME_DEFAULT_BROWSER = "applink.chrome_default
_browser"; |
| 46 | 46 |
| 47 private static final String NTP_SIGNIN_PROMO_DISMISSED = "ntp.signin_promo_d
ismissed"; |
| 48 |
| 47 private static final String SUCCESS_UPLOAD_SUFFIX = "_crash_success_upload"; | 49 private static final String SUCCESS_UPLOAD_SUFFIX = "_crash_success_upload"; |
| 48 private static final String FAILURE_UPLOAD_SUFFIX = "_crash_failure_upload"; | 50 private static final String FAILURE_UPLOAD_SUFFIX = "_crash_failure_upload"; |
| 49 | 51 |
| 50 private static final int SIGNIN_PROMO_CYCLE_IN_DAYS = 120; | 52 private static final int SIGNIN_PROMO_CYCLE_IN_DAYS = 120; |
| 51 private static final long MILLISECONDS_IN_DAY = 1000 * 60 * 60 * 24; | 53 private static final long MILLISECONDS_IN_DAY = 1000 * 60 * 60 * 24; |
| 52 | 54 |
| 53 private static ChromePreferenceManager sPrefs; | 55 private static ChromePreferenceManager sPrefs; |
| 54 | 56 |
| 55 private final SharedPreferences mSharedPreferences; | 57 private final SharedPreferences mSharedPreferences; |
| 56 private final Context mContext; | 58 private final Context mContext; |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 public boolean getCachedChromeDefaultBrowser() { | 350 public boolean getCachedChromeDefaultBrowser() { |
| 349 return mSharedPreferences.getBoolean(CHROME_DEFAULT_BROWSER, false); | 351 return mSharedPreferences.getBoolean(CHROME_DEFAULT_BROWSER, false); |
| 350 } | 352 } |
| 351 | 353 |
| 352 public void setCachedChromeDefaultBrowser(boolean isDefault) { | 354 public void setCachedChromeDefaultBrowser(boolean isDefault) { |
| 353 SharedPreferences.Editor ed = mSharedPreferences.edit(); | 355 SharedPreferences.Editor ed = mSharedPreferences.edit(); |
| 354 ed.putBoolean(CHROME_DEFAULT_BROWSER, isDefault); | 356 ed.putBoolean(CHROME_DEFAULT_BROWSER, isDefault); |
| 355 ed.apply(); | 357 ed.apply(); |
| 356 } | 358 } |
| 357 | 359 |
| 360 /** Checks if the user dismissed the sign in promo from the new tab page. */ |
| 361 public boolean getNewTabPageSigninPromoDismissed() { |
| 362 return mSharedPreferences.getBoolean(NTP_SIGNIN_PROMO_DISMISSED, false); |
| 363 } |
| 364 |
| 365 /** Set whether the user dismissed the sign in promo from the new tab page.
*/ |
| 366 public void setNewTabPageSigninPromoDismissed(boolean isPromoDismissed) { |
| 367 SharedPreferences.Editor ed = mSharedPreferences.edit(); |
| 368 ed.putBoolean(NTP_SIGNIN_PROMO_DISMISSED, isPromoDismissed); |
| 369 ed.apply(); |
| 370 } |
| 371 |
| 358 /** | 372 /** |
| 359 * Writes the given int value to the named shared preference. | 373 * Writes the given int value to the named shared preference. |
| 360 * | 374 * |
| 361 * @param key The name of the preference to modify. | 375 * @param key The name of the preference to modify. |
| 362 * @param value The new value for the preference. | 376 * @param value The new value for the preference. |
| 363 */ | 377 */ |
| 364 private void writeInt(String key, int value) { | 378 private void writeInt(String key, int value) { |
| 365 SharedPreferences.Editor ed = mSharedPreferences.edit(); | 379 SharedPreferences.Editor ed = mSharedPreferences.edit(); |
| 366 ed.putInt(key, value); | 380 ed.putInt(key, value); |
| 367 ed.apply(); | 381 ed.apply(); |
| 368 } | 382 } |
| 369 | 383 |
| 370 /** | 384 /** |
| 371 * Writes the given String to the named shared preference. | 385 * Writes the given String to the named shared preference. |
| 372 * | 386 * |
| 373 * @param key The name of the preference to modify. | 387 * @param key The name of the preference to modify. |
| 374 * @param value The new value for the preference. | 388 * @param value The new value for the preference. |
| 375 */ | 389 */ |
| 376 private void writeString(String key, String value) { | 390 private void writeString(String key, String value) { |
| 377 SharedPreferences.Editor ed = mSharedPreferences.edit(); | 391 SharedPreferences.Editor ed = mSharedPreferences.edit(); |
| 378 ed.putString(key, value); | 392 ed.putString(key, value); |
| 379 ed.apply(); | 393 ed.apply(); |
| 380 } | 394 } |
| 381 } | 395 } |
| OLD | NEW |