Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(988)

Unified Diff: chromeos/login/auth/cryptohome_authenticator.h

Issue 495563003: Move ParallelAuthnticator to chromeos and rename it to CryptohomeAuthenticator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/login/auth/cryptohome_authenticator.h
diff --git a/chrome/browser/chromeos/login/auth/parallel_authenticator.h b/chromeos/login/auth/cryptohome_authenticator.h
similarity index 86%
rename from chrome/browser/chromeos/login/auth/parallel_authenticator.h
rename to chromeos/login/auth/cryptohome_authenticator.h
index 5f50bf2e00828e78936ab3b8e7fcd95ddbcc2f27..174d742bfbeda30437fc7126e1488ad5e025f28a 100644
--- a/chrome/browser/chromeos/login/auth/parallel_authenticator.h
+++ b/chromeos/login/auth/cryptohome_authenticator.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_PARALLEL_AUTHENTICATOR_H_
-#define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_PARALLEL_AUTHENTICATOR_H_
+#ifndef CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_
+#define CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_
#include <string>
@@ -12,6 +12,7 @@
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
+#include "base/task_runner.h"
#include "chromeos/login/auth/auth_attempt_state.h"
#include "chromeos/login/auth/auth_attempt_state_resolver.h"
#include "chromeos/login/auth/authenticator.h"
@@ -31,7 +32,7 @@ class AuthStatusConsumer;
//
// At a high, level, here's what happens:
// AuthenticateToLogin() calls a Cryptohome's method to perform offline login.
-// Resultes are stored in a AuthAttemptState owned by ParallelAuthenticator
+// Resultes are stored in a AuthAttemptState owned by CryptohomeAuthenticator
// and then call Resolve(). Resolve() will attempt to
// determine which AuthState we're in, based on the info at hand.
// It then triggers further action based on the calculated AuthState; this
@@ -50,10 +51,9 @@ class AuthStatusConsumer;
// Old password failure: NEED_OLD_PW
// Old password ok: RECOVER_MOUNT > CONTINUE > ONLINE_LOGIN
//
-// TODO(nkostylev): Rename ParallelAuthenticator since it is not doing
-// offline/online login operations in parallel anymore.
-class ParallelAuthenticator : public Authenticator,
- public AuthAttemptStateResolver {
+class CHROMEOS_EXPORT CryptohomeAuthenticator
Nikita (slow) 2014/08/21 10:55:25 #include "chromeos/chromeos_export.h"
Denis Kuznetsov (DE-MUC) 2014/08/21 11:22:03 Done.
+ : public Authenticator,
+ public AuthAttemptStateResolver {
public:
enum AuthState {
CONTINUE = 0, // State indeterminate; try again with more info.
@@ -80,15 +80,16 @@ class ParallelAuthenticator : public Authenticator,
GUEST_LOGIN = 17, // Logged in guest mode.
PUBLIC_ACCOUNT_LOGIN = 18, // Logged into a public account.
SUPERVISED_USER_LOGIN = 19, // Logged in as a supervised user.
- LOGIN_FAILED = 20, // Login denied.
- OWNER_REQUIRED = 21, // Login is restricted to the owner only.
+ LOGIN_FAILED = 20, // Login denied.
+ OWNER_REQUIRED = 21, // Login is restricted to the owner only.
FAILED_USERNAME_HASH = 22, // Failed GetSanitizedUsername request.
KIOSK_ACCOUNT_LOGIN = 23, // Logged into a kiosk account.
REMOVED_DATA_AFTER_FAILURE = 24, // Successfully removed the user's
// cryptohome after a login failure.
};
- explicit ParallelAuthenticator(AuthStatusConsumer* consumer);
+ explicit CryptohomeAuthenticator(scoped_refptr<base::TaskRunner> task_runner,
Nikita (slow) 2014/08/21 10:55:25 Drop explicit.
Denis Kuznetsov (DE-MUC) 2014/08/21 11:22:03 Done.
+ AuthStatusConsumer* consumer);
// Authenticator overrides.
virtual void CompleteLogin(Profile* profile,
@@ -114,8 +115,7 @@ class ParallelAuthenticator : public Authenticator,
// Initiates supervised user login.
// Creates cryptohome if missing or mounts existing one and
// notifies consumer on the success/failure.
- virtual void LoginAsSupervisedUser(
- const UserContext& user_context) OVERRIDE;
+ virtual void LoginAsSupervisedUser(const UserContext& user_context) OVERRIDE;
// Initiates retail mode login.
// Mounts tmpfs and notifies consumer on the success/failure.
@@ -143,8 +143,7 @@ class ParallelAuthenticator : public Authenticator,
virtual void OnRetailModeAuthSuccess() OVERRIDE;
virtual void OnAuthSuccess() OVERRIDE;
virtual void OnAuthFailure(const AuthFailure& error) OVERRIDE;
- virtual void RecoverEncryptedData(
- const std::string& old_password) OVERRIDE;
+ virtual void RecoverEncryptedData(const std::string& old_password) OVERRIDE;
virtual void ResyncEncryptedData() OVERRIDE;
// AuthAttemptStateResolver overrides.
@@ -160,14 +159,22 @@ class ParallelAuthenticator : public Authenticator,
void OnPasswordChangeDetected();
protected:
- virtual ~ParallelAuthenticator();
+ virtual ~CryptohomeAuthenticator();
+
+ typedef base::Callback<void(bool is_owner)> IsOwnerCallback;
+
+ virtual bool IsKnownUser(const UserContext& context) = 0;
Nikita (slow) 2014/08/21 10:55:25 nit: Please add comments for these methods.
Denis Kuznetsov (DE-MUC) 2014/08/21 11:22:03 Done.
+ virtual bool IsSafeMode() = 0;
+ virtual void CheckSafeModeOwnership(const UserContext& context,
+ const IsOwnerCallback& callback) = 0;
private:
- friend class ParallelAuthenticatorTest;
- FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest,
+ friend class CryptohomeAuthenticatorTest;
+ FRIEND_TEST_ALL_PREFIXES(CryptohomeAuthenticatorTest,
ResolveOwnerNeededDirectFailedMount);
- FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, ResolveOwnerNeededMount);
- FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest,
+ FRIEND_TEST_ALL_PREFIXES(CryptohomeAuthenticatorTest,
+ ResolveOwnerNeededMount);
+ FRIEND_TEST_ALL_PREFIXES(CryptohomeAuthenticatorTest,
ResolveOwnerNeededFailedMount);
// Removes the cryptohome of the user.
@@ -216,6 +223,8 @@ class ParallelAuthenticator : public Authenticator,
// an external authentication provider (i.e. GAIA extension).
void ResolveLoginCompletionStatus();
+ scoped_refptr<base::TaskRunner> task_runner_;
+
scoped_ptr<AuthAttemptState> current_state_;
bool migrate_attempted_;
bool remove_attempted_;
@@ -242,9 +251,9 @@ class ParallelAuthenticator : public Authenticator,
// consumer_->OnAuthFailure() until we removed the user cryptohome.
const AuthFailure* delayed_login_failure_;
- DISALLOW_COPY_AND_ASSIGN(ParallelAuthenticator);
+ DISALLOW_COPY_AND_ASSIGN(CryptohomeAuthenticator);
};
} // namespace chromeos
-#endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_PARALLEL_AUTHENTICATOR_H_
+#endif // CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_

Powered by Google App Engine
This is Rietveld 408576698