Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/ChromePreferenceManager.java

Issue 2903293002: [Android] Omnibox Placeholder Experiment (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.SharedPreferences; 7 import android.content.SharedPreferences;
8 8
9 import org.chromium.base.ContextUtils; 9 import org.chromium.base.ContextUtils;
10 import org.chromium.base.annotations.SuppressFBWarnings; 10 import org.chromium.base.annotations.SuppressFBWarnings;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 private static final String CHROME_HOME_ENABLED_KEY = "chrome_home_enabled"; 49 private static final String CHROME_HOME_ENABLED_KEY = "chrome_home_enabled";
50 50
51 private static final String CHROME_DEFAULT_BROWSER = "applink.chrome_default _browser"; 51 private static final String CHROME_DEFAULT_BROWSER = "applink.chrome_default _browser";
52 52
53 private static final String NTP_SIGNIN_PROMO_DISMISSED = "ntp.signin_promo_d ismissed"; 53 private static final String NTP_SIGNIN_PROMO_DISMISSED = "ntp.signin_promo_d ismissed";
54 private static final String NTP_ANIMATION_RUN_COUNT = "ntp_recycler_view_ani mation_run_count"; 54 private static final String NTP_ANIMATION_RUN_COUNT = "ntp_recycler_view_ani mation_run_count";
55 55
56 private static final String SUCCESS_UPLOAD_SUFFIX = "_crash_success_upload"; 56 private static final String SUCCESS_UPLOAD_SUFFIX = "_crash_success_upload";
57 private static final String FAILURE_UPLOAD_SUFFIX = "_crash_failure_upload"; 57 private static final String FAILURE_UPLOAD_SUFFIX = "_crash_failure_upload";
58 58
59 private static final String URL_BAR_HINT_KEY = "url_bar_hint";
60
59 private static ChromePreferenceManager sPrefs; 61 private static ChromePreferenceManager sPrefs;
60 62
61 private final SharedPreferences mSharedPreferences; 63 private final SharedPreferences mSharedPreferences;
62 64
63 private ChromePreferenceManager() { 65 private ChromePreferenceManager() {
64 mSharedPreferences = ContextUtils.getAppSharedPreferences(); 66 mSharedPreferences = ContextUtils.getAppSharedPreferences();
65 } 67 }
66 68
67 /** 69 /**
68 * Get the static instance of ChromePreferenceManager if exists else create it. 70 * Get the static instance of ChromePreferenceManager if exists else create it.
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 412
411 /** 413 /**
412 * Get whether or not Chrome Home is enabled. 414 * Get whether or not Chrome Home is enabled.
413 * @return True if Chrome Home is enabled. 415 * @return True if Chrome Home is enabled.
414 */ 416 */
415 public boolean isChromeHomeEnabled() { 417 public boolean isChromeHomeEnabled() {
416 return mSharedPreferences.getBoolean(CHROME_HOME_ENABLED_KEY, false); 418 return mSharedPreferences.getBoolean(CHROME_HOME_ENABLED_KEY, false);
417 } 419 }
418 420
419 /** 421 /**
422 * Set hint text to show on url bar
423 * @param hint Hint text to show on url bar
424 */
425 public void setUrlBarHint(String hint) {
mdjones 2017/05/26 16:14:34 Same as above; is this caching the hint or the exp
huayinz 2017/05/26 17:21:36 See above^
426 writeString(URL_BAR_HINT_KEY, hint);
427 }
428
429 /**
430 * Get hint text to show on url bar
431 * @return String of hint text to show on url bar, null if not set
432 */
433 public String getUrlBarHint() {
434 return mSharedPreferences.getString(URL_BAR_HINT_KEY, null);
435 }
436
437 /**
420 * Writes the given int value to the named shared preference. 438 * Writes the given int value to the named shared preference.
421 * @param key The name of the preference to modify. 439 * @param key The name of the preference to modify.
422 * @param value The new value for the preference. 440 * @param value The new value for the preference.
423 */ 441 */
424 public void writeInt(String key, int value) { 442 public void writeInt(String key, int value) {
425 SharedPreferences.Editor ed = mSharedPreferences.edit(); 443 SharedPreferences.Editor ed = mSharedPreferences.edit();
426 ed.putInt(key, value); 444 ed.putInt(key, value);
427 ed.apply(); 445 ed.apply();
428 } 446 }
429 447
(...skipping 23 matching lines...) Expand all
453 * 471 *
454 * @param key The name of the preference to modify. 472 * @param key The name of the preference to modify.
455 * @param value The new value for the preference. 473 * @param value The new value for the preference.
456 */ 474 */
457 private void writeBoolean(String key, boolean value) { 475 private void writeBoolean(String key, boolean value) {
458 SharedPreferences.Editor ed = mSharedPreferences.edit(); 476 SharedPreferences.Editor ed = mSharedPreferences.edit();
459 ed.putBoolean(key, value); 477 ed.putBoolean(key, value);
460 ed.apply(); 478 ed.apply();
461 } 479 }
462 } 480 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698