chrome: Add cleanup when context menu isn't running (fixes #3711)

The menu may not be running in the following cases:

- If the menu is empty (e.g. cleared in OnBeforeContextMenu).
- If the menu is disabled (see e.g. RenderViewContextMenuViews::Show).
- When the run call blocks until the menu is dismissed (macOS behavior).

We explicitly clean up in these cases instead of waiting for OnMenuClosed
which will otherwise never be called for the first 2 cases.

Menu run status is exposed via new ContextMenuDelegate and
RenderViewContextMenuBase methods.
This commit is contained in:
Marshall Greenblatt
2024-06-12 17:12:50 -04:00
parent cc40cbdd45
commit fe24ce3c71
5 changed files with 219 additions and 13 deletions

View File

@@ -21,6 +21,8 @@ void RegisterCallbacks();
bool HandleContextMenu(content::WebContents* opener,
const content::ContextMenuParams& params);
void MaybeResetContextMenu(content::WebContents* opener);
} // namespace context_menu
#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_CONTEXT_MENU_HANDLER_H_