#include "chrome/browser/extensions/extension_context_menu_model.h"
#include <memory>
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/notreached.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/api/side_panel/side_panel_service.h"
#include "chrome/browser/extensions/context_menu_matcher.h"
#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/extension_uninstall_dialog.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/menu_manager.h"
#include "chrome/browser/extensions/permissions/site_permissions_helper.h"
#include "chrome/browser/extensions/permissions_url_constants.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/browser_window/public/browser_window_features.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/extensions/extension_side_panel_utils.h"
#include "chrome/browser/ui/extensions/extensions_container.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/side_panel/side_panel_entry_id.h"
#include "chrome/browser/ui/views/side_panel/side_panel_entry_key.h"
#include "chrome/browser/ui/views/side_panel/side_panel_ui.h"
#include "chrome/common/extensions/api/side_panel.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
#include "components/sessions/content/session_tab_helper.h"
#include "components/url_formatter/url_formatter.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/browser/context_menu_params.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_action.h"
#include "extensions/browser/extension_action_manager.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/management_policy.h"
#include "extensions/browser/permissions_manager.h"
#include "extensions/browser/uninstall_reason.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/manifest_handlers/options_page_info.h"
#include "extensions/common/manifest_url_handlers.h"
#include "extensions/common/permissions/api_permission.h"
#include "extensions/common/permissions/permissions_data.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
#include "ui/base/models/menu_separator_types.h"
namespace extensions {
namespace {
bool MenuItemMatchesAction(const std::optional<ActionInfo::Type> action_type,
const MenuItem* item) { … }
bool IsExtensionForcePinned(const Extension& extension, Profile* profile) { … }
int GetVisibilityStringId(Profile* profile,
const Extension* extension,
bool is_pinned) { … }
bool IsExtensionRequiredByPolicy(const Extension* extension, Profile* profile) { … }
std::u16string GetCurrentSite(const GURL& url) { … }
ExtensionContextMenuModel::ContextMenuAction CommandIdToContextMenuAction(
int command_id) { … }
PermissionsManager::UserSiteAccess CommandIdToSiteAccess(int command_id) { … }
void LogPageAccessAction(int command_id) { … }
void LogToggleVisibility(bool visible) { … }
void OpenUrl(Browser& browser, const GURL& url) { … }
class UninstallDialogHelper : public ExtensionUninstallDialog::Delegate { … };
}
ExtensionContextMenuModel::ExtensionContextMenuModel(
const Extension* extension,
Browser* browser,
bool is_pinned,
PopupDelegate* delegate,
bool can_show_icon_in_toolbar,
ContextMenuSource source)
: … { … }
bool ExtensionContextMenuModel::IsCommandIdChecked(int command_id) const { … }
bool ExtensionContextMenuModel::IsCommandIdVisible(int command_id) const { … }
bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const { … }
void ExtensionContextMenuModel::ExecuteCommand(int command_id,
int event_flags) { … }
void ExtensionContextMenuModel::OnMenuWillShow(ui::SimpleMenuModel* menu) { … }
void ExtensionContextMenuModel::MenuClosed(ui::SimpleMenuModel* menu) { … }
ExtensionContextMenuModel::~ExtensionContextMenuModel() = default;
void ExtensionContextMenuModel::InitMenuWithFeature(
const Extension* extension,
bool can_show_icon_in_toolbar) { … }
void ExtensionContextMenuModel::InitMenu(const Extension* extension,
bool can_show_icon_in_toolbar) { … }
void ExtensionContextMenuModel::AddSidePanelEntryIfPresent(
const Extension& extension) { … }
const Extension* ExtensionContextMenuModel::GetExtension() const { … }
void ExtensionContextMenuModel::AppendExtensionItems() { … }
void ExtensionContextMenuModel::CreatePageAccessItems(
const Extension* extension,
content::WebContents* web_contents) { … }
content::WebContents* ExtensionContextMenuModel::GetActiveWebContents() const { … }
SidePanelService* ExtensionContextMenuModel::GetSidePanelService() const { … }
}