From e4d0cb9c4b884ab50c5a77c415b44ea475217fab Mon Sep 17 00:00:00 2001 From: brave-builds Date: Tue, 12 Sep 2023 01:50:51 +0000 Subject: [PATCH] Uplift of #20118 (squashed) to release --- .../browser/settings/AppearancePreferences.java | 1 - .../tasks/tab_groups/BraveTabGroupModelFilter.java | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/android/java/org/chromium/chrome/browser/settings/AppearancePreferences.java b/android/java/org/chromium/chrome/browser/settings/AppearancePreferences.java index 1c2c3f464d76..9bf41752a52b 100644 --- a/android/java/org/chromium/chrome/browser/settings/AppearancePreferences.java +++ b/android/java/org/chromium/chrome/browser/settings/AppearancePreferences.java @@ -55,7 +55,6 @@ public void onCreate(Bundle savedInstanceState) { ContextUtils.getApplicationContext()); if (isTablet) { removePreferenceIfPresent(BravePreferenceKeys.BRAVE_BOTTOM_TOOLBAR_ENABLED_KEY); - removePreferenceIfPresent(PREF_BRAVE_ENABLE_TAB_GROUPS); } if (!NightModeUtils.isNightModeSupported()) { diff --git a/browser/tab_group/java/src/org/chromium/chrome/browser/tasks/tab_groups/BraveTabGroupModelFilter.java b/browser/tab_group/java/src/org/chromium/chrome/browser/tasks/tab_groups/BraveTabGroupModelFilter.java index 4f9a818b206c..c4cad9631a72 100644 --- a/browser/tab_group/java/src/org/chromium/chrome/browser/tasks/tab_groups/BraveTabGroupModelFilter.java +++ b/browser/tab_group/java/src/org/chromium/chrome/browser/tasks/tab_groups/BraveTabGroupModelFilter.java @@ -11,6 +11,7 @@ import org.chromium.base.BraveReflectionUtil; import org.chromium.chrome.browser.preferences.SharedPreferencesManager; import org.chromium.chrome.browser.tab.Tab; +import org.chromium.chrome.browser.tab.TabLaunchType; import org.chromium.chrome.browser.tab.state.CriticalPersistedTabData; import org.chromium.chrome.browser.tabmodel.TabModel; import org.chromium.chrome.browser.tabmodel.TabModelFilter; @@ -34,9 +35,10 @@ public BraveTabGroupModelFilter(TabModel tabModel) { * Call from {@link TabGroupModelFilter} will be redirected here via bytrcode. */ public int getParentId(Tab tab) { - if (isTabModelRestored() && !mIsResetting + if (linkClicked(tab.getLaunchType()) && SharedPreferencesManager.getInstance().readBoolean( - BravePreferenceKeys.BRAVE_TAB_GROUPS_ENABLED, true)) { + BravePreferenceKeys.BRAVE_TAB_GROUPS_ENABLED, true) + && isTabModelRestored() && !mIsResetting) { Tab parentTab = TabModelUtils.getTabById( getTabModel(), CriticalPersistedTabData.from(tab).getParentId()); if (parentTab != null) { @@ -48,4 +50,11 @@ public int getParentId(Tab tab) { return (int) BraveReflectionUtil.InvokeMethod( TabGroupModelFilter.class, this, "getParentId", Tab.class, tab); } + + /** + * Determine if a launch type is the result of linked being clicked. + */ + private boolean linkClicked(@TabLaunchType int type) { + return type == TabLaunchType.FROM_LINK || type == TabLaunchType.FROM_LONGPRESS_FOREGROUND; + } }