Commit f95b8c27 authored by tedchoc's avatar tedchoc Committed by Commit bot

Remove unused context params from FirstRunStatus.

Split out from:
https://codereview.chromium.org/2559573002/

There is a downstream caller for one method, so will
land this first to allow a quicker patch time.

TBR=yusufo@chromium.org
BUG=671149

Review-Url: https://codereview.chromium.org/2565183005
Cr-Commit-Position: refs/heads/master@{#437937}
parent d3dd3038
...@@ -369,7 +369,7 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode ...@@ -369,7 +369,7 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance(this); ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance(this);
// Promos can only be shown when we start with ACTION_MAIN intent and // Promos can only be shown when we start with ACTION_MAIN intent and
// after FRE is complete. // after FRE is complete.
if (!mIntentWithEffect && FirstRunStatus.getFirstRunFlowComplete(this)) { if (!mIntentWithEffect && FirstRunStatus.getFirstRunFlowComplete()) {
// Only show promos on the second oppurtunity. This is because we show FRE on the // Only show promos on the second oppurtunity. This is because we show FRE on the
// first oppurtunity, and we don't want to show such content back to back. // first oppurtunity, and we don't want to show such content back to back.
if (preferenceManager.getPromosSkippedOnFirstStart()) { if (preferenceManager.getPromosSkippedOnFirstStart()) {
......
...@@ -86,7 +86,7 @@ public class EmbedContentViewActivity extends FullScreenActivity { ...@@ -86,7 +86,7 @@ public class EmbedContentViewActivity extends FullScreenActivity {
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
boolean retVal = super.onCreateOptionsMenu(menu); boolean retVal = super.onCreateOptionsMenu(menu);
if (!FirstRunStatus.getFirstRunFlowComplete(this)) return retVal; if (!FirstRunStatus.getFirstRunFlowComplete()) return retVal;
return true; return true;
} }
......
...@@ -260,7 +260,7 @@ public class FirstRunActivity extends AppCompatActivity implements FirstRunPageD ...@@ -260,7 +260,7 @@ public class FirstRunActivity extends AppCompatActivity implements FirstRunPageD
UmaUtils.recordForegroundStartTime(); UmaUtils.recordForegroundStartTime();
stopProgressionIfNotAcceptedTermsOfService(); stopProgressionIfNotAcceptedTermsOfService();
if (!mFreProperties.getBoolean(EXTRA_USE_FRE_FLOW_SEQUENCER)) { if (!mFreProperties.getBoolean(EXTRA_USE_FRE_FLOW_SEQUENCER)) {
if (FirstRunStatus.getFirstRunFlowComplete(this)) { if (FirstRunStatus.getFirstRunFlowComplete()) {
// This is a parallel flow that needs to be refreshed/re-fired. // This is a parallel flow that needs to be refreshed/re-fired.
// Signal the FRE flow completion and re-launch the original intent. // Signal the FRE flow completion and re-launch the original intent.
completeFirstRunExperience(); completeFirstRunExperience();
...@@ -403,7 +403,7 @@ public class FirstRunActivity extends AppCompatActivity implements FirstRunPageD ...@@ -403,7 +403,7 @@ public class FirstRunActivity extends AppCompatActivity implements FirstRunPageD
// If default is true then it corresponds to opt-out and false corresponds to opt-in. // If default is true then it corresponds to opt-out and false corresponds to opt-in.
UmaUtils.recordMetricsReportingDefaultOptIn(!DEFAULT_METRICS_AND_CRASH_REPORTING); UmaUtils.recordMetricsReportingDefaultOptIn(!DEFAULT_METRICS_AND_CRASH_REPORTING);
sGlue.acceptTermsOfService(allowCrashUpload); sGlue.acceptTermsOfService(allowCrashUpload);
FirstRunStatus.setSkipWelcomePage(FirstRunActivity.this, true); FirstRunStatus.setSkipWelcomePage(true);
flushPersistentData(); flushPersistentData();
stopProgressionIfNotAcceptedTermsOfService(); stopProgressionIfNotAcceptedTermsOfService();
jumpToPage(mPager.getCurrentItem() + 1); jumpToPage(mPager.getCurrentItem() + 1);
......
...@@ -86,7 +86,7 @@ public abstract class FirstRunFlowSequencer { ...@@ -86,7 +86,7 @@ public abstract class FirstRunFlowSequencer {
@VisibleForTesting @VisibleForTesting
protected boolean isFirstRunFlowComplete() { protected boolean isFirstRunFlowComplete() {
return FirstRunStatus.getFirstRunFlowComplete(mActivity); return FirstRunStatus.getFirstRunFlowComplete();
} }
@VisibleForTesting @VisibleForTesting
...@@ -263,13 +263,13 @@ public abstract class FirstRunFlowSequencer { ...@@ -263,13 +263,13 @@ public abstract class FirstRunFlowSequencer {
fromIntent != null && TextUtils.equals(fromIntent.getAction(), Intent.ACTION_MAIN); fromIntent != null && TextUtils.equals(fromIntent.getAction(), Intent.ACTION_MAIN);
if (!fromChromeIcon && ToSAckedReceiver.checkAnyUserHasSeenToS(context)) return null; if (!fromChromeIcon && ToSAckedReceiver.checkAnyUserHasSeenToS(context)) return null;
final boolean baseFreComplete = FirstRunStatus.getFirstRunFlowComplete(context); final boolean baseFreComplete = FirstRunStatus.getFirstRunFlowComplete();
if (!baseFreComplete) { if (!baseFreComplete) {
if (forLightweightFre if (forLightweightFre
&& CommandLine.getInstance().hasSwitch( && CommandLine.getInstance().hasSwitch(
ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE)) { ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE)) {
if (!FirstRunStatus.shouldSkipWelcomePage(context) if (!FirstRunStatus.shouldSkipWelcomePage()
&& !FirstRunStatus.getLightweightFirstRunFlowComplete(context)) { && !FirstRunStatus.getLightweightFirstRunFlowComplete()) {
return createLightweightFirstRunIntent(context, fromChromeIcon); return createLightweightFirstRunIntent(context, fromChromeIcon);
} }
} else { } else {
......
...@@ -58,7 +58,7 @@ public final class FirstRunSignInProcessor { ...@@ -58,7 +58,7 @@ public final class FirstRunSignInProcessor {
SigninManager signinManager = SigninManager.get(activity.getApplicationContext()); SigninManager signinManager = SigninManager.get(activity.getApplicationContext());
signinManager.onFirstRunCheckDone(); signinManager.onFirstRunCheckDone();
boolean firstRunFlowComplete = FirstRunStatus.getFirstRunFlowComplete(activity); boolean firstRunFlowComplete = FirstRunStatus.getFirstRunFlowComplete();
// We skip signin and the FRE if // We skip signin and the FRE if
// - FRE is disabled, or // - FRE is disabled, or
// - FRE hasn't been completed, but the user has already seen the ToS in the Setup Wizard. // - FRE hasn't been completed, but the user has already seen the ToS in the Setup Wizard.
...@@ -129,7 +129,7 @@ public final class FirstRunSignInProcessor { ...@@ -129,7 +129,7 @@ public final class FirstRunSignInProcessor {
Log.e(TAG, "Attempt to pass-through without completed FRE"); Log.e(TAG, "Attempt to pass-through without completed FRE");
// Things went wrong -- we want the user to go through the full FRE. // Things went wrong -- we want the user to go through the full FRE.
FirstRunStatus.setFirstRunFlowComplete(activity, false); FirstRunStatus.setFirstRunFlowComplete(false);
setFirstRunFlowSignInComplete(activity, false); setFirstRunFlowSignInComplete(activity, false);
setFirstRunFlowSignInAccountName(activity, null); setFirstRunFlowSignInAccountName(activity, null);
setFirstRunFlowSignInSetup(activity, false); setFirstRunFlowSignInSetup(activity, false);
...@@ -207,7 +207,7 @@ public final class FirstRunSignInProcessor { ...@@ -207,7 +207,7 @@ public final class FirstRunSignInProcessor {
* @param data Resulting FRE properties bundle * @param data Resulting FRE properties bundle
*/ */
public static void finalizeFirstRunFlowState(Context context, Bundle data) { public static void finalizeFirstRunFlowState(Context context, Bundle data) {
FirstRunStatus.setFirstRunFlowComplete(context, true); FirstRunStatus.setFirstRunFlowComplete(true);
setFirstRunFlowSignInAccountName(context, setFirstRunFlowSignInAccountName(context,
data.getString(FirstRunActivity.RESULT_SIGNIN_ACCOUNT_NAME)); data.getString(FirstRunActivity.RESULT_SIGNIN_ACCOUNT_NAME));
setFirstRunFlowSignInSetup( setFirstRunFlowSignInSetup(
...@@ -221,7 +221,7 @@ public final class FirstRunSignInProcessor { ...@@ -221,7 +221,7 @@ public final class FirstRunSignInProcessor {
public static void updateSigninManagerFirstRunCheckDone(Context context) { public static void updateSigninManagerFirstRunCheckDone(Context context) {
SigninManager manager = SigninManager.get(context); SigninManager manager = SigninManager.get(context);
if (manager.isSignInAllowed()) return; if (manager.isSignInAllowed()) return;
if (!FirstRunStatus.getFirstRunFlowComplete(context)) return; if (!FirstRunStatus.getFirstRunFlowComplete()) return;
if (!getFirstRunFlowSignInComplete(context)) return; if (!getFirstRunFlowSignInComplete(context)) return;
manager.onFirstRunCheckDone(); manager.onFirstRunCheckDone();
} }
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
package org.chromium.chrome.browser.firstrun; package org.chromium.chrome.browser.firstrun;
import android.content.Context;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
/** /**
...@@ -21,10 +19,9 @@ public class FirstRunStatus { ...@@ -21,10 +19,9 @@ public class FirstRunStatus {
/** /**
* Sets the "main First Run Experience flow complete" preference. * Sets the "main First Run Experience flow complete" preference.
* @param context Any context
* @param isComplete Whether the main First Run Experience flow is complete * @param isComplete Whether the main First Run Experience flow is complete
*/ */
public static void setFirstRunFlowComplete(Context context, boolean isComplete) { public static void setFirstRunFlowComplete(boolean isComplete) {
ContextUtils.getAppSharedPreferences() ContextUtils.getAppSharedPreferences()
.edit() .edit()
.putBoolean(FIRST_RUN_FLOW_COMPLETE, isComplete) .putBoolean(FIRST_RUN_FLOW_COMPLETE, isComplete)
...@@ -35,35 +32,38 @@ public class FirstRunStatus { ...@@ -35,35 +32,38 @@ public class FirstRunStatus {
* Returns whether the main First Run Experience flow is complete. * Returns whether the main First Run Experience flow is complete.
* Note: that might NOT include "intro"/"what's new" pages, but it always * Note: that might NOT include "intro"/"what's new" pages, but it always
* includes ToS and Sign In pages if necessary. * includes ToS and Sign In pages if necessary.
* @param context Any context
*/ */
public static boolean getFirstRunFlowComplete(Context context) { public static boolean getFirstRunFlowComplete() {
return ContextUtils.getAppSharedPreferences() return ContextUtils.getAppSharedPreferences()
.getBoolean(FIRST_RUN_FLOW_COMPLETE, false); .getBoolean(FIRST_RUN_FLOW_COMPLETE, false);
} }
// TODO(tedchoc): Remove once downstream callers migrate to non-param version.
public static boolean getFirstRunFlowComplete(
@SuppressWarnings("unused") android.content.Context context) {
return getFirstRunFlowComplete();
}
/** /**
* Sets the preference to skip the welcome page from the main First Run Experience. * Sets the preference to skip the welcome page from the main First Run Experience.
* @param context Any context * @param isSkip Whether the welcome page should be skpped
* @param isSkip Whether the welcome page should be skpped
*/ */
public static void setSkipWelcomePage(Context context, boolean isSkip) { public static void setSkipWelcomePage(boolean isSkip) {
ContextUtils.getAppSharedPreferences().edit().putBoolean(SKIP_WELCOME_PAGE, isSkip).apply(); ContextUtils.getAppSharedPreferences().edit().putBoolean(SKIP_WELCOME_PAGE, isSkip).apply();
} }
/** /**
* Checks whether the welcome page should be skipped from the main First Run Experience. * Checks whether the welcome page should be skipped from the main First Run Experience.
*/ */
public static boolean shouldSkipWelcomePage(Context context) { public static boolean shouldSkipWelcomePage() {
return ContextUtils.getAppSharedPreferences().getBoolean(SKIP_WELCOME_PAGE, false); return ContextUtils.getAppSharedPreferences().getBoolean(SKIP_WELCOME_PAGE, false);
} }
/** /**
* Sets the "lightweight First Run Experience flow complete" preference. * Sets the "lightweight First Run Experience flow complete" preference.
* @param context Any context
* @param isComplete Whether the lightweight First Run Experience flow is complete * @param isComplete Whether the lightweight First Run Experience flow is complete
*/ */
public static void setLightweightFirstRunFlowComplete(Context context, boolean isComplete) { public static void setLightweightFirstRunFlowComplete(boolean isComplete) {
ContextUtils.getAppSharedPreferences() ContextUtils.getAppSharedPreferences()
.edit() .edit()
.putBoolean(LIGHTWEIGHT_FIRST_RUN_FLOW_COMPLETE, isComplete) .putBoolean(LIGHTWEIGHT_FIRST_RUN_FLOW_COMPLETE, isComplete)
...@@ -72,9 +72,8 @@ public class FirstRunStatus { ...@@ -72,9 +72,8 @@ public class FirstRunStatus {
/** /**
* Returns whether the "lightweight First Run Experience flow" is complete. * Returns whether the "lightweight First Run Experience flow" is complete.
* @param context Any context
*/ */
public static boolean getLightweightFirstRunFlowComplete(Context context) { public static boolean getLightweightFirstRunFlowComplete() {
return ContextUtils.getAppSharedPreferences().getBoolean( return ContextUtils.getAppSharedPreferences().getBoolean(
LIGHTWEIGHT_FIRST_RUN_FLOW_COMPLETE, false); LIGHTWEIGHT_FIRST_RUN_FLOW_COMPLETE, false);
} }
......
...@@ -78,7 +78,7 @@ public class LightweightFirstRunActivity extends FirstRunActivity { ...@@ -78,7 +78,7 @@ public class LightweightFirstRunActivity extends FirstRunActivity {
@Override @Override
public void completeFirstRunExperience() { public void completeFirstRunExperience() {
FirstRunStatus.setLightweightFirstRunFlowComplete(LightweightFirstRunActivity.this, true); FirstRunStatus.setLightweightFirstRunFlowComplete(true);
Intent intent = new Intent(); Intent intent = new Intent();
intent.putExtras(mFreProperties); intent.putExtras(mFreProperties);
finishAllTheActivities(getLocalClassName(), Activity.RESULT_OK, intent); finishAllTheActivities(getLocalClassName(), Activity.RESULT_OK, intent);
......
...@@ -104,6 +104,6 @@ public class ToSAndUMAFirstRunFragment extends FirstRunPage { ...@@ -104,6 +104,6 @@ public class ToSAndUMAFirstRunFragment extends FirstRunPage {
@Override @Override
public boolean shouldSkipPageOnCreate(Context appContext) { public boolean shouldSkipPageOnCreate(Context appContext) {
return FirstRunStatus.shouldSkipWelcomePage(appContext); return FirstRunStatus.shouldSkipWelcomePage();
} }
} }
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