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
|
// Copyright 2020 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_WEBID_IDENTITY_DIALOG_CONTROLLER_H_
#define CHROME_BROWSER_UI_WEBID_IDENTITY_DIALOG_CONTROLLER_H_
#include <memory>
#include <utility>
#include <vector>
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "chrome/browser/ui/webid/account_selection_view.h"
#include "content/public/browser/identity_request_dialog_controller.h"
#include "content/public/browser/web_contents.h"
#include "ui/gfx/native_widget_types.h"
using AccountSelectionCallback =
content::IdentityRequestDialogController::AccountSelectionCallback;
using DismissCallback =
content::IdentityRequestDialogController::DismissCallback;
using TokenError = content::IdentityCredentialTokenError;
// The IdentityDialogController controls the views that are used across
// browser-mediated federated sign-in flows.
class IdentityDialogController
: public content::IdentityRequestDialogController,
public AccountSelectionView::Delegate {
public:
explicit IdentityDialogController(content::WebContents* rp_web_contents);
IdentityDialogController(const IdentityDialogController&) = delete;
IdentityDialogController& operator=(const IdentityDialogController&) = delete;
~IdentityDialogController() override;
// content::IdentityRequestDelegate
int GetBrandIconMinimumSize() override;
int GetBrandIconIdealSize() override;
// content::IdentityRequestDialogController
void ShowAccountsDialog(
const std::string& top_frame_for_display,
const absl::optional<std::string>& iframe_for_display,
const std::vector<content::IdentityProviderData>& identity_provider_data,
content::IdentityRequestAccount::SignInMode sign_in_mode,
bool show_auto_reauthn_checkbox,
AccountSelectionCallback on_selected,
DismissCallback dismiss_callback) override;
void ShowFailureDialog(const std::string& top_frame_for_display,
const absl::optional<std::string>& iframe_for_display,
const std::string& idp_for_display,
const blink::mojom::RpContext& rp_context,
const content::IdentityProviderMetadata& idp_metadata,
DismissCallback dismiss_callback,
SigninToIdPCallback signin_callback) override;
void ShowErrorDialog(const std::string& top_frame_for_display,
const absl::optional<std::string>& iframe_for_display,
const std::string& idp_for_display,
const blink::mojom::RpContext& rp_context,
const content::IdentityProviderMetadata& idp_metadata,
const absl::optional<TokenError>& error,
DismissCallback dismiss_callback,
MoreDetailsCallback more_details_callback) override;
void ShowIdpSigninFailureDialog(base::OnceClosure dismiss_callback) override;
std::string GetTitle() const override;
absl::optional<std::string> GetSubtitle() const override;
// Show a modal dialog that loads content from the IdP in a WebView.
content::WebContents* ShowModalDialog(
const GURL& url,
DismissCallback dismiss_callback) override;
void CloseModalDialog() override;
// AccountSelectionView::Delegate:
void OnAccountSelected(const GURL& idp_config_url,
const Account& account) override;
void OnDismiss(DismissReason dismiss_reason) override;
void OnSigninToIdP() override;
void OnMoreDetails() override;
gfx::NativeView GetNativeView() override;
content::WebContents* GetWebContents() override;
private:
std::unique_ptr<AccountSelectionView> account_view_{nullptr};
AccountSelectionCallback on_account_selection_;
DismissCallback on_dismiss_;
SigninToIdPCallback on_signin_;
MoreDetailsCallback on_more_details_;
raw_ptr<content::WebContents> rp_web_contents_;
};
#endif // CHROME_BROWSER_UI_WEBID_IDENTITY_DIALOG_CONTROLLER_H_
|