chromium/chrome/browser/ui/views/bookmarks/saved_tab_groups/saved_tab_group_bar.cc

// Copyright 2022 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/ui/views/bookmarks/saved_tab_groups/saved_tab_group_bar.h"

#include <algorithm>
#include <memory>
#include <optional>
#include <unordered_map>

#include "base/functional/bind.h"
#include "base/metrics/user_metrics.h"
#include "base/types/to_address.h"
#include "base/uuid.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/tabs/saved_tab_groups/saved_tab_group_service_factory.h"
#include "chrome/browser/ui/tabs/saved_tab_groups/saved_tab_group_utils.h"
#include "chrome/browser/ui/tabs/saved_tab_groups/tab_group_action_context_desktop.h"
#include "chrome/browser/ui/tabs/saved_tab_groups/tab_group_sync_service_proxy.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/bookmarks/saved_tab_groups/saved_tab_group_button.h"
#include "chrome/browser/ui/views/bookmarks/saved_tab_groups/saved_tab_group_drag_data.h"
#include "chrome/browser/ui/views/bookmarks/saved_tab_groups/saved_tab_group_overflow_button.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/grit/generated_resources.h"
#include "components/feature_engagement/public/feature_list.h"
#include "components/saved_tab_groups/features.h"
#include "components/saved_tab_groups/saved_tab_group_tab.h"
#include "components/saved_tab_groups/tab_group_sync_service.h"
#include "components/saved_tab_groups/types.h"
#include "ui/accessibility/ax_enums.mojom-shared.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/drop_target_event.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-shared.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/dialog_model.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/window_open_disposition.h"
#include "ui/compositor/layer_tree_owner.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/insets_outsets_base.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/layout_types.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/view_utils.h"

