| 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 #ifndef CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_H_ | 5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_FAKE_SIGNIN_MANAGER_H_ |
| 6 #define CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_H_ | 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_FAKE_SIGNIN_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "components/signin/core/browser/signin_manager.h" | 12 #include "components/signin/core/browser/signin_manager.h" |
| 13 #include "components/signin/core/browser/signin_metrics.h" | 13 #include "components/signin/core/browser/signin_metrics.h" |
| 14 | 14 |
| 15 namespace content { | |
| 16 class BrowserContext; | |
| 17 } | |
| 18 | |
| 19 class Profile; | |
| 20 | |
| 21 // SigninManager to use for testing. Tests should use the type | 15 // SigninManager to use for testing. Tests should use the type |
| 22 // SigninManagerForTesting to ensure that the right type for their platform is | 16 // SigninManagerForTesting to ensure that the right type for their platform is |
| 23 // used. | 17 // used. |
| 24 | 18 |
| 25 // Overrides InitTokenService to do-nothing in tests. | 19 // Overrides InitTokenService to do-nothing in tests. |
| 26 class FakeSigninManagerBase : public SigninManagerBase { | 20 class FakeSigninManagerBase : public SigninManagerBase { |
| 27 public: | 21 public: |
| 28 explicit FakeSigninManagerBase(Profile* profile); | 22 FakeSigninManagerBase(SigninClient* client, |
| 23 AccountTrackerService* account_tracker_service); |
| 29 ~FakeSigninManagerBase() override; | 24 ~FakeSigninManagerBase() override; |
| 30 | |
| 31 // Helper function to be used with | |
| 32 // KeyedService::SetTestingFactory(). In order to match | |
| 33 // the API of SigninManagerFactory::GetForProfile(), returns a | |
| 34 // FakeSigninManagerBase* on ChromeOS, and a FakeSigninManager* on all other | |
| 35 // platforms. The returned instance is initialized. | |
| 36 static scoped_ptr<KeyedService> Build(content::BrowserContext* context); | |
| 37 }; | 25 }; |
| 38 | 26 |
| 39 #if !defined(OS_CHROMEOS) | 27 #if !defined(OS_CHROMEOS) |
| 40 | 28 |
| 41 // A signin manager that bypasses actual authentication routines with servers | 29 // A signin manager that bypasses actual authentication routines with servers |
| 42 // and accepts the credentials provided to StartSignIn. | 30 // and accepts the credentials provided to StartSignIn. |
| 43 class FakeSigninManager : public SigninManager { | 31 class FakeSigninManager : public SigninManager { |
| 44 public: | 32 public: |
| 45 explicit FakeSigninManager(Profile* profile); | 33 FakeSigninManager(SigninClient* client, |
| 34 ProfileOAuth2TokenService* token_service, |
| 35 AccountTrackerService* account_tracker_service, |
| 36 GaiaCookieManagerService* cookie_manager_service); |
| 46 ~FakeSigninManager() override; | 37 ~FakeSigninManager() override; |
| 47 | 38 |
| 48 void set_auth_in_progress(const std::string& account_id) { | 39 void set_auth_in_progress(const std::string& account_id) { |
| 49 possibly_invalid_account_id_ = account_id; | 40 possibly_invalid_account_id_ = account_id; |
| 50 } | 41 } |
| 51 | 42 |
| 52 void set_password(const std::string& password) { password_ = password; } | 43 void set_password(const std::string& password) { password_ = password; } |
| 53 | 44 |
| 54 void SignIn(const std::string& account_id, | 45 void SignIn(const std::string& account_id, |
| 55 const std::string& username, | 46 const std::string& username, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 67 void SignOut(signin_metrics::ProfileSignout signout_source_metric) override; | 58 void SignOut(signin_metrics::ProfileSignout signout_source_metric) override; |
| 68 | 59 |
| 69 void CompletePendingSignin() override; | 60 void CompletePendingSignin() override; |
| 70 | 61 |
| 71 // Username specified in StartSignInWithRefreshToken() call. | 62 // Username specified in StartSignInWithRefreshToken() call. |
| 72 std::string username_; | 63 std::string username_; |
| 73 }; | 64 }; |
| 74 | 65 |
| 75 #endif // !defined (OS_CHROMEOS) | 66 #endif // !defined (OS_CHROMEOS) |
| 76 | 67 |
| 77 #if defined(OS_CHROMEOS) | 68 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_FAKE_SIGNIN_MANAGER_H_ |
| 78 typedef FakeSigninManagerBase FakeSigninManagerForTesting; | |
| 79 #else | |
| 80 typedef FakeSigninManager FakeSigninManagerForTesting; | |
| 81 #endif | |
| 82 | |
| 83 #endif // CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_H_ | |
| OLD | NEW |