chromium/chrome/browser/ui/views/webid/account_selection_view_base.cc

// Copyright 2024 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_view_base.h"

#include "base/functional/callback_forward.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/image_fetcher/image_decoder_impl.h"
#include "chrome/browser/ui/views/controls/hover_button.h"
#include "chrome/browser/ui/views/webid/account_selection_bubble_view.h"
#include "chrome/grit/generated_resources.h"
#include "components/image_fetcher/core/image_decoder.h"
#include "components/image_fetcher/core/image_fetcher_impl.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/browser/web_contents.h"
#include "third_party/blink/public/mojom/webid/federated_auth_request.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/border.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/layout/flex_layout_view.h"
#include "ui/views/style/typography.h"
#include "ui/views/widget/widget_observer.h"
#include "url/gurl.h"

namespace {

// safe_zone_diameter/icon_size as defined in
// https://www.w3.org/TR/appmanifest/#icon-masks
constexpr float kMaskableWebIconSafeZoneRatio =;

// The border radius of the background circle containing the IDP icon in an
// account button.
constexpr int kIdpBorderRadius =;

// Selects string for disclosure text based on passed-in `privacy_policy_url`
// and `terms_of_service_url`.
int SelectDisclosureTextResourceId(const GURL& privacy_policy_url,
                                   const GURL& terms_of_service_url) {}

constexpr net::NetworkTrafficAnnotationTag kTrafficAnnotation =;

class LetterCircleCroppedImageSkiaSource : public gfx::CanvasImageSource {};

// A CanvasImageSource that:
// 1) Applies an optional square center-crop.
// 2) Resizes the cropped image (while maintaining the image's aspect ratio) to
//    fit into the target canvas. If no center-crop was applied and the source
//    image is rectangular, the image is resized so that
//    `avatar` small edge size == `canvas_edge_size`.
// 3) Circle center-crops the resized image.
class CircleCroppedImageSkiaSource : public gfx::CanvasImageSource {};

gfx::ImageSkia CreateCircleCroppedImage(const gfx::ImageSkia& original_image,
                                        int image_size) {}

class AccountImageView : public views::ImageView {};

BEGIN_METADATA()

class AccountHoverButton : public HoverButton {};

}  // namespace

BrandIconImageView::BrandIconImageView(
    base::OnceCallback<void(const GURL&, const gfx::ImageSkia&)> add_image,
    int image_size,
    bool should_circle_crop,
    std::optional<SkColor> background_color,
    base::RepeatingClosure on_image_set)
    :{}

BrandIconImageView::~BrandIconImageView() = default;

void BrandIconImageView::FetchImage(
    const GURL& icon_url,
    image_fetcher::ImageFetcher& image_fetcher) {}

void BrandIconImageView::CropAndSetImage(const gfx::ImageSkia& original_image) {}

void BrandIconImageView::OnImageFetched(
    const GURL& image_url,
    const gfx::Image& image,
    const image_fetcher::RequestMetadata& metadata) {}

void BrandIconImageView::OnBackgroundColorUpdated(
    const SkColor& background_color) {}

BEGIN_METADATA()

AccountSelectionViewBase::AccountSelectionViewBase(
    content::WebContents* web_contents,
    AccountSelectionViewBase::Observer* observer,
    views::WidgetObserver* widget_observer,
    scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
    std::u16string rp_for_display)
    :{}

AccountSelectionViewBase::AccountSelectionViewBase() = default;
AccountSelectionViewBase::~AccountSelectionViewBase() {}

void AccountSelectionViewBase::OnOcclusionStateChanged(bool occluded) {}

void AccountSelectionViewBase::SetLabelProperties(views::Label* label) {}

std::unique_ptr<views::View> AccountSelectionViewBase::CreateAccountRow(
    const content::IdentityRequestAccount& account,
    const content::IdentityProviderData& idp_display_data,
    std::optional<int> clickable_position,
    bool should_include_idp,
    bool is_modal_dialog,
    int additional_vertical_padding,
    std::optional<std::u16string> last_used_string) {}

void AccountSelectionViewBase::AddIdpImage(const GURL& image_url,
                                           const gfx::ImageSkia& image) {}

void AccountSelectionViewBase::ConfigureBrandImageView(
    BrandIconImageView* image_view,
    const GURL& brand_icon_url) {}

std::unique_ptr<views::StyledLabel>
AccountSelectionViewBase::CreateDisclosureLabel(
    const content::IdentityProviderData& idp_display_data) {}

base::WeakPtr<views::Widget> AccountSelectionViewBase::GetDialogWidget() {}

// static
net::NetworkTrafficAnnotationTag
AccountSelectionViewBase::GetTrafficAnnotation() {}

bool AccountSelectionViewBase::CanFitInWebContents() {}