| Index: chrome/browser/signin/signin_manager_base.cc
|
| diff --git a/chrome/browser/signin/signin_manager_base.cc b/chrome/browser/signin/signin_manager_base.cc
|
| index 0433e447c5840c236fe3edcfbcc1ab8743c3f428..be6a0a052979d7023ac131216c0f195a9bbfd944 100644
|
| --- a/chrome/browser/signin/signin_manager_base.cc
|
| +++ b/chrome/browser/signin/signin_manager_base.cc
|
| @@ -33,7 +33,6 @@
|
| #include "content/public/browser/browser_thread.h"
|
| #include "google_apis/gaia/gaia_constants.h"
|
| #include "google_apis/gaia/gaia_urls.h"
|
| -#include "third_party/icu/public/i18n/unicode/regex.h"
|
|
|
| using namespace signin_internals_util;
|
|
|
| @@ -55,39 +54,6 @@ bool SigninManagerBase::AreSigninCookiesAllowed(
|
| GURL(GaiaUrls::GetInstance()->gaia_origin_url()));
|
| }
|
|
|
| -// static
|
| -bool SigninManagerBase::IsAllowedUsername(const std::string& username,
|
| - const std::string& policy) {
|
| - if (policy.empty())
|
| - return true;
|
| -
|
| - // Patterns like "*@foo.com" are not accepted by our regex engine (since they
|
| - // are not valid regular expressions - they should instead be ".*@foo.com").
|
| - // For convenience, detect these patterns and insert a "." character at the
|
| - // front.
|
| - string16 pattern = UTF8ToUTF16(policy);
|
| - if (pattern[0] == L'*')
|
| - pattern.insert(pattern.begin(), L'.');
|
| -
|
| - // See if the username matches the policy-provided pattern.
|
| - UErrorCode status = U_ZERO_ERROR;
|
| - const icu::UnicodeString icu_pattern(pattern.data(), pattern.length());
|
| - icu::RegexMatcher matcher(icu_pattern, UREGEX_CASE_INSENSITIVE, status);
|
| - if (!U_SUCCESS(status)) {
|
| - LOG(ERROR) << "Invalid login regex: " << pattern << ", status: " << status;
|
| - // If an invalid pattern is provided, then prohibit *all* logins (better to
|
| - // break signin than to quietly allow users to sign in).
|
| - return false;
|
| - }
|
| - string16 username16 = UTF8ToUTF16(username);
|
| - icu::UnicodeString icu_input(username16.data(), username16.length());
|
| - matcher.reset(icu_input);
|
| - status = U_ZERO_ERROR;
|
| - UBool match = matcher.matches(status);
|
| - DCHECK(U_SUCCESS(status));
|
| - return !!match; // !! == convert from UBool to bool.
|
| -}
|
| -
|
| SigninManagerBase::SigninManagerBase()
|
| : profile_(NULL),
|
| weak_pointer_factory_(this) {
|
| @@ -106,18 +72,6 @@ void SigninManagerBase::Initialize(Profile* profile) {
|
| signin_global_error_.reset(new SigninGlobalError(this, profile));
|
| GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError(
|
| signin_global_error_.get());
|
| - PrefService* local_state = g_browser_process->local_state();
|
| - // local_state can be null during unit tests.
|
| - if (local_state) {
|
| - local_state_pref_registrar_.Init(local_state);
|
| - local_state_pref_registrar_.Add(
|
| - prefs::kGoogleServicesUsernamePattern,
|
| - base::Bind(&SigninManagerBase::OnGoogleServicesUsernamePatternChanged,
|
| - weak_pointer_factory_.GetWeakPtr()));
|
| - }
|
| - signin_allowed_.Init(prefs::kSigninAllowed, profile_->GetPrefs(),
|
| - base::Bind(&SigninManagerBase::OnSigninAllowedPrefChanged,
|
| - base::Unretained(this)));
|
|
|
| // If the user is clearing the token service from the command line, then
|
| // clear their login info also (not valid to be logged in without any
|
| @@ -132,12 +86,6 @@ void SigninManagerBase::Initialize(Profile* profile) {
|
| SetAuthenticatedUsername(user);
|
|
|
| InitTokenService();
|
| -
|
| - if ((!user.empty() && !IsAllowedUsername(user)) || !IsSigninAllowed()) {
|
| - // User is signed in, but the username is invalid - the administrator must
|
| - // have changed the policy since the last signin, so sign out the user.
|
| - SignOut();
|
| - }
|
| }
|
|
|
| void SigninManagerBase::InitTokenService() {
|
| @@ -153,24 +101,8 @@ bool SigninManagerBase::IsInitialized() const {
|
| return profile_ != NULL;
|
| }
|
|
|
| -bool SigninManagerBase::IsAllowedUsername(const std::string& username) const {
|
| - PrefService* local_state = g_browser_process->local_state();
|
| - if (!local_state)
|
| - return true; // In a unit test with no local state - all names are allowed.
|
| -
|
| - std::string pattern = local_state->GetString(
|
| - prefs::kGoogleServicesUsernamePattern);
|
| - return IsAllowedUsername(username, pattern);
|
| -}
|
| -
|
| bool SigninManagerBase::IsSigninAllowed() const {
|
| - return signin_allowed_.GetValue();
|
| -}
|
| -
|
| -// static
|
| -bool SigninManagerBase::IsSigninAllowedOnIOThread(ProfileIOData* io_data) {
|
| - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
| - return io_data->signin_allowed()->GetValue();
|
| + return profile_->GetPrefs()->GetBoolean(prefs::kSigninAllowed);
|
| }
|
|
|
| const std::string& SigninManagerBase::GetAuthenticatedUsername() const {
|
| @@ -197,29 +129,8 @@ void SigninManagerBase::SetAuthenticatedUsername(const std::string& username) {
|
| profile_->GetPrefs()->SetString(prefs::kGoogleServicesLastUsername, username);
|
| }
|
|
|
| -void SigninManagerBase::SignOut() {
|
| - DCHECK(IsInitialized());
|
| -
|
| - if (authenticated_username_.empty() && !AuthInProgress())
|
| - return;
|
| -
|
| - GoogleServiceSignoutDetails details(authenticated_username_);
|
| +void SigninManagerBase::clear_authenticated_username() {
|
| authenticated_username_.clear();
|
| - profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
|
| -
|
| - // Erase (now) stale information from AboutSigninInternals.
|
| - NotifyDiagnosticsObservers(USERNAME, "");
|
| - NotifyDiagnosticsObservers(LSID, "");
|
| - NotifyDiagnosticsObservers(
|
| - signin_internals_util::SID, "");
|
| -
|
| - TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
|
| - content::NotificationService::current()->Notify(
|
| - chrome::NOTIFICATION_GOOGLE_SIGNED_OUT,
|
| - content::Source<Profile>(profile_),
|
| - content::Details<const GoogleServiceSignoutDetails>(&details));
|
| - token_service->ResetCredentialsInMemory();
|
| - token_service->EraseTokensFromDB();
|
| }
|
|
|
| bool SigninManagerBase::AuthInProgress() const {
|
| @@ -235,20 +146,6 @@ void SigninManagerBase::Shutdown() {
|
| }
|
| }
|
|
|
| -void SigninManagerBase::OnGoogleServicesUsernamePatternChanged() {
|
| - if (!authenticated_username_.empty() &&
|
| - !IsAllowedUsername(authenticated_username_)) {
|
| - // Signed in user is invalid according to the current policy so sign
|
| - // the user out.
|
| - SignOut();
|
| - }
|
| -}
|
| -
|
| -void SigninManagerBase::OnSigninAllowedPrefChanged() {
|
| - if (!IsSigninAllowed())
|
| - SignOut();
|
| -}
|
| -
|
| void SigninManagerBase::AddSigninDiagnosticsObserver(
|
| SigninDiagnosticsObserver* observer) {
|
| signin_diagnostics_observers_.AddObserver(observer);
|
|
|