Commit 787cd93f authored by Henrique Nakashima's avatar Henrique Nakashima Committed by Commit Bot

Migrate SharedPrefs from VrFeedbackStatus to ChromePreferenceKeys

Register them in ChromePreferenceKeys and use SharedPreferencesManager
consistently instead of SharedPreferences directly.

Bug: 1022108
Change-Id: Ica20f108c27b33a04a547713d344e0d11f646278
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2011291Reviewed-by: default avatarPiotr Bialecki <bialpio@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734200}
parent 93830701
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
package org.chromium.chrome.browser.vr; package org.chromium.chrome.browser.vr;
import org.chromium.base.ContextUtils;
import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.preferences.ChromePreferenceKeys;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
/** /**
* Gets and sets preferences related to the status of the Vr feedback infobar. * Gets and sets preferences related to the status of the Vr feedback infobar.
...@@ -14,9 +15,6 @@ public class VrFeedbackStatus { ...@@ -14,9 +15,6 @@ public class VrFeedbackStatus {
private static final String FEEDBACK_FREQUENCY_PARAM_NAME = "feedback_frequency"; private static final String FEEDBACK_FREQUENCY_PARAM_NAME = "feedback_frequency";
private static final int DEFAULT_FEEDBACK_FREQUENCY = 10; private static final int DEFAULT_FEEDBACK_FREQUENCY = 10;
private static final String VR_FEEDBACK_OPT_OUT = "VR_FEEDBACK_OPT_OUT";
private static final String VR_EXIT_TO_2D_COUNT = "VR_EXIT_TO_2D_COUNT";
/** /**
* Returns how often we should show the feedback prompt. * Returns how often we should show the feedback prompt.
*/ */
...@@ -31,17 +29,16 @@ public class VrFeedbackStatus { ...@@ -31,17 +29,16 @@ public class VrFeedbackStatus {
* @param optOut Whether the VR feedback option has been opted-out of. * @param optOut Whether the VR feedback option has been opted-out of.
*/ */
public static void setFeedbackOptOut(boolean optOut) { public static void setFeedbackOptOut(boolean optOut) {
ContextUtils.getAppSharedPreferences() SharedPreferencesManager.getInstance().writeBoolean(
.edit() ChromePreferenceKeys.VR_FEEDBACK_OPT_OUT, optOut);
.putBoolean(VR_FEEDBACK_OPT_OUT, optOut)
.apply();
} }
/** /**
* Returns whether the user opted out of entering feedback for their VR experience. * Returns whether the user opted out of entering feedback for their VR experience.
*/ */
public static boolean getFeedbackOptOut() { public static boolean getFeedbackOptOut() {
return ContextUtils.getAppSharedPreferences().getBoolean(VR_FEEDBACK_OPT_OUT, false); return SharedPreferencesManager.getInstance().readBoolean(
ChromePreferenceKeys.VR_FEEDBACK_OPT_OUT, false);
} }
/** /**
...@@ -49,7 +46,8 @@ public class VrFeedbackStatus { ...@@ -49,7 +46,8 @@ public class VrFeedbackStatus {
* @param count The number of times the user exited VR and entered 2D browsing mode * @param count The number of times the user exited VR and entered 2D browsing mode
*/ */
public static void setUserExitedAndEntered2DCount(int count) { public static void setUserExitedAndEntered2DCount(int count) {
ContextUtils.getAppSharedPreferences().edit().putInt(VR_EXIT_TO_2D_COUNT, count).apply(); SharedPreferencesManager.getInstance().writeInt(
ChromePreferenceKeys.VR_EXIT_TO_2D_COUNT, count);
} }
/** /**
...@@ -57,6 +55,7 @@ public class VrFeedbackStatus { ...@@ -57,6 +55,7 @@ public class VrFeedbackStatus {
* mode. * mode.
*/ */
public static int getUserExitedAndEntered2DCount() { public static int getUserExitedAndEntered2DCount() {
return ContextUtils.getAppSharedPreferences().getInt(VR_EXIT_TO_2D_COUNT, 0); return SharedPreferencesManager.getInstance().readInt(
ChromePreferenceKeys.VR_EXIT_TO_2D_COUNT, 0);
} }
} }
...@@ -601,6 +601,9 @@ public final class ChromePreferenceKeys { ...@@ -601,6 +601,9 @@ public final class ChromePreferenceKeys {
public static final String VERIFIED_DIGITAL_ASSET_LINKS = "verified_digital_asset_links"; public static final String VERIFIED_DIGITAL_ASSET_LINKS = "verified_digital_asset_links";
public static final String VR_EXIT_TO_2D_COUNT = "VR_EXIT_TO_2D_COUNT";
public static final String VR_FEEDBACK_OPT_OUT = "VR_FEEDBACK_OPT_OUT";
/** /**
* Whether VR assets component should be registered on startup. * Whether VR assets component should be registered on startup.
* Default value is false. * Default value is false.
...@@ -864,6 +867,8 @@ public final class ChromePreferenceKeys { ...@@ -864,6 +867,8 @@ public final class ChromePreferenceKeys {
UI_THEME_SETTING, UI_THEME_SETTING,
VARIATION_CACHED_BOTTOM_TOOLBAR, VARIATION_CACHED_BOTTOM_TOOLBAR,
VERIFIED_DIGITAL_ASSET_LINKS, VERIFIED_DIGITAL_ASSET_LINKS,
VR_EXIT_TO_2D_COUNT,
VR_FEEDBACK_OPT_OUT,
VR_SHOULD_REGISTER_ASSETS_COMPONENT_ON_STARTUP, VR_SHOULD_REGISTER_ASSETS_COMPONENT_ON_STARTUP,
WEBAPK_EXTRACTED_DEX_VERSION, WEBAPK_EXTRACTED_DEX_VERSION,
WEBAPK_LAST_SDK_VERSION, WEBAPK_LAST_SDK_VERSION,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment