#include "chrome/browser/ui/views/tabs/tab_group_editor_bubble_view.h"
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/containers/adapters.h"
#include "base/containers/flat_map.h"
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/ranges/algorithm.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/data_sharing/data_sharing_service_factory.h"
#include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_group_sync/feature_utils.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/tabs/saved_tab_groups/saved_tab_group_keyed_service.h"
#include "chrome/browser/ui/tabs/saved_tab_groups/saved_tab_group_pref_names.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_sync_service_proxy.h"
#include "chrome/browser/ui/tabs/tab_group.h"
#include "chrome/browser/ui/tabs/tab_group_deletion_dialog_controller.h"
#include "chrome/browser/ui/tabs/tab_group_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/bubble_menu_item_factory.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/browser/ui/views/controls/hover_button.h"
#include "chrome/browser/ui/views/data_sharing/data_sharing_bubble_controller.h"
#include "chrome/browser/ui/views/global_media_controls/media_item_ui_helper.h"
#include "chrome/browser/ui/views/tabs/color_picker_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_ink_drop_util.h"
#include "chrome/browser/user_education/tutorial_identifiers.h"
#include "chrome/browser/user_education/user_education_service.h"
#include "chrome/browser/user_education/user_education_service_factory.h"
#include "chrome/grit/generated_resources.h"
#include "components/data_sharing/public/features.h"
#include "components/feature_engagement/public/feature_constants.h"
#include "components/saved_tab_groups/features.h"
#include "components/saved_tab_groups/saved_tab_group.h"
#include "components/tab_groups/tab_group_color.h"
#include "components/tab_groups/tab_group_id.h"
#include "components/tab_groups/tab_group_visual_data.h"
#include "tab_group_editor_bubble_view.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/models/dialog_model_field.h"
#include "ui/base/models/image_model.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/base/mojom/ui_base_types.mojom-shared.h"
#include "ui/base/pointer/touch_ui_controller.h"
#include "ui/events/types/event_type.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/range/range.h"
#include "ui/gfx/text_constants.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/toggle_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/separator.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/interaction/element_tracker_views.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/layout/flex_layout_types.h"
#include "ui/views/layout/layout_types.h"
#include "ui/views/view.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/view_utils.h"
namespace {
constexpr int kSeparatorPadding = …;
int GetHorizontalSpacing() { … }
int GetVerticalSpacing() { … }
gfx::Insets GetControlInsets() { … }
constexpr base::TimeDelta kTemporaryBookmarkBarDuration = …;
constexpr int kDialogWidth = …;
static constexpr int kDefaultIconSize = …;
constexpr int kFooterDisplayLimit = …;
std::unique_ptr<views::LabelButton> CreateMenuItem(
int button_id,
const std::u16string& name,
views::Button::PressedCallback callback,
const ui::ImageModel& icon = ui::ImageModel()) { … }
}
saved_tab_group_prefs;
views::Widget* TabGroupEditorBubbleView::Show(
const Browser* browser,
const tab_groups::TabGroupId& group,
TabGroupHeader* header_view,
std::optional<gfx::Rect> anchor_rect,
views::View* anchor_view,
bool stop_context_menu_propagation) { … }
views::View* TabGroupEditorBubbleView::GetInitiallyFocusedView() { … }
gfx::Rect TabGroupEditorBubbleView::GetAnchorRect() const { … }
void TabGroupEditorBubbleView::AddedToWidget() { … }
TabGroupEditorBubbleView::TabGroupEditorBubbleView(
const Browser* browser,
const tab_groups::TabGroupId& group,
views::View* anchor_view,
std::optional<gfx::Rect> anchor_rect,
bool stop_context_menu_propagation)
: … { … }
void TabGroupEditorBubbleView::RebuildMenuContents() { … }
void TabGroupEditorBubbleView::UpdateMenuContentsVisibility() { … }
std::unique_ptr<views::Separator> TabGroupEditorBubbleView::BuildSeparator() { … }
std::unique_ptr<ColorPickerView> TabGroupEditorBubbleView::BuildColorPicker() { … }
std::unique_ptr<TabGroupEditorBubbleView::TitleField>
TabGroupEditorBubbleView::BuildTitleField(const std::u16string& title) { … }
std::unique_ptr<views::LabelButton>
TabGroupEditorBubbleView::BuildNewTabInGroupButton() { … }
std::unique_ptr<views::LabelButton>
TabGroupEditorBubbleView::BuildUngroupButton() { … }
std::unique_ptr<views::LabelButton>
TabGroupEditorBubbleView::BuildHideGroupButton() { … }
std::unique_ptr<views::LabelButton>
TabGroupEditorBubbleView::BuildDeleteGroupButton() { … }
std::unique_ptr<views::LabelButton>
TabGroupEditorBubbleView::BuildMoveGroupToNewWindowButton() { … }
std::unique_ptr<views::LabelButton>
TabGroupEditorBubbleView::BuildManageSharedGroupButton() { … }
std::unique_ptr<views::LabelButton>
TabGroupEditorBubbleView::BuildShareGroupButton() { … }
TabGroupEditorBubbleView::~TabGroupEditorBubbleView() = default;
tab_groups::TabGroupColorId TabGroupEditorBubbleView::InitColorSet() { … }
void TabGroupEditorBubbleView::UpdateGroup() { … }
const std::u16string TabGroupEditorBubbleView::GetTextForCloseButton() const { … }
const std::u16string TabGroupEditorBubbleView::GetSaveToggleAccessibleName()
const { … }
bool TabGroupEditorBubbleView::CanSaveGroups() const { … }
bool TabGroupEditorBubbleView::CanShareGroups() const { … }
bool TabGroupEditorBubbleView::IsGroupSaved() const { … }
bool TabGroupEditorBubbleView::IsGroupShared() const { … }
bool TabGroupEditorBubbleView::ShouldShowSavedFooter() const { … }
void TabGroupEditorBubbleView::OnSaveTogglePressed() { … }
void TabGroupEditorBubbleView::NewTabInGroupPressed() { … }
void TabGroupEditorBubbleView::UngroupPressed() { … }
void TabGroupEditorBubbleView::ShareOrManagePressed() { … }
void TabGroupEditorBubbleView::Ungroup(const Browser* browser,
tab_groups::TabGroupId group) { … }
void TabGroupEditorBubbleView::HideGroupPressed() { … }
void TabGroupEditorBubbleView::DeleteGroupPressed() { … }
void TabGroupEditorBubbleView::DeleteGroupFromTabstrip() { … }
void TabGroupEditorBubbleView::MoveGroupToNewWindowPressed() { … }
bool TabGroupEditorBubbleView::CanMoveGroupToNewWindow() { … }
views::View* TabGroupEditorBubbleView::CreateSavedTabGroupToggle(
views::LabelButton* layout_helper) { … }
void TabGroupEditorBubbleView::OnBubbleClose() { … }
BEGIN_METADATA(…)
void TabGroupEditorBubbleView::TitleFieldController::ContentsChanged(
views::Textfield* sender,
const std::u16string& new_contents) { … }
bool TabGroupEditorBubbleView::TitleFieldController::HandleKeyEvent(
views::Textfield* sender,
const ui::KeyEvent& key_event) { … }
void TabGroupEditorBubbleView::TitleField::ShowContextMenu(
const gfx::Point& p,
ui::MenuSourceType source_type) { … }
BEGIN_METADATA(…)
END_METADATA
TabGroupEditorBubbleView::Footer::Footer(const Browser* browser) { … }
void TabGroupEditorBubbleView::Footer::OpenLearnMorePage(
const Browser* browser) { … }
BEGIN_METADATA(…)
END_METADATA