Commit 7109368d authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Add feature to control Focus on Omnibox in incognito tab intents.

Incognito tab launcher intents are followed by focus on Omnibox and
partially hiding incognito NTP message and totally hiding incognito
tab counter.
This behavior is moved behind "kFocusOnOmniboxInIncognitoTabIntents"
feature. The feature is disabled by default until appropriate privacy
notice is added.

Bug: 1029018
Change-Id: I9e1152b747f6d0d02aa6e31263a36c345ff77dab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1941309Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720869}
parent c8187c73
......@@ -247,6 +247,8 @@ public abstract class ChromeFeatureList {
public static final String EPHEMERAL_TAB_USING_BOTTOM_SHEET = "EphemeralTabUsingBottomSheet";
public static final String EXPLICIT_LANGUAGE_ASK = "ExplicitLanguageAsk";
public static final String EXPLORE_SITES = "ExploreSites";
public static final String FOCUS_OMNIBOX_IN_INCOGNITO_TAB_INTENTS =
"FocusOmniboxInIncognitoTabIntents";
public static final String OFFLINE_HOME = "OfflineHome";
public static final String GENERIC_SENSOR_EXTRA_CLASSES = "GenericSensorExtraClasses";
public static final String GRANT_NOTIFICATIONS_TO_DSE = "GrantNotificationsToDSE";
......
......@@ -1467,14 +1467,15 @@ public class ChromeTabbedActivity extends ChromeActivity implements ScreenshotMo
} else if (IncognitoTabLauncher.didCreateIntent(intent)) {
Tab tab = getTabCreator(true).launchUrl(UrlConstants.NTP_URL,
TabLaunchType.FROM_LAUNCH_NEW_INCOGNITO_TAB);
// Since the Tab is created in the foreground, its View will gain focus,
// and since the Tab and the URL bar are not yet in the same View
// hierarchy, setting the URL bar's focus here won't clear the Tab's
// focus.
// When the Tab is added to the hierarchy, we want the URL bar to retain
// focus, so we clear the Tab's focus here.
tab.getView().clearFocus();
focus = true;
if (IncognitoTabLauncher.shouldFocusOmnibox()) {
// Since the Tab is created in the foreground, its View will gain
// focus, and since the Tab and the URL bar are not yet in the same
// View hierarchy, setting the URL bar's focus here won't clear the
// Tab's focus. When the Tab is added to the hierarchy, we want the
// URL bar to retain focus, so we clear the Tab's focus here.
tab.getView().clearFocus();
focus = true;
}
IncognitoTabLauncher.recordUse();
} else {
......
......@@ -74,6 +74,14 @@ public class IncognitoTabLauncher extends Activity {
intent, IntentHandler.EXTRA_INVOKED_FROM_LAUNCH_NEW_INCOGNITO_TAB, false);
}
/**
* Returns whether the omnibox should be focused after launching the incognito tab.
*/
public static boolean shouldFocusOmnibox() {
return ChromeFeatureList.isEnabled(
ChromeFeatureList.FOCUS_OMNIBOX_IN_INCOGNITO_TAB_INTENTS);
}
/**
* Records UMA that a new incognito tab has been launched as a result of this Activity.
*/
......
......@@ -65,6 +65,7 @@ public class IncognitoTabLauncherTest {
@Test
@Feature("Incognito")
@MediumTest
@Features.EnableFeatures({ChromeFeatureList.FOCUS_OMNIBOX_IN_INCOGNITO_TAB_INTENTS})
public void testLaunchIncognitoNewTab_omniboxFocused() {
ChromeTabbedActivity activity = launchIncognitoTab();
CriteriaHelper.pollUiThread(() -> activity.getToolbarManager().isUrlBarFocused());
......
......@@ -142,6 +142,7 @@ const base::Feature* kFeaturesExposedToJava[] = {
&kEphemeralTab,
&kEphemeralTabUsingBottomSheet,
&kExploreSites,
&kFocusOmniboxInIncognitoTabIntents,
&kHandleMediaIntents,
&kHomepageLocation,
&kHorizontalTabSwitcherAndroid,
......@@ -267,6 +268,9 @@ const base::Feature kAndroidPayIntegrationV1{"AndroidPayIntegrationV1",
const base::Feature kAllowNewIncognitoTabIntents{
"AllowNewIncognitoTabIntents", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kFocusOmniboxInIncognitoTabIntents{
"FocusOmniboxInIncognitoTabIntents", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kAllowRemoteContextForNotifications{
"AllowRemoteContextForNotifications", base::FEATURE_ENABLED_BY_DEFAULT};
......
......@@ -73,6 +73,7 @@ extern const base::Feature kDuetTabStripIntegrationAndroid;
extern const base::Feature kEphemeralTab;
extern const base::Feature kEphemeralTabUsingBottomSheet;
extern const base::Feature kExploreSites;
extern const base::Feature kFocusOmniboxInIncognitoTabIntents;
extern const base::Feature kHandleMediaIntents;
extern const base::Feature kHomepageLocation;
extern const base::Feature kHorizontalTabSwitcherAndroid;
......
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