-
Notifications
You must be signed in to change notification settings - Fork 879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore deleted tab context menu #3836
Conversation
6f49623
to
8daa441
Compare
8daa441
to
190fafd
Compare
Oh, there are some lint error and missing deps. updating now. |
616fec5
to
30eb667
Compare
Ready to review. |
30eb667
to
983abe0
Compare
@simonhong can you link to the Chromium details (in the commit message)? And then I believe it was removed with https://chromium.googlesource.com/chromium/src.git/+/32bb26026fb3fd768dda878f9193a5080593d5ec |
983abe0
to
63d7514
Compare
23d4293
to
e3db310
Compare
tab_strip_model_(tab_strip_model) { | ||
// Take owner ship of TabMenuModelDelegateProxy instance. | ||
// There is no way to instantiate it before calling ctor of base class. | ||
delegate_proxy_.reset(TabMenuModel::delegate()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed anymore? (how is delegate_proxy_
used?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs because SimpleMenuModel
doesn't own delegate.
BraveTabMenuModel
should manage proxy's lifecycle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely does not look right to me. The TabMenuModel is not supposed to take ownership of the delegate and this seems likely to cause a crash at some point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The delegate is owned by the BrowserTabStripController and I'm fairly certain that this will crash if you close a window with a context menu open. At the very least it breaks the cancel behavior here
BrowserTabStripController::~BrowserTabStripController() {
// When we get here the TabStrip is being deleted. We need to explicitly
// cancel the menu, otherwise it may try to invoke something on the tabstrip
// from its destructor.
if (context_menu_contents_.get())
context_menu_contents_->Cancel();
model_->RemoveObserver(this);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I just noticed that you're creating a new proxy delegate there, but that's also a potential problem. Let's dm and discuss when you're available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this creates a bit of a convoluted chain of ownership and while it may or may not be ok, it seems like it would be easier to subclass BrowserTabStripController in BrowserViews and implement ShowContextMenuForTab
. Then we can create our own delegate from the start with our own TabMenuModel
and calling back into our own ExecuteCommandForTab
. Then we can check the command ids in our BrowserTabStripController and either delegate to the TabStripModel or call the command in BraveBrowserTabStripController
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then at least the commands have the same flow at least through ExecuteCommandForTab
and there are no confusing ownership chains
Kindly ping to @bridiver :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++
Reopen closed tab, Close other tabs and Bookmark all tabs items are restored to tab context menu. Chromium removed some items from tab context menu by below CL. CL: https://chromium-review.googlesource.com/c/chromium/src/+/1761666 Issue: https://bugs.chromium.org/p/chromium/issues/detail?id=515930 Update tab and frame context menus to match most recent UX specs. This removes four entries from the tab context menu; changes the text on several others to stop saying "tab(s)" explicitly; adds one entry to the frame context menu; and changes the bookmark-related menu entry strings from "page" to "tab" for consistency. Most of the file changes here are due to renaming enums/APIs to match the string changes.
e3db310
to
feff2ae
Compare
|
||
private: | ||
FRIEND_TEST_ALL_PREFIXES(TabStripModelTest, GetIndicesClosedByCommand); | ||
+ friend class TabMenuModelDelegateProxy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this friend is needed. Can you explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is needed, @bridiver added an example for how to do it cleaner under https://github.com/brave/brave-browser/wiki/Patching-Chromium#subclass-and-override
Revert "Merge pull request #3836 from brave/tab_menu_model"
} | ||
|
||
bool TabMenuModelDelegateProxy::IsCommandIdChecked(int command_id) const { | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be returning delegate_->IsCommandIdChecked
return indices; | ||
} | ||
|
||
bool TabMenuModelDelegateProxy::IsBraveCommandIds(int command_id) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: IsBraveCommandIds
-> IsBraveCommandId
the use of Ids
here is not grammatically correct
} | ||
} | ||
|
||
std::vector<int> TabMenuModelDelegateProxy::GetIndicesClosed(int index) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method name is confused to me. Maybe it should be GetIndicesToClose
?
Re-opened PR at #3875 cc: @simonhong on the above review comments |
Fix brave/brave-browser#6513
Reopen closed tab, Close other tabs and Bookmark all tabs items
are restored to tab context menu.
Chromium removed some items from tab context menu by below CL.
CL: https://chromium-review.googlesource.com/c/chromium/src/+/1761666
Issue: https://bugs.chromium.org/p/chromium/issues/detail?id=515930
Update tab and frame context menus to match most recent UX specs.
This removes four entries from the tab context menu; changes the text on several
others to stop saying "tab(s)" explicitly; adds one entry to the frame context
menu; and changes the bookmark-related menu entry strings from "page" to "tab"
for consistency.
Most of the file changes here are due to renaming enums/APIs to match the string
changes.
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Enabled state of
Bookmark all tabs
andReopen closed tab
are same as frame's same context menu.Close other tabs
is enabled only when closing candidates exists.yarn test brave_browser_tests --filter=*BraveTabMenuModelTest*
Reviewer Checklist:
After-merge Checklist:
changes has landed on.