| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/signin/signin_manager.h" | 5 #include "chrome/browser/signin/signin_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 icu::UnicodeString icu_input(username16.data(), username16.length()); | 187 icu::UnicodeString icu_input(username16.data(), username16.length()); |
| 188 matcher.reset(icu_input); | 188 matcher.reset(icu_input); |
| 189 status = U_ZERO_ERROR; | 189 status = U_ZERO_ERROR; |
| 190 UBool match = matcher.matches(status); | 190 UBool match = matcher.matches(status); |
| 191 DCHECK(U_SUCCESS(status)); | 191 DCHECK(U_SUCCESS(status)); |
| 192 return !!match; // !! == convert from UBool to bool. | 192 return !!match; // !! == convert from UBool to bool. |
| 193 } | 193 } |
| 194 | 194 |
| 195 SigninManager::SigninManager() | 195 SigninManager::SigninManager() |
| 196 : profile_(NULL), | 196 : profile_(NULL), |
| 197 prohibit_signout_(false), |
| 197 had_two_factor_error_(false), | 198 had_two_factor_error_(false), |
| 198 type_(SIGNIN_TYPE_NONE), | 199 type_(SIGNIN_TYPE_NONE), |
| 199 weak_pointer_factory_(this) { | 200 weak_pointer_factory_(this) { |
| 200 } | 201 } |
| 201 | 202 |
| 202 SigninManager::~SigninManager() { | 203 SigninManager::~SigninManager() { |
| 203 DCHECK(!signin_global_error_.get()) << | 204 DCHECK(!signin_global_error_.get()) << |
| 204 "SigninManager::Initialize called but not SigninManager::Shutdown"; | 205 "SigninManager::Initialize called but not SigninManager::Shutdown"; |
| 205 } | 206 } |
| 206 | 207 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 536 |
| 536 // In some cases, the user should not be signed out. For example, the failure | 537 // In some cases, the user should not be signed out. For example, the failure |
| 537 // may be due to a captcha or OTP challenge. In these cases, the transient | 538 // may be due to a captcha or OTP challenge. In these cases, the transient |
| 538 // data must be kept to properly handle the follow up. | 539 // data must be kept to properly handle the follow up. |
| 539 if (clear_transient_data) | 540 if (clear_transient_data) |
| 540 ClearTransientSigninData(); | 541 ClearTransientSigninData(); |
| 541 } | 542 } |
| 542 | 543 |
| 543 void SigninManager::SignOut() { | 544 void SigninManager::SignOut() { |
| 544 DCHECK(IsInitialized()); | 545 DCHECK(IsInitialized()); |
| 546 if (prohibit_signout_) { |
| 547 DVLOG(1) << "Ignoring attempt to sign out while signout is prohibited"; |
| 548 return; |
| 549 } |
| 545 if (authenticated_username_.empty() && !client_login_.get()) { | 550 if (authenticated_username_.empty() && !client_login_.get()) { |
| 546 // Clean up our transient data and exit if we aren't signed in (or in the | 551 // Clean up our transient data and exit if we aren't signed in (or in the |
| 547 // process of signing in). This avoids a perf regression from clearing out | 552 // process of signing in). This avoids a perf regression from clearing out |
| 548 // the TokenDB if SignOut() is invoked on startup to clean up any | 553 // the TokenDB if SignOut() is invoked on startup to clean up any |
| 549 // incomplete previous signin attempts. | 554 // incomplete previous signin attempts. |
| 550 ClearTransientSigninData(); | 555 ClearTransientSigninData(); |
| 551 return; | 556 return; |
| 552 } | 557 } |
| 553 | 558 |
| 554 GoogleServiceSignoutDetails details(authenticated_username_); | 559 GoogleServiceSignoutDetails details(authenticated_username_); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 } | 887 } |
| 883 | 888 |
| 884 void SigninManager::Shutdown() { | 889 void SigninManager::Shutdown() { |
| 885 if (signin_global_error_.get()) { | 890 if (signin_global_error_.get()) { |
| 886 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( | 891 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( |
| 887 signin_global_error_.get()); | 892 signin_global_error_.get()); |
| 888 signin_global_error_.reset(); | 893 signin_global_error_.reset(); |
| 889 } | 894 } |
| 890 } | 895 } |
| 891 | 896 |
| 897 void SigninManager::ProhibitSignout() { |
| 898 prohibit_signout_ = true; |
| 899 } |
| 900 |
| 901 bool SigninManager::IsSignoutProhibited() const { |
| 902 return prohibit_signout_; |
| 903 } |
| 904 |
| 892 void SigninManager::OnGoogleServicesUsernamePatternChanged() { | 905 void SigninManager::OnGoogleServicesUsernamePatternChanged() { |
| 893 if (!authenticated_username_.empty() && | 906 if (!authenticated_username_.empty() && |
| 894 !IsAllowedUsername(authenticated_username_)) { | 907 !IsAllowedUsername(authenticated_username_)) { |
| 895 // Signed in user is invalid according to the current policy so sign | 908 // Signed in user is invalid according to the current policy so sign |
| 896 // the user out. | 909 // the user out. |
| 897 SignOut(); | 910 SignOut(); |
| 898 } | 911 } |
| 899 } | 912 } |
| 900 | 913 |
| 901 void SigninManager::AddSigninDiagnosticsObserver( | 914 void SigninManager::AddSigninDiagnosticsObserver( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 916 NotifySigninValueChanged(field, value)); | 929 NotifySigninValueChanged(field, value)); |
| 917 } | 930 } |
| 918 | 931 |
| 919 void SigninManager::NotifyDiagnosticsObservers( | 932 void SigninManager::NotifyDiagnosticsObservers( |
| 920 const TimedSigninStatusField& field, | 933 const TimedSigninStatusField& field, |
| 921 const std::string& value) { | 934 const std::string& value) { |
| 922 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, | 935 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, |
| 923 signin_diagnostics_observers_, | 936 signin_diagnostics_observers_, |
| 924 NotifySigninValueChanged(field, value)); | 937 NotifySigninValueChanged(field, value)); |
| 925 } | 938 } |
| OLD | NEW |