chrome: Support customization of context menus (see issue #2969)

This commit is contained in:
Marshall Greenblatt
2021-04-08 19:15:51 -04:00
parent 701f51b1cc
commit 09a9d9b54c
12 changed files with 1169 additions and 10 deletions

View File

@@ -321,24 +321,32 @@ void ClientHandler::OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
if (model->GetCount() > 0)
model->AddSeparator();
// Add DevTools items to all context menus.
model->AddItem(CLIENT_ID_SHOW_DEVTOOLS, "&Show DevTools");
model->AddItem(CLIENT_ID_CLOSE_DEVTOOLS, "Close DevTools");
model->AddSeparator();
model->AddItem(CLIENT_ID_INSPECT_ELEMENT, "Inspect Element");
const bool use_chrome_runtime = MainContext::Get()->UseChromeRuntime();
if (!use_chrome_runtime) {
// TODO(chrome-runtime): Add support for this.
// Add DevTools items to all context menus.
model->AddItem(CLIENT_ID_SHOW_DEVTOOLS, "&Show DevTools");
model->AddItem(CLIENT_ID_CLOSE_DEVTOOLS, "Close DevTools");
model->AddSeparator();
model->AddItem(CLIENT_ID_INSPECT_ELEMENT, "Inspect Element");
}
if (HasSSLInformation(browser)) {
model->AddSeparator();
model->AddItem(CLIENT_ID_SHOW_SSL_INFO, "Show SSL information");
}
model->AddSeparator();
model->AddItem(CLIENT_ID_CURSOR_CHANGE_DISABLED, "Cursor change disabled");
if (mouse_cursor_change_disabled_)
model->SetChecked(CLIENT_ID_CURSOR_CHANGE_DISABLED, true);
if (!use_chrome_runtime) {
// TODO(chrome-runtime): Add support for this.
model->AddSeparator();
model->AddCheckItem(CLIENT_ID_CURSOR_CHANGE_DISABLED,
"Cursor change disabled");
if (mouse_cursor_change_disabled_)
model->SetChecked(CLIENT_ID_CURSOR_CHANGE_DISABLED, true);
}
model->AddSeparator();
model->AddItem(CLIENT_ID_OFFLINE, "Offline mode");
model->AddCheckItem(CLIENT_ID_OFFLINE, "Offline mode");
if (offline_)
model->SetChecked(CLIENT_ID_OFFLINE, true);

View File

@@ -38,6 +38,9 @@ class MainContext {
// Returns the background color.
virtual cef_color_t GetBackgroundColor() = 0;
// Returns true if the Chrome runtime will be used.
virtual bool UseChromeRuntime() = 0;
// Returns true if the Views framework will be used.
virtual bool UseViews() = 0;

View File

@@ -171,6 +171,10 @@ cef_color_t MainContextImpl::GetBackgroundColor() {
return background_color_;
}
bool MainContextImpl::UseChromeRuntime() {
return use_chrome_runtime_;
}
bool MainContextImpl::UseViews() {
return use_views_;
}

View File

@@ -27,6 +27,7 @@ class MainContextImpl : public MainContext {
std::string GetAppWorkingDirectory() OVERRIDE;
std::string GetMainURL() OVERRIDE;
cef_color_t GetBackgroundColor() OVERRIDE;
bool UseChromeRuntime() OVERRIDE;
bool UseViews() OVERRIDE;
bool UseWindowlessRendering() OVERRIDE;
bool TouchEventsEnabled() OVERRIDE;