Commit aabacf9e authored by Ned Nguyen's avatar Ned Nguyen Committed by Commit Bot

Revert "Migrate consumers of SigninManager::IsAllowedUsername()"

This reverts commit 198eca95.

Reason for revert: breaking GPU Linux Builder

Original change's description:
> Migrate consumers of SigninManager::IsAllowedUsername()
> 
> Use identity::IsUsernameAllowedByPattern() instead so that we can migrate
> those consumers entirely to the IdentityManager in follow-up patches.
> 
> Also, in order to make it explicit that this API should not be used any
> more, make SigninManager::IsAllowedUsername() a private method and friend
> it with the relevant test cases from SigninManagerTest, so that it can
> only be used from there. And while at it, also remove some stale lines
> "friending" SigninManager with test cases that no longer exist.
> 
> Bug: 890794, 890815, 906085
> Change-Id: Id8a72b0efd89818e02c6d1e73aac1451207b9625
> Reviewed-on: https://chromium-review.googlesource.com/c/1346409
> Reviewed-by: Mihai Sardarescu <msarda@chromium.org>
> Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
> Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
> Cr-Commit-Position: refs/heads/master@{#611704}

TBR=blundell@chromium.org,msarda@chromium.org,sdefresne@chromium.org,mario@igalia.com

Change-Id: I8172674e32d7671868fa5374a9457abd6413321e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 890794, 890815, 906085
Reviewed-on: https://chromium-review.googlesource.com/c/1354121Reviewed-by: default avatarNed Nguyen <nednguyen@google.com>
Commit-Queue: Ned Nguyen <nednguyen@google.com>
Cr-Commit-Position: refs/heads/master@{#611710}
parent f4f05ced
......@@ -11,7 +11,6 @@
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
......@@ -32,9 +31,7 @@
#include "components/signin/core/browser/account_info.h"
#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/gaia_cookie_manager_service.h"
#include "components/signin/core/browser/identity_utils.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/browser/signin_pref_names.h"
#include "components/user_manager/user_manager.h"
#include "services/identity/public/cpp/identity_manager.h"
#include "third_party/re2/src/re2/re2.h"
......@@ -243,9 +240,7 @@ std::vector<AccountInfo> GetAccountsForDicePromos(Profile* profile) {
std::vector<AccountInfo> accounts;
for (auto account_info : accounts_with_tokens) {
DCHECK(!account_info.IsEmpty());
if (!identity::LegacyIsUsernameAllowedByPatternFromPrefs(
g_browser_process->local_state(), account_info.email,
prefs::kGoogleServicesUsernamePattern)) {
if (!signin_manager->IsAllowedUsername(account_info.email)) {
continue;
}
if (account_info.account_id == default_account_id)
......
......@@ -18,7 +18,6 @@
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "components/signin/core/browser/identity_utils.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/browser/signin_pref_names.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -46,9 +45,7 @@ bool CanOfferSignin(Profile* profile,
return false;
// Make sure this username is not prohibited by policy.
if (!identity::LegacyIsUsernameAllowedByPatternFromPrefs(
g_browser_process->local_state(), email,
prefs::kGoogleServicesUsernamePattern)) {
if (!manager->IsAllowedUsername(email)) {
if (error_message) {
error_message->assign(
l10n_util::GetStringUTF8(IDS_SYNC_LOGIN_NAME_PROHIBITED));
......
......@@ -168,6 +168,10 @@ class SigninManager : public SigninManagerBase,
// Sets whether sign-in is allowed or not.
void SetSigninAllowed(bool allowed);
// Returns true if the passed username is allowed by policy. Virtual for
// mocking in tests.
virtual bool IsAllowedUsername(const std::string& username) const;
// If an authentication is in progress, return the account id being
// authenticated. Returns an empty string if no auth is in progress.
const std::string& GetAccountIdForAuthInProgress() const;
......@@ -198,8 +202,9 @@ class SigninManager : public SigninManagerBase,
std::string SigninTypeToString(SigninType type);
friend class FakeSigninManager;
friend class identity::IdentityManager;
FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, Prohibited);
FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, TestAlternateWildcard);
FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ClearTransientSigninData);
FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ProvideSecondFactorSuccess);
FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ProvideSecondFactorFailure);
// Called to setup the transient signin data during one of the
// StartSigninXXX methods. |type| indicates which of the methods is being
......@@ -251,9 +256,6 @@ class SigninManager : public SigninManagerBase,
void OnSigninAllowedPrefChanged();
void OnGoogleServicesUsernamePatternChanged();
// Returns true if the passed username is allowed by policy.
bool IsAllowedUsername(const std::string& username) const;
std::string possibly_invalid_account_id_;
std::string possibly_invalid_gaia_id_;
std::string possibly_invalid_email_;
......
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