1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_SAVE_TO_DRIVE_ACCOUNT_CHOOSER_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_SAVE_TO_DRIVE_ACCOUNT_CHOOSER_VIEW_H_
#include "chrome/browser/ui/save_to_drive/account_chooser_controller_delegate.h"
#include "chrome/browser/ui/save_to_drive/account_chooser_view_delegate.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/layout/box_layout_view.h"
#include "ui/views/layout/flex_layout_view.h"
#include "ui/views/view.h"
namespace save_to_drive {
class AccountChooserView : public views::FlexLayoutView {
METADATA_HEADER(AccountChooserView, views::FlexLayoutView)
public:
explicit AccountChooserView(
AccountChooserControllerDelegate* account_chooser_controller_delegate,
AccountChooserViewDelegate* parent_dialog,
const std::vector<AccountInfo>& accounts,
std::optional<CoreAccountId> primary_account_id);
~AccountChooserView() override;
// Updates the view with the new accounts and primary account id.
void UpdateView(const std::vector<AccountInfo>& accounts,
std::optional<CoreAccountId> primary_account_id);
private:
// Creates the view containing the account rows based on the number of
// accounts.
std::unique_ptr<views::View> CreateBodyMultiAccount(
const std::vector<AccountInfo>& accounts,
std::optional<CoreAccountId> primary_account_id);
// Creates the view containing the account rows based on the number of
// accounts.
std::unique_ptr<views::View> CreateBodySingleAccount(
const AccountInfo& account);
// Creates the view containing the account rows based on the number of
// accounts.
std::unique_ptr<views::View> CreateBodyView(
const std::vector<AccountInfo>& accounts,
std::optional<CoreAccountId> primary_account_id);
std::unique_ptr<views::View> CreateDriveLogoView();
// Creates the view containing the "Use a different account", "Cancel", and
// "Save" buttons.
std::unique_ptr<views::View> CreateFooterView();
// Creates the view containing the title, subtitle, and Drive logo.
std::unique_ptr<views::View> CreateHeaderView(
const std::vector<AccountInfo>& accounts);
std::unique_ptr<views::Label> CreateTitleLabel(
const std::vector<AccountInfo>& accounts);
std::unique_ptr<views::StyledLabel> CreateSubtitleLabel();
std::unique_ptr<views::View> CreateTitleView(
const std::vector<AccountInfo>& accounts);
// Gets the title of the account chooser dialog based on the number of
// accounts.
std::u16string GetTitle(const std::vector<AccountInfo>& accounts);
bool IsMultiAccount(const std::vector<AccountInfo>& accounts);
bool IsSingleAccount(const std::vector<AccountInfo>& accounts);
void SetLabelProperties(views::Label* label);
// Updates the body view with the new accounts and primary account id.
void UpdateBodyView(const std::vector<AccountInfo>& accounts,
std::optional<CoreAccountId> primary_account_id);
// Updates the header view with the new accounts.
void UpdateHeaderView(const std::vector<AccountInfo>& accounts);
raw_ptr<AccountChooserControllerDelegate>
account_chooser_controller_delegate_ = nullptr;
raw_ptr<AccountChooserViewDelegate> parent_dialog_ = nullptr;
// View containing the logo of the identity provider and the title.
raw_ptr<views::View> header_view_ = nullptr;
raw_ptr<views::View> body_view_ = nullptr;
raw_ptr<views::View> footer_view_ = nullptr;
};
} // namespace save_to_drive
#endif // CHROME_BROWSER_UI_VIEWS_SAVE_TO_DRIVE_ACCOUNT_CHOOSER_VIEW_H_
|