File: plus_address_creation_dialog_delegate.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (105 lines) | stat: -rw-r--r-- 3,844 bytes parent folder | download | duplicates (2)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright 2023 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_PLUS_ADDRESSES_VIEWS_PLUS_ADDRESS_CREATION_DIALOG_DELEGATE_H_
#define CHROME_BROWSER_UI_PLUS_ADDRESSES_VIEWS_PLUS_ADDRESS_CREATION_DIALOG_DELEGATE_H_

#include "base/functional/callback_forward.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "chrome/browser/ui/plus_addresses/plus_address_creation_view.h"
#include "components/plus_addresses/plus_address_types.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"

namespace content {
class WebContents;
}  // namespace content

namespace views {
class ImageButton;
class MdTextButton;
class ProgressBar;
class View;
}  // namespace views

namespace plus_addresses {

class PlusAddressCreationController;

// A delegate that creates and updates the PlusAddresses dialog.
class PlusAddressCreationDialogDelegate : public views::BubbleDialogDelegate,
                                          public PlusAddressCreationView {
 public:
  PlusAddressCreationDialogDelegate(
      base::WeakPtr<PlusAddressCreationController> controller,
      content::WebContents* web_contents,
      const std::string& primary_email_address,
      const std::u16string& domain,
      bool show_notice);
  PlusAddressCreationDialogDelegate(const PlusAddressCreationDialogDelegate&) =
      delete;
  PlusAddressCreationDialogDelegate& operator=(
      const PlusAddressCreationDialogDelegate&) = delete;
  ~PlusAddressCreationDialogDelegate() override;

  // WidgetDelegate:
  void OnWidgetInitialized() override;

  // PlusAddressCreationView:
  void ShowReserveResult(const PlusProfileOrError& maybe_plus_profile,
                         bool offer_refresh) override;
  void ShowConfirmResult(const PlusProfileOrError& maybe_plus_profile) override;

  // Calls the respective controller method for `type`.
  void HandleButtonPress(PlusAddressViewButtonType type);

 private:
  // Helper methods for view setup.

  // Creates the logo displayed at the top of the dialog.
  std::unique_ptr<views::View> CreateLogo();

  // Creates a hidden refresh button.
  std::unique_ptr<views::ImageButton> CreateRefreshButton();

  // Creates a view containing the two buttons for the dialog and saves a
  // pointer to the confirm button to `confirm_button_`.
  std::unique_ptr<views::View> CreateButtons();

  // Shows and hides the progress bar at the top of the dialog.
  void SetProgressBarVisibility(bool is_visible);

  // Updates the modal dialog to show error messages.
  // TODO(crbug.com/363720961): Remove once updated error states are launched -
  // it will then have been superseded by the methods below.
  void ShowErrorStateUI();

  // Updates the icon in the suggested address box to an error icon and shows an
  // error message below the suggested plus address container.
  void ShowCreateErrorMessage(bool is_timeout);

  void HideCreateErrorMessage();

  // Updates `plus_address_label_` to indicate that a new address is loading,
  // disables `confirm_button_` and informs the controller.
  void OnRefreshClicked();

  base::WeakPtr<PlusAddressCreationController> controller_;
  raw_ptr<content::WebContents> web_contents_;
  raw_ptr<views::ProgressBar> progress_bar_ = nullptr;

  // The container for the suggested plus address and the refresh button.
  class PlusAddressContainerView;
  raw_ptr<PlusAddressContainerView> plus_address_container_ = nullptr;

  // A single line error message in red.
  raw_ptr<views::Label> create_error_message_label_ = nullptr;

  // The button for confirming the modal dialog.
  raw_ptr<views::MdTextButton> confirm_button_ = nullptr;
};

}  // namespace plus_addresses

#endif  // CHROME_BROWSER_UI_PLUS_ADDRESSES_VIEWS_PLUS_ADDRESS_CREATION_DIALOG_DELEGATE_H_