Commit dd17e95c authored by David Roger's avatar David Roger Committed by Commit Bot

[signin] Plumb the Multilogin mode to the identity service

The multilogin mode is currently dropped on the floor by the account
reconcilor. This mode needs to be passed to the Gaia server.

This CL passes it to the identity service (by passing the full
MultiloginParameters structure instead of the account list).
A follow-up CL will complete the plumbing to Gaia.

Bug: 890321
Change-Id: I711fed0b26a60b74b976e348111029f6948b187f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1893252Reviewed-by: default avatarMonica Basta <msalama@chromium.org>
Commit-Queue: David Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712528}
parent 20e6bad9
......@@ -35,8 +35,6 @@ static_library("browser") {
"mice_account_reconcilor_delegate.h",
"mirror_account_reconcilor_delegate.cc",
"mirror_account_reconcilor_delegate.h",
"multilogin_parameters.cc",
"multilogin_parameters.h",
"signin_error_controller.cc",
"signin_error_controller.h",
"signin_header_helper.cc",
......
......@@ -451,13 +451,8 @@ void AccountReconcilor::PerformSetCookiesAction(
//
// Using Unretained is safe here because the CookieManagerService outlives
// the AccountReconcilor.
// TODO(triploblastic): Remove this vector once account_reconcilor and
// related classes has been refactored to use CoreAccountId.
std::vector<CoreAccountId> accounts_to_send;
for (const auto& account : parameters.accounts_to_send)
accounts_to_send.push_back(CoreAccountId(account));
identity_manager_->GetAccountsCookieMutator()->SetAccountsInCookie(
accounts_to_send, delegate_->GetGaiaApiSource(),
parameters, delegate_->GetGaiaApiSource(),
base::BindOnce(&AccountReconcilor::OnSetAccountsInCookieCompleted,
base::Unretained(this)));
}
......
......@@ -9,7 +9,7 @@
#include <vector>
#include "base/time/time.h"
#include "components/signin/core/browser/multilogin_parameters.h"
#include "components/signin/public/base/multilogin_parameters.h"
#include "google_apis/gaia/gaia_auth_fetcher.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/google_service_auth_error.h"
......
......@@ -9,6 +9,7 @@
#include "build/build_config.h"
#include "components/signin/internal/identity_manager/account_tracker_service.h"
#include "components/signin/internal/identity_manager/gaia_cookie_manager_service.h"
#include "components/signin/public/base/multilogin_parameters.h"
#include "google_apis/gaia/core_account_id.h"
#include "google_apis/gaia/google_service_auth_error.h"
......@@ -43,12 +44,12 @@ void AccountsCookieMutatorImpl::AddAccountToCookieWithToken(
}
void AccountsCookieMutatorImpl::SetAccountsInCookie(
const std::vector<CoreAccountId>& account_ids,
const MultiloginParameters& parameters,
gaia::GaiaSource source,
base::OnceCallback<void(SetAccountsInCookieResult)>
set_accounts_in_cookies_completed_callback) {
std::vector<GaiaCookieManagerService::AccountIdGaiaIdPair> accounts;
for (const auto& account_id : account_ids) {
for (const auto& account_id : parameters.accounts_to_send) {
accounts.push_back(make_pair(
account_id, account_tracker_service_->GetAccountInfo(account_id).gaia));
}
......
......@@ -41,7 +41,7 @@ class AccountsCookieMutatorImpl : public AccountsCookieMutator {
AddAccountToCookieCompletedCallback completion_callback) override;
void SetAccountsInCookie(
const std::vector<CoreAccountId>& account_ids,
const MultiloginParameters& parameters,
gaia::GaiaSource source,
base::OnceCallback<void(SetAccountsInCookieResult)>
set_accounts_in_cookies_completed_callback) override;
......
......@@ -25,6 +25,8 @@ static_library("base") {
"avatar_icon_util.h",
"device_id_helper.cc",
"device_id_helper.h",
"multilogin_parameters.cc",
"multilogin_parameters.h",
"signin_client.cc",
"signin_client.h",
"signin_metrics.cc",
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/signin/core/browser/multilogin_parameters.h"
#include "components/signin/public/base/multilogin_parameters.h"
namespace signin {
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_SIGNIN_CORE_BROWSER_MULTILOGIN_PARAMETERS_H_
#define COMPONENTS_SIGNIN_CORE_BROWSER_MULTILOGIN_PARAMETERS_H_
#ifndef COMPONENTS_SIGNIN_PUBLIC_BASE_MULTILOGIN_PARAMETERS_H_
#define COMPONENTS_SIGNIN_PUBLIC_BASE_MULTILOGIN_PARAMETERS_H_
#include <string>
#include <vector>
......@@ -30,4 +30,4 @@ struct MultiloginParameters {
};
} // namespace signin
#endif // COMPONENTS_SIGNIN_CORE_BROWSER_MULTILOGIN_PARAMETERS_H_
#endif // COMPONENTS_SIGNIN_PUBLIC_BASE_MULTILOGIN_PARAMETERS_H_
......@@ -17,6 +17,7 @@ class GoogleServiceAuthError;
namespace signin {
struct MultiloginParameters;
enum class SetAccountsInCookieResult;
// AccountsCookieMutator is the interface to support merging known local Google
......@@ -46,16 +47,22 @@ class AccountsCookieMutator {
gaia::GaiaSource source,
AddAccountToCookieCompletedCallback completion_callback) = 0;
// Updates the state of the Gaia cookie to contain |account_ids|, including
// removal of any accounts that are currently present in the cookie but not
// contained in |account_ids|. |set_accounts_in_cookies_completed_callback|
// will be invoked with the result of the operation: if the error is equal to
// Updates the state of the Gaia cookie to contain the accounts in
// |parameters|.
// If the mode is MULTILOGIN_UPDATE_COOKIE_ACCOUNTS_ORDER the order of the
// accounts will be enforced, and any extra account (including invalid
// sessions) will be removed.
// If the mode is MULTILOGIN_PRESERVE_COOKIE_ACCOUNTS_ORDER, the ordering of
// accounts will not be enforced. Additionally, extra accounts won't be
// removed from the cookie but only invalidated.
// |set_accounts_in_cookies_completed_callback| will be invoked with the
// result of the operation: if the error is equal to
// GoogleServiceAuthError::AuthErrorNone() then the operation succeeded.
// Notably, if there are accounts being added for which IdentityManager does
// not have refresh tokens, the operation will fail with a
// GoogleServiceAuthError::USER_NOT_SIGNED_UP error.
virtual void SetAccountsInCookie(
const std::vector<CoreAccountId>& account_ids,
const MultiloginParameters& parameters,
gaia::GaiaSource source,
base::OnceCallback<void(SetAccountsInCookieResult)>
set_accounts_in_cookies_completed_callback) = 0;
......
......@@ -14,6 +14,7 @@
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "components/signin/public/base/list_accounts_test_utils.h"
#include "components/signin/public/base/multilogin_parameters.h"
#include "components/signin/public/base/test_signin_client.h"
#include "components/signin/public/identity_manager/accounts_in_cookie_jar_info.h"
#include "components/signin/public/identity_manager/identity_manager.h"
......@@ -280,10 +281,11 @@ TEST_F(AccountsCookieMutatorTest, SetAccountsInCookie_AllNonExistingAccounts) {
AccountsCookiesMutatorAction::kSetAccountsInCookie);
base::RunLoop run_loop;
std::vector<CoreAccountId> accounts_ids = {kTestUnavailableAccountId,
kTestOtherUnavailableAccountId};
MultiloginParameters parameters = {
gaia::MultiloginMode::MULTILOGIN_UPDATE_COOKIE_ACCOUNTS_ORDER,
{kTestUnavailableAccountId, kTestOtherUnavailableAccountId}};
accounts_cookie_mutator()->SetAccountsInCookie(
accounts_ids, gaia::GaiaSource::kChrome,
parameters, gaia::GaiaSource::kChrome,
base::BindOnce(
[](base::OnceClosure quit_closure, SetAccountsInCookieResult result) {
EXPECT_EQ(result, SetAccountsInCookieResult::kPersistentError);
......@@ -305,10 +307,11 @@ TEST_F(AccountsCookieMutatorTest, SetAccountsInCookie_SomeNonExistingAccounts) {
std::string account_id = AddAcountWithRefreshToken(kTestAccountEmail);
base::RunLoop run_loop;
std::vector<CoreAccountId> accounts_ids = {account_id,
kTestUnavailableAccountId};
MultiloginParameters parameters = {
gaia::MultiloginMode::MULTILOGIN_UPDATE_COOKIE_ACCOUNTS_ORDER,
{account_id, kTestUnavailableAccountId}};
accounts_cookie_mutator()->SetAccountsInCookie(
accounts_ids, gaia::GaiaSource::kChrome,
parameters, gaia::GaiaSource::kChrome,
base::BindOnce(
[](base::OnceClosure quit_closure, SetAccountsInCookieResult result) {
EXPECT_EQ(result, SetAccountsInCookieResult::kPersistentError);
......@@ -332,9 +335,11 @@ TEST_F(AccountsCookieMutatorTest, SetAccountsInCookie_AllExistingAccounts) {
std::string other_account_id =
AddAcountWithRefreshToken(kTestOtherAccountEmail);
base::RunLoop run_loop;
std::vector<CoreAccountId> accounts_ids = {account_id, other_account_id};
MultiloginParameters parameters = {
gaia::MultiloginMode::MULTILOGIN_UPDATE_COOKIE_ACCOUNTS_ORDER,
{account_id, other_account_id}};
accounts_cookie_mutator()->SetAccountsInCookie(
accounts_ids, gaia::GaiaSource::kChrome,
parameters, gaia::GaiaSource::kChrome,
base::BindOnce(
[](base::OnceClosure quit_closure, SetAccountsInCookieResult result) {
EXPECT_EQ(result, SetAccountsInCookieResult::kSuccess);
......
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