chrome: Add ability to handle chrome menu/keyboard commands (fixes issue #3280)

This change adds a CefCommandHandler::OnChromeCommand callback for optionally
handling Chrome commands triggered via menus or keyboard shortcuts. Supported
command IDs are listed in a new cef_command_ids.h header file.

To test: Run `cefclient --enable-chrome-runtime --hide-controls`. Most commands
will blocked and removed from context menus.
This commit is contained in:
Marshall Greenblatt
2022-03-22 14:31:30 -04:00
parent 13ca38e4e0
commit 2f5838eaaa
44 changed files with 703 additions and 44 deletions

View File

@@ -10,6 +10,7 @@
#include "base/memory/scoped_refptr.h"
#include "content/public/browser/web_contents_delegate.h"
#include "ui/base/window_open_disposition.h"
class Browser;
@@ -47,6 +48,13 @@ class BrowserDelegate : public content::WebContentsDelegate {
virtual bool ShowStatusBubble(bool show_by_default) {
return show_by_default;
}
// Return true to handle (or disable) a command. ID values come from
// chrome/app/chrome_command_ids.h.
virtual bool HandleCommand(int command_id,
WindowOpenDisposition disposition) {
return false;
}
};
} // namespace cef