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

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

Issue 2903293002: [Android] Omnibox Placeholder Experiment (Closed)
Patch Set: remove chrome flag 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 CONTENT_SUGGESTIONS_SHOWN_KEY = "content_suggest ions_shown"; 53 private static final String CONTENT_SUGGESTIONS_SHOWN_KEY = "content_suggest ions_shown";
54 54
55 private static final String NTP_SIGNIN_PROMO_DISMISSED = "ntp.signin_promo_d ismissed"; 55 private static final String NTP_SIGNIN_PROMO_DISMISSED = "ntp.signin_promo_d ismissed";
56 private static final String NTP_ANIMATION_RUN_COUNT = "ntp_recycler_view_ani mation_run_count"; 56 private static final String NTP_ANIMATION_RUN_COUNT = "ntp_recycler_view_ani mation_run_count";
57 57
58 private static final String SUCCESS_UPLOAD_SUFFIX = "_crash_success_upload"; 58 private static final String SUCCESS_UPLOAD_SUFFIX = "_crash_success_upload";
59 private static final String FAILURE_UPLOAD_SUFFIX = "_crash_failure_upload"; 59 private static final String FAILURE_UPLOAD_SUFFIX = "_crash_failure_upload";
60 60
61 private static final String OMNIBOX_PLACEHOLDER_GROUP = "omnibox-placeholder -group";
62
61 private static ChromePreferenceManager sPrefs; 63 private static ChromePreferenceManager sPrefs;
62 64
63 private final SharedPreferences mSharedPreferences; 65 private final SharedPreferences mSharedPreferences;
64 66
65 private ChromePreferenceManager() { 67 private ChromePreferenceManager() {
66 mSharedPreferences = ContextUtils.getAppSharedPreferences(); 68 mSharedPreferences = ContextUtils.getAppSharedPreferences();
67 } 69 }
68 70
69 /** 71 /**
70 * Get the static instance of ChromePreferenceManager if exists else create it. 72 * Get the static instance of ChromePreferenceManager if exists else create it.
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 public void setSuggestionsSurfaceShown() { 414 public void setSuggestionsSurfaceShown() {
413 writeBoolean(CONTENT_SUGGESTIONS_SHOWN_KEY, true); 415 writeBoolean(CONTENT_SUGGESTIONS_SHOWN_KEY, true);
414 } 416 }
415 417
416 /** Returns whether the content suggestions surface has ever been shown. */ 418 /** Returns whether the content suggestions surface has ever been shown. */
417 public boolean getSuggestionsSurfaceShown() { 419 public boolean getSuggestionsSurfaceShown() {
418 return mSharedPreferences.getBoolean(CONTENT_SUGGESTIONS_SHOWN_KEY, fals e); 420 return mSharedPreferences.getBoolean(CONTENT_SUGGESTIONS_SHOWN_KEY, fals e);
419 } 421 }
420 422
421 /** 423 /**
424 * Set group of omnibox placeholder experiment
425 * @param group group name of omnibox placeholder experiment
426 */
427 public void setOmniboxPlaceholderGroup(String group) {
428 writeString(OMNIBOX_PLACEHOLDER_GROUP, group);
429 }
430
431 /**
432 * Get group of omnibox placeholder experiment
433 * @return String of omnibox placeholder experiment group name, empty string if not set
434 */
435 public String getOmniboxPlaceholderGroup() {
436 return mSharedPreferences.getString(OMNIBOX_PLACEHOLDER_GROUP, "");
437 }
438
439 /**
422 * Writes the given int value to the named shared preference. 440 * Writes the given int value to the named shared preference.
423 * @param key The name of the preference to modify. 441 * @param key The name of the preference to modify.
424 * @param value The new value for the preference. 442 * @param value The new value for the preference.
425 */ 443 */
426 public void writeInt(String key, int value) { 444 public void writeInt(String key, int value) {
427 SharedPreferences.Editor ed = mSharedPreferences.edit(); 445 SharedPreferences.Editor ed = mSharedPreferences.edit();
428 ed.putInt(key, value); 446 ed.putInt(key, value);
429 ed.apply(); 447 ed.apply();
430 } 448 }
431 449
(...skipping 23 matching lines...) Expand all
455 * 473 *
456 * @param key The name of the preference to modify. 474 * @param key The name of the preference to modify.
457 * @param value The new value for the preference. 475 * @param value The new value for the preference.
458 */ 476 */
459 private void writeBoolean(String key, boolean value) { 477 private void writeBoolean(String key, boolean value) {
460 SharedPreferences.Editor ed = mSharedPreferences.edit(); 478 SharedPreferences.Editor ed = mSharedPreferences.edit();
461 ed.putBoolean(key, value); 479 ed.putBoolean(key, value);
462 ed.apply(); 480 ed.apply();
463 } 481 }
464 } 482 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698