Commit 7ca7a33b authored by Anastasiia Nikolaienko's avatar Anastasiia Nikolaienko Committed by Commit Bot

Use EDU-specific add account flow

Use crosAddAccountEdu flow name for Child users.

Bug: 1043108
Change-Id: I5598f05105cd3817e544d82a74d7b6aaebea5f0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2120361
Commit-Queue: Anastasiia Nikolaienko <anastasiian@chromium.org>
Reviewed-by: default avatarKush Sinha <sinhak@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755044}
parent 9e379598
...@@ -15,19 +15,25 @@ ...@@ -15,19 +15,25 @@
#include "chrome/browser/browser_process_platform_part.h" #include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/chrome_device_id_helper.h" #include "chrome/browser/signin/chrome_device_id_helper.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/webui/signin/inline_login_handler.h" #include "chrome/browser/ui/webui/signin/inline_login_handler.h"
#include "chromeos/components/account_manager/account_manager.h" #include "chromeos/components/account_manager/account_manager.h"
#include "chromeos/components/account_manager/account_manager_factory.h" #include "chromeos/components/account_manager/account_manager_factory.h"
#include "chromeos/constants/chromeos_features.h"
#include "components/signin/public/identity_manager/account_info.h" #include "components/signin/public/identity_manager/account_info.h"
#include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_manager.h"
#include "crypto/sha2.h" #include "crypto/sha2.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/gaia_urls.h" #include "google_apis/gaia/gaia_urls.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
namespace chromeos { namespace chromeos {
namespace { namespace {
constexpr char kCrosAddAccountFlow[] = "crosAddAccount";
constexpr char kCrosAddAccountEduFlow[] = "crosAddAccountEdu";
// Returns a base64-encoded hash code of "signin_scoped_device_id:gaia_id". // Returns a base64-encoded hash code of "signin_scoped_device_id:gaia_id".
std::string GetAccountDeviceId(const std::string& signin_scoped_device_id, std::string GetAccountDeviceId(const std::string& signin_scoped_device_id,
const std::string& gaia_id) { const std::string& gaia_id) {
...@@ -38,6 +44,27 @@ std::string GetAccountDeviceId(const std::string& signin_scoped_device_id, ...@@ -38,6 +44,27 @@ std::string GetAccountDeviceId(const std::string& signin_scoped_device_id,
return account_device_id; return account_device_id;
} }
std::string GetInlineLoginFlowName(Profile* profile, const std::string* email) {
DCHECK(profile);
if (!profile->IsChild()) {
return kCrosAddAccountFlow;
}
std::string primary_account_email =
IdentityManagerFactory::GetForProfile(profile)
->GetPrimaryAccountInfo(signin::ConsentLevel::kNotRequired)
.email;
// If provided email is for primary account - it's a reauthentication, use
// normal add account flow.
if (email && gaia::AreEmailsSame(primary_account_email, *email)) {
return kCrosAddAccountFlow;
}
// Child user is adding/reauthenticating a secondary account.
CHECK(features::IsEduCoexistenceEnabled());
return kCrosAddAccountEduFlow;
}
// A helper class for completing the inline login flow. Primarily, it is // A helper class for completing the inline login flow. Primarily, it is
// responsible for exchanging the auth code, obtained after a successful user // responsible for exchanging the auth code, obtained after a successful user
// sign in, for OAuth tokens and subsequently populating Chrome OS // sign in, for OAuth tokens and subsequently populating Chrome OS
...@@ -139,7 +166,9 @@ void InlineLoginHandlerChromeOS::SetExtraInitParams( ...@@ -139,7 +166,9 @@ void InlineLoginHandlerChromeOS::SetExtraInitParams(
params.SetKey("gaiaPath", base::Value(url.path().substr(1))); params.SetKey("gaiaPath", base::Value(url.path().substr(1)));
params.SetKey("constrained", base::Value("1")); params.SetKey("constrained", base::Value("1"));
params.SetKey("flow", base::Value("crosAddAccount")); params.SetKey("flow", base::Value(GetInlineLoginFlowName(
Profile::FromWebUI(web_ui()),
params.FindStringKey("email"))));
params.SetBoolean("dontResizeNonEmbeddedPages", true); params.SetBoolean("dontResizeNonEmbeddedPages", true);
// For in-session login flows, request Gaia to ignore third party SAML IdP SSO // For in-session login flows, request Gaia to ignore third party SAML IdP SSO
......
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