chromium/chrome/browser/extensions/extension_context_menu_model.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// Returns true if the given |item| is of the given |type|.
bool MenuItemMatchesAction(const std::optional<ActionInfo::Type> action_type,
                           const MenuItem* item) {}

// Returns true if the given |extension| is required to remain pinned/visible in
// the toolbar by policy.
bool IsExtensionForcePinned(const Extension& extension, Profile* profile) {}

// Returns the id for the visibility command for the given |extension|.
int GetVisibilityStringId(Profile* profile,
                          const Extension* extension,
                          bool is_pinned) {}

// Returns true if the given |extension| is required to remain installed by
// policy.
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) {}

// Logs a user action when an option is selected in the page access section of
// the context menu.
void LogPageAccessAction(int command_id) {}

// Logs the action's visibility in the toolbar after it was set to `visible`.
void LogToggleVisibility(bool visible) {}

void OpenUrl(Browser& browser, const GURL& url) {}

// A stub for the uninstall dialog.
// TODO(devlin): Ideally, we would just have the uninstall dialog take a
// base::OnceCallback, but that's a bunch of churn.
class UninstallDialogHelper : public ExtensionUninstallDialog::Delegate {};

}  // namespace

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 {}

}  // namespace extensions