Commit 90348029 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

[Home] Add information-only promo for startup

This change adds a finch feature that allows the Chrome Home promo
dialog to act as an information-only dialog that provides no option
to opt out -- it will only display on 'ok' button. This flag acts
independently of the other promo flags. The "ChromeHomePromo" flag
does not need to be enabled for "ChromeHomePromoInfoOnly" to trigger
the promo.

This version of the dialog will show on startup if:
- Chrome Home is enabled.
- Chrome Home has been enabled for < 60 seconds.
- The normal promo has not been seen before.

Outcome metrics are not recorded in this case.

BUG=789685

Change-Id: Ib8378ed86867275519aa78deb4240bd255a57939
Reviewed-on: https://chromium-review.googlesource.com/798122Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520705}
parent 65f30f28
......@@ -170,6 +170,7 @@ public abstract class ChromeFeatureList {
public static final String CHROME_HOME_PERSONALIZED_OMNIBOX_SUGGESTIONS =
"ChromeHomePersonalizedOmniboxSuggestions";
public static final String CHROME_HOME_PROMO = "ChromeHomePromo";
public static final String CHROME_HOME_PROMO_INFO_ONLY = "ChromeHomePromoInfoOnly";
public static final String CHROME_HOME_PROMO_ON_STARTUP = "ChromeHomePromoOnStartup";
public static final String CHROME_HOME_SWIPE_VELOCITY_FEATURE = "ChromeHomeSwipeLogicVelocity";
public static final String CHROME_MEMEX = "ChromeMemex";
......
......@@ -8,6 +8,7 @@ import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Build;
......@@ -21,6 +22,7 @@ import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
import org.chromium.base.FieldTrialList;
import org.chromium.base.Log;
import org.chromium.base.StrictModeContext;
import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
......@@ -53,6 +55,8 @@ public class FeatureUtilities {
private static final String ENABLED_EXPERIMENT_GROUP = "Enabled";
private static final String DISABLED_EXPERIMENT_GROUP = "Disabled";
private static final long CHROME_HOME_MAX_ENABLED_TIME_MS = 60000; // 60 seconds.
private static Boolean sHasGoogleAccountAuthenticator;
private static Boolean sHasRecognitionIntentHandler;
private static Boolean sChromeHomeEnabled;
......@@ -381,16 +385,36 @@ public class FeatureUtilities {
* @return Whether the Chrome Home promo should be shown for cold-start.
*/
public static boolean shouldShowChromeHomePromoForStartup() {
if (DeviceFormFactor.isTablet() || isChromeHomeEnabled()
|| !ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO)
|| !ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO_ON_STARTUP)) {
return false;
}
if (DeviceFormFactor.isTablet()) return false;
// The preference will be set if the promo has been seen before. If that is the case, do not
// show it again.
ChromePreferenceManager prefManager = ChromePreferenceManager.getInstance();
boolean isChromeHomePrefSet = prefManager.isChromeHomeUserPreferenceSet();
if (isChromeHomePrefSet) return false;
if (isChromeHomeEnabled()
&& ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO_INFO_ONLY)) {
long chromeHomeEnabledDate = System.currentTimeMillis();
try (StrictModeContext unused = StrictModeContext.allowDiskReads()) {
SharedPreferences sharedPreferences = ContextUtils.getAppSharedPreferences();
chromeHomeEnabledDate = sharedPreferences.getLong(
ChromePreferenceManager.CHROME_HOME_SHARED_PREFERENCES_KEY,
chromeHomeEnabledDate);
}
long timeDeadlineForPromo = chromeHomeEnabledDate + CHROME_HOME_MAX_ENABLED_TIME_MS;
// If Chrome Home has been enabled for < 60 seconds, show the info dialog.
return System.currentTimeMillis() < timeDeadlineForPromo;
} else if (!isChromeHomeEnabled()
&& ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO)
&& ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO_ON_STARTUP)) {
return true;
}
// Don't show the promo is the user has Chrome Home enabled.
return !prefManager.isChromeHomeUserPreferenceSet();
return false;
}
private static native void nativeSetCustomTabVisible(boolean visible);
......
......@@ -106,7 +106,9 @@ public class ChromeHomePromoDialog extends PromoDialog {
? R.string.chrome_home_promo_dialog_message_accessibility
: R.string.chrome_home_promo_dialog_message;
if (FeatureUtilities.isChromeHomeEnabled()) {
if (ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO_INFO_ONLY)) {
params.primaryButtonStringResource = R.string.ok;
} else if (FeatureUtilities.isChromeHomeEnabled()) {
params.primaryButtonStringResource = R.string.ok;
params.secondaryButtonStringResource = R.string.chrome_home_promo_dialog_turn_off;
} else {
......@@ -192,6 +194,10 @@ public class ChromeHomePromoDialog extends PromoDialog {
@Override
public void onDismiss(DialogInterface dialogInterface) {
// If the dialog is info-only, do not record any metrics since there were no provided
// options.
if (ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO_INFO_ONLY)) return;
// If the state of Chrome Home changed while this dialog was opened, do nothing. This can
// happen in multi-window if this dialog is shown in both windows.
if (mChromeHomeEnabledOnShow != FeatureUtilities.isChromeHomeEnabled()) return;
......
......@@ -69,6 +69,7 @@ const base::Feature* kFeaturesExposedToJava[] = {
&kChromeHomeInactivitySheetExpansion,
&kChromeHomePersistentIph,
&kChromeHomePromo,
&kChromeHomePromoInfoOnly,
&kChromeHomePromoOnStartup,
&kChromeHomeOptOutSnackbar,
&kChromeHomeSwipeLogic,
......@@ -199,6 +200,9 @@ const base::Feature kChromeHomePersistentIph{"ChromeHomePersistentIph",
const base::Feature kChromeHomePromo{"ChromeHomePromo",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kChromeHomePromoInfoOnly{"ChromeHomePromoInfoOnly",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kChromeHomePromoOnStartup{"ChromeHomePromoOnStartup",
base::FEATURE_ENABLED_BY_DEFAULT};
......
......@@ -29,6 +29,7 @@ extern const base::Feature kChromeHomeDestroySuggestions;
extern const base::Feature kChromeHomeDropAllButFirstThumbnail;
extern const base::Feature kChromeHomePersistentIph;
extern const base::Feature kChromeHomePromo;
extern const base::Feature kChromeHomePromoInfoOnly;
extern const base::Feature kChromeHomePromoOnStartup;
extern const base::Feature kChromeHomeOptOutSnackbar;
extern const base::Feature kChromeHomeSwipeLogic;
......
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