From: csagan5 <32685696+csagan5@users.noreply.github.com> Date: Fri, 24 Jan 2020 19:17:22 +0100 Subject: Disable smart selection by default Allow web search in incognito mode; Smart Selection still disabled in incognito as per upstream. Partial revert of da1d809c003749846cb4ade8c11b6d038e44416b to restore the ChromeSmartSelection feature flag. License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- .../contextualsearch/SelectionClientManager.java | 4 +++- .../browser/flags/android/chrome_feature_list.cc | 5 +++++ .../browser/flags/android/chrome_feature_list.h | 1 + .../chrome/browser/flags/ChromeFeatureList.java | 1 + .../selection/SelectionPopupControllerImpl.java | 2 +- testing/variations/fieldtrial_testing_config.json | 15 +++++++++++++++ 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/SelectionClientManager.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/SelectionClientManager.java --- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/SelectionClientManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/SelectionClientManager.java @@ -10,6 +10,7 @@ import android.view.textclassifier.TextClassifier; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; +import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.content_public.browser.SelectAroundCaretResult; import org.chromium.content_public.browser.SelectionClient; import org.chromium.content_public.browser.SelectionEventProcessor; @@ -45,7 +46,8 @@ public class SelectionClientManager { * @param webContents The {@link WebContents} that will show popups for this client. */ SelectionClientManager(WebContents webContents) { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) { + if (ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_SMART_SELECTION) + && Build.VERSION.SDK_INT > Build.VERSION_CODES.O) { assert webContents != null; mOptionalSelectionClient = SelectionClient.createSmartSelectionClient(webContents); SelectionPopupController controller = diff --git a/chrome/browser/flags/android/chrome_feature_list.cc b/chrome/browser/flags/android/chrome_feature_list.cc --- a/chrome/browser/flags/android/chrome_feature_list.cc +++ b/chrome/browser/flags/android/chrome_feature_list.cc @@ -202,6 +202,7 @@ const base::Feature* const kFeaturesExposedToJava[] = { &kCCTDeprecatedAPIs, &kCCTFeatureUsage, &kCCTIncognito, + &kChromeSmartSelection, &kCCTIncognitoAvailableToThirdParty, &kCCTIntentFeatureOverrides, &kCCTMinimized, @@ -1059,6 +1060,10 @@ BASE_FEATURE(kTabEngagementReportingAndroid, "TabEngagementReportingAndroid", base::FEATURE_DISABLED_BY_DEFAULT); +BASE_FEATURE(kChromeSmartSelection, + "ChromeSmartSelection", + base::FEATURE_DISABLED_BY_DEFAULT); + BASE_FEATURE(kTabStripRedesign, "TabStripRedesign", base::FEATURE_DISABLED_BY_DEFAULT); diff --git a/chrome/browser/flags/android/chrome_feature_list.h b/chrome/browser/flags/android/chrome_feature_list.h --- a/chrome/browser/flags/android/chrome_feature_list.h +++ b/chrome/browser/flags/android/chrome_feature_list.h @@ -78,6 +78,7 @@ BASE_DECLARE_FEATURE(kCCTToolbarCustomizations); BASE_DECLARE_FEATURE(kDontAutoHideBrowserControls); BASE_DECLARE_FEATURE(kCacheDeprecatedSystemLocationSetting); BASE_DECLARE_FEATURE(kChromeNewDownloadTab); +BASE_DECLARE_FEATURE(kChromeSmartSelection); BASE_DECLARE_FEATURE(kChromeShareScreenshot); BASE_DECLARE_FEATURE(kChromeSharingHub); BASE_DECLARE_FEATURE(kChromeSharingHubLaunchAdjacent); diff --git a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java --- a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java +++ b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java @@ -190,6 +190,7 @@ public abstract class ChromeFeatureList { public static final String CCT_REAL_TIME_ENGAGEMENT_SIGNALS_ALTERNATIVE_IMPL = "CCTRealTimeEngagementSignalsAlternativeImpl"; public static final String CCT_REDIRECT_PRECONNECT = "CCTRedirectPreconnect"; + public static final String CHROME_SMART_SELECTION = "ChromeSmartSelection"; public static final String CCT_REMOVE_REMOTE_VIEW_IDS = "CCTRemoveRemoteViewIds"; public static final String CCT_REPORT_PARALLEL_REQUEST_STATUS = "CCTReportParallelRequestStatus"; diff --git a/content/public/android/java/src/org/chromium/content/browser/selection/SelectionPopupControllerImpl.java b/content/public/android/java/src/org/chromium/content/browser/selection/SelectionPopupControllerImpl.java --- a/content/public/android/java/src/org/chromium/content/browser/selection/SelectionPopupControllerImpl.java +++ b/content/public/android/java/src/org/chromium/content/browser/selection/SelectionPopupControllerImpl.java @@ -1120,7 +1120,7 @@ public class SelectionPopupControllerImpl extends ActionModeCallbackHelper */ @Override public boolean canWebSearch() { - return hasSelection() && !isFocusedNodeEditable() && !isIncognito() + return hasSelection() && !isFocusedNodeEditable() && isSelectActionModeAllowed(MENU_ITEM_WEB_SEARCH); } diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json @@ -4088,6 +4088,21 @@ ] } ], + "ChromeSmartSelection": [ + { + "platforms": [ + "android" + ], + "experiments": [ + { + "name": "Enabled_Launch", + "enable_features": [ + "ChromeSmartSelection" + ] + } + ] + } + ], "CommerceHintAndroid": [ { "platforms": [ -- 2.25.1