Chromium Code Reviews| 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_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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 profile->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); | 123 profile->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); |
| 124 | 124 |
| 125 std::string user = profile_->GetPrefs()->GetString( | 125 std::string user = profile_->GetPrefs()->GetString( |
| 126 prefs::kGoogleServicesUsername); | 126 prefs::kGoogleServicesUsername); |
| 127 if (!user.empty()) | 127 if (!user.empty()) |
| 128 SetAuthenticatedUsername(user); | 128 SetAuthenticatedUsername(user); |
| 129 // TokenService can be null for unit tests. | 129 // TokenService can be null for unit tests. |
| 130 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 130 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
| 131 if (token_service) { | 131 if (token_service) { |
| 132 token_service->Initialize(GaiaConstants::kChromeSource, profile_); | 132 token_service->Initialize(GaiaConstants::kChromeSource, profile_); |
| 133 // ChromeOS will kick off TokenService::LoadTokensFromDB from | |
| 134 // OAuthLoginManager once the rest of the Profile is fully initialized. | |
| 135 // Starting it from here would cause OAuthLoginManager mismatch the origin | |
| 136 // of OAuth2 tokens. | |
| 137 #if !defined(OS_CHROMEOS) | |
|
tim (not reviewing)
2013/01/15 02:36:34
fwiw, we've been trying to get rid of ifdefs like
| |
| 133 if (!authenticated_username_.empty()) { | 138 if (!authenticated_username_.empty()) { |
| 134 token_service->LoadTokensFromDB(); | 139 token_service->LoadTokensFromDB(); |
| 135 } | 140 } |
| 141 #endif | |
| 136 } | 142 } |
| 137 if (!user.empty() && !IsAllowedUsername(user)) { | 143 if (!user.empty() && !IsAllowedUsername(user)) { |
| 138 // User is signed in, but the username is invalid - the administrator must | 144 // User is signed in, but the username is invalid - the administrator must |
| 139 // have changed the policy since the last signin, so sign out the user. | 145 // have changed the policy since the last signin, so sign out the user. |
| 140 SignOut(); | 146 SignOut(); |
| 141 } | 147 } |
| 142 } | 148 } |
| 143 | 149 |
| 144 bool SigninManager::IsInitialized() const { | 150 bool SigninManager::IsInitialized() const { |
| 145 return profile_ != NULL; | 151 return profile_ != NULL; |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 DisableOneClickSignIn(profile_); // Don't ever offer again. | 553 DisableOneClickSignIn(profile_); // Don't ever offer again. |
| 548 | 554 |
| 549 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 555 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
| 550 token_service->UpdateCredentials(last_result_); | 556 token_service->UpdateCredentials(last_result_); |
| 551 DCHECK(token_service->AreCredentialsValid()); | 557 DCHECK(token_service->AreCredentialsValid()); |
| 552 token_service->StartFetchingTokens(); | 558 token_service->StartFetchingTokens(); |
| 553 | 559 |
| 554 // If we have oauth2 tokens, tell token service about them so it does not | 560 // If we have oauth2 tokens, tell token service about them so it does not |
| 555 // need to fetch them again. | 561 // need to fetch them again. |
| 556 if (!temp_oauth_login_tokens_.refresh_token.empty()) { | 562 if (!temp_oauth_login_tokens_.refresh_token.empty()) { |
| 557 token_service->OnClientOAuthSuccess(temp_oauth_login_tokens_); | 563 token_service->UpdateCredentialsWithOAuth2(temp_oauth_login_tokens_); |
| 558 temp_oauth_login_tokens_ = ClientOAuthResult(); | 564 temp_oauth_login_tokens_ = ClientOAuthResult(); |
| 559 } | 565 } |
| 560 } | 566 } |
| 561 | 567 |
| 562 void SigninManager::OnGetUserInfoFailure(const GoogleServiceAuthError& error) { | 568 void SigninManager::OnGetUserInfoFailure(const GoogleServiceAuthError& error) { |
| 563 LOG(ERROR) << "Unable to retreive the canonical email address. Login failed."; | 569 LOG(ERROR) << "Unable to retreive the canonical email address. Login failed."; |
| 564 NotifyDiagnosticsObservers(GET_USER_INFO_STATUS, error.ToString()); | 570 NotifyDiagnosticsObservers(GET_USER_INFO_STATUS, error.ToString()); |
| 565 // REVIEW: why does this call OnClientLoginFailure? | 571 // REVIEW: why does this call OnClientLoginFailure? |
| 566 OnClientLoginFailure(error); | 572 OnClientLoginFailure(error); |
| 567 } | 573 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 NotifySigninValueChanged(field, value)); | 632 NotifySigninValueChanged(field, value)); |
| 627 } | 633 } |
| 628 | 634 |
| 629 void SigninManager::NotifyDiagnosticsObservers( | 635 void SigninManager::NotifyDiagnosticsObservers( |
| 630 const TimedSigninStatusField& field, | 636 const TimedSigninStatusField& field, |
| 631 const std::string& value) { | 637 const std::string& value) { |
| 632 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, | 638 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, |
| 633 signin_diagnostics_observers_, | 639 signin_diagnostics_observers_, |
| 634 NotifySigninValueChanged(field, value)); | 640 NotifySigninValueChanged(field, value)); |
| 635 } | 641 } |
| OLD | NEW |