Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / authenticator.h
blobf061803683285627b030c32763bdd50608946d6a
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_AUTHENTICATOR_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTHENTICATOR_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "chrome/browser/chromeos/login/login_status_consumer.h"
13 #include "google_apis/gaia/gaia_auth_consumer.h"
15 class Profile;
17 namespace chromeos {
19 struct UserContext;
21 // An interface for objects that will authenticate a Chromium OS user.
22 // Callbacks will be called on the UI thread:
23 // 1. On successful authentication, will call consumer_->OnLoginSuccess().
24 // 2. On failure, will call consumer_->OnLoginFailure().
25 // 3. On password change, will call consumer_->OnPasswordChangeDetected().
26 class Authenticator : public base::RefCountedThreadSafe<Authenticator> {
27 public:
28 explicit Authenticator(LoginStatusConsumer* consumer);
30 // Given externally authenticated username and password (part of
31 // |user_context|), this method attempts to complete authentication process.
32 virtual void CompleteLogin(Profile* profile,
33 const UserContext& user_context) = 0;
35 // Given a user credentials in |user_context|,
36 // this method attempts to authenticate to login.
37 // Must be called on the UI thread.
38 virtual void AuthenticateToLogin(Profile* profile,
39 const UserContext& user_context) = 0;
41 // Given a user credentials in |user_context|, this method attempts to
42 // authenticate to unlock the computer.
43 // Must be called on the UI thread.
44 virtual void AuthenticateToUnlock(const UserContext& user_context) = 0;
46 // Initiates locally managed user login.
47 virtual void LoginAsLocallyManagedUser(
48 const UserContext& user_context) = 0;
50 // Initiates retail mode login.
51 virtual void LoginRetailMode() = 0;
53 // Initiates incognito ("browse without signing in") login.
54 virtual void LoginOffTheRecord() = 0;
56 // Initiates login into the public account identified by |username|.
57 virtual void LoginAsPublicAccount(const std::string& username) = 0;
59 // Initiates login into kiosk mode account identified by |app_user_id|.
60 // The |app_user_id| is a generated username for the account.
61 virtual void LoginAsKioskAccount(const std::string& app_user_id) = 0;
63 // Completes retail mode login.
64 virtual void OnRetailModeLoginSuccess() = 0;
66 // Notifies caller that login was successful. Must be called on the UI thread.
67 virtual void OnLoginSuccess() = 0;
69 // Must be called on the UI thread.
70 virtual void OnLoginFailure(const LoginFailure& error) = 0;
72 // Call these methods on the UI thread.
73 // If a password logs the user in online, but cannot be used to
74 // mount his cryptohome, we expect that a password change has
75 // occurred.
76 // Call this method to migrate the user's encrypted data
77 // forward to use his new password. |old_password| is the password
78 // his data was last encrypted with.
79 virtual void RecoverEncryptedData(
80 const std::string& old_password) = 0;
82 // Call this method to erase the user's encrypted data
83 // and create a new cryptohome.
84 virtual void ResyncEncryptedData() = 0;
86 // Profile (usually off the record ) that was used to perform the last
87 // authentication process.
88 Profile* authentication_profile() { return authentication_profile_; }
90 // Sets consumer explicitly.
91 void SetConsumer(LoginStatusConsumer* consumer);
93 protected:
94 virtual ~Authenticator();
96 LoginStatusConsumer* consumer_;
97 Profile* authentication_profile_;
99 private:
100 friend class base::RefCountedThreadSafe<Authenticator>;
102 DISALLOW_COPY_AND_ASSIGN(Authenticator);
105 } // namespace chromeos
107 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTHENTICATOR_H_