Skip to content
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

chrome: Add ability to block/handle chrome commands (menus & keyboard shortcuts) #3280

Closed
magreenblatt opened this issue Mar 18, 2022 · 11 comments
Labels
chrome Related to the Chrome runtime enhancement Enhancement request Framework Related to framework code or APIs

Comments

@magreenblatt
Copy link
Collaborator

Original report by me.


Some applications won’t want default handling of Chrome keyboard shortcuts.

@magreenblatt
Copy link
Collaborator Author

See issue #2969 for background on the Chrome runtime.

@magreenblatt
Copy link
Collaborator Author

Most commands are routed through BrowserCommandController::ExecuteCommandWithDisposition with IDs defined in chrome_command_ids.h.

Keyboard shortcuts are delivered to this method via call stacks like (at M100 on Windows):

>   libcef.dll!chrome::BrowserCommandController::ExecuteCommandWithDisposition(int id, WindowOpenDisposition disposition, base::TimeTicks time_stamp) Line 374  C++
    libcef.dll!chrome::BrowserCommandController::ExecuteCommand(int id, base::TimeTicks time_stamp) Line 361    C++
    libcef.dll!chrome::ExecuteCommand(Browser * browser, int command, base::TimeTicks time_stamp) Line 413  C++
    libcef.dll!BrowserView::AcceleratorPressed(const ui::Accelerator & accelerator) Line 3551   C++
    ui_base.dll!ui::AcceleratorManager::AcceleratorTargetInfo::TryProcess(const ui::Accelerator & accelerator) Line 152 C++
    ui_base.dll!ui::AcceleratorManager::Process(const ui::Accelerator & accelerator) Line 83    C++
    views.dll!views::FocusManager::ProcessAccelerator(const ui::Accelerator & accelerator) Line 536 C++
    views.dll!views::FocusManager::OnKeyEvent(const ui::KeyEvent & event) Line 113  C++
    views.dll!views::FocusManagerEventHandler::OnKeyEvent(ui::KeyEvent * event) Line 25 C++
    events.dll!ui::EventHandler::OnEvent(ui::Event * event) Line 32 C++

The translation of accelerator to command ID is performed by BrowserView::FindCommandIdForAccelerator using the mapping from accelerator_table.cc.

@magreenblatt
Copy link
Collaborator Author

We should probably include the contents of chrome_command_ids.h in the CEF binary distribution, and allow the client to block/handle any command via a callback from ExecuteCommandWithDisposition.

@magreenblatt
Copy link
Collaborator Author

  • changed title from "chrome: Add ability to disable/override default keyboard shortcut handling" to "chrome: Add ability to handle/disable chrome commands (menus & keyboard shortcuts)"

@magreenblatt
Copy link
Collaborator Author

For this issue we’ll limit functionality to blocking or handling commands that are otherwise enabled. Overriding the current enable/disable state (in a menu, for example) will be left for another time/issue. That would likely require changing the registrations in BrowserCommandController::InitCommandState and possibly other places.

@magreenblatt
Copy link
Collaborator Author

  • changed title from "chrome: Add ability to handle/disable chrome commands (menus & keyboard shortcuts)" to "chrome: Add ability to block/handle chrome commands (menus & keyboard shortcuts)"

@magreenblatt
Copy link
Collaborator Author

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.

→ <<cset 2f5838eaaaee (bb)>>

@magreenblatt
Copy link
Collaborator Author

  • changed state from "new" to "resolved"

@magreenblatt
Copy link
Collaborator Author

Adding additional support for customizing the Chrome toolbar contents.


The above highlighted toolbar zones are controlled as follows:

Visibility of the back, forward, reload, site information, experiments, media controls, extensions, profile and app menu toolbar buttons will not be configurable at this time (each hidden button will require custom code in ToolbarView, and verification that the app doesn’t crash as a result). Return CEF_CTT_LOCATION via CefBrowserViewDelegate::GetChromeToolbarType if you don't want any of that functionality.

@magreenblatt
Copy link
Collaborator Author

chrome: Add ability to hide toolbar and app menu contents (see issue #3280)

This change adds new CefCommandHandler callbacks for optionally hiding
specific Chrome toolbar icons, buttons and app menu items.

To test: Run cefclient --enable-chrome-runtime --filter-chrome-commands.
Most icons, buttons and app/context menu items will be hidden.

→ <<cset 14dd0c0d0616 (bb)>>

@magreenblatt
Copy link
Collaborator Author

chrome: Add ability to hide toolbar and app menu contents (see issue #3280)

This change adds new CefCommandHandler callbacks for optionally hiding
specific Chrome toolbar icons, buttons and app menu items.

To test: Run cefclient --enable-chrome-runtime --filter-chrome-commands.
Most icons, buttons and app/context menu items will be hidden.

→ <<cset f8b9812cb40d (bb)>>

bb33bb pushed a commit to bb33bb/cef that referenced this issue Mar 18, 2023
…hromiumembedded#3280)

This change adds new CefCommandHandler callbacks for optionally hiding
specific Chrome toolbar icons, buttons and app menu items.

To test: Run `cefclient --enable-chrome-runtime --filter-chrome-commands`.
Most icons, buttons and app/context menu items will be hidden.
robincarlisle pushed a commit to robincarlisle/cef that referenced this issue Apr 28, 2023
…sue chromiumembedded#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.
wjh-la pushed a commit to loongson/cef that referenced this issue Jun 29, 2023
…hromiumembedded#3280)

This change adds new CefCommandHandler callbacks for optionally hiding
specific Chrome toolbar icons, buttons and app menu items.

To test: Run `cefclient --enable-chrome-runtime --filter-chrome-commands`.
Most icons, buttons and app/context menu items will be hidden.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chrome Related to the Chrome runtime enhancement Enhancement request Framework Related to framework code or APIs
Projects
None yet
Development

No branches or pull requests

1 participant