| 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 "components/signin/core/browser/fake_signin_manager.h" | 5 #include "components/signin/core/browser/fake_signin_manager.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "components/prefs/pref_service.h" | 9 #include "components/prefs/pref_service.h" |
| 10 #include "components/signin/core/browser/account_tracker_service.h" | 10 #include "components/signin/core/browser/account_tracker_service.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 possibly_invalid_gaia_id_.assign(gaia_id); | 49 possibly_invalid_gaia_id_.assign(gaia_id); |
| 50 possibly_invalid_email_.assign(username); | 50 possibly_invalid_email_.assign(username); |
| 51 | 51 |
| 52 if (!oauth_fetched_callback.is_null()) | 52 if (!oauth_fetched_callback.is_null()) |
| 53 oauth_fetched_callback.Run(refresh_token); | 53 oauth_fetched_callback.Run(refresh_token); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void FakeSigninManager::CompletePendingSignin() { | 56 void FakeSigninManager::CompletePendingSignin() { |
| 57 SetAuthenticatedAccountId(GetAccountIdForAuthInProgress()); | 57 SetAuthenticatedAccountId(GetAccountIdForAuthInProgress()); |
| 58 set_auth_in_progress(std::string()); | 58 set_auth_in_progress(std::string()); |
| 59 FOR_EACH_OBSERVER( | 59 for (auto& observer : observer_list_) { |
| 60 SigninManagerBase::Observer, observer_list_, | 60 observer.GoogleSigninSucceeded(authenticated_account_id_, username_, |
| 61 GoogleSigninSucceeded(authenticated_account_id_, username_, password_)); | 61 password_); |
| 62 } |
| 62 } | 63 } |
| 63 | 64 |
| 64 void FakeSigninManager::SignIn(const std::string& gaia_id, | 65 void FakeSigninManager::SignIn(const std::string& gaia_id, |
| 65 const std::string& username, | 66 const std::string& username, |
| 66 const std::string& password) { | 67 const std::string& password) { |
| 67 StartSignInWithRefreshToken(std::string(), gaia_id, username, password, | 68 StartSignInWithRefreshToken(std::string(), gaia_id, username, password, |
| 68 OAuthTokenFetchedCallback()); | 69 OAuthTokenFetchedCallback()); |
| 69 CompletePendingSignin(); | 70 CompletePendingSignin(); |
| 70 } | 71 } |
| 71 | 72 |
| 72 void FakeSigninManager::ForceSignOut() { | 73 void FakeSigninManager::ForceSignOut() { |
| 73 prohibit_signout_ = false; | 74 prohibit_signout_ = false; |
| 74 SignOut(signin_metrics::SIGNOUT_TEST, | 75 SignOut(signin_metrics::SIGNOUT_TEST, |
| 75 signin_metrics::SignoutDelete::IGNORE_METRIC); | 76 signin_metrics::SignoutDelete::IGNORE_METRIC); |
| 76 } | 77 } |
| 77 | 78 |
| 78 void FakeSigninManager::FailSignin(const GoogleServiceAuthError& error) { | 79 void FakeSigninManager::FailSignin(const GoogleServiceAuthError& error) { |
| 79 FOR_EACH_OBSERVER(SigninManagerBase::Observer, observer_list_, | 80 for (auto& observer : observer_list_) |
| 80 GoogleSigninFailed(error)); | 81 observer.GoogleSigninFailed(error); |
| 81 } | 82 } |
| 82 | 83 |
| 83 void FakeSigninManager::SignOut( | 84 void FakeSigninManager::SignOut( |
| 84 signin_metrics::ProfileSignout signout_source_metric, | 85 signin_metrics::ProfileSignout signout_source_metric, |
| 85 signin_metrics::SignoutDelete signout_delete_metric) { | 86 signin_metrics::SignoutDelete signout_delete_metric) { |
| 86 if (IsSignoutProhibited()) | 87 if (IsSignoutProhibited()) |
| 87 return; | 88 return; |
| 88 set_auth_in_progress(std::string()); | 89 set_auth_in_progress(std::string()); |
| 89 set_password(std::string()); | 90 set_password(std::string()); |
| 90 const std::string account_id = GetAuthenticatedAccountId(); | 91 const std::string account_id = GetAuthenticatedAccountId(); |
| 91 const std::string username = GetAuthenticatedAccountInfo().email; | 92 const std::string username = GetAuthenticatedAccountInfo().email; |
| 92 authenticated_account_id_.clear(); | 93 authenticated_account_id_.clear(); |
| 93 | 94 |
| 94 FOR_EACH_OBSERVER(SigninManagerBase::Observer, observer_list_, | 95 for (auto& observer : observer_list_) |
| 95 GoogleSignedOut(account_id, username)); | 96 observer.GoogleSignedOut(account_id, username); |
| 96 } | 97 } |
| 97 | 98 |
| 98 #endif // !defined (OS_CHROMEOS) | 99 #endif // !defined (OS_CHROMEOS) |
| OLD | NEW |