#include "components/renderer_context_menu/render_view_context_menu_base.h"
#include <algorithm>
#include <utility>
#include <vector>
#include "base/command_line.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/observer_list.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "ppapi/buildflags/buildflags.h"
#include "third_party/blink/public/mojom/context_menu/context_menu.mojom.h"
#include "ui/base/models/image_model.h"
#include "url/origin.h"
BrowserContext;
GlobalRenderFrameHostId;
OpenURLParams;
RenderFrameHost;
RenderViewHost;
WebContents;
namespace {
int content_context_custom_first = …;
int content_context_custom_last = …;
bool IsCustomItemEnabledInternal(
const std::vector<blink::mojom::CustomContextMenuItemPtr>& items,
int id) { … }
bool IsCustomItemCheckedInternal(
const std::vector<blink::mojom::CustomContextMenuItemPtr>& items,
int id) { … }
const size_t kMaxCustomMenuDepth = …;
const size_t kMaxCustomMenuTotalItems = …;
void AddCustomItemsToMenu(
const std::vector<blink::mojom::CustomContextMenuItemPtr>& items,
size_t depth,
size_t* total_items,
std::vector<std::unique_ptr<ui::SimpleMenuModel>>* submenus,
ui::SimpleMenuModel::Delegate* delegate,
ui::SimpleMenuModel* menu_model) { … }
}
void RenderViewContextMenuBase::SetContentCustomCommandIdRange(
int first, int last) { … }
const size_t RenderViewContextMenuBase::kMaxSelectionTextLength = …;
int RenderViewContextMenuBase::ConvertToContentCustomCommandId(int id) { … }
bool RenderViewContextMenuBase::IsContentCustomCommandId(int id) { … }
RenderViewContextMenuBase::RenderViewContextMenuBase(
content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params)
: … { … }
RenderViewContextMenuBase::~RenderViewContextMenuBase() { … }
void RenderViewContextMenuBase::Init() { … }
void RenderViewContextMenuBase::Cancel() { … }
void RenderViewContextMenuBase::InitMenu() { … }
void RenderViewContextMenuBase::AddMenuItem(int command_id,
const std::u16string& title) { … }
void RenderViewContextMenuBase::AddMenuItemWithIcon(
int command_id,
const std::u16string& title,
const ui::ImageModel& icon) { … }
void RenderViewContextMenuBase::AddCheckItem(int command_id,
const std::u16string& title) { … }
void RenderViewContextMenuBase::AddSeparator() { … }
void RenderViewContextMenuBase::AddSubMenu(int command_id,
const std::u16string& label,
ui::MenuModel* model) { … }
void RenderViewContextMenuBase::AddSubMenuWithStringIdAndIcon(
int command_id,
int message_id,
ui::MenuModel* model,
const ui::ImageModel& icon) { … }
void RenderViewContextMenuBase::UpdateMenuItem(int command_id,
bool enabled,
bool hidden,
const std::u16string& label) { … }
void RenderViewContextMenuBase::UpdateMenuIcon(int command_id,
const ui::ImageModel& icon) { … }
void RenderViewContextMenuBase::RemoveMenuItem(int command_id) { … }
void RenderViewContextMenuBase::RemoveAdjacentSeparators() { … }
void RenderViewContextMenuBase::RemoveSeparatorBeforeMenuItem(int command_id) { … }
WebContents* RenderViewContextMenuBase::GetWebContents() const { … }
BrowserContext* RenderViewContextMenuBase::GetBrowserContext() const { … }
bool RenderViewContextMenuBase::AppendCustomItems() { … }
bool RenderViewContextMenuBase::IsCommandIdKnown(
int id,
bool* enabled) const { … }
bool RenderViewContextMenuBase::IsCommandIdChecked(int id) const { … }
void RenderViewContextMenuBase::ExecuteCommand(int id, int event_flags) { … }
void RenderViewContextMenuBase::OnMenuWillShow(ui::SimpleMenuModel* source) { … }
void RenderViewContextMenuBase::MenuClosed(ui::SimpleMenuModel* source) { … }
RenderFrameHost* RenderViewContextMenuBase::GetRenderFrameHost() const { … }
void RenderViewContextMenuBase::OpenURL(const GURL& url,
const GURL& referring_url,
const url::Origin& initiator,
WindowOpenDisposition disposition,
ui::PageTransition transition) { … }
void RenderViewContextMenuBase::OpenURLWithExtraHeaders(
const GURL& url,
const GURL& referring_url,
const url::Origin& initiator,
WindowOpenDisposition disposition,
ui::PageTransition transition,
const std::string& extra_headers,
bool started_from_context_menu) { … }
content::OpenURLParams
RenderViewContextMenuBase::GetOpenURLParamsWithExtraHeaders(
const GURL& url,
const GURL& referring_url,
const url::Origin& initiator,
WindowOpenDisposition disposition,
ui::PageTransition transition,
const std::string& extra_headers,
bool started_from_context_menu) { … }
bool RenderViewContextMenuBase::IsCustomItemChecked(int id) const { … }
bool RenderViewContextMenuBase::IsCustomItemEnabled(int id) const { … }