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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 void SigninManager::CompletePendingSignin() { | 547 void SigninManager::CompletePendingSignin() { |
548 DCHECK(!possibly_invalid_username_.empty()); | 548 DCHECK(!possibly_invalid_username_.empty()); |
549 OnSignedIn(possibly_invalid_username_); | 549 OnSignedIn(possibly_invalid_username_); |
550 | 550 |
551 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 551 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
552 token_service->UpdateCredentials(last_result_); | 552 token_service->UpdateCredentials(last_result_); |
553 DCHECK(token_service->AreCredentialsValid()); | 553 DCHECK(token_service->AreCredentialsValid()); |
554 token_service->StartFetchingTokens(); | 554 token_service->StartFetchingTokens(); |
555 | 555 |
556 // If we have oauth2 tokens, tell token service about them so it does not | 556 // If we have oauth2 tokens, tell token service about them so it does not |
557 // need to fetch them again. | 557 // need to fetch them again. Its important that the authenticated name has |
| 558 // already been set before sending the oauth2 token to the token service. |
| 559 // Some token service listeners will query the authenticated name when they |
| 560 // receive the token available notification. |
558 if (!temp_oauth_login_tokens_.refresh_token.empty()) { | 561 if (!temp_oauth_login_tokens_.refresh_token.empty()) { |
| 562 DCHECK(!GetAuthenticatedUsername().empty()); |
559 token_service->UpdateCredentialsWithOAuth2(temp_oauth_login_tokens_); | 563 token_service->UpdateCredentialsWithOAuth2(temp_oauth_login_tokens_); |
560 temp_oauth_login_tokens_ = ClientOAuthResult(); | 564 temp_oauth_login_tokens_ = ClientOAuthResult(); |
561 } | 565 } |
562 } | 566 } |
563 | 567 |
564 void SigninManager::OnExternalSigninCompleted(const std::string& username) { | 568 void SigninManager::OnExternalSigninCompleted(const std::string& username) { |
565 OnSignedIn(username); | 569 OnSignedIn(username); |
566 } | 570 } |
567 | 571 |
568 void SigninManager::OnSignedIn(const std::string& username) { | 572 void SigninManager::OnSignedIn(const std::string& username) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 } | 611 } |
608 } | 612 } |
609 | 613 |
610 void SigninManager::ProhibitSignout(bool prohibit_signout) { | 614 void SigninManager::ProhibitSignout(bool prohibit_signout) { |
611 prohibit_signout_ = prohibit_signout; | 615 prohibit_signout_ = prohibit_signout; |
612 } | 616 } |
613 | 617 |
614 bool SigninManager::IsSignoutProhibited() const { | 618 bool SigninManager::IsSignoutProhibited() const { |
615 return prohibit_signout_; | 619 return prohibit_signout_; |
616 } | 620 } |
OLD | NEW |