Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / signin / core / browser / fake_signin_manager.h
blobb12f48dcd1ad65667cb262980df0e3473ec88538
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_FAKE_SIGNIN_MANAGER_H_
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_FAKE_SIGNIN_MANAGER_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "components/signin/core/browser/signin_manager.h"
13 #include "components/signin/core/browser/signin_metrics.h"
15 // SigninManager to use for testing. Tests should use the type
16 // SigninManagerForTesting to ensure that the right type for their platform is
17 // used.
19 // Overrides InitTokenService to do-nothing in tests.
20 class FakeSigninManagerBase : public SigninManagerBase {
21 public:
22 FakeSigninManagerBase(SigninClient* client,
23 AccountTrackerService* account_tracker_service);
24 ~FakeSigninManagerBase() override;
27 #if !defined(OS_CHROMEOS)
29 // A signin manager that bypasses actual authentication routines with servers
30 // and accepts the credentials provided to StartSignIn.
31 class FakeSigninManager : public SigninManager {
32 public:
33 FakeSigninManager(SigninClient* client,
34 ProfileOAuth2TokenService* token_service,
35 AccountTrackerService* account_tracker_service,
36 GaiaCookieManagerService* cookie_manager_service);
37 ~FakeSigninManager() override;
39 void set_auth_in_progress(const std::string& account_id) {
40 possibly_invalid_account_id_ = account_id;
43 void set_password(const std::string& password) { password_ = password; }
45 void SignIn(const std::string& account_id,
46 const std::string& username,
47 const std::string& password);
49 void ForceSignOut();
51 void FailSignin(const GoogleServiceAuthError& error);
53 void StartSignInWithRefreshToken(
54 const std::string& refresh_token,
55 const std::string& gaia_id,
56 const std::string& username,
57 const std::string& password,
58 const OAuthTokenFetchedCallback& oauth_fetched_callback) override;
60 void SignOut(signin_metrics::ProfileSignout signout_source_metric) override;
62 void CompletePendingSignin() override;
64 // Username specified in StartSignInWithRefreshToken() call.
65 std::string username_;
68 #endif // !defined (OS_CHROMEOS)
70 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_FAKE_SIGNIN_MANAGER_H_