#include "chrome/browser/ui/views/toolbar/pinned_toolbar_actions_container.h"
#include <algorithm>
#include <iterator>
#include <memory>
#include <string>
#include <type_traits>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/user_metrics.h"
#include "base/not_fatal_until.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_actions.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/toolbar/toolbar_pref_names.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/extensions/browser_action_drag_data.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/companion/companion_utils.h"
#include "chrome/browser/ui/views/side_panel/search_companion/search_companion_side_panel_coordinator.h"
#include "chrome/browser/ui/views/side_panel/side_panel_enums.h"
#include "chrome/browser/ui/views/side_panel/side_panel_util.h"
#include "chrome/browser/ui/views/toolbar/pinned_action_toolbar_button.h"
#include "chrome/browser/ui/views/toolbar/pinned_toolbar_actions_container_layout.h"
#include "chrome/grit/generated_resources.h"
#include "ui/actions/action_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/dialog_model_menu_model_adapter.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/compositor/layer_tree_owner.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/text_constants.h"
#include "ui/gfx/vector_icon_types.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/actions/action_view_controller.h"
#include "ui/views/cascading_property.h"
#include "ui/views/controls/button/button_controller.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/layout/layout_manager_base.h"
#include "ui/views/layout/layout_types.h"
#include "ui/views/view_class_properties.h"
namespace {
void RecordPinnedActionsCount(int count) { … }
}
struct PinnedToolbarActionsContainer::DropInfo { … };
PinnedToolbarActionsContainer::DropInfo::DropInfo(actions::ActionId action_id,
size_t index)
: … { … }
PinnedToolbarActionsContainer::PinnedToolbarActionsContainer(
BrowserView* browser_view)
: … { … }
int PinnedToolbarActionsContainer::CalculatePoppedOutButtonsWidth() { … }
gfx::Size PinnedToolbarActionsContainer::DefaultFlexRule(
const views::SizeBounds& size_bounds) { … }
PinnedToolbarActionsContainer::~PinnedToolbarActionsContainer() = default;
void PinnedToolbarActionsContainer::UpdateActionState(actions::ActionId id,
bool is_active) { … }
void PinnedToolbarActionsContainer::ShowActionEphemerallyInToolbar(
actions::ActionId id,
bool show) { … }
void PinnedToolbarActionsContainer::MovePinnedActionBy(actions::ActionId id,
int delta) { … }
void PinnedToolbarActionsContainer::UpdateAllIcons() { … }
void PinnedToolbarActionsContainer::OnThemeChanged() { … }
bool PinnedToolbarActionsContainer::GetDropFormats(
int* formats,
std::set<ui::ClipboardFormatType>* format_types) { … }
bool PinnedToolbarActionsContainer::AreDropTypesRequired() { … }
bool PinnedToolbarActionsContainer::CanDrop(const OSExchangeData& data) { … }
void PinnedToolbarActionsContainer::OnDragEntered(
const ui::DropTargetEvent& event) { … }
int PinnedToolbarActionsContainer::OnDragUpdated(
const ui::DropTargetEvent& event) { … }
void PinnedToolbarActionsContainer::OnDragExited() { … }
views::View::DropCallback PinnedToolbarActionsContainer::GetDropCallback(
const ui::DropTargetEvent& event) { … }
void PinnedToolbarActionsContainer::OnActionAddedLocally(
const actions::ActionId& id) { … }
void PinnedToolbarActionsContainer::OnActionRemovedLocally(
const actions::ActionId& id) { … }
void PinnedToolbarActionsContainer::OnActionsChanged() { … }
void PinnedToolbarActionsContainer::WriteDragDataForView(
View* sender,
const gfx::Point& press_pt,
ui::OSExchangeData* data) { … }
int PinnedToolbarActionsContainer::GetDragOperationsForView(
View* sender,
const gfx::Point& p) { … }
bool PinnedToolbarActionsContainer::CanStartDragForView(
View* sender,
const gfx::Point& press_pt,
const gfx::Point& p) { … }
actions::ActionItem* PinnedToolbarActionsContainer::GetActionItemFor(
const actions::ActionId& id) { … }
PinnedActionToolbarButton* PinnedToolbarActionsContainer::AddPoppedOutButtonFor(
const actions::ActionId& id) { … }
void PinnedToolbarActionsContainer::MaybeRemovePoppedOutButtonFor(
const actions::ActionId& id) { … }
void PinnedToolbarActionsContainer::AddPinnedActionButtonFor(
const actions::ActionId& id) { … }
void PinnedToolbarActionsContainer::RemovePinnedActionButtonFor(
const actions::ActionId& id) { … }
PinnedActionToolbarButton* PinnedToolbarActionsContainer::GetPinnedButtonFor(
const actions::ActionId& id) { … }
PinnedActionToolbarButton* PinnedToolbarActionsContainer::GetPoppedOutButtonFor(
const actions::ActionId& id) { … }
PinnedActionToolbarButton* PinnedToolbarActionsContainer::GetButtonFor(
const actions::ActionId& id) { … }
bool PinnedToolbarActionsContainer::ShouldRemainPoppedOutInToolbar(
PinnedActionToolbarButton* button) { … }
void PinnedToolbarActionsContainer::RemoveButton(
PinnedActionToolbarButton* button) { … }
bool PinnedToolbarActionsContainer::IsOverflowed(const actions::ActionId& id) { … }
views::View* PinnedToolbarActionsContainer::GetContainerView() { … }
bool PinnedToolbarActionsContainer::ShouldAnyButtonsOverflow(
gfx::Size available_size) const { … }
bool PinnedToolbarActionsContainer::IsActionPinned(
const actions::ActionId& id) { … }
bool PinnedToolbarActionsContainer::IsActionPoppedOut(
const actions::ActionId& id) { … }
bool PinnedToolbarActionsContainer::IsActionPinnedOrPoppedOut(
const actions::ActionId& id) { … }
void PinnedToolbarActionsContainer::ReorderViews() { … }
void PinnedToolbarActionsContainer::UpdateViews() { … }
void PinnedToolbarActionsContainer::SetActionButtonIconVisibility(
actions::ActionId id,
bool visible) { … }
void PinnedToolbarActionsContainer::MovePinnedAction(
const actions::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 PinnedToolbarActionsContainer::DragDropCleanup(
const actions::ActionId& dragged_action_id) { … }
size_t PinnedToolbarActionsContainer::WidthToIconCount(int x_offset) { … }
BEGIN_METADATA(…)