Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profile_oauth2_token_service.h" | 5 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 const GoogleServiceAuthError& error) { | 115 const GoogleServiceAuthError& error) { |
| 116 // Do not report connection errors as these are not actually auth errors. | 116 // Do not report connection errors as these are not actually auth errors. |
| 117 // We also want to avoid masking a "real" auth error just because we | 117 // We also want to avoid masking a "real" auth error just because we |
| 118 // subsequently get a transient network error. | 118 // subsequently get a transient network error. |
| 119 if (error.state() == GoogleServiceAuthError::CONNECTION_FAILED) | 119 if (error.state() == GoogleServiceAuthError::CONNECTION_FAILED) |
| 120 return; | 120 return; |
| 121 | 121 |
| 122 if (error.state() != last_auth_error_.state()) { | 122 if (error.state() != last_auth_error_.state()) { |
| 123 last_auth_error_ = error; | 123 last_auth_error_ = error; |
| 124 signin_global_error_->AuthStatusChanged(); | 124 signin_global_error_->AuthStatusChanged(); |
| 125 | |
| 126 if (last_auth_error_.state() == | |
| 127 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) { | |
| 128 TokenService* token_service = | |
| 129 TokenServiceFactory::GetForProfile(profile_); | |
| 130 token_service->ClearOAuth2Credentials(); | |
| 131 DCHECK(!token_service->HasOAuthLoginToken()); | |
| 132 } | |
|
fgorski
2013/08/29 22:31:12
You should call RevokeCredentials for the respecti
Roger Tawa OOO till Jul 10th
2013/08/30 02:25:14
Yeah totally makes sense. Done.
| |
| 125 } | 133 } |
| 126 } | 134 } |
| 127 | 135 |
| 128 void ProfileOAuth2TokenService::Observe( | 136 void ProfileOAuth2TokenService::Observe( |
| 129 int type, | 137 int type, |
| 130 const content::NotificationSource& source, | 138 const content::NotificationSource& source, |
| 131 const content::NotificationDetails& details) { | 139 const content::NotificationDetails& details) { |
| 132 switch (type) { | 140 switch (type) { |
| 133 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { | 141 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { |
| 134 TokenService::TokenAvailableDetails* tok_details = | 142 TokenService::TokenAvailableDetails* tok_details = |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 } | 331 } |
| 324 } | 332 } |
| 325 | 333 |
| 326 if (!old_login_token.empty() && | 334 if (!old_login_token.empty() && |
| 327 refresh_tokens_.count(GetAccountId(profile_)) == 0) { | 335 refresh_tokens_.count(GetAccountId(profile_)) == 0) { |
| 328 UpdateCredentials(GetAccountId(profile_), old_login_token); | 336 UpdateCredentials(GetAccountId(profile_), old_login_token); |
| 329 } | 337 } |
| 330 | 338 |
| 331 FireRefreshTokensLoaded(); | 339 FireRefreshTokensLoaded(); |
| 332 } | 340 } |
| OLD | NEW |