Commit 8c2d78fb authored by Alex Ilin's avatar Alex Ilin Committed by Commit Bot

[Signin] Dummy Reauth API

This CL adds a new method ShowReauthPrompt() to SigninViewController.

The callers cannot rely on Reauth prompt being displayed in a modal
dialog, since for some accounts Reauth is always shown in a popup
window.

Bug: 1045515
Change-Id: Ida343ffae2cff59b51f4b4c7f12b1e27db3b8297
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2020764
Commit-Queue: Alex Ilin <alexilin@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736516}
parent dbef7753
...@@ -1680,6 +1680,7 @@ jumbo_static_library("browser") { ...@@ -1680,6 +1680,7 @@ jumbo_static_library("browser") {
"signin/investigator_dependency_provider.h", "signin/investigator_dependency_provider.h",
"signin/local_auth.cc", "signin/local_auth.cc",
"signin/local_auth.h", "signin/local_auth.h",
"signin/reauth_result.h",
"signin/signin_error_controller_factory.cc", "signin/signin_error_controller_factory.cc",
"signin/signin_error_controller_factory.h", "signin/signin_error_controller_factory.h",
"signin/signin_profile_attributes_updater.cc", "signin/signin_profile_attributes_updater.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SIGNIN_REAUTH_RESULT_H_
#define CHROME_BROWSER_SIGNIN_REAUTH_RESULT_H_
namespace signin {
// Indicates the result of the Gaia Reauth flow.
enum class ReauthResult {
// The user was successfully re-authenticated.
kSuccess = 0,
// The user account is not signed in.
kAccountNotSignedIn = 1,
// The user dismissed the reauth prompt.
kDismissedByUser = 2,
// The reauth page failed to load.
kLoadFailed = 3,
// A caller canceled the reauth flow.
kCancelled = 4,
};
} // namespace signin
#endif // CHROME_BROWSER_SIGNIN_REAUTH_RESULT_H_
...@@ -7,11 +7,13 @@ ...@@ -7,11 +7,13 @@
#include <utility> #include <utility>
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/reauth_result.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/signin_view_controller_delegate.h" #include "chrome/browser/ui/signin_view_controller_delegate.h"
#include "components/signin/public/base/signin_buildflags.h" #include "components/signin/public/base/signin_buildflags.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "google_apis/gaia/core_account_id.h"
#if BUILDFLAG(ENABLE_DICE_SUPPORT) #if BUILDFLAG(ENABLE_DICE_SUPPORT)
#include "chrome/browser/search/search.h" #include "chrome/browser/search/search.h"
...@@ -155,6 +157,14 @@ void SigninViewController::ShowModalSigninErrorDialog(Browser* browser) { ...@@ -155,6 +157,14 @@ void SigninViewController::ShowModalSigninErrorDialog(Browser* browser) {
chrome::RecordDialogCreation(chrome::DialogIdentifier::SIGN_IN_ERROR); chrome::RecordDialogCreation(chrome::DialogIdentifier::SIGN_IN_ERROR);
} }
void SigninViewController::ShowReauthPrompt(
Browser* browser,
const CoreAccountId& account_id,
base::OnceCallback<void(signin::ReauthResult)> reauth_callback) {
// TODO(crbug.com/1045515): implement this.
std::move(reauth_callback).Run(signin::ReauthResult::kSuccess);
}
bool SigninViewController::ShowsModalDialog() { bool SigninViewController::ShowsModalDialog() {
return delegate_ != nullptr; return delegate_ != nullptr;
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
class Browser; class Browser;
class SigninViewControllerDelegate; class SigninViewControllerDelegate;
struct CoreAccountId;
namespace content { namespace content {
class WebContents; class WebContents;
...@@ -34,11 +35,15 @@ enum class PromoAction; ...@@ -34,11 +35,15 @@ enum class PromoAction;
enum class Reason; enum class Reason;
} // namespace signin_metrics } // namespace signin_metrics
namespace signin {
enum class ReauthResult;
}
// Class responsible for showing and hiding all sign-in related UIs // Class responsible for showing and hiding all sign-in related UIs
// (modal sign-in, DICE full-tab sign-in page, sync confirmation dialog, sign-in // (modal sign-in, DICE full-tab sign-in page, sync confirmation dialog, sign-in
// error dialog). Sync confirmation is used on Win/Mac/Linux/Chrome OS. // error dialog, reauth prompt). Sync confirmation is used on
// Sign-in is only used on Win/Mac/Linux because Chrome OS has its own sign-in // Win/Mac/Linux/Chrome OS. Sign-in is only used on Win/Mac/Linux because
// flow and doesn't use DICE. // Chrome OS has its own sign-in flow and doesn't use DICE.
class SigninViewController { class SigninViewController {
public: public:
SigninViewController(); SigninViewController();
...@@ -80,6 +85,18 @@ class SigninViewController { ...@@ -80,6 +85,18 @@ class SigninViewController {
// the |browser|'s window. // the |browser|'s window.
void ShowModalSigninErrorDialog(Browser* browser); void ShowModalSigninErrorDialog(Browser* browser);
// Shows the reauth prompt for |account_id| as either:
// - a browser-modal dialog on top of the |browser|'s window, or
// - a popup window
// |account_id| should be signed into the content area. Otherwise, the method
// fails with |kAccountNotSignedIn| error.
// Calls |reauth_callback| on completion of the reauth flow, or on error. The
// callback may be called synchronously.
void ShowReauthPrompt(
Browser* browser,
const CoreAccountId& account_id,
base::OnceCallback<void(signin::ReauthResult)> reauth_callback);
// Returns true if the modal dialog is shown. // Returns true if the modal dialog is shown.
bool ShowsModalDialog(); bool ShowsModalDialog();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment