| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_HOST_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_HOST_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_HOST_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_HOST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/chromeos/login/auth/auth_attempt_state_resolver.h" | 13 #include "chrome/browser/chromeos/login/auth/auth_attempt_state_resolver.h" |
| 14 | 14 |
| 15 class Profile; | 15 namespace content { |
| 16 class BrowserContext; |
| 17 } |
| 16 | 18 |
| 17 namespace chromeos { | 19 namespace chromeos { |
| 18 | 20 |
| 19 class AuthAttemptState; | 21 class AuthAttemptState; |
| 20 class OnlineAttempt; | 22 class OnlineAttempt; |
| 21 class UserContext; | 23 class UserContext; |
| 22 | 24 |
| 23 // Helper class which hosts OnlineAttempt for online credentials checking. | 25 // Helper class which hosts OnlineAttempt for online credentials checking. |
| 24 class OnlineAttemptHost : public AuthAttemptStateResolver { | 26 class OnlineAttemptHost : public AuthAttemptStateResolver { |
| 25 public: | 27 public: |
| 26 class Delegate { | 28 class Delegate { |
| 27 public: | 29 public: |
| 28 // Called after user_context were checked online. | 30 // Called after user_context were checked online. |
| 29 virtual void OnChecked(const std::string &username, bool success) = 0; | 31 virtual void OnChecked(const std::string &username, bool success) = 0; |
| 30 }; | 32 }; |
| 31 | 33 |
| 32 explicit OnlineAttemptHost(Delegate *delegate); | 34 explicit OnlineAttemptHost(Delegate *delegate); |
| 33 virtual ~OnlineAttemptHost(); | 35 virtual ~OnlineAttemptHost(); |
| 34 | 36 |
| 35 // Checks user credentials using an online attempt. Calls callback with the | 37 // Checks user credentials using an online attempt. Calls callback with the |
| 36 // check result (whether authentication was successful). Note, only one | 38 // check result (whether authentication was successful). Note, only one |
| 37 // checking at a time (the newest call stops the old one, if called with | 39 // checking at a time (the newest call stops the old one, if called with |
| 38 // another username and password combination). | 40 // another username and password combination). |
| 39 void Check(Profile* profile, const UserContext& user_context); | 41 void Check(content::BrowserContext* auth_context, |
| 42 const UserContext& user_context); |
| 40 | 43 |
| 41 // Resets the checking process. | 44 // Resets the checking process. |
| 42 void Reset(); | 45 void Reset(); |
| 43 | 46 |
| 44 // AuthAttemptStateResolver overrides. | 47 // AuthAttemptStateResolver overrides. |
| 45 // Executed on IO thread. | 48 // Executed on IO thread. |
| 46 virtual void Resolve() OVERRIDE; | 49 virtual void Resolve() OVERRIDE; |
| 47 | 50 |
| 48 // Does an actual resolve on UI thread. | 51 // Does an actual resolve on UI thread. |
| 49 void ResolveOnUIThread(bool success); | 52 void ResolveOnUIThread(bool success); |
| 50 | 53 |
| 51 private: | 54 private: |
| 52 Delegate* delegate_; | 55 Delegate* delegate_; |
| 53 std::string current_attempt_hash_; | 56 std::string current_attempt_hash_; |
| 54 std::string current_username_; | 57 std::string current_username_; |
| 55 scoped_ptr<OnlineAttempt> online_attempt_; | 58 scoped_ptr<OnlineAttempt> online_attempt_; |
| 56 scoped_ptr<AuthAttemptState> state_; | 59 scoped_ptr<AuthAttemptState> state_; |
| 57 base::WeakPtrFactory<OnlineAttemptHost> weak_ptr_factory_; | 60 base::WeakPtrFactory<OnlineAttemptHost> weak_ptr_factory_; |
| 58 | 61 |
| 59 DISALLOW_COPY_AND_ASSIGN(OnlineAttemptHost); | 62 DISALLOW_COPY_AND_ASSIGN(OnlineAttemptHost); |
| 60 }; | 63 }; |
| 61 | 64 |
| 62 } // namespace chromeos | 65 } // namespace chromeos |
| 63 | 66 |
| 64 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_HOST_H_ | 67 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_HOST_H_ |
| 65 | 68 |
| OLD | NEW |