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 CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_H_
6 #define CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_H_
10 #include "base/compiler_specific.h"
11 #include "chrome/browser/signin/signin_manager.h"
14 class BrowserContextKeyedService;
16 // SigninManager to use for testing. Tests should use the type
17 // SigninManagerForTesting to ensure that the right type for their platform is
20 // Overrides InitTokenService to do-nothing in tests.
21 class FakeSigninManagerBase : public SigninManagerBase {
23 explicit FakeSigninManagerBase();
24 virtual ~FakeSigninManagerBase();
26 // Helper function to be used with
27 // BrowserContextKeyedService::SetTestingFactory(). In order to match
28 // the API of SigninManagerFactory::GetForProfile(), returns a
29 // FakeSigninManagerBase* on ChromeOS, and a FakeSigninManager* on all other
31 static BrowserContextKeyedService* Build(content::BrowserContext* profile);
34 #if !defined(OS_CHROMEOS)
36 // A signin manager that bypasses actual authentication routines with servers
37 // and accepts the credentials provided to StartSignIn.
38 class FakeSigninManager : public SigninManager {
40 explicit FakeSigninManager(Profile* profile);
41 virtual ~FakeSigninManager();
43 void set_auth_in_progress(const std::string& username) {
44 possibly_invalid_username_ = username;
47 virtual void SignOut() OVERRIDE;
49 virtual void StartSignInWithCredentials(
50 const std::string& session_index,
51 const std::string& username,
52 const std::string& password,
53 const OAuthTokenFetchedCallback& oauth_fetched_callback) OVERRIDE;
55 virtual void CompletePendingSignin() OVERRIDE;
58 #endif // !defined (OS_CHROMEOS)
60 #if defined(OS_CHROMEOS)
61 typedef FakeSigninManagerBase FakeSigninManagerForTesting;
63 typedef FakeSigninManager FakeSigninManagerForTesting;
66 #endif // CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_H_