-
Notifications
You must be signed in to change notification settings - Fork 922
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25310 from jagadeshjai/feature__toggle_for_show_u…
…ndo_bar [Android] Add an option to Show/Hide Undo bar when tab[s] closed.
- Loading branch information
Showing
12 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
.../java/org/chromium/chrome/browser/undo_tab_close_snackbar/BraveUndoBarControllerBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.chromium.chrome.browser.undo_tab_close_snackbar; | ||
|
||
import org.chromium.base.BravePreferenceKeys; | ||
import org.chromium.base.BraveReflectionUtil; | ||
import org.chromium.chrome.browser.preferences.ChromeSharedPreferences; | ||
import org.chromium.chrome.browser.tab.Tab; | ||
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager; | ||
|
||
import java.util.List; | ||
|
||
public class BraveUndoBarControllerBase implements SnackbarManager.SnackbarController { | ||
public void showUndoBar(List<Tab> closedTabs, boolean isAllTabs) { | ||
boolean showUndoBar = | ||
ChromeSharedPreferences.getInstance() | ||
.readBoolean(BravePreferenceKeys.SHOW_UNDO_WHEN_TABS_CLOSED, true); | ||
if (!showUndoBar) { | ||
if (closedTabs.isEmpty()) { | ||
return; | ||
} | ||
Object actionData = closedTabs.size() == 1 ? closedTabs.get(0).getId() : closedTabs; | ||
onDismissNoAction(actionData); | ||
return; | ||
} | ||
|
||
BraveReflectionUtil.invokeMethod( | ||
UndoBarController.class, | ||
this, | ||
"showUndoBar", | ||
List.class, | ||
closedTabs, | ||
boolean.class, | ||
isAllTabs); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
build/android/bytecode/java/org/brave/bytecode/BraveUndoBarControllerBaseClassAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.brave.bytecode; | ||
|
||
import org.objectweb.asm.ClassVisitor; | ||
|
||
public class BraveUndoBarControllerBaseClassAdapter extends BraveClassVisitor { | ||
static String sUndoBarController = | ||
"org/chromium/chrome/browser/undo_tab_close_snackbar/UndoBarController"; | ||
static String sBraveUndoBarControllerBase = | ||
"org/chromium/chrome/browser/undo_tab_close_snackbar/BraveUndoBarControllerBase"; | ||
|
||
public BraveUndoBarControllerBaseClassAdapter(ClassVisitor visitor) { | ||
super(visitor); | ||
|
||
changeSuperName(sUndoBarController, sBraveUndoBarControllerBase); | ||
|
||
changeMethodOwner(sUndoBarController, "showUndoBar", sBraveUndoBarControllerBase); | ||
} | ||
} |