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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 HandleServiceStateChange(); | 123 HandleServiceStateChange(); |
124 } | 124 } |
125 | 125 |
126 void SigninTracker::HandleServiceStateChange() { | 126 void SigninTracker::HandleServiceStateChange() { |
127 if (state_ != SERVICES_INITIALIZING) { | 127 if (state_ != SERVICES_INITIALIZING) { |
128 // Ignore service updates until after our GAIA credentials are validated. | 128 // Ignore service updates until after our GAIA credentials are validated. |
129 return; | 129 return; |
130 } | 130 } |
131 | 131 |
132 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 132 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
133 if (signin->GetAuthenticatedUsername().empty()) { | 133 if (signin->GetAuthenticatedUsername().empty() || |
| 134 !signin->IsSigninAllowed()) { |
134 // User is signed out, trigger a signin failure. | 135 // User is signed out, trigger a signin failure. |
135 state_ = WAITING_FOR_GAIA_VALIDATION; | 136 state_ = WAITING_FOR_GAIA_VALIDATION; |
136 observer_->SigninFailed( | 137 observer_->SigninFailed( |
137 GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED)); | 138 GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED)); |
138 return; | 139 return; |
139 } | 140 } |
140 | 141 |
141 // Wait until all of our services are logged in. For now this just means sync. | 142 // Wait until all of our services are logged in. For now this just means sync. |
142 // Long term, we should separate out service auth failures from the signin | 143 // Long term, we should separate out service auth failures from the signin |
143 // process, but for the current UI flow we'll validate service signin status | 144 // process, but for the current UI flow we'll validate service signin status |
144 // also. | 145 // also. |
145 ProfileSyncService* service = profile_->IsSyncAccessible() ? | 146 ProfileSyncService* service = |
146 ProfileSyncServiceFactory::GetForProfile(profile_) : NULL; | 147 profile_->IsSyncAccessible() ? |
| 148 ProfileSyncServiceFactory::GetForProfile(profile_) : NULL; |
147 if (service && service->waiting_for_auth()) { | 149 if (service && service->waiting_for_auth()) { |
148 // Still waiting for an auth token to come in so stay in the INITIALIZING | 150 // Still waiting for an auth token to come in so stay in the INITIALIZING |
149 // state (we do this to avoid triggering an early signin error in the case | 151 // state (we do this to avoid triggering an early signin error in the case |
150 // where there's a previous auth error in the sync service that hasn't | 152 // where there's a previous auth error in the sync service that hasn't |
151 // been cleared yet). | 153 // been cleared yet). |
152 return; | 154 return; |
153 } | 155 } |
154 | 156 |
155 // If we haven't loaded all our service tokens yet, just exit (we'll be called | 157 // If we haven't loaded all our service tokens yet, just exit (we'll be called |
156 // again when another token is loaded, or will transition to SigninFailed if | 158 // again when another token is loaded, or will transition to SigninFailed if |
(...skipping 29 matching lines...) Expand all Loading... |
186 // Don't care about the sync state if sync is disabled by policy. | 188 // Don't care about the sync state if sync is disabled by policy. |
187 if (!profile->IsSyncAccessible()) | 189 if (!profile->IsSyncAccessible()) |
188 return true; | 190 return true; |
189 ProfileSyncService* service = | 191 ProfileSyncService* service = |
190 ProfileSyncServiceFactory::GetForProfile(profile); | 192 ProfileSyncServiceFactory::GetForProfile(profile); |
191 return (service->IsSyncEnabledAndLoggedIn() && | 193 return (service->IsSyncEnabledAndLoggedIn() && |
192 service->IsSyncTokenAvailable() && | 194 service->IsSyncTokenAvailable() && |
193 service->GetAuthError().state() == GoogleServiceAuthError::NONE && | 195 service->GetAuthError().state() == GoogleServiceAuthError::NONE && |
194 !service->HasUnrecoverableError()); | 196 !service->HasUnrecoverableError()); |
195 } | 197 } |
OLD | NEW |