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.
This commit is contained in:
Marshall Greenblatt
2023-03-06 18:21:57 -05:00
parent 06af9c85da
commit 14dd0c0d06
15 changed files with 866 additions and 77 deletions

View File

@@ -139,6 +139,12 @@ class ClientHandler : public CefClient,
bool OnChromeCommand(CefRefPtr<CefBrowser> browser,
int command_id,
cef_window_open_disposition_t disposition) override;
bool IsChromeAppMenuItemVisible(CefRefPtr<CefBrowser> browser,
int command_id) override;
bool IsChromePageActionIconVisible(
cef_chrome_page_action_icon_type_t icon_type) override;
bool IsChromeToolbarButtonVisible(
cef_chrome_toolbar_button_type_t button_type) override;
// CefContextMenuHandler methods
void OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
@@ -371,10 +377,6 @@ class ClientHandler : public CefClient,
void SetOfflineState(CefRefPtr<CefBrowser> browser, bool offline);
// Filter menu and keyboard shortcut commands.
void FilterMenuModel(CefRefPtr<CefMenuModel> model);
bool IsAllowedCommandId(int command_id);
// THREAD SAFE MEMBERS
// The following members may be accessed from any thread.
@@ -396,6 +398,9 @@ class ClientHandler : public CefClient,
// True if the browser is currently offline.
bool offline_;
// True if the Chrome toolbar and menu contents/commands should be filtered.
bool filter_chrome_commands_;
// True if Favicon images should be downloaded.
bool download_favicon_images_ = false;