Chromium Code Reviews| Index: chromeos/login/auth/authpolicy_login_helper.h |
| diff --git a/chromeos/login/auth/authpolicy_login_helper.h b/chromeos/login/auth/authpolicy_login_helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6b1b153f8e68c5f804625eaa41d9d6b6995b9658 |
| --- /dev/null |
| +++ b/chromeos/login/auth/authpolicy_login_helper.h |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2017 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 CHROMEOS_LOGIN_AUTH_AUTHPOLICY_LOGIN_HELPER_H_ |
| +#define CHROMEOS_LOGIN_AUTH_AUTHPOLICY_LOGIN_HELPER_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/callback.h" |
| +#include "base/files/scoped_file.h" |
| +#include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "chromeos/dbus/auth_policy_client.h" |
| + |
| +namespace chromeos { |
| + |
| +// Helper class to use AuthPolicyClient. For Active Directory domain join and |
| +// authenticate users this class should be used instead of AuthPolicyClient. |
| +// Allows canceling all pending calls and restarting AuthPolicy service. Used |
| +// for enrollment and login UI to proper cancel the flows. |
| +class CHROMEOS_EXPORT AuthPolicyLoginHelper { |
| + public: |
| + using AuthCallback = AuthPolicyClient::AuthCallback; |
| + using JoinCallback = AuthPolicyClient::JoinCallback; |
| + |
| + AuthPolicyLoginHelper(); |
| + ~AuthPolicyLoginHelper(); |
| + // See AuthPolicyClient::JoinAdDomain. |
|
xiyuan
2017/04/07 15:04:24
nit: insert an empty line before
Roman Sorokin (ftl)
2017/04/10 16:09:00
Done.
|
| + void JoinAdDomain(const std::string& machine_name, |
| + const std::string& username, |
| + const std::string& password, |
| + JoinCallback callback); |
| + // See AuthPolicyClient::AuthenticateUser. |
|
xiyuan
2017/04/07 15:04:24
nit: insert an empty line before
Roman Sorokin (ftl)
2017/04/10 16:09:00
Done.
|
| + void AuthenticateUser(const std::string& username, |
| + const std::string& password, |
| + AuthCallback callback); |
| + // Cancel pending requests and restarts AuthPolicy service. |
|
xiyuan
2017/04/07 15:04:24
nit: insert an empty line before
Roman Sorokin (ftl)
2017/04/10 16:09:00
Done.
|
| + void CancelRequestsAndRestart(); |
| + |
| + private: |
| + // Called from AuthPolicyClient::JoinAdDomain. |
| + void OnJoinCallback(JoinCallback callback, authpolicy::ErrorType error); |
| + |
| + // Called from AuthPolicyClient::AuthenticateUser. |
| + void OnAuthCallback( |
| + AuthCallback callback, |
| + authpolicy::ErrorType error, |
| + const authpolicy::ActiveDirectoryAccountData& account_data); |
| + |
| + base::WeakPtrFactory<AuthPolicyLoginHelper> weak_factory_; |
| + DISALLOW_COPY_AND_ASSIGN(AuthPolicyLoginHelper); |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROMEOS_LOGIN_AUTH_AUTHPOLICY_LOGIN_HELPER_H_ |