chromium/chrome/browser/ui/views/webid/account_selection_bubble_view.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/webid/account_selection_bubble_view.h"

#include <algorithm>
#include <utility>

#include "base/feature_list.h"
#include "base/i18n/case_conversion.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/accessibility/accessibility_state_utils.h"
#include "chrome/browser/image_fetcher/image_decoder_impl.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/monogram_utils.h"
#include "chrome/browser/ui/views/controls/hover_button.h"
#include "chrome/browser/ui/views/webid/account_selection_view_base.h"
#include "chrome/browser/ui/views/webid/fedcm_account_selection_view_desktop.h"
#include "chrome/browser/ui/views/webid/webid_utils.h"
#include "chrome/grit/generated_resources.h"
#include "components/image_fetcher/core/image_fetcher_impl.h"
#include "components/strings/grit/components_strings.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/common/content_features.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "skia/ext/image_operations.h"
#include "third_party/blink/public/mojom/webid/federated_auth_request.mojom.h"
#include "third_party/skia/include/core/SkPath.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/time_format.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/image/canvas_image_source.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/image_button_factory.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/separator.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/box_layout_view.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/widget/widget.h"

namespace {

// Error codes.
constexpr char kInvalidRequest[] =;
constexpr char kUnauthorizedClient[] =;
constexpr char kAccessDenied[] =;
constexpr char kTemporarilyUnavailable[] =;
constexpr char kServerError[] =;

// views::MdTextButton which:
// - Uses the passed-in `brand_background_color` based on whether the button
//   background contrasts sufficiently with dialog background.
// - If `brand_text_color` is not provided, computes the text color such that it
//   contrasts sufficiently with `brand_background_color`.
// - If `extra_accessible_text` is passed, appends this to the button's
// accessible name. This is useful when the user logs in via a popup window and
// cannot easily navigate the rest of the text in the dialog to confirm which is
// the account being used to login via FedCM.
class ContinueButton : public views::MdTextButton {};

BEGIN_METADATA()

std::pair<std::u16string, std::u16string> GetErrorDialogText(
    const std::optional<TokenError>& error,
    const std::u16string& rp_for_display,
    const std::u16string& idp_for_display) {}

std::u16string BuildStringFromIDPs(
    const std::vector<std::u16string> mismatch_idps,
    const std::vector<std::u16string> non_mismatch_idps) {}

}  // namespace

AccountSelectionBubbleView::AccountSelectionBubbleView(
    const std::u16string& rp_for_display,
    const std::optional<std::u16string>& idp_title,
    blink::mojom::RpContext rp_context,
    content::WebContents* web_contents,
    views::View* anchor_view,
    scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
    AccountSelectionViewBase::Observer* observer,
    views::WidgetObserver* widget_observer)
    :{}

AccountSelectionBubbleView::~AccountSelectionBubbleView() = default;

void AccountSelectionBubbleView::InitDialogWidget() {}

void AccountSelectionBubbleView::ShowMultiAccountPicker(
    const std::vector<content::IdentityProviderData>& idp_data_list,
    bool show_back_button,
    bool is_choose_an_account) {}

void AccountSelectionBubbleView::ShowVerifyingSheet(
    const content::IdentityRequestAccount& account,
    const content::IdentityProviderData& idp_display_data,
    const std::u16string& title) {}

void AccountSelectionBubbleView::ShowSingleAccountConfirmDialog(
    const content::IdentityRequestAccount& account,
    const content::IdentityProviderData& idp_display_data,
    bool show_back_button) {}

void AccountSelectionBubbleView::ShowFailureDialog(
    const std::u16string& idp_for_display,
    const content::IdentityProviderMetadata& idp_metadata) {}

void AccountSelectionBubbleView::ShowErrorDialog(
    const std::u16string& idp_for_display,
    const content::IdentityProviderMetadata& idp_metadata,
    const std::optional<TokenError>& error) {}

void AccountSelectionBubbleView::ShowLoadingDialog() {}

void AccountSelectionBubbleView::ShowRequestPermissionDialog(
    const content::IdentityRequestAccount& account,
    const content::IdentityProviderData& idp_display_data) {}

void AccountSelectionBubbleView::ShowSingleReturningAccountDialog(
    const std::vector<content::IdentityProviderData>& idp_data_list) {}

void AccountSelectionBubbleView::CloseDialog() {}

std::string AccountSelectionBubbleView::GetDialogTitle() const {}

void AccountSelectionBubbleView::UpdateDialogPosition() {}

void AccountSelectionBubbleView::OnAnchorBoundsChanged() {}

gfx::Rect AccountSelectionBubbleView::GetBubbleBounds() {}

std::unique_ptr<views::View> AccountSelectionBubbleView::CreateHeaderView(
    bool has_idp_icon) {}

std::unique_ptr<views::View>
AccountSelectionBubbleView::CreateSingleAccountChooser(
    const content::IdentityProviderData& idp_display_data,
    const content::IdentityRequestAccount& account) {}

void AccountSelectionBubbleView::AddSeparatorAndMultipleAccountChooser(
    const std::vector<content::IdentityProviderData>& idp_data_list) {}

void AccountSelectionBubbleView::AddAccounts(
    const std::vector<content::IdentityProviderData>& idp_data_list,
    views::View* accounts_content,
    Account::LoginState login_state,
    int& out_position) {}

void AccountSelectionBubbleView::AddSignInAccounts(
    const std::vector<content::IdentityProviderData>& idp_data_list,
    views::View* accounts_content,
    int& out_position) {}

std::unique_ptr<views::View>
AccountSelectionBubbleView::CreateSingleReturningAccountChooser(
    const std::vector<content::IdentityProviderData>& idp_data_list) {}

std::unique_ptr<views::View> AccountSelectionBubbleView::CreateIdpLoginRow(
    const std::u16string& idp_for_display,
    const content::IdentityProviderMetadata& idp_metadata) {}

std::unique_ptr<views::View>
AccountSelectionBubbleView::CreateUseOtherAccountButton(
    const content::IdentityProviderMetadata& idp_metadata) {}

void AccountSelectionBubbleView::UpdateHeader(
    const content::IdentityProviderMetadata& idp_metadata,
    const std::u16string title,
    bool show_back_button) {}

void AccountSelectionBubbleView::RemoveNonHeaderChildViews() {}

std::unique_ptr<views::View>
AccountSelectionBubbleView::CreateChooseAnAccountButton(
    const std::vector<std::u16string> mismatch_idps,
    const std::vector<std::u16string> non_mismatch_idps) {}

BEGIN_METADATA()