#include "chrome/browser/ui/views/extensions/extensions_menu_item_view.h"
#include <memory>
#include <string>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/controls/hover_button.h"
#include "chrome/browser/ui/views/extensions/extension_context_menu_controller.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_button.h"
#include "chrome/grit/generated_resources.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/browser/web_contents.h"
#include "extensions/common/extension_features.h"
#include "ui/accessibility/ax_enums.mojom-shared.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/models/image_model.h"
#include "ui/color/color_id.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icon_types.h"
#include "ui/gfx/vector_icon_utils.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/ink_drop_host.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/menu_button_controller.h"
#include "ui/views/controls/button/toggle_button.h"
#include "ui/views/controls/combobox/combobox.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/layout/flex_layout_types.h"
#include "ui/views/layout/flex_layout_view.h"
#include "ui/views/layout/layout_types.h"
#include "ui/views/style/typography.h"
#include "ui/views/vector_icons.h"
#include "ui/views/view_class_properties.h"
namespace {
constexpr int EXTENSION_CONTEXT_MENU = …;
constexpr int EXTENSION_PINNING = …;
void SetButtonIconWithColor(HoverButton* button,
const gfx::VectorIcon& icon,
ui::ColorId icon_color_id,
ui::ColorId disabled_icon_color_id) { … }
std::u16string GetPinButtonTooltip(bool is_force_pinned, bool is_pinned) { … }
std::u16string GetPinButtonAccessibleName(
bool is_force_pinned,
bool is_pinned,
const std::u16string& extension_name) { … }
std::u16string GetContextMenuAccessibleName(bool is_pinned) { … }
std::u16string GetPinButtonPressedAccText(bool is_pinned) { … }
std::u16string GetSiteAccessToggleTooltip(bool is_on) { … }
std::u16string GetSitePermissionsButtonText(
ExtensionMenuItemView::SitePermissionsButtonAccess button_access) { … }
std::u16string GetSitePermissionsButtonTooltip(
bool is_enterprise,
ExtensionMenuItemView::SitePermissionsButtonAccess button_access) { … }
std::u16string GetSitePermissionsButtonAccName(
bool is_enterprise,
ExtensionMenuItemView::SitePermissionsButtonAccess button_access,
std::u16string& button_text) { … }
views::Builder<HoverButton> GetSitePermissionsButtonBuilder(
views::Button::PressedCallback callback,
bool is_enterprise,
int small_icon_size,
int icon_size,
int icon_label_spacing) { … }
}
ExtensionMenuItemView::ExtensionMenuItemView(
Browser* browser,
std::unique_ptr<ToolbarActionViewController> controller,
bool allow_pinning)
: … { … }
ExtensionMenuItemView::ExtensionMenuItemView(
Browser* browser,
bool is_enterprise,
std::unique_ptr<ToolbarActionViewController> controller,
base::RepeatingCallback<void(bool)> site_access_toggle_callback,
views::Button::PressedCallback site_permissions_button_callback)
: … { … }
ExtensionMenuItemView::~ExtensionMenuItemView() = default;
void ExtensionMenuItemView::OnThemeChanged() { … }
void ExtensionMenuItemView::Update(
SiteAccessToggleState site_access_toggle_state,
SitePermissionsButtonState site_permissions_button_state,
SitePermissionsButtonAccess site_permissions_button_access,
bool is_enterprise) { … }
void ExtensionMenuItemView::UpdatePinButton(bool is_force_pinned,
bool is_pinned) { … }
void ExtensionMenuItemView::UpdateContextMenuButton(bool is_action_pinned) { … }
void ExtensionMenuItemView::SetupContextMenuButton() { … }
void ExtensionMenuItemView::OnContextMenuPressed() { … }
void ExtensionMenuItemView::OnPinButtonPressed() { … }
bool ExtensionMenuItemView::IsContextMenuRunningForTesting() const { … }
BEGIN_METADATA(…)