Commit 2048b2aa authored by Matt Simmons's avatar Matt Simmons Committed by Commit Bot

Experiment for showing the Tab Switcher on returning to Chrome.

Adding a utility class to handle the logic of calculating if enough time
has passed. The last backgrounded time is already tracked in
ChromeTabbedActivity::onStopWithNative().

Experiment name is enable-tab-switcher-on-return. See `chrome://flags`

Available options are 30 or 60 minutes.

R=yusufo@chromium.org

Bug: 898685
Change-Id: I916eb86b55525f06335d27cec84de78b1e366e98
Reviewed-on: https://chromium-review.googlesource.com/c/1384658Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Matt Simmons <mattsimmons@google.com>
Cr-Commit-Position: refs/heads/master@{#618309}
parent a7cb2805
......@@ -277,6 +277,7 @@ public abstract class ChromeFeatureList {
public static final String SUBRESOURCE_FILTER = "SubresourceFilter";
public static final String QUERY_IN_OMNIBOX = "QueryInOmnibox";
public static final String TAB_REPARENTING = "TabReparenting";
public static final String TAB_SWITCHER_ON_RETURN = "TabSwitcherOnReturn";
public static final String TRANSLATE_ANDROID_MANUAL_TRIGGER = "TranslateAndroidManualTrigger";
public static final String TRUSTED_WEB_ACTIVITY = "TrustedWebActivity";
public static final String TRUSTED_WEB_ACTIVITY_POST_MESSAGE = "TrustedWebActivityPostMessage";
......
......@@ -785,6 +785,16 @@ public class ChromeTabbedActivity
private void setInitialOverviewState() {
boolean isOverviewVisible = mLayoutManager.overviewVisible();
// Experiment: show tab switcher on return after {x} minutes (enable-tab-switcher-on-return}
long lastBackgroundedTimeMillis =
ContextUtils.getAppSharedPreferences().getLong(LAST_BACKGROUNDED_TIME_MS_PREF, -1);
if (ReturnToChromeExperimentsUtil.shouldShowTabSwitcher(lastBackgroundedTimeMillis)
&& !isOverviewVisible) {
toggleOverview();
return;
}
if (getActivityTab() == null && !isOverviewVisible) {
toggleOverview();
}
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser;
/**
* This is a utility class for managing experiments related to returning to Chrome.
*/
final class ReturnToChromeExperimentsUtil {
private static final String TAB_SWITCHER_ON_RETURN_MS = "tab_switcher_on_return_time_ms";
private ReturnToChromeExperimentsUtil() {}
/**
* Determine if we should show the tab switcher on returning to Chrome.
* Returns true if enough time has elapsed since the app was last backgrounded.
* The threshold time in milliseconds is set by experiment "enable-tab-switcher-on-return"
*
* @param lastBackgroundedTimeMillis The last time the application was backgrounded. Set in
* ChromeTabbedActivity::onStopWithNative
* @return true if past threshold, false if not past threshold or experiment cannot be loaded.
*/
static boolean shouldShowTabSwitcher(final long lastBackgroundedTimeMillis) {
if (lastBackgroundedTimeMillis == -1) {
// No last background timestamp set, use control behavior.
return false;
}
int tabSwitcherAfterMillis = ChromeFeatureList.getFieldTrialParamByFeatureAsInt(
ChromeFeatureList.TAB_SWITCHER_ON_RETURN, TAB_SWITCHER_ON_RETURN_MS, -1);
if (tabSwitcherAfterMillis < 0) {
// If no value for experiment, use control behavior.
return false;
}
long expirationTime = lastBackgroundedTimeMillis + tabSwitcherAfterMillis;
return System.currentTimeMillis() > expirationTime;
}
}
......@@ -63,6 +63,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/PowerBroadcastReceiver.java",
"java/src/org/chromium/chrome/browser/RepostFormWarningDialog.java",
"java/src/org/chromium/chrome/browser/SSLClientCertificateRequest.java",
"java/src/org/chromium/chrome/browser/ReturnToChromeExperimentsUtil.java",
"java/src/org/chromium/chrome/browser/SearchGeolocationDisclosureTabHelper.java",
"java/src/org/chromium/chrome/browser/ServiceTabLauncher.java",
"java/src/org/chromium/chrome/browser/ShortcutHelper.java",
......
......@@ -1185,6 +1185,19 @@ const FeatureEntry::FeatureVariation kOfflineIndicatorFeatureVariations[] = {
base::size(kBottomOfflineIndicatorEnabled), nullptr}};
#endif // OS_ANDROID
#if defined(OS_ANDROID)
const FeatureEntry::FeatureParam kTabSwitcherOnReturn_30Minutes[] = {
{"tab_switcher_on_return_time_ms", "1800000"}};
const FeatureEntry::FeatureParam kTabSwitcherOnReturn_60Minutes[] = {
{"tab_switcher_on_return_time_ms", "3600000"}};
const FeatureEntry::FeatureVariation kTabSwitcherOnReturnVariations[] = {
{"30 minutes", kTabSwitcherOnReturn_30Minutes,
base::size(kTabSwitcherOnReturn_30Minutes), nullptr},
{"60 minutes", kTabSwitcherOnReturn_60Minutes,
base::size(kTabSwitcherOnReturn_60Minutes), nullptr},
};
#endif // OS_ANDROID
// RECORDING USER METRICS FOR FLAGS:
// -----------------------------------------------------------------------------
// The first line of the entry is the internal name.
......@@ -3690,6 +3703,15 @@ const FeatureEntry kFeatureEntries[] = {
FEATURE_VALUE_TYPE(chrome::android::kHorizontalTabSwitcherAndroid)},
#endif // OS_ANDROID
#if defined(OS_ANDROID)
{"enable-tab-switcher-on-return",
flag_descriptions::kTabSwitcherOnReturnName,
flag_descriptions::kTabSwitcherOnReturnDescription, kOsAndroid,
FEATURE_WITH_PARAMS_VALUE_TYPE(chrome::android::kTabSwitcherOnReturn,
kTabSwitcherOnReturnVariations,
"TabSwitcherOnReturn")},
#endif
#if defined(OS_CHROMEOS)
{"enable-apps-grid-gap", flag_descriptions::kEnableAppsGridGapFeatureName,
flag_descriptions::kEnableAppsGridGapFeatureDescription, kOsCrOS,
......
......@@ -144,6 +144,7 @@ const base::Feature* kFeaturesExposedToJava[] = {
&kSpecialLocaleFeature,
&kSpecialLocaleWrapper,
&kTabReparenting,
&kTabSwitcherOnReturn,
&kTrustedWebActivity,
&kTrustedWebActivityPostMessage,
&kVideoPersistence,
......@@ -405,6 +406,9 @@ const base::Feature kSpecialLocaleWrapper{"SpecialLocaleWrapper",
const base::Feature kTabReparenting{"TabReparenting",
base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kTabSwitcherOnReturn{"TabSwitcherOnReturn",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kTrustedWebActivity{"TrustedWebActivity",
base::FEATURE_ENABLED_BY_DEFAULT};
......
......@@ -81,6 +81,7 @@ extern const base::Feature kSpannableInlineAutocomplete;
extern const base::Feature kSpecialLocaleFeature;
extern const base::Feature kSpecialLocaleWrapper;
extern const base::Feature kTabReparenting;
extern const base::Feature kTabSwitcherOnReturn;
extern const base::Feature kTrustedWebActivity;
extern const base::Feature kTrustedWebActivityPostMessage;
extern const base::Feature kUserMediaScreenCapturing;
......
......@@ -1919,6 +1919,11 @@
// "owners": [ "your-team" ],
"expiry_milestone": 76
},
{
"name": "enable-tab-switcher-on-return",
"owners": [ "memex-team@google.com" ],
"expiry_milestone": 76
},
{
"name": "enable-tcp-fast-open",
// "owners": [ "your-team" ],
......
......@@ -1091,6 +1091,10 @@ const char kHorizontalTabSwitcherAndroidDescription[] =
"Changes the layout of the Android tab switcher so tabs scroll "
"horizontally instead of vertically.";
const char kTabSwitcherOnReturnName[] = "Enable tab switcher on return";
const char kTabSwitcherOnReturnDescription[] =
"Enable tab switcher on return after specified time has elapsed";
const char kHostedAppQuitNotificationName[] =
"Quit notification for hosted apps";
const char kHostedAppQuitNotificationDescription[] =
......
......@@ -650,6 +650,9 @@ extern const char kHarfbuzzRendertextDescription[];
extern const char kHorizontalTabSwitcherAndroidName[];
extern const char kHorizontalTabSwitcherAndroidDescription[];
extern const char kTabSwitcherOnReturnName[];
extern const char kTabSwitcherOnReturnDescription[];
extern const char kViewsCastDialogName[];
extern const char kViewsCastDialogDescription[];
......
......@@ -30421,6 +30421,7 @@ from previous Chrome versions.
<int value="-1503851906" label="EnableSettingsShortcutSearch:enabled"/>
<int value="-1498334893" label="ExperimentalVRFeatures:enabled"/>
<int value="-1497338981" label="disable-accelerated-overflow-scroll"/>
<int value="-1492934655" label="TabSwitcherOnReturn:enabled"/>
<int value="-1492589689" label="ContentSuggestionsCategories:enabled"/>
<int value="-1491417046" label="enable-fullscreen-toolbar-reveal"/>
<int value="-1491304576" label="ProgressBarThrottle:disabled"/>
......@@ -32307,6 +32308,7 @@ from previous Chrome versions.
<int value="1887882558" label="RTCUnifiedPlanByDefault:enabled"/>
<int value="1888812860" label="ChromeModernAlternateCardLayout:enabled"/>
<int value="1889076955" label="disable-app-link"/>
<int value="1889198874" label="TabSwitcherOnReturn:disabled"/>
<int value="1891210939" label="enable-blink-features"/>
<int value="1891312456" label="AndroidMessagesProdEndpoint:disabled"/>
<int value="1892201400" label="enable-password-separated-signin-flow"/>
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