| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_LOGIN_PERFORMER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_PERFORMER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_PERFORMER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_PERFORMER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // input & error messages display is dedicated to ScreenLocker instance. | 47 // input & error messages display is dedicated to ScreenLocker instance. |
| 48 // | 48 // |
| 49 // 2 things make LoginPerfrormer instance exist longer: | 49 // 2 things make LoginPerfrormer instance exist longer: |
| 50 // 1. ScreenLock active (pending correct new password input) | 50 // 1. ScreenLock active (pending correct new password input) |
| 51 // 2. Pending online auth request. | 51 // 2. Pending online auth request. |
| 52 // TODO(nkostylev): Cleanup ClientLogin related code, update class description. | 52 // TODO(nkostylev): Cleanup ClientLogin related code, update class description. |
| 53 class LoginPerformer : public LoginStatusConsumer, | 53 class LoginPerformer : public LoginStatusConsumer, |
| 54 public content::NotificationObserver, | 54 public content::NotificationObserver, |
| 55 public OnlineAttemptHost::Delegate { | 55 public OnlineAttemptHost::Delegate { |
| 56 public: | 56 public: |
| 57 typedef enum AuthorizationMode { |
| 58 // Authorization performed internally by Chrome. |
| 59 AUTH_MODE_INTERNAL, |
| 60 // Authorization performed by an extension. |
| 61 AUTH_MODE_EXTENSION |
| 62 } AuthorizationMode; |
| 63 |
| 57 // Delegate class to get notifications from the LoginPerformer. | 64 // Delegate class to get notifications from the LoginPerformer. |
| 58 class Delegate : public LoginStatusConsumer { | 65 class Delegate : public LoginStatusConsumer { |
| 59 public: | 66 public: |
| 60 virtual ~Delegate() {} | 67 virtual ~Delegate() {} |
| 61 virtual void WhiteListCheckFailed(const std::string& email) = 0; | 68 virtual void WhiteListCheckFailed(const std::string& email) = 0; |
| 62 virtual void PolicyLoadFailed() = 0; | 69 virtual void PolicyLoadFailed() = 0; |
| 63 virtual void OnOnlineChecked(const std::string& email, bool success) = 0; | 70 virtual void OnOnlineChecked(const std::string& email, bool success) = 0; |
| 64 }; | 71 }; |
| 65 | 72 |
| 66 explicit LoginPerformer(Delegate* delegate); | 73 explicit LoginPerformer(Delegate* delegate); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 77 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE; | 84 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE; |
| 78 virtual void OnDemoUserLoginSuccess() OVERRIDE; | 85 virtual void OnDemoUserLoginSuccess() OVERRIDE; |
| 79 virtual void OnLoginSuccess( | 86 virtual void OnLoginSuccess( |
| 80 const std::string& username, | 87 const std::string& username, |
| 81 const std::string& password, | 88 const std::string& password, |
| 82 bool pending_requests, | 89 bool pending_requests, |
| 83 bool using_oauth) OVERRIDE; | 90 bool using_oauth) OVERRIDE; |
| 84 virtual void OnOffTheRecordLoginSuccess() OVERRIDE; | 91 virtual void OnOffTheRecordLoginSuccess() OVERRIDE; |
| 85 virtual void OnPasswordChangeDetected() OVERRIDE; | 92 virtual void OnPasswordChangeDetected() OVERRIDE; |
| 86 | 93 |
| 87 // Completes login process that has already been authenticated with | 94 // Performs a login for |username| and |password|. If auth_mode is |
| 88 // provided |username| and |password|. | 95 // AUTH_MODE_EXTENSION, there are no further auth checks, AUTH_MODE_INTERNAL |
| 89 void CompleteLogin(const std::string& username, const std::string& password); | 96 // will perform auth checks. |
| 90 | 97 void PerformLogin(const std::string& username, |
| 91 // Performs login with the |username| and |password| specified. | 98 const std::string& password, |
| 92 void Login(const std::string& username, const std::string& password); | 99 AuthorizationMode auth_mode); |
| 93 | 100 |
| 94 // Performs login for the demo user. | 101 // Performs login for the demo user. |
| 95 void LoginDemoUser(); | 102 void LoginDemoUser(); |
| 96 | 103 |
| 97 // Performs actions to prepare Guest mode login. | 104 // Performs actions to prepare Guest mode login. |
| 98 void LoginOffTheRecord(); | 105 void LoginOffTheRecord(); |
| 99 | 106 |
| 100 // Migrates cryptohome using |old_password| specified. | 107 // Migrates cryptohome using |old_password| specified. |
| 101 void RecoverEncryptedData(const std::string& old_password); | 108 void RecoverEncryptedData(const std::string& old_password); |
| 102 | 109 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 120 // If user enters incorrect old password, same LoginPerformer instance will | 127 // If user enters incorrect old password, same LoginPerformer instance will |
| 121 // be called so callback count makes it possible to distinguish initial | 128 // be called so callback count makes it possible to distinguish initial |
| 122 // "password changed detected" event from further attempts to enter old | 129 // "password changed detected" event from further attempts to enter old |
| 123 // password for cryptohome migration (when > 1). | 130 // password for cryptohome migration (when > 1). |
| 124 int password_changed_callback_count() { | 131 int password_changed_callback_count() { |
| 125 return password_changed_callback_count_; | 132 return password_changed_callback_count_; |
| 126 } | 133 } |
| 127 | 134 |
| 128 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | 135 void set_delegate(Delegate* delegate) { delegate_ = delegate; } |
| 129 | 136 |
| 130 typedef enum AuthorizationMode { | |
| 131 // Authorization performed internally by Chrome. | |
| 132 AUTH_MODE_INTERNAL, | |
| 133 // Authorization performed by an extension. | |
| 134 AUTH_MODE_EXTENSION | |
| 135 } AuthorizationMode; | |
| 136 AuthorizationMode auth_mode() const { return auth_mode_; } | 137 AuthorizationMode auth_mode() const { return auth_mode_; } |
| 137 | 138 |
| 138 protected: | 139 protected: |
| 139 // Implements OnlineAttemptHost::Delegate. | 140 // Implements OnlineAttemptHost::Delegate. |
| 140 virtual void OnChecked(const std::string& username, bool success) OVERRIDE; | 141 virtual void OnChecked(const std::string& username, bool success) OVERRIDE; |
| 141 | 142 |
| 142 private: | 143 private: |
| 143 // content::NotificationObserver implementation: | 144 // content::NotificationObserver implementation: |
| 144 virtual void Observe(int type, | 145 virtual void Observe(int type, |
| 145 const content::NotificationSource& source, | 146 const content::NotificationSource& source, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 bool using_oauth_; | 221 bool using_oauth_; |
| 221 | 222 |
| 222 base::WeakPtrFactory<LoginPerformer> weak_factory_; | 223 base::WeakPtrFactory<LoginPerformer> weak_factory_; |
| 223 | 224 |
| 224 DISALLOW_COPY_AND_ASSIGN(LoginPerformer); | 225 DISALLOW_COPY_AND_ASSIGN(LoginPerformer); |
| 225 }; | 226 }; |
| 226 | 227 |
| 227 } // namespace chromeos | 228 } // namespace chromeos |
| 228 | 229 |
| 229 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_PERFORMER_H_ | 230 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_PERFORMER_H_ |
| OLD | NEW |