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

@ -1,5 +1,5 @@
diff --git chrome/browser/ui/browser_command_controller.cc chrome/browser/ui/browser_command_controller.cc
index cff1df2490bb6..9d156bd9993fa 100644
index cff1df2490bb6..864a03a2e29c9 100644
--- chrome/browser/ui/browser_command_controller.cc
+++ chrome/browser/ui/browser_command_controller.cc
@@ -371,8 +371,10 @@ bool BrowserCommandController::ExecuteCommandWithDisposition(
@ -14,7 +14,21 @@ index cff1df2490bb6..9d156bd9993fa 100644
// No commands are enabled if there is not yet any selected tab.
// TODO(pkasting): It seems like we should not need this, because either
@@ -985,11 +987,13 @@ void BrowserCommandController::TabRestoreServiceLoaded(
@@ -387,6 +389,13 @@ bool BrowserCommandController::ExecuteCommandWithDisposition(
DCHECK(command_updater_.IsCommandEnabled(id))
<< "Invalid/disabled command " << id;
+#if BUILDFLAG(ENABLE_CEF)
+ if (browser_->cef_delegate() &&
+ browser_->cef_delegate()->HandleCommand(id, disposition)) {
+ return true;
+ }
+#endif
+
// The order of commands in this switch statement must match the function
// declaration order in browser.h!
switch (id) {
@@ -985,11 +994,13 @@ void BrowserCommandController::TabRestoreServiceLoaded(
// BrowserCommandController, private:
bool BrowserCommandController::IsShowingMainUI() {