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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
137 if (signin->GetAuthenticatedUsername().empty()) { | 137 if (signin->GetAuthenticatedUsername().empty() || |
138 !signin->IsSigninAllowed()) { | |
sail
2013/02/08 20:18:57
This code doesn't make any sense. If sign in is no
Andrew T Wilson (Slow)
2013/02/08 20:33:11
Because signin isn't allowed, so signin should fai
Adrian Kuegel
2013/02/11 16:47:30
IsSigninAllowed returns true if signin is allowed.
| |
138 // User is signed out, trigger a signin failure. | 139 // User is signed out, trigger a signin failure. |
139 state_ = WAITING_FOR_GAIA_VALIDATION; | 140 state_ = WAITING_FOR_GAIA_VALIDATION; |
140 observer_->SigninFailed( | 141 observer_->SigninFailed( |
141 GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED)); | 142 GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED)); |
142 return; | 143 return; |
143 } | 144 } |
144 | 145 |
145 // Wait until all of our services are logged in. For now this just means sync. | 146 // 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 | 147 // Long term, we should separate out service auth failures from the signin |
147 // process, but for the current UI flow we'll validate service signin status | 148 // process, but for the current UI flow we'll validate service signin status |
148 // also. | 149 // also. |
149 ProfileSyncService* service = profile_->IsSyncAccessible() ? | 150 ProfileSyncService* service = |
sail
2013/02/08 20:18:57
Why this change?
Adrian Kuegel
2013/02/11 16:47:30
Sorry, that was a relict from an earlier version o
| |
150 ProfileSyncServiceFactory::GetForProfile(profile_) : NULL; | 151 profile_->IsSyncAccessible() ? |
152 ProfileSyncServiceFactory::GetForProfile(profile_) : NULL; | |
151 if (service && service->waiting_for_auth()) { | 153 if (service && service->waiting_for_auth()) { |
152 // Still waiting for an auth token to come in so stay in the INITIALIZING | 154 // Still waiting for an auth token to come in so stay in the INITIALIZING |
153 // state (we do this to avoid triggering an early signin error in the case | 155 // state (we do this to avoid triggering an early signin error in the case |
154 // where there's a previous auth error in the sync service that hasn't | 156 // where there's a previous auth error in the sync service that hasn't |
155 // been cleared yet). | 157 // been cleared yet). |
156 return; | 158 return; |
157 } | 159 } |
158 | 160 |
159 // If we haven't loaded all our service tokens yet, just exit (we'll be called | 161 // If we haven't loaded all our service tokens yet, just exit (we'll be called |
160 // again when another token is loaded, or will transition to SigninFailed if | 162 // again when another token is loaded, or will transition to SigninFailed if |
(...skipping 29 matching lines...) Expand all Loading... | |
190 // Don't care about the sync state if sync is disabled by policy. | 192 // Don't care about the sync state if sync is disabled by policy. |
191 if (!profile->IsSyncAccessible()) | 193 if (!profile->IsSyncAccessible()) |
192 return true; | 194 return true; |
193 ProfileSyncService* service = | 195 ProfileSyncService* service = |
194 ProfileSyncServiceFactory::GetForProfile(profile); | 196 ProfileSyncServiceFactory::GetForProfile(profile); |
195 return (service->IsSyncEnabledAndLoggedIn() && | 197 return (service->IsSyncEnabledAndLoggedIn() && |
196 service->IsSyncTokenAvailable() && | 198 service->IsSyncTokenAvailable() && |
197 service->GetAuthError().state() == GoogleServiceAuthError::NONE && | 199 service->GetAuthError().state() == GoogleServiceAuthError::NONE && |
198 !service->HasUnrecoverableError()); | 200 !service->HasUnrecoverableError()); |
199 } | 201 } |
OLD | NEW |