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

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

Issue 614973002: Extract LoginPerformer to chromeos/auth (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge Created 6 years, 2 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/login_performer.h
diff --git a/chrome/browser/chromeos/login/auth/login_performer.h b/chromeos/login/auth/login_performer.h
similarity index 58%
rename from chrome/browser/chromeos/login/auth/login_performer.h
rename to chromeos/login/auth/login_performer.h
index 00d6ace8ff9ee88253efcf8d2648e6b2b17f86e8..0d40a79ec37fabeb8399f73726b86ece0eef0a9d 100644
--- a/chrome/browser/chromeos/login/auth/login_performer.h
+++ b/chromeos/login/auth/login_performer.h
@@ -2,28 +2,33 @@
// 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_LOGIN_PERFORMER_H_
-#define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_LOGIN_PERFORMER_H_
+#ifndef CHROMEOS_LOGIN_AUTH_LOGIN_PERFORMER_H_
+#define CHROMEOS_LOGIN_AUTH_LOGIN_PERFORMER_H_
#include <string>
#include "base/basictypes.h"
+#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "chrome/browser/chromeos/policy/wildcard_login_checker.h"
+#include "chromeos/chromeos_export.h"
#include "chromeos/login/auth/auth_status_consumer.h"
#include "chromeos/login/auth/authenticator.h"
#include "chromeos/login/auth/extended_authenticator.h"
#include "chromeos/login/auth/online_attempt_host.h"
#include "chromeos/login/auth/user_context.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
#include "google_apis/gaia/google_service_auth_error.h"
+namespace net {
+class URLRequestContextGetter;
+}
+
namespace policy {
class WildcardLoginChecker;
}
+class Profile;
Nikita (slow) 2014/10/06 14:55:33 use BrowserContext instead.
+
namespace chromeos {
// This class encapsulates sign in operations.
@@ -34,8 +39,8 @@ namespace chromeos {
// If auth is succeeded, cookie fetcher is executed, LP instance deletes itself.
//
// If |delegate_| is not NULL it will handle error messages, password input.
-class LoginPerformer : public AuthStatusConsumer,
- public OnlineAttemptHost::Delegate {
+class CHROMEOS_EXPORT LoginPerformer : public AuthStatusConsumer,
+ public OnlineAttemptHost::Delegate {
public:
typedef enum AuthorizationMode {
// Authorization performed internally by Chrome.
@@ -53,17 +58,10 @@ class LoginPerformer : public AuthStatusConsumer,
virtual void OnOnlineChecked(const std::string& email, bool success) = 0;
};
- explicit LoginPerformer(Delegate* delegate);
+ LoginPerformer(scoped_refptr<base::TaskRunner> task_runner,
+ Delegate* delegate);
virtual ~LoginPerformer();
- // AuthStatusConsumer implementation:
- virtual void OnAuthFailure(const AuthFailure& error) override;
- virtual void OnRetailModeAuthSuccess(
- const UserContext& user_context) override;
- virtual void OnAuthSuccess(const UserContext& user_context) override;
- virtual void OnOffTheRecordAuthSuccess() override;
- virtual void OnPasswordChangeDetected() override;
-
// Performs a login for |user_context|.
// If auth_mode is AUTH_MODE_EXTENSION, there are no further auth checks,
// AUTH_MODE_INTERNAL will perform auth checks.
@@ -86,6 +84,14 @@ class LoginPerformer : public AuthStatusConsumer,
void LoginAsKioskAccount(const std::string& app_user_id,
bool use_guest_mount);
+ // AuthStatusConsumer implementation:
+ virtual void OnAuthFailure(const AuthFailure& error) OVERRIDE;
+ virtual void OnRetailModeAuthSuccess(
+ const UserContext& user_context) OVERRIDE;
+ virtual void OnAuthSuccess(const UserContext& user_context) OVERRIDE;
+ virtual void OnOffTheRecordAuthSuccess() OVERRIDE;
+ virtual void OnPasswordChangeDetected() OVERRIDE;
+
// Migrates cryptohome using |old_password| specified.
void RecoverEncryptedData(const std::string& old_password);
@@ -115,7 +121,64 @@ class LoginPerformer : public AuthStatusConsumer,
protected:
// Implements OnlineAttemptHost::Delegate.
- virtual void OnChecked(const std::string& username, bool success) override;
+ virtual void OnChecked(const std::string& username, bool success) OVERRIDE;
Nikita (slow) 2014/10/06 15:02:30 nit: username > user_id here and through this clas
+
+ // Platform-dependant methods do be implemented by concrete class.
Nikita (slow) 2014/10/06 15:02:30 nit: to be
+
+ // Run trusted check for platform. If trusted check have to be performed
Nikita (slow) 2014/10/06 15:02:30 nit: for a platform
+ // asynchronously,
Nikita (slow) 2014/10/06 15:02:30 nit: please combine with the next line looks stran
+ // |false| will be returned, and either delegate's PolicyLoadFailed() or
+ // |callback| will be
+ // called upon actual check.
Nikita (slow) 2014/10/06 15:02:31 nit: last two lines may be combined
+ virtual bool RunTrustedCheck(const base::Closure& callback) = 0;
+ // Check if user is allowed to sign in on device. |wildcard_match| will
Nikita (slow) 2014/10/06 15:02:31 nit: insert extra empty line before comment.
+ // contain
Nikita (slow) 2014/10/06 15:02:30 nit: Please combine with the next line.
+ // additional information whether this user is explicitly listed or not (may
+ // be relevant for
Nikita (slow) 2014/10/06 15:02:30 nit: combine two last lines.
+ // extension-based sign-in).
+ virtual bool IsUserWhitelisted(const std::string& username,
+ bool* wildcard_match) = 0;
+ // This method should run addional online check if user can sign in on device.
Nikita (slow) 2014/10/06 15:02:31 nit: Insert empty line before comment.
+ // Either |success_callback| or |failure_callback| should be called upon this
+ // check.
+ virtual void RunOnlineWhitelistCheck(
+ const std::string& username,
+ bool wildcard_match,
+ const base::Closure& success_callback,
+ const base::Closure& failure_callback) = 0;
+
+ // Supervised users-related methods.
+
+ // Check if supervised users are allowed on this device.
+ virtual bool AreSupervisedUsersAllowed() = 0;
+
+ // Check which authenticator should be used for supervised user.
+ virtual bool UseExtendedAuthenticatorForSupervisedUser(
+ const UserContext& user_context) = 0;
+
+ // Probably transform supervised user's authentication key.
+ virtual UserContext TransformSupervisedKey(const UserContext& context) = 0;
+
+ // Set up sign-in flow for supervised user.
+ virtual void SetupSupervisedUserFlow(const std::string& user_id) = 0;
+
+ // Run policy check for user. If something is wrong, delegate's
Nikita (slow) 2014/10/06 15:02:30 nit: for |user_id|
+ // PolicyLoadFailed is called.
+ virtual bool CheckPolicyForUser(const std::string& username) = 0;
Nikita (slow) 2014/10/06 15:02:30 nit: username > user_id
+
+ // Look up profile to use during signin.
+ virtual Profile* GetSigninProfile() = 0;
Nikita (slow) 2014/10/06 15:02:30 nit: Should not use Profile here thus rename metho
+
+ // Get implementation of RequestContext.
Nikita (slow) 2014/10/06 15:02:30 nit: Get RequestContext used for sign in.
+ virtual net::URLRequestContextGetter* GetSigninRequestContext() = 0;
+
+ // Create authenticator implementation.
+ virtual scoped_refptr<Authenticator> CreateAuthenticator() = 0;
+
+ void set_authenticator(scoped_refptr<Authenticator> authenticator);
+
+ // Notifications receiver.
+ Delegate* delegate_;
private:
// Starts login completion of externally authenticated user.
@@ -123,15 +186,23 @@ class LoginPerformer : public AuthStatusConsumer,
// Starts authentication.
void StartAuthentication();
+ void NotifyWhitelistCheckFailure();
+
+ // Makes sure that authenticator is created.
+ void EnsureAuthenticator();
+ void EnsureExtendedAuthenticator();
+
+ // Actual implementantion of PeformLogin that is run after trusted values
+ // check.
+ void DoPerformLogin(const UserContext& user_context,
+ AuthorizationMode auth_mode);
- // Completion callback for the online wildcard login check for enterprise
- // devices. Continues the login process or signals whitelist check failure
- // depending on the value of |result|.
- void OnlineWildcardLoginCheckCompleted(
- policy::WildcardLoginChecker::Result result);
+ scoped_refptr<base::TaskRunner> task_runner_;
// Used for logging in.
scoped_refptr<Authenticator> authenticator_;
+
+ // Used for logging in.
scoped_refptr<ExtendedAuthenticator> extended_authenticator_;
// Used to make auxiliary online check.
@@ -144,9 +215,6 @@ class LoginPerformer : public AuthStatusConsumer,
// User credentials for the current login attempt.
UserContext user_context_;
- // Notifications receiver.
- Delegate* delegate_;
-
// True if password change has been detected.
// Once correct password is entered homedir migration is executed.
bool password_changed_;
@@ -155,14 +223,10 @@ class LoginPerformer : public AuthStatusConsumer,
// Authorization mode type.
AuthorizationMode auth_mode_;
- // Used to verify logins that matched wildcard on the login whitelist.
- scoped_ptr<policy::WildcardLoginChecker> wildcard_login_checker_;
-
base::WeakPtrFactory<LoginPerformer> weak_factory_;
-
DISALLOW_COPY_AND_ASSIGN(LoginPerformer);
};
} // namespace chromeos
-#endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_LOGIN_PERFORMER_H_
+#endif // CHROMEOS_LOGIN_AUTH_LOGIN_PERFORMER_H_

Powered by Google App Engine
This is Rietveld 408576698