#include "chrome/browser/ui/views/extensions/extensions_toolbar_container.h"
#include <algorithm>
#include <memory>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/no_destructor.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "build/build_config.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/browser_window/public/browser_window_features.h"
#include "chrome/browser/ui/extensions/extension_action_view_controller.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/toolbar/toolbar_action_hover_card_types.h"
#include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/extensions/browser_action_drag_data.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_coordinator.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_view.h"
#include "chrome/browser/ui/views/extensions/extensions_request_access_button.h"
#include "chrome/browser/ui/views/extensions/extensions_toolbar_button.h"
#include "chrome/browser/ui/views/extensions/extensions_toolbar_container_view_controller.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/toolbar_button_provider.h"
#include "chrome/browser/ui/views/side_panel/side_panel_ui.h"
#include "chrome/browser/ui/views/toolbar/toolbar_action_hover_card_controller.h"
#include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/feature_engagement/public/event_constants.h"
#include "content/public/browser/web_contents.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_id.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-shared.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom.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/views/layout/animating_layout_manager.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/layout/flex_layout_types.h"
#include "ui/views/view_class_properties.h"
namespace {
DragOperation;
base::OnceClosure& GetOnVisibleCallbackForTesting() { … }
}
void ExtensionsToolbarContainer::SetOnVisibleCallbackForTesting(
base::OnceClosure callback) { … }
struct ExtensionsToolbarContainer::DropInfo { … };
ExtensionsToolbarContainer::DropInfo::DropInfo(
ToolbarActionsModel::ActionId action_id,
size_t index)
: … { … }
ExtensionsToolbarContainer::ExtensionsToolbarContainer(Browser* browser,
DisplayMode display_mode)
: … { … }
ExtensionsToolbarContainer::~ExtensionsToolbarContainer() { … }
void ExtensionsToolbarContainer::CreateActions() { … }
void ExtensionsToolbarContainer::AddAction(
const ToolbarActionsModel::ActionId& action_id) { … }
void ExtensionsToolbarContainer::RemoveAction(
const ToolbarActionsModel::ActionId& action_id) { … }
void ExtensionsToolbarContainer::UpdateAction(
const ToolbarActionsModel::ActionId& action_id) { … }
void ExtensionsToolbarContainer::UpdatePinnedActions() { … }
void ExtensionsToolbarContainer::UpdateExtensionsButton(
extensions::PermissionsManager::UserSiteSetting site_setting,
content::WebContents* web_contents,
bool is_restricted_url) { … }
void ExtensionsToolbarContainer::UpdateRequestAccessButton(
extensions::PermissionsManager::UserSiteSetting site_setting,
content::WebContents* web_contents) { … }
void ExtensionsToolbarContainer::UpdateAllIcons() { … }
ToolbarActionView* ExtensionsToolbarContainer::GetViewForId(
const std::string& id) { … }
void ExtensionsToolbarContainer::ShowWidgetForExtension(
views::Widget* widget,
const std::string& extension_id) { … }
views::Widget*
ExtensionsToolbarContainer::GetAnchoredWidgetForExtensionForTesting(
const std::string& extension_id) { … }
bool ExtensionsToolbarContainer::IsExtensionsMenuShowing() const { … }
void ExtensionsToolbarContainer::HideExtensionsMenu() { … }
bool ExtensionsToolbarContainer::ShouldForceVisibility(
const std::string& extension_id) const { … }
void ExtensionsToolbarContainer::UpdateIconVisibility(
const std::string& extension_id) { … }
void ExtensionsToolbarContainer::AnchorAndShowWidgetImmediately(
MayBeDangling<views::Widget> widget) { … }
ToolbarActionViewController* ExtensionsToolbarContainer::GetActionForId(
const std::string& action_id) { … }
std::optional<extensions::ExtensionId>
ExtensionsToolbarContainer::GetPoppedOutActionId() const { … }
void ExtensionsToolbarContainer::OnContextMenuShownFromToolbar(
const std::string& action_id) { … }
void ExtensionsToolbarContainer::OnContextMenuClosedFromToolbar() { … }
bool ExtensionsToolbarContainer::IsActionVisibleOnToolbar(
const std::string& action_id) const { … }
void ExtensionsToolbarContainer::UndoPopOut() { … }
void ExtensionsToolbarContainer::SetPopupOwner(
ToolbarActionViewController* popup_owner) { … }
void ExtensionsToolbarContainer::HideActivePopup() { … }
bool ExtensionsToolbarContainer::CloseOverflowMenuIfOpen() { … }
void ExtensionsToolbarContainer::PopOutAction(
const extensions::ExtensionId& action_id,
base::OnceClosure closure) { … }
bool ExtensionsToolbarContainer::ShowToolbarActionPopupForAPICall(
const std::string& action_id,
ShowPopupCallback callback) { … }
void ExtensionsToolbarContainer::ShowToolbarActionBubble(
std::unique_ptr<ToolbarActionsBarBubbleDelegate> controller) { … }
void ExtensionsToolbarContainer::ToggleExtensionsMenu() { … }
bool ExtensionsToolbarContainer::HasAnyExtensions() const { … }
void ExtensionsToolbarContainer::ReorderAllChildViews() { … }
void ExtensionsToolbarContainer::CreateActionForId(
const ToolbarActionsModel::ActionId& action_id) { … }
content::WebContents* ExtensionsToolbarContainer::GetCurrentWebContents() { … }
views::LabelButton* ExtensionsToolbarContainer::GetOverflowReferenceView()
const { … }
gfx::Size ExtensionsToolbarContainer::GetToolbarActionSize() { … }
void ExtensionsToolbarContainer::WriteDragDataForView(
View* sender,
const gfx::Point& press_pt,
ui::OSExchangeData* data) { … }
int ExtensionsToolbarContainer::GetDragOperationsForView(View* sender,
const gfx::Point& p) { … }
bool ExtensionsToolbarContainer::CanStartDragForView(View* sender,
const gfx::Point& press_pt,
const gfx::Point& p) { … }
bool ExtensionsToolbarContainer::GetDropFormats(
int* formats,
std::set<ui::ClipboardFormatType>* format_types) { … }
bool ExtensionsToolbarContainer::AreDropTypesRequired() { … }
bool ExtensionsToolbarContainer::CanDrop(const OSExchangeData& data) { … }
void ExtensionsToolbarContainer::OnDragEntered(
const ui::DropTargetEvent& event) { … }
int ExtensionsToolbarContainer::OnDragUpdated(
const ui::DropTargetEvent& event) { … }
void ExtensionsToolbarContainer::OnDragExited() { … }
views::View::DropCallback ExtensionsToolbarContainer::GetDropCallback(
const ui::DropTargetEvent& event) { … }
void ExtensionsToolbarContainer::OnWidgetDestroying(views::Widget* widget) { … }
size_t ExtensionsToolbarContainer::WidthToIconCount(int x_offset) { … }
ui::ImageModel ExtensionsToolbarContainer::GetExtensionIcon(
ToolbarActionView* extension_view) { … }
void ExtensionsToolbarContainer::SetExtensionIconVisibility(
ToolbarActionsModel::ActionId id,
bool visible) { … }
void ExtensionsToolbarContainer::UpdateContainerVisibility() { … }
bool ExtensionsToolbarContainer::ShouldContainerBeVisible() const { … }
void ExtensionsToolbarContainer::UpdateContainerVisibilityAfterAnimation() { … }
void ExtensionsToolbarContainer::OnMenuOpening() { … }
void ExtensionsToolbarContainer::OnMenuClosed() { … }
void ExtensionsToolbarContainer::UpdateSidePanelState(bool is_active) { … }
void ExtensionsToolbarContainer::MovePinnedAction(
const ToolbarActionsModel::ActionId& action_id,
size_t index,
base::ScopedClosureRunner cleanup,
const ui::DropTargetEvent& event,
ui::mojom::DragOperation& output_drag_op,
std::unique_ptr<ui::LayerTreeOwner> drag_image_layer_owner) { … }
void ExtensionsToolbarContainer::DragDropCleanup(
const ToolbarActionsModel::ActionId& dragged_extension_id) { … }
void ExtensionsToolbarContainer::UpdateControlsVisibility() { … }
void ExtensionsToolbarContainer::CloseSidePanelButtonPressed() { … }
void ExtensionsToolbarContainer::UpdateToolbarActionHoverCard(
ToolbarActionView* action_view,
ToolbarActionHoverCardUpdateType update_type) { … }
void ExtensionsToolbarContainer::CollapseConfirmation() { … }
void ExtensionsToolbarContainer::OnMouseExited(const ui::MouseEvent& event) { … }
void ExtensionsToolbarContainer::OnMouseMoved(const ui::MouseEvent& event) { … }
void ExtensionsToolbarContainer::UpdateCloseSidePanelButtonIcon() { … }
BEGIN_METADATA(…)