File: account_chooser_view.h

package info (click to toggle)
chromium 140.0.7339.185-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,193,740 kB
  • sloc: cpp: 35,093,945; ansic: 7,161,670; javascript: 4,199,694; python: 1,441,797; asm: 949,904; xml: 747,515; pascal: 187,748; perl: 88,691; sh: 88,248; objc: 79,953; sql: 52,714; cs: 44,599; fortran: 24,137; makefile: 22,114; tcl: 15,277; php: 13,980; yacc: 9,000; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (87 lines) | stat: -rw-r--r-- 3,861 bytes parent folder | download | duplicates (5)
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_