2024-04-17 18:01:26 +02:00
|
|
|
// Copyright 2024 The Chromium Embedded Framework Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/chrome/chrome_web_contents_view_delegate_cef.h"
|
2024-04-17 18:01:26 +02:00
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/chrome/chrome_context_menu_handler.h"
|
2024-04-17 18:01:26 +02:00
|
|
|
|
|
|
|
ChromeWebContentsViewDelegateCef::ChromeWebContentsViewDelegateCef(
|
|
|
|
content::WebContents* web_contents)
|
|
|
|
: ChromeWebContentsViewDelegateBase(web_contents),
|
|
|
|
web_contents_(web_contents) {}
|
|
|
|
|
|
|
|
void ChromeWebContentsViewDelegateCef::ShowContextMenu(
|
|
|
|
content::RenderFrameHost& render_frame_host,
|
|
|
|
const content::ContextMenuParams& params) {
|
|
|
|
if (context_menu::HandleContextMenu(web_contents_, params)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ChromeWebContentsViewDelegateBase::ShowContextMenu(render_frame_host, params);
|
2024-06-12 23:12:50 +02:00
|
|
|
|
|
|
|
// The menu may not be running in the following cases:
|
|
|
|
// - If the menu is empty (e.g. cleared in OnBeforeContextMenu).
|
|
|
|
// - If the menu is disabled (see e.g. RenderViewContextMenuViews::Show).
|
|
|
|
// - When the above call blocks until the menu is dismissed (macOS behavior).
|
|
|
|
// We explicitly clean up in these cases instead of waiting for OnMenuClosed
|
|
|
|
// which will otherwise never be called for the first 2 cases.
|
|
|
|
if (!IsMenuRunning()) {
|
|
|
|
context_menu::MaybeResetContextMenu(web_contents_);
|
|
|
|
}
|
2024-04-17 18:01:26 +02:00
|
|
|
}
|