namespace tab_groups {
namespace {

// The maximum number of buttons (excluding the overflow menu button) that can
// appear in the SavedTabGroupBar.
constexpr int kMaxVisibleButtons =;
// The amount of padding between elements listed in the overflow menu.
const int kOverflowMenuButtonPadding =;
// The padding at the top and bottom of the bar used to center all displayed
// buttons.
constexpr int kButtonPadding =;
// The amount of padding between buttons in the view.
constexpr int kBetweenElementSpacing =;
// The thickness, in dips, of the drop indicators during drop sessions.
constexpr int kDropIndicatorThicknessDips =;
}  // namespace

// OverflowMenu generally handles drop sessions by delegating to `parent_bar_`.
// Important lifecycle note: when the drop session moves from the bar to the
// overflow menu or vice versa, the state for tracking it in the bar will be
// destroyed and recreated.
class SavedTabGroupBar::OverflowMenu : public views::View {};

BEGIN_METADATA()
END_METADATA

SavedTabGroupBar::SavedTabGroupBar(Browser* browser,
                                   TabGroupSyncService* tab_group_service,
                                   bool animations_enabled = true)
    :{}

SavedTabGroupBar::SavedTabGroupBar(Browser* browser,
                                   bool animations_enabled = true)
    :{}

SavedTabGroupBar::~SavedTabGroupBar() {}

void SavedTabGroupBar::ShowEverythingMenu() {}

std::optional<size_t> SavedTabGroupBar::GetIndexOfGroup(
    const base::Uuid& guid) const {}

void SavedTabGroupBar::UpdateDropIndex() {}

std::optional<size_t> SavedTabGroupBar::GetDropIndex() const {}

void SavedTabGroupBar::HandleDrop() {}

bool SavedTabGroupBar::GetDropFormats(
    int* formats,
    std::set<ui::ClipboardFormatType>* format_types) {}

bool SavedTabGroupBar::AreDropTypesRequired() {}

bool SavedTabGroupBar::CanDrop(const OSExchangeData& data) {}

void SavedTabGroupBar::OnDragEntered(const ui::DropTargetEvent& event) {}

int SavedTabGroupBar::OnDragUpdated(const ui::DropTargetEvent& event) {}

void SavedTabGroupBar::OnDragExited() {}

views::View::DropCallback SavedTabGroupBar::GetDropCallback(
    const ui::DropTargetEvent& event) {}

void SavedTabGroupBar::OnPaint(gfx::Canvas* canvas) {}

void SavedTabGroupBar::SavedTabGroupAddedLocally(const base::Uuid& guid) {}

void SavedTabGroupBar::SavedTabGroupRemovedLocally(
    const SavedTabGroup& removed_group) {}

void SavedTabGroupBar::SavedTabGroupLocalIdChanged(
    const base::Uuid& saved_group_id) {}

void SavedTabGroupBar::SavedTabGroupUpdatedLocally(
    const base::Uuid& group_guid,
    const std::optional<base::Uuid>& tab_guid) {}

void SavedTabGroupBar::SavedTabGroupReorderedLocally() {}

void SavedTabGroupBar::SavedTabGroupReorderedFromSync() {}

void SavedTabGroupBar::SavedTabGroupTabsReorderedLocally(
    const base::Uuid& group_guid) {}

void SavedTabGroupBar::SavedTabGroupAddedFromSync(const base::Uuid& guid) {}

void SavedTabGroupBar::SavedTabGroupRemovedFromSync(
    const SavedTabGroup& removed_group) {}

void SavedTabGroupBar::SavedTabGroupUpdatedFromSync(
    const base::Uuid& group_guid,
    const std::optional<base::Uuid>& tab_guid) {}

void SavedTabGroupBar::OnInitialized() {}

void SavedTabGroupBar::OnTabGroupAdded(const SavedTabGroup& group,
                                       TriggerSource source) {}

void SavedTabGroupBar::OnTabGroupUpdated(const SavedTabGroup& group,
                                         TriggerSource source) {}

void SavedTabGroupBar::OnTabGroupLocalIdChanged(
    const base::Uuid& sync_id,
    const std::optional<LocalTabGroupID>& local_id) {}

void SavedTabGroupBar::OnTabGroupRemoved(const base::Uuid& sync_id,
                                         TriggerSource source) {}

void SavedTabGroupBar::OnWidgetDestroying(views::Widget* widget) {}

void SavedTabGroupBar::Layout(PassKey) {}

int SavedTabGroupBar::V2CalculatePreferredWidthRestrictedBy(
    int max_width) const {}

int SavedTabGroupBar::CalculatePreferredWidthRestrictedBy(int max_width) const {}

bool SavedTabGroupBar::IsOverflowButtonVisible() {}

void SavedTabGroupBar::AddTabGroupButton(const SavedTabGroup& group,
                                         int index) {}

void SavedTabGroupBar::SavedTabGroupAdded(const base::Uuid& guid) {}

void SavedTabGroupBar::SavedTabGroupRemoved(const base::Uuid& guid) {}

void SavedTabGroupBar::SavedTabGroupUpdated(const base::Uuid& guid) {}

void SavedTabGroupBar::SavedTabGroupReordered() {}

void SavedTabGroupBar::LoadAllButtonsFromModel() {}

void SavedTabGroupBar::RemoveTabGroupButton(const base::Uuid& guid) {}

void SavedTabGroupBar::RemoveAllButtons() {}

views::View* SavedTabGroupBar::GetButton(const base::Uuid& guid) {}

void SavedTabGroupBar::OnTabGroupButtonPressed(const base::Uuid& id,
                                               const ui::Event& event) {}

std::unique_ptr<SavedTabGroupOverflowButton>
SavedTabGroupBar::CreateOverflowButton() {}

void SavedTabGroupBar::MaybeShowOverflowMenu() {}

void SavedTabGroupBar::UpdateOverflowMenu() {}

void SavedTabGroupBar::HideOverflowButton() {}

void SavedTabGroupBar::ShowOverflowButton() {}

int SavedTabGroupBar::GetNumberOfVisibleGroups() const {}

void SavedTabGroupBar::UpdateButtonVisibilities(bool show_overflow,
                                                int last_visible_button_index) {}

bool SavedTabGroupBar::ShouldShowOverflowButtonForWidth(int max_width) const {}

int SavedTabGroupBar::CalculateLastVisibleButtonIndexForWidth(
    int max_width) const {}

void SavedTabGroupBar::MaybePaintDropIndicatorInBar(gfx::Canvas* canvas) {}

std::optional<int> SavedTabGroupBar::CalculateDropIndicatorIndexInBar() const {}

std::optional<int>
SavedTabGroupBar::CalculateDropIndicatorIndexInCombinedSpace() const {}

void SavedTabGroupBar::MaybeShowClosePromo(const base::Uuid& saved_group_id) {}

BEGIN_METADATA()

}  // namespace tab_groups