// Copyright (c) 2010 The Chromium Authors. All rights reserved. // 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_AUTHENTICATOR_H_ #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTHENTICATOR_H_ #include #include "base/logging.h" #include "base/ref_counted.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/chromeos/login/login_status_consumer.h" class Profile; namespace chromeos { // An interface for objects that will authenticate a Chromium OS user. // When authentication successfully completes, will call // consumer_->OnLoginSuccess(|username|) on the UI thread. // On failure, will call consumer_->OnLoginFailure() on the UI thread. class Authenticator : public base::RefCountedThreadSafe { public: explicit Authenticator(LoginStatusConsumer* consumer) : consumer_(consumer) { } virtual ~Authenticator() {} // Given a |username| and |password|, this method attempts to authenticate // to login. // Returns true if we kick off the attempt successfully and false if we can't. // Must be called on the FILE thread. virtual bool AuthenticateToLogin(Profile* profile, const std::string& username, const std::string& password) = 0; // Given a |username| and |password|, this method attempts to // authenticate to unlock the computer. // Returns true if we kick off the attempt successfully and false if // we can't. Must be called on the FILE thread. virtual bool AuthenticateToUnlock(const std::string& username, const std::string& password) = 0; // Initiates off the record ("browse without signing in") login. virtual void LoginOffTheRecord() = 0; // These methods must be called on the UI thread, as they make DBus calls // and also call back to the login UI. virtual void OnLoginSuccess(const std::string& credentials) = 0; virtual void OnLoginFailure(const std::string& data) = 0; protected: LoginStatusConsumer* consumer_; private: DISALLOW_COPY_AND_ASSIGN(Authenticator); }; } // namespace chromeos #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTHENTICATOR_H_