/** * Checks if the First Run needs to be launched. * * @return The intent to launch the First Run Experience if necessary, or null. * @param context The context. * @param fromIntent The intent that was used to launch Chrome. * @param forLightweightFre Whether this is a check for the Lightweight First Run Experience. */ public static Intent checkIfFirstRunIsNecessary( Context context, Intent fromIntent, boolean forLightweightFre) { // If FRE is disabled (e.g. in tests), proceed directly to the intent handling. if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE) || ApiCompatibilityUtils.isDemoUser(context)) { return null; } // If Chrome isn't opened via the Chrome icon, and the user accepted the ToS // in the Setup Wizard, skip any First Run Experience screens and proceed directly // to the intent handling. final boolean fromChromeIcon = fromIntent != null && TextUtils.equals(fromIntent.getAction(), Intent.ACTION_MAIN); if (!fromChromeIcon && ToSAckedReceiver.checkAnyUserHasSeenToS(context)) return null; final boolean baseFreComplete = FirstRunStatus.getFirstRunFlowComplete(context); if (!baseFreComplete) { if (forLightweightFre && CommandLine.getInstance() .hasSwitch(ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE)) { if (!FirstRunStatus.shouldSkipWelcomePage(context) && !FirstRunStatus.getLightweightFirstRunFlowComplete(context)) { return createLightweightFirstRunIntent(context, fromChromeIcon); } } else { return createGenericFirstRunIntent(context, fromChromeIcon); } } // Promo pages are removed, so there is nothing else to show in FRE. return null; }
@VisibleForTesting protected boolean hasAnyUserSeenToS() { return ToSAckedReceiver.checkAnyUserHasSeenToS(mActivity); }