Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / signin / fake_signin_manager.h
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.
4
5 #ifndef CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_H_
6 #define CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "chrome/browser/signin/signin_manager.h"
12
13 class Profile;
14 class BrowserContextKeyedService;
15
16 // SigninManager to use for testing. Tests should use the type
17 // SigninManagerForTesting to ensure that the right type for their platform is
18 // used.
19
20 // Overrides InitTokenService to do-nothing in tests.
21 class FakeSigninManagerBase : public SigninManagerBase {
22  public:
23   explicit FakeSigninManagerBase();
24   virtual ~FakeSigninManagerBase();
25
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
30   // platforms.
31   static BrowserContextKeyedService* Build(content::BrowserContext* profile);
32 };
33
34 #if !defined(OS_CHROMEOS)
35
36 // A signin manager that bypasses actual authentication routines with servers
37 // and accepts the credentials provided to StartSignIn.
38 class FakeSigninManager : public SigninManager {
39  public:
40   explicit FakeSigninManager(Profile* profile);
41   virtual ~FakeSigninManager();
42
43   void set_auth_in_progress(const std::string& username) {
44     possibly_invalid_username_ = username;
45   }
46
47   virtual void SignOut() OVERRIDE;
48
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;
54
55   virtual void CompletePendingSignin() OVERRIDE;
56 };
57
58 #endif  // !defined (OS_CHROMEOS)
59
60 #if defined(OS_CHROMEOS)
61 typedef FakeSigninManagerBase FakeSigninManagerForTesting;
62 #else
63 typedef FakeSigninManager FakeSigninManagerForTesting;
64 #endif
65
66 #endif  // CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_H_