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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunGlueImpl.java

Issue 2614183002: Expand code that syncs ToS-seen prefs on Android. (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunGlueImpl.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunGlueImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunGlueImpl.java
index 3a7f7add7cc0c8fd87e23776efb2e081d3027977..c0eab35b6dd149f2c9f612ffc3b34e353d53a582 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunGlueImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunGlueImpl.java
@@ -24,15 +24,28 @@ public class FirstRunGlueImpl implements FirstRunGlue {
private static final String CACHED_TOS_ACCEPTED_PREF = "first_run_tos_accepted";
/**
- * Synchronizes first run native and Java preferences. Previous versions would
- * set only the native pref so this function synchronizes that state to Java.
+ * Synchronizes first run native and Java preferences.
* Must be called after native initialization.
*/
public static void cacheFirstRunPrefs() {
SharedPreferences javaPrefs = ContextUtils.getAppSharedPreferences();
- if (!javaPrefs.getBoolean(CACHED_TOS_ACCEPTED_PREF, false)
- && PrefServiceBridge.getInstance().isFirstRunEulaAccepted()) {
- javaPrefs.edit().putBoolean(CACHED_TOS_ACCEPTED_PREF, true).apply();
+ PrefServiceBridge prefsBridge = PrefServiceBridge.getInstance();
+ // Set both Java and native prefs if any of the three indicators indicate ToS has been
+ // accepted. This needed because:
+ // - Old versions only set native pref, so this syncs Java pref.
+ // - Backup & restore does not restore native pref, so this needs to update it.
aberent 2017/01/13 10:34:46 Why not simply add the native pref to the list of
+ // - checkAnyUserHasSeenToS() may be true which needs to sync its state to the prefs.
+ boolean javaPrefValue = javaPrefs.getBoolean(CACHED_TOS_ACCEPTED_PREF, false);
+ boolean nativePrefValue = prefsBridge.isFirstRunEulaAccepted();
+ boolean userHasSeenTos =
+ ToSAckedReceiver.checkAnyUserHasSeenToS(ContextUtils.getApplicationContext());
+ if (javaPrefValue || nativePrefValue || userHasSeenTos) {
+ if (!javaPrefValue) {
+ javaPrefs.edit().putBoolean(CACHED_TOS_ACCEPTED_PREF, true).apply();
+ }
+ if (!nativePrefValue) {
+ prefsBridge.setEulaAccepted();
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698