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

[signin] AccountReconcilor use different Gaia sources for Dice/Mirror

The Gaia server needs to be able to distinguish between Dice and Mirror
calls.
This CL sets a new different source for Dice calls.

Bug: 854743
Change-Id: Id697d5aad326283b0002c6ce76dde4e619b9885e
Reviewed-on: https://chromium-review.googlesource.com/1109898Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: David Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569681}
parent 3ee6269d
...@@ -32,9 +32,6 @@ using signin::AccountReconcilorDelegate; ...@@ -32,9 +32,6 @@ using signin::AccountReconcilorDelegate;
namespace { namespace {
// String used for source parameter in GAIA cookie manager calls.
const char kSource[] = "ChromiumAccountReconcilor";
class AccountEqualToFunc { class AccountEqualToFunc {
public: public:
explicit AccountEqualToFunc(const gaia::ListedAccount& account) explicit AccountEqualToFunc(const gaia::ListedAccount& account)
...@@ -275,7 +272,7 @@ void AccountReconcilor::OnAuthErrorChanged( ...@@ -275,7 +272,7 @@ void AccountReconcilor::OnAuthErrorChanged(
// This should cover well the Mirror and Desktop Identity Consistency cases as // This should cover well the Mirror and Desktop Identity Consistency cases as
// the cookies are always bound to the refresh tokens in these cases. // the cookies are always bound to the refresh tokens in these cases.
if (error != GoogleServiceAuthError::AuthErrorNone()) if (error != GoogleServiceAuthError::AuthErrorNone())
cookie_manager_service_->TriggerListAccounts(kSource); cookie_manager_service_->TriggerListAccounts(delegate_->GetGaiaApiSource());
} }
void AccountReconcilor::PerformMergeAction(const std::string& account_id) { void AccountReconcilor::PerformMergeAction(const std::string& account_id) {
...@@ -285,7 +282,8 @@ void AccountReconcilor::PerformMergeAction(const std::string& account_id) { ...@@ -285,7 +282,8 @@ void AccountReconcilor::PerformMergeAction(const std::string& account_id) {
return; return;
} }
VLOG(1) << "AccountReconcilor::PerformMergeAction: " << account_id; VLOG(1) << "AccountReconcilor::PerformMergeAction: " << account_id;
cookie_manager_service_->AddAccountToCookie(account_id, kSource); cookie_manager_service_->AddAccountToCookie(account_id,
delegate_->GetGaiaApiSource());
} }
void AccountReconcilor::PerformLogoutAllAccountsAction() { void AccountReconcilor::PerformLogoutAllAccountsAction() {
...@@ -293,7 +291,7 @@ void AccountReconcilor::PerformLogoutAllAccountsAction() { ...@@ -293,7 +291,7 @@ void AccountReconcilor::PerformLogoutAllAccountsAction() {
if (!delegate_->IsAccountConsistencyEnforced()) if (!delegate_->IsAccountConsistencyEnforced())
return; return;
VLOG(1) << "AccountReconcilor::PerformLogoutAllAccountsAction"; VLOG(1) << "AccountReconcilor::PerformLogoutAllAccountsAction";
cookie_manager_service_->LogOutAllAccounts(kSource); cookie_manager_service_->LogOutAllAccounts(delegate_->GetGaiaApiSource());
} }
void AccountReconcilor::StartReconcile() { void AccountReconcilor::StartReconcile() {
...@@ -352,7 +350,7 @@ void AccountReconcilor::StartReconcile() { ...@@ -352,7 +350,7 @@ void AccountReconcilor::StartReconcile() {
std::vector<gaia::ListedAccount> accounts; std::vector<gaia::ListedAccount> accounts;
std::vector<gaia::ListedAccount> signed_out_accounts; std::vector<gaia::ListedAccount> signed_out_accounts;
if (cookie_manager_service_->ListAccounts(&accounts, &signed_out_accounts, if (cookie_manager_service_->ListAccounts(&accounts, &signed_out_accounts,
kSource)) { delegate_->GetGaiaApiSource())) {
OnGaiaAccountsInCookieUpdated( OnGaiaAccountsInCookieUpdated(
accounts, signed_out_accounts, accounts, signed_out_accounts,
GoogleServiceAuthError(GoogleServiceAuthError::NONE)); GoogleServiceAuthError(GoogleServiceAuthError::NONE));
...@@ -457,7 +455,7 @@ std::vector<std::string> AccountReconcilor::LoadValidAccountsFromTokenService() ...@@ -457,7 +455,7 @@ std::vector<std::string> AccountReconcilor::LoadValidAccountsFromTokenService()
void AccountReconcilor::OnReceivedManageAccountsResponse( void AccountReconcilor::OnReceivedManageAccountsResponse(
signin::GAIAServiceType service_type) { signin::GAIAServiceType service_type) {
if (service_type == signin::GAIA_SERVICE_TYPE_ADDSESSION) { if (service_type == signin::GAIA_SERVICE_TYPE_ADDSESSION) {
cookie_manager_service_->TriggerListAccounts(kSource); cookie_manager_service_->TriggerListAccounts(delegate_->GetGaiaApiSource());
} }
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "components/signin/core/browser/account_reconcilor_delegate.h" #include "components/signin/core/browser/account_reconcilor_delegate.h"
#include "base/logging.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "google_apis/gaia/google_service_auth_error.h" #include "google_apis/gaia/google_service_auth_error.h"
...@@ -17,6 +18,11 @@ bool AccountReconcilorDelegate::IsAccountConsistencyEnforced() const { ...@@ -17,6 +18,11 @@ bool AccountReconcilorDelegate::IsAccountConsistencyEnforced() const {
return false; return false;
} }
std::string AccountReconcilorDelegate::GetGaiaApiSource() const {
NOTREACHED() << "Reconcile is not enabled, no Gaia API calls should be made.";
return "ChromiumAccountReconcilorInvalidSource";
}
bool AccountReconcilorDelegate::ShouldAbortReconcileIfPrimaryHasError() const { bool AccountReconcilorDelegate::ShouldAbortReconcileIfPrimaryHasError() const {
return false; return false;
} }
......
...@@ -41,6 +41,9 @@ class AccountReconcilorDelegate { ...@@ -41,6 +41,9 @@ class AccountReconcilorDelegate {
// changes to the accounts are made. Defaults to false. // changes to the accounts are made. Defaults to false.
virtual bool IsAccountConsistencyEnforced() const; virtual bool IsAccountConsistencyEnforced() const;
// Returns the value to set in the "source" parameter for Gaia API calls.
virtual std::string GetGaiaApiSource() const;
// Returns true if Reconcile should be aborted when the primary account is in // Returns true if Reconcile should be aborted when the primary account is in
// error state. Defaults to false. // error state. Defaults to false.
virtual bool ShouldAbortReconcileIfPrimaryHasError() const; virtual bool ShouldAbortReconcileIfPrimaryHasError() const;
......
...@@ -78,6 +78,8 @@ class SpyReconcilorDelegate : public signin::AccountReconcilorDelegate { ...@@ -78,6 +78,8 @@ class SpyReconcilorDelegate : public signin::AccountReconcilorDelegate {
bool IsAccountConsistencyEnforced() const override { return true; } bool IsAccountConsistencyEnforced() const override { return true; }
std::string GetGaiaApiSource() const override { return "TestSource"; }
bool ShouldAbortReconcileIfPrimaryHasError() const override { return true; } bool ShouldAbortReconcileIfPrimaryHasError() const override { return true; }
std::string GetFirstGaiaAccountForReconcile( std::string GetFirstGaiaAccountForReconcile(
......
...@@ -31,6 +31,10 @@ bool DiceAccountReconcilorDelegate::IsAccountConsistencyEnforced() const { ...@@ -31,6 +31,10 @@ bool DiceAccountReconcilorDelegate::IsAccountConsistencyEnforced() const {
return account_consistency_ == AccountConsistencyMethod::kDice; return account_consistency_ == AccountConsistencyMethod::kDice;
} }
std::string DiceAccountReconcilorDelegate::GetGaiaApiSource() const {
return "ChromiumAccountReconcilorDice";
}
// - On first execution, the candidates are examined in this order: // - On first execution, the candidates are examined in this order:
// 1. The primary account // 1. The primary account
// 2. The current first Gaia account // 2. The current first Gaia account
......
...@@ -25,6 +25,7 @@ class DiceAccountReconcilorDelegate : public AccountReconcilorDelegate { ...@@ -25,6 +25,7 @@ class DiceAccountReconcilorDelegate : public AccountReconcilorDelegate {
// AccountReconcilorDelegate: // AccountReconcilorDelegate:
bool IsReconcileEnabled() const override; bool IsReconcileEnabled() const override;
bool IsAccountConsistencyEnforced() const override; bool IsAccountConsistencyEnforced() const override;
std::string GetGaiaApiSource() const override;
std::string GetFirstGaiaAccountForReconcile( std::string GetFirstGaiaAccountForReconcile(
const std::vector<std::string>& chrome_accounts, const std::vector<std::string>& chrome_accounts,
const std::vector<gaia::ListedAccount>& gaia_accounts, const std::vector<gaia::ListedAccount>& gaia_accounts,
......
...@@ -28,6 +28,10 @@ bool MirrorAccountReconcilorDelegate::IsAccountConsistencyEnforced() const { ...@@ -28,6 +28,10 @@ bool MirrorAccountReconcilorDelegate::IsAccountConsistencyEnforced() const {
return true; return true;
} }
std::string MirrorAccountReconcilorDelegate::GetGaiaApiSource() const {
return "ChromiumAccountReconcilor";
}
bool MirrorAccountReconcilorDelegate::ShouldAbortReconcileIfPrimaryHasError() bool MirrorAccountReconcilorDelegate::ShouldAbortReconcileIfPrimaryHasError()
const { const {
return true; return true;
......
...@@ -22,6 +22,7 @@ class MirrorAccountReconcilorDelegate : public AccountReconcilorDelegate, ...@@ -22,6 +22,7 @@ class MirrorAccountReconcilorDelegate : public AccountReconcilorDelegate,
// AccountReconcilorDelegate: // AccountReconcilorDelegate:
bool IsReconcileEnabled() const override; bool IsReconcileEnabled() const override;
bool IsAccountConsistencyEnforced() const override; bool IsAccountConsistencyEnforced() const override;
std::string GetGaiaApiSource() const override;
bool ShouldAbortReconcileIfPrimaryHasError() const override; bool ShouldAbortReconcileIfPrimaryHasError() const override;
std::string GetFirstGaiaAccountForReconcile( std::string GetFirstGaiaAccountForReconcile(
const std::vector<std::string>& chrome_accounts, const std::vector<std::string>& chrome_accounts,
......
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