Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 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. | |
| 4 | |
| 5 #ifndef CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_ | |
| 6 #define CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "chromeos/chromeos_export.h" | |
| 12 #include "chromeos/dbus/dbus_client.h" | |
| 13 | |
| 14 // TODO(rsorokin, 659732): Switch to service constants when it's landed. | |
| 15 namespace authpolicy { | |
| 16 enum ADJoinErrorType { | |
| 17 AD_JOIN_ERROR_NONE = 0, | |
| 18 AD_JOIN_ERROR_UNKNOWN = 1, | |
| 19 AD_JOIN_ERROR_DBUS_FAIL = 2, | |
| 20 }; | |
| 21 } | |
| 22 | |
| 23 namespace chromeos { | |
| 24 | |
| 25 // AuthPolicyClient is used to communicate with the org.chromium.AuthPolicy | |
| 26 // sevice. All method should be called from the origin thread (UI thread) which | |
| 27 // initializes the DBusThreadManager instance. | |
| 28 class CHROMEOS_EXPORT AuthPolicyClient : public DBusClient { | |
| 29 public: | |
| 30 typedef base::Callback<void(int error_code)> JoinCallback; | |
|
xiyuan
2016/10/26 22:03:17
nit: using JoinCallback = base::Callback<void(int
Roman Sorokin (ftl)
2016/10/27 13:10:46
Done.
| |
| 31 | |
| 32 ~AuthPolicyClient() override; | |
| 33 | |
| 34 // Factory function, creates a new instance and returns ownership. | |
| 35 // For normal usage, access the singleton via DBusThreadManager::Get(). | |
| 36 static AuthPolicyClient* Create(); | |
| 37 | |
| 38 // TODO(rsorokin): Write more descriptive comment. | |
| 39 // Calls JoinADDomain. Uses |machine_name| to join it to the domain. |user|, | |
| 40 // |password_fd| are credentials of the AD user which have right to join the | |
| 41 // domain. |password_fd| is a file descriptor password is read from. | |
| 42 // The caller should close it after the call. | |
| 43 // |callback| is called after the method call succeeds. | |
| 44 virtual void JoinADDomain(const std::string& machine_name, | |
| 45 const std::string& user, | |
| 46 int password_fd, | |
| 47 const JoinCallback& callback) = 0; | |
| 48 | |
| 49 protected: | |
| 50 // Create() should be used instead. | |
| 51 AuthPolicyClient(); | |
| 52 | |
| 53 private: | |
| 54 DISALLOW_COPY_AND_ASSIGN(AuthPolicyClient); | |
| 55 }; | |
| 56 | |
| 57 } // namespace chromeos | |
| 58 | |
| 59 #endif // CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_ | |
| OLD | NEW |