chromium/chrome/browser/ui/views/intent_picker_bubble_view.cc

// Copyright 2016 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/intent_picker_bubble_view.h"

#include <string_view>
#include <utility>

#include "base/auto_reset.h"
#include "base/check_op.h"
#include "base/debug/dump_without_crashing.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/i18n/rtl.h"
#include "base/ranges/algorithm.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/apps/link_capturing/link_capturing_features.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/sharing/click_to_call/click_to_call_ui_controller.h"
#include "chrome/browser/ui/color/chrome_color_id.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/toolbar/toolbar_view.h"
#include "chrome/common/chrome_features.h"
#include "chrome/grit/generated_resources.h"
#include "components/services/app_service/public/cpp/intent_util.h"
#include "components/url_formatter/elide_url.h"
#include "content/public/browser/navigation_handle.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.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/image_model.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/color/color_id.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/text_constants.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/ink_drop_host.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/focus_ring.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/separator.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/layout_types.h"
#include "ui/views/layout/table_layout.h"
#include "ui/views/layout/table_layout_view.h"
#include "ui/views/style/typography.h"
#include "ui/views/style/typography_provider.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/view_utils.h"

#if BUILDFLAG(IS_CHROMEOS)
#include "ui/chromeos/devicetype_utils.h"
#endif

namespace {

constexpr char kInvalidLaunchName[] =;

constexpr int kGridItemPreferredSize =;
constexpr int kGridItemsPerRow =;
constexpr int kGridInteriorColumnPadding =;
constexpr int kGridInteriorRowPadding =;
constexpr int kGridExteriorColumnPadding =;

constexpr int kGridItemTopInset =;
constexpr int kGridItemInset =;
constexpr int kGridItemInteriorPadding =;
constexpr int kGridItemBorderRadius =;
constexpr int kGridItemGroupId =;

bool g_auto_accept_intent_picker_bubble_for_testing =;

bool IsKeyboardCodeArrow(ui::KeyboardCode key_code) {}

bool IsDoubleClick(const ui::Event& event) {}

// Callback for when an app is selected in the app list. First parameter is the
// index, second parameter is true if the dialog should be immediately accepted.
AppSelectedCallback;

// Grid view:

// A Button which displays an app icon and name, as part of a grid layout of
// apps.
class IntentPickerAppGridButton : public views::Button {};

BEGIN_METADATA()

// Displays a list of apps as a grid of buttons.
class IntentPickerAppGridView
    : public IntentPickerBubbleView::IntentPickerAppsView {};

BEGIN_METADATA()

// List view:

// A button that represents a candidate intent handler.
class IntentPickerLabelButton : public views::LabelButton {};

BEGIN_METADATA()

class IntentPickerAppListView
    : public IntentPickerBubbleView::IntentPickerAppsView {};

BEGIN_METADATA()

}  // namespace

// static
IntentPickerBubbleView* IntentPickerBubbleView::intent_picker_bubble_ =;

// static
views::Widget* IntentPickerBubbleView::ShowBubble(
    views::View* anchor_view,
    views::Button* highlighted_button,
    BubbleType bubble_type,
    content::WebContents* web_contents,
    std::vector<AppInfo> app_info,
    bool show_stay_in_chrome,
    bool show_remember_selection,
    const std::optional<url::Origin>& initiating_origin,
    IntentPickerResponse intent_picker_cb) {}

// static
base::AutoReset<bool>
IntentPickerBubbleView::SetAutoAcceptIntentPickerBubbleForTesting() {}

// static
void IntentPickerBubbleView::CloseCurrentBubble() {}

void IntentPickerBubbleView::CloseBubble() {}

void IntentPickerBubbleView::OnDialogAccepted() {}

void IntentPickerBubbleView::OnDialogCancelled() {}

void IntentPickerBubbleView::OnDialogClosed() {}

bool IntentPickerBubbleView::ShouldShowCloseButton() const {}

void IntentPickerBubbleView::SelectDefaultItem() {}

std::optional<size_t> IntentPickerBubbleView::GetSelectedIndex() const {}

std::u16string IntentPickerBubbleView::GetWindowTitle() const {}

IntentPickerBubbleView::IntentPickerBubbleView(
    views::View* anchor_view,
    BubbleType bubble_type,
    std::vector<AppInfo> app_info,
    IntentPickerResponse intent_picker_cb,
    content::WebContents* web_contents,
    bool show_stay_in_chrome,
    bool show_remember_selection,
    const std::optional<url::Origin>& initiating_origin)
    :{}

IntentPickerBubbleView::~IntentPickerBubbleView() {}

// If the widget gets closed without an app being selected we still need to use
// the callback so the caller can Resume the navigation.
void IntentPickerBubbleView::OnWidgetDestroying(views::Widget* widget) {}

void IntentPickerBubbleView::OnAppSelected(std::optional<size_t> index,
                                           bool accepted) {}

void IntentPickerBubbleView::Initialize() {}

bool IntentPickerBubbleView::HasCandidates() const {}

void IntentPickerBubbleView::RunCallbackAndCloseBubble(
    const std::string& launch_name,
    apps::PickerEntryType entry_type,
    apps::IntentPickerCloseReason close_reason,
    bool should_persist) {}

void IntentPickerBubbleView::UpdateCheckboxState(size_t index) {}

void IntentPickerBubbleView::ClearIntentPickerBubbleView() {}

BEGIN_METADATA()

BEGIN_METADATA()
END_METADATA