// Copyright 2015 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_PASSWORDS_ACCOUNT_CHOOSER_DIALOG_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_PASSWORDS_ACCOUNT_CHOOSER_DIALOG_VIEW_H_

#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/passwords/password_dialog_prompts.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/window/dialog_delegate.h"

namespace content {
class WebContents;
}

namespace password_manager {
struct PasswordForm;
}  // namespace password_manager

class CredentialManagerDialogController;

class AccountChooserDialogView : public views::DialogDelegate,
                                 public AccountChooserPrompt {
 public:
  AccountChooserDialogView(CredentialManagerDialogController* controller,
                           content::WebContents* web_contents);
  AccountChooserDialogView(const AccountChooserDialogView&) = delete;
  AccountChooserDialogView& operator=(const AccountChooserDialogView&) = delete;
  ~AccountChooserDialogView() override;

  // AccountChooserPrompt:
  void ShowAccountChooser() override;
  void ControllerGone() override;

  // DialogDelegate:
  bool Accept() override;
  bool ShouldAllowKeyEventsDuringInputProtection() const override;

 private:
  std::u16string GetWindowTitle() const override;
  bool ShouldShowCloseButton() const override;
  void WindowClosing() override;

  // Sets up the child views.
  void InitWindow();

  void CredentialsItemPressed(const password_manager::PasswordForm* form,
                              const ui::Event& event);

  // A weak pointer to the controller.
  raw_ptr<CredentialManagerDialogController> controller_;
  const base::WeakPtr<content::WebContents> web_contents_;

  std::unique_ptr<views::Widget> widget_;
};

#endif  // CHROME_BROWSER_UI_VIEWS_PASSWORDS_ACCOUNT_CHOOSER_DIALOG_VIEW_H_
