| 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/fake_signin_manager.h" | 5 #include "chrome/browser/signin/fake_signin_manager.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 10 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 | 61 |
| 62 void FakeSigninManager::CompletePendingSignin() { | 62 void FakeSigninManager::CompletePendingSignin() { |
| 63 SetAuthenticatedUsername(GetUsernameForAuthInProgress()); | 63 SetAuthenticatedUsername(GetUsernameForAuthInProgress()); |
| 64 set_auth_in_progress(std::string()); | 64 set_auth_in_progress(std::string()); |
| 65 FOR_EACH_OBSERVER(Observer, | 65 FOR_EACH_OBSERVER(Observer, |
| 66 observer_list_, | 66 observer_list_, |
| 67 GoogleSigninSucceeded(authenticated_username_, password_)); | 67 GoogleSigninSucceeded(authenticated_username_, password_)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void FakeSigninManager::AddMergeSessionObserver( |
| 71 MergeSessionHelper::Observer* observer) { |
| 72 SigninManager::AddMergeSessionObserver(observer); |
| 73 merge_session_observer_list_.AddObserver(observer); |
| 74 } |
| 75 |
| 76 void FakeSigninManager::RemoveMergeSessionObserver( |
| 77 MergeSessionHelper::Observer* observer) { |
| 78 SigninManager::RemoveMergeSessionObserver(observer); |
| 79 merge_session_observer_list_.RemoveObserver(observer); |
| 80 } |
| 81 |
| 82 void FakeSigninManager::NotifyMergeSessionObservers( |
| 83 const GoogleServiceAuthError& error) { |
| 84 FOR_EACH_OBSERVER(MergeSessionHelper::Observer, merge_session_observer_list_, |
| 85 MergeSessionCompleted(GetAuthenticatedUsername(), error)); |
| 86 } |
| 87 |
| 70 void FakeSigninManager::SignIn(const std::string& username, | 88 void FakeSigninManager::SignIn(const std::string& username, |
| 71 const std::string& password) { | 89 const std::string& password) { |
| 72 StartSignInWithRefreshToken( | 90 StartSignInWithRefreshToken( |
| 73 std::string(), username, password, OAuthTokenFetchedCallback()); | 91 std::string(), username, password, OAuthTokenFetchedCallback()); |
| 74 CompletePendingSignin(); | 92 CompletePendingSignin(); |
| 75 } | 93 } |
| 76 | 94 |
| 77 void FakeSigninManager::FailSignin(const GoogleServiceAuthError& error) { | 95 void FakeSigninManager::FailSignin(const GoogleServiceAuthError& error) { |
| 78 FOR_EACH_OBSERVER(Observer, observer_list_, GoogleSigninFailed(error)); | 96 FOR_EACH_OBSERVER(Observer, observer_list_, GoogleSigninFailed(error)); |
| 79 } | 97 } |
| 80 | 98 |
| 81 void FakeSigninManager::SignOut() { | 99 void FakeSigninManager::SignOut() { |
| 82 if (IsSignoutProhibited()) | 100 if (IsSignoutProhibited()) |
| 83 return; | 101 return; |
| 84 set_auth_in_progress(std::string()); | 102 set_auth_in_progress(std::string()); |
| 85 set_password(std::string()); | 103 set_password(std::string()); |
| 86 const std::string username = authenticated_username_; | 104 const std::string username = authenticated_username_; |
| 87 authenticated_username_.clear(); | 105 authenticated_username_.clear(); |
| 88 | 106 |
| 89 FOR_EACH_OBSERVER(SigninManagerBase::Observer, observer_list_, | 107 FOR_EACH_OBSERVER(SigninManagerBase::Observer, observer_list_, |
| 90 GoogleSignedOut(username)); | 108 GoogleSignedOut(username)); |
| 91 } | 109 } |
| 92 | 110 |
| 93 #endif // !defined (OS_CHROMEOS) | 111 #endif // !defined (OS_CHROMEOS) |
| OLD | NEW |