#include "chrome/browser/ui/views/toolbar/toolbar_controller.h"
#include <optional>
#include <string_view>
#include "base/functional/overloaded.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/no_destructor.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_actions.h"
#include "chrome/browser/ui/toolbar_controller_util.h"
#include "chrome/browser/ui/views/side_panel/side_panel_action_callback.h"
#include "chrome/browser/ui/views/side_panel/side_panel_enums.h"
#include "chrome/browser/ui/views/toolbar/overflow_button.h"
#include "chrome/browser/ui/views/toolbar/pinned_toolbar_button_status_indicator.h"
#include "chrome/browser/ui/views/toolbar/toolbar_button.h"
#include "chrome/grit/generated_resources.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/menu_model_adapter.h"
#include "ui/views/controls/menu/submenu_view.h"
#include "ui/views/interaction/element_tracker_views.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/layout/flex_layout_types.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/view_utils.h"
namespace {
constexpr gfx::Rect kStatusRect(10, 2);
constexpr int kImageContainerLowerPadding = …;
base::flat_map<ui::ElementIdentifier, int> CalculateFlexOrder(
const std::vector<ui::ElementIdentifier>& elements_in_overflow_order,
int element_flex_order_start) { … }
}
ToolbarController::PopOutState::PopOutState() = default;
ToolbarController::PopOutState::~PopOutState() = default;
ToolbarController::PopOutHandler::PopOutHandler(
ToolbarController* controller,
ui::ElementContext context,
ui::ElementIdentifier identifier,
ui::ElementIdentifier observed_identifier)
: … { … }
ToolbarController::PopOutHandler::~PopOutHandler() = default;
void ToolbarController::PopOutHandler::OnElementShown(
ui::TrackedElement* element) { … }
void ToolbarController::PopOutHandler::OnElementHidden(
ui::TrackedElement* element) { … }
ToolbarController::ResponsiveElementInfo::ResponsiveElementInfo(
absl::variant<ElementIdInfo, actions::ActionId> overflow_id,
bool is_section_end,
std::optional<ui::ElementIdentifier> observed_identifier)
: … { … }
ToolbarController::ResponsiveElementInfo::ResponsiveElementInfo(
const ResponsiveElementInfo& info) = default;
ToolbarController::ResponsiveElementInfo::~ResponsiveElementInfo() = default;
ToolbarController::ToolbarController(
const std::vector<ToolbarController::ResponsiveElementInfo>&
responsive_elements,
const std::vector<ui::ElementIdentifier>& elements_in_overflow_order,
int element_flex_order_start,
views::View* toolbar_container_view,
OverflowButton* overflow_button,
ToolbarController::PinnedActionsDelegate* pinned_actions_delegate)
: … { … }
ToolbarController::~ToolbarController() { … }
std::vector<ToolbarController::ResponsiveElementInfo>
ToolbarController::GetDefaultResponsiveElements(Browser* browser) { … }
std::vector<ui::ElementIdentifier>
ToolbarController::GetDefaultOverflowOrder() { … }
std::string ToolbarController::GetActionNameFromElementIdentifier(
absl::variant<ui::ElementIdentifier, actions::ActionId> identifier) { … }
bool ToolbarController::PopOut(ui::ElementIdentifier identifier) { … }
bool ToolbarController::EndPopOut(ui::ElementIdentifier identifier) { … }
bool ToolbarController::ShouldShowOverflowButton(gfx::Size available_size) { … }
bool ToolbarController::InOverflowMode() const { … }
std::u16string ToolbarController::GetMenuText(
const ResponsiveElementInfo& element_info) const { … }
std::optional<ui::ImageModel> ToolbarController::GetMenuIcon(
const ResponsiveElementInfo& element_info) const { … }
views::View* ToolbarController::FindToolbarElementWithId(
views::View* view,
ui::ElementIdentifier id) { … }
std::vector<const ToolbarController::ResponsiveElementInfo*>
ToolbarController::GetOverflowedElements() { … }
bool ToolbarController::IsOverflowed(
const ResponsiveElementInfo& element,
const views::ProposedLayout* proposed_layout) const { … }
std::unique_ptr<ui::SimpleMenuModel>
ToolbarController::CreateOverflowMenuModel() { … }
bool ToolbarController::IsCommandIdEnabled(int command_id) const { … }
void ToolbarController::ExecuteCommand(int command_id, int event_flags) { … }
void ToolbarController::ShowStatusIndicator() { … }
void ToolbarController::ActionItemChanged(actions::ActionItem* action_item) { … }
void ToolbarController::PopulateMenu(views::MenuItemView* parent) { … }
void ToolbarController::ShowMenu() { … }
bool ToolbarController::IsMenuRunning() const { … }
void ToolbarController::CloseMenu() { … }