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_tracker.h" | 5 #include "chrome/browser/signin/signin_tracker.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/signin/signin_manager.h" | 8 #include "chrome/browser/signin/signin_manager.h" |
9 #include "chrome/browser/signin/signin_manager_factory.h" | 9 #include "chrome/browser/signin/signin_manager_factory.h" |
10 #include "chrome/browser/signin/token_service.h" | 10 #include "chrome/browser/signin/token_service.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 void SigninTracker::OnStateChanged() { | 126 void SigninTracker::OnStateChanged() { |
127 HandleServiceStateChange(); | 127 HandleServiceStateChange(); |
128 } | 128 } |
129 | 129 |
130 void SigninTracker::HandleServiceStateChange() { | 130 void SigninTracker::HandleServiceStateChange() { |
131 if (state_ != SERVICES_INITIALIZING) { | 131 if (state_ != SERVICES_INITIALIZING) { |
132 // Ignore service updates until after our GAIA credentials are validated. | 132 // Ignore service updates until after our GAIA credentials are validated. |
133 return; | 133 return; |
134 } | 134 } |
135 | 135 |
136 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 136 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_); |
137 if (signin->GetAuthenticatedUsername().empty()) { | 137 if (signin->GetAuthenticatedUsername().empty()) { |
138 // User is signed out, trigger a signin failure. | 138 // User is signed out, trigger a signin failure. |
139 state_ = WAITING_FOR_GAIA_VALIDATION; | 139 state_ = WAITING_FOR_GAIA_VALIDATION; |
140 observer_->SigninFailed( | 140 observer_->SigninFailed( |
141 GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED)); | 141 GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED)); |
142 return; | 142 return; |
143 } | 143 } |
144 | 144 |
145 // Wait until all of our services are logged in. For now this just means sync. | 145 // Wait until all of our services are logged in. For now this just means sync. |
146 // Long term, we should separate out service auth failures from the signin | 146 // Long term, we should separate out service auth failures from the signin |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // Don't care about the sync state if sync is disabled by policy. | 190 // Don't care about the sync state if sync is disabled by policy. |
191 if (!profile->IsSyncAccessible()) | 191 if (!profile->IsSyncAccessible()) |
192 return true; | 192 return true; |
193 ProfileSyncService* service = | 193 ProfileSyncService* service = |
194 ProfileSyncServiceFactory::GetForProfile(profile); | 194 ProfileSyncServiceFactory::GetForProfile(profile); |
195 return (service->IsSyncEnabledAndLoggedIn() && | 195 return (service->IsSyncEnabledAndLoggedIn() && |
196 service->IsSyncTokenAvailable() && | 196 service->IsSyncTokenAvailable() && |
197 service->GetAuthError().state() == GoogleServiceAuthError::NONE && | 197 service->GetAuthError().state() == GoogleServiceAuthError::NONE && |
198 !service->HasUnrecoverableError()); | 198 !service->HasUnrecoverableError()); |
199 } | 199 } |
OLD | NEW |