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_CHROMEOS_LOGIN_ONLINE_ATTEMPT_HOST_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ONLINE_ATTEMPT_HOST_H_
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/chromeos/login/auth_attempt_state_resolver.h"
19 class AuthAttemptState;
23 // Helper class which hosts OnlineAttempt for online credentials checking.
24 class OnlineAttemptHost : public AuthAttemptStateResolver {
28 // Called after user_context were checked online.
29 virtual void OnChecked(const std::string &username, bool success) = 0;
32 explicit OnlineAttemptHost(Delegate *delegate);
33 virtual ~OnlineAttemptHost();
35 // Checks user credentials using an online attempt. Calls callback with the
36 // check result (whether authentication was successful). Note, only one
37 // checking at a time (the newest call stops the old one, if called with
38 // another username and password combination).
39 void Check(Profile* profile,
40 const UserContext& user_context);
42 // Resets the checking process.
45 // AuthAttemptStateResolver overrides.
46 // Executed on IO thread.
47 virtual void Resolve() OVERRIDE;
49 // Does an actual resolve on UI thread.
50 void ResolveOnUIThread(bool success);
54 std::string current_attempt_hash_;
55 std::string current_username_;
56 scoped_ptr<OnlineAttempt> online_attempt_;
57 scoped_ptr<AuthAttemptState> state_;
58 base::WeakPtrFactory<OnlineAttemptHost> weak_ptr_factory_;
60 DISALLOW_COPY_AND_ASSIGN(OnlineAttemptHost);
63 } // namespace chromeos
65 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ONLINE_ATTEMPT_HOST_H_