Refactoring : Move AuthAttempt and Authenticators to chromeos/login
[chromium-blink-merge.git] / chrome / browser / chromeos / login / auth / online_attempt_host.h
blobe7d26727b0bff11b8ab4896a5f24718e494e5b73
1 // Copyright 2014 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_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_HOST_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_HOST_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chromeos/login/auth/auth_attempt_state_resolver.h"
14 #include "chromeos/login/auth/user_context.h"
16 namespace content {
17 class BrowserContext;
20 namespace chromeos {
22 class AuthAttemptState;
23 class OnlineAttempt;
24 class UserContext;
26 // Helper class which hosts OnlineAttempt for online credentials checking.
27 class OnlineAttemptHost : public AuthAttemptStateResolver {
28 public:
29 class Delegate {
30 public:
31 // Called after user_context were checked online.
32 virtual void OnChecked(const std::string& username, bool success) = 0;
35 explicit OnlineAttemptHost(Delegate *delegate);
36 virtual ~OnlineAttemptHost();
38 // Performs an online check of the credentials in |user_context| and invokes
39 // the delegate's OnChecked() with the result. Note that only one check can be
40 // in progress at any given time. If this method is invoked with a different
41 // |user_context| than a check currently in progress, the current check will
42 // be silently aborted.
43 void Check(content::BrowserContext* auth_context,
44 const UserContext& user_context);
46 // Resets the checking process.
47 void Reset();
49 // AuthAttemptStateResolver overrides.
50 // Executed on IO thread.
51 virtual void Resolve() OVERRIDE;
53 // Does an actual resolve on UI thread.
54 void ResolveOnUIThread(bool success);
56 private:
57 Delegate* delegate_;
58 UserContext current_attempt_user_context_;
59 scoped_ptr<OnlineAttempt> online_attempt_;
60 scoped_ptr<AuthAttemptState> state_;
61 base::WeakPtrFactory<OnlineAttemptHost> weak_ptr_factory_;
63 DISALLOW_COPY_AND_ASSIGN(OnlineAttemptHost);
66 } // namespace chromeos
68 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_HOST_H_