From 30c3e1924967c7c1d6e0190f5bf8a2e45fb06e83 Mon Sep 17 00:00:00 2001 From: tapanmodh Date: Mon, 9 Jan 2023 23:21:08 +0530 Subject: [PATCH] open in a new tab from brave news in background tab --- .../brave_news/BraveNewsBottomSheetDialogFragment.java | 2 +- .../org/chromium/chrome/browser/util/TabUtils.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/android/java/org/chromium/chrome/browser/brave_news/BraveNewsBottomSheetDialogFragment.java b/android/java/org/chromium/chrome/browser/brave_news/BraveNewsBottomSheetDialogFragment.java index 4fa8828044ee..1b0f1ecb416a 100644 --- a/android/java/org/chromium/chrome/browser/brave_news/BraveNewsBottomSheetDialogFragment.java +++ b/android/java/org/chromium/chrome/browser/brave_news/BraveNewsBottomSheetDialogFragment.java @@ -91,7 +91,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat newTab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - TabUtils.openUrlInNewTab(false, mUrl); + TabUtils.openUrlInNewTabInBackground(false, mUrl); dismiss(); } }); diff --git a/android/java/org/chromium/chrome/browser/util/TabUtils.java b/android/java/org/chromium/chrome/browser/util/TabUtils.java index df72fd67372e..d1756b64b10c 100644 --- a/android/java/org/chromium/chrome/browser/util/TabUtils.java +++ b/android/java/org/chromium/chrome/browser/util/TabUtils.java @@ -77,6 +77,16 @@ public static void openUrlInNewTab(boolean isIncognito, String url) { } } + public static void openUrlInNewTabInBackground(boolean isIncognito, String url) { + BraveActivity braveActivity = BraveActivity.getBraveActivity(); + if (braveActivity != null && braveActivity.getTabModelSelector() != null + && braveActivity.getActivityTab() != null) { + braveActivity.getTabModelSelector().openNewTab(new LoadUrlParams(url), + TabLaunchType.FROM_LONGPRESS_BACKGROUND_IN_GROUP, + braveActivity.getActivityTab(), isIncognito); + } + } + public static void openUrlInSameTab(String url) { BraveActivity braveActivity = BraveActivity.getBraveActivity(); if (braveActivity != null && braveActivity.getActivityTab() != null) {