From: csagan5 <32685696+csagan5@users.noreply.github.com> Date: Mon, 8 Aug 2022 02:35:35 +0200 Subject: Re-introduce modal dialog flag to close all tabs Revert "[Tab Management] Cleanup close all tabs modal dialog flags" This reverts commit 614a998c5af5dcd36baffa6d65090c0b8decb03f. License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- .../browser/tasks/tab_management/CloseAllTabsDialog.java | 6 ++++++ chrome/browser/about_flags.cc | 7 +++++++ chrome/browser/flag_descriptions.cc | 5 +++++ chrome/browser/flag_descriptions.h | 3 +++ chrome/browser/flags/android/chrome_feature_list.cc | 9 +++++++-- chrome/browser/flags/android/chrome_feature_list.h | 1 + .../chromium/chrome/browser/flags/ChromeFeatureList.java | 1 + 7 files changed, 30 insertions(+), 2 deletions(-) diff --git a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/CloseAllTabsDialog.java b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/CloseAllTabsDialog.java --- a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/CloseAllTabsDialog.java +++ b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/CloseAllTabsDialog.java @@ -12,6 +12,7 @@ import androidx.annotation.VisibleForTesting; import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.supplier.Supplier; +import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.R; import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.ui.modaldialog.DialogDismissalCause; @@ -35,6 +36,11 @@ public class CloseAllTabsDialog { public static void show(Context context, Supplier modalDialogManagerSupplier, @NonNull TabModelSelector tabModelSelector, Runnable onCloseAll) { + if (!ChromeFeatureList.isEnabled(ChromeFeatureList.CLOSE_ALL_TABS_MODAL_DIALOG)) { + onCloseAll.run(); + return; + } + assert modalDialogManagerSupplier.hasValue(); final ModalDialogManager manager = modalDialogManagerSupplier.get(); final boolean isIncognito = tabModelSelector.getCurrentModel().isIncognito(); diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -9939,6 +9939,13 @@ const FeatureEntry kFeatureEntries[] = { FEATURE_VALUE_TYPE(base::i18n::kLacrosMergeIcuDataFile)}, #endif +#if BUILDFLAG(IS_ANDROID) + {"close-all-tabs-modal-dialog", + flag_descriptions::kCloseAllTabsModalDialogName, + flag_descriptions::kCloseAllTabsModalDialogDescription, kOsAndroid, + FEATURE_VALUE_TYPE(chrome::android::kCloseAllTabsModalDialog)}, +#endif // BUILDFLAG(IS_ANDROID) + #if !BUILDFLAG(IS_ANDROID) // TODO(https://crbug.com/1443349): Add Windows once library supports it. {"layout-extraction", flag_descriptions::kLayoutExtractionName, diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc @@ -3981,6 +3981,11 @@ const char kChimeAndroidSdkDescription[] = "Enable Chime SDK to receive push notification."; const char kChimeAndroidSdkName[] = "Use Chime SDK"; +const char kCloseAllTabsModalDialogName[] = "Close all tabs modal dialog"; +const char kCloseAllTabsModalDialogDescription[] = + "Shows a confirmation modal dialog when clicking 'Close all tabs' in the" + "app menu."; + const char kCloseTabSuggestionsName[] = "Suggest to close Tabs"; const char kCloseTabSuggestionsDescription[] = "Suggests to the user to close Tabs that haven't been used beyond a " diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h @@ -46,6 +46,9 @@ namespace flag_descriptions { extern const char kAccelerated2dCanvasName[]; extern const char kAccelerated2dCanvasDescription[]; +extern const char kCloseAllTabsModalDialogName[]; +extern const char kCloseAllTabsModalDialogDescription[]; + extern const char kAcceleratedVideoDecodeName[]; extern const char kAcceleratedVideoDecodeDescription[]; 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 @@ -183,6 +183,7 @@ const base::Feature* const kFeaturesExposedToJava[] = { &kBackGestureActivityTabProvider, &kBackGestureRefactorActivityAndroid, &kBackGestureRefactorAndroid, + &kCloseAllTabsModalDialog, &kBackgroundThreadPool, &kBaselineGM3SurfaceColors, &kBlockIntentsWhileLocked, @@ -536,6 +537,10 @@ BASE_FEATURE(kCacheActivityTaskID, "CacheActivityTaskID", base::FEATURE_ENABLED_BY_DEFAULT); +BASE_FEATURE(kCloseAllTabsModalDialog, + "CloseAllTabsModalDialog", + base::FEATURE_ENABLED_BY_DEFAULT); + // Used in downstream code. BASE_FEATURE(kCastDeviceFilter, "CastDeviceFilter", @@ -546,8 +551,8 @@ BASE_FEATURE(kClearOmniboxFocusAfterNavigation, base::FEATURE_ENABLED_BY_DEFAULT); BASE_FEATURE(kCloseTabSuggestions, - "CloseTabSuggestions", - base::FEATURE_DISABLED_BY_DEFAULT); + "CloseTabSuggestions", // must be enabled + base::FEATURE_ENABLED_BY_DEFAULT); // in Bromite BASE_FEATURE(kCloseTabSaveTabList, "CloseTabSaveTabList", 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 @@ -41,6 +41,7 @@ BASE_DECLARE_FEATURE(kBaselineGM3SurfaceColors); BASE_DECLARE_FEATURE(kBlockIntentsWhileLocked); BASE_DECLARE_FEATURE(kCacheActivityTaskID); BASE_DECLARE_FEATURE(kClearOmniboxFocusAfterNavigation); +BASE_DECLARE_FEATURE(kCloseAllTabsModalDialog); BASE_DECLARE_FEATURE(kCloseTabSuggestions); BASE_DECLARE_FEATURE(kCloseTabSaveTabList); BASE_DECLARE_FEATURE(kCreateNewTabInitializeRenderer); 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 @@ -197,6 +197,7 @@ public abstract class ChromeFeatureList { public static final String CCT_RESIZABLE_90_MAXIMUM_HEIGHT = "CCTResizable90MaximumHeight"; public static final String CCT_RESIZABLE_ALLOW_RESIZE_BY_USER_GESTURE = "CCTResizableAllowResizeByUserGesture"; + public static final String CLOSE_ALL_TABS_MODAL_DIALOG = "CloseAllTabsModalDialog"; public static final String CCT_RESIZABLE_FOR_THIRD_PARTIES = "CCTResizableForThirdParties"; public static final String CCT_RESIZABLE_SIDE_SHEET = "CCTResizableSideSheet"; public static final String CCT_RESIZABLE_SIDE_SHEET_FOR_THIRD_PARTIES = -- 2.25.1