Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: chrome/browser/signin/signin_manager.cc

Issue 12310009: Merge 182705 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1410/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/signin/signin_manager.h ('k') | chrome/browser/signin/signin_manager_fake.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 icu::UnicodeString icu_input(username16.data(), username16.length()); 189 icu::UnicodeString icu_input(username16.data(), username16.length());
190 matcher.reset(icu_input); 190 matcher.reset(icu_input);
191 status = U_ZERO_ERROR; 191 status = U_ZERO_ERROR;
192 UBool match = matcher.matches(status); 192 UBool match = matcher.matches(status);
193 DCHECK(U_SUCCESS(status)); 193 DCHECK(U_SUCCESS(status));
194 return !!match; // !! == convert from UBool to bool. 194 return !!match; // !! == convert from UBool to bool.
195 } 195 }
196 196
197 SigninManager::SigninManager() 197 SigninManager::SigninManager()
198 : profile_(NULL), 198 : profile_(NULL),
199 prohibit_signout_(false),
199 had_two_factor_error_(false), 200 had_two_factor_error_(false),
200 type_(SIGNIN_TYPE_NONE), 201 type_(SIGNIN_TYPE_NONE),
201 weak_pointer_factory_(this) { 202 weak_pointer_factory_(this) {
202 } 203 }
203 204
204 SigninManager::~SigninManager() { 205 SigninManager::~SigninManager() {
205 DCHECK(!signin_global_error_.get()) << 206 DCHECK(!signin_global_error_.get()) <<
206 "SigninManager::Initialize called but not SigninManager::Shutdown"; 207 "SigninManager::Initialize called but not SigninManager::Shutdown";
207 } 208 }
208 209
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 538
538 // In some cases, the user should not be signed out. For example, the failure 539 // In some cases, the user should not be signed out. For example, the failure
539 // may be due to a captcha or OTP challenge. In these cases, the transient 540 // may be due to a captcha or OTP challenge. In these cases, the transient
540 // data must be kept to properly handle the follow up. 541 // data must be kept to properly handle the follow up.
541 if (clear_transient_data) 542 if (clear_transient_data)
542 ClearTransientSigninData(); 543 ClearTransientSigninData();
543 } 544 }
544 545
545 void SigninManager::SignOut() { 546 void SigninManager::SignOut() {
546 DCHECK(IsInitialized()); 547 DCHECK(IsInitialized());
548 if (prohibit_signout_) {
549 DVLOG(1) << "Ignoring attempt to sign out while signout is prohibited";
550 return;
551 }
547 if (authenticated_username_.empty() && !client_login_.get()) { 552 if (authenticated_username_.empty() && !client_login_.get()) {
548 // Clean up our transient data and exit if we aren't signed in (or in the 553 // Clean up our transient data and exit if we aren't signed in (or in the
549 // process of signing in). This avoids a perf regression from clearing out 554 // process of signing in). This avoids a perf regression from clearing out
550 // the TokenDB if SignOut() is invoked on startup to clean up any 555 // the TokenDB if SignOut() is invoked on startup to clean up any
551 // incomplete previous signin attempts. 556 // incomplete previous signin attempts.
552 ClearTransientSigninData(); 557 ClearTransientSigninData();
553 return; 558 return;
554 } 559 }
555 560
556 GoogleServiceSignoutDetails details(authenticated_username_); 561 GoogleServiceSignoutDetails details(authenticated_username_);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 } 892 }
888 893
889 void SigninManager::Shutdown() { 894 void SigninManager::Shutdown() {
890 if (signin_global_error_.get()) { 895 if (signin_global_error_.get()) {
891 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( 896 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(
892 signin_global_error_.get()); 897 signin_global_error_.get());
893 signin_global_error_.reset(); 898 signin_global_error_.reset();
894 } 899 }
895 } 900 }
896 901
902 void SigninManager::ProhibitSignout() {
903 prohibit_signout_ = true;
904 }
905
906 bool SigninManager::IsSignoutProhibited() const {
907 return prohibit_signout_;
908 }
909
897 void SigninManager::OnGoogleServicesUsernamePatternChanged() { 910 void SigninManager::OnGoogleServicesUsernamePatternChanged() {
898 if (!authenticated_username_.empty() && 911 if (!authenticated_username_.empty() &&
899 !IsAllowedUsername(authenticated_username_)) { 912 !IsAllowedUsername(authenticated_username_)) {
900 // Signed in user is invalid according to the current policy so sign 913 // Signed in user is invalid according to the current policy so sign
901 // the user out. 914 // the user out.
902 SignOut(); 915 SignOut();
903 } 916 }
904 } 917 }
905 918
906 void SigninManager::AddSigninDiagnosticsObserver( 919 void SigninManager::AddSigninDiagnosticsObserver(
(...skipping 14 matching lines...) Expand all
921 NotifySigninValueChanged(field, value)); 934 NotifySigninValueChanged(field, value));
922 } 935 }
923 936
924 void SigninManager::NotifyDiagnosticsObservers( 937 void SigninManager::NotifyDiagnosticsObservers(
925 const TimedSigninStatusField& field, 938 const TimedSigninStatusField& field,
926 const std::string& value) { 939 const std::string& value) {
927 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, 940 FOR_EACH_OBSERVER(SigninDiagnosticsObserver,
928 signin_diagnostics_observers_, 941 signin_diagnostics_observers_,
929 NotifySigninValueChanged(field, value)); 942 NotifySigninValueChanged(field, value));
930 } 943 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_manager.h ('k') | chrome/browser/signin/signin_manager_fake.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698