OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromeos/dbus/fake_auth_policy_client.h" | 5 #include "chromeos/dbus/fake_auth_policy_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/md5.h" | 11 #include "base/md5.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
14 #include "base/threading/worker_pool.h" | 14 #include "base/threading/worker_pool.h" |
15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
16 #include "chromeos/chromeos_paths.h" | 16 #include "chromeos/chromeos_paths.h" |
17 #include "components/policy/proto/device_management_backend.pb.h" | 17 #include "components/policy/proto/device_management_backend.pb.h" |
| 18 #include "third_party/cros_system_api/dbus/service_constants.h" |
18 | 19 |
19 namespace em = enterprise_management; | 20 namespace em = enterprise_management; |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // Create minimal stub device policy file and drop it at the place where | 24 // Create minimal stub device policy file and drop it at the place where |
24 // SessionManagerClientStubImpl is looking for it. | 25 // SessionManagerClientStubImpl is looking for it. |
25 bool WriteDevicePolicyFile() { | 26 bool WriteDevicePolicyFile() { |
26 em::ChromeDeviceSettingsProto policy; | 27 em::ChromeDeviceSettingsProto policy; |
27 em::PolicyData data; | 28 em::PolicyData data; |
(...skipping 30 matching lines...) Expand all Loading... |
58 FakeAuthPolicyClient::FakeAuthPolicyClient() {} | 59 FakeAuthPolicyClient::FakeAuthPolicyClient() {} |
59 | 60 |
60 FakeAuthPolicyClient::~FakeAuthPolicyClient() {} | 61 FakeAuthPolicyClient::~FakeAuthPolicyClient() {} |
61 | 62 |
62 void FakeAuthPolicyClient::Init(dbus::Bus* bus) {} | 63 void FakeAuthPolicyClient::Init(dbus::Bus* bus) {} |
63 | 64 |
64 void FakeAuthPolicyClient::JoinAdDomain(const std::string& machine_name, | 65 void FakeAuthPolicyClient::JoinAdDomain(const std::string& machine_name, |
65 const std::string& user_principal_name, | 66 const std::string& user_principal_name, |
66 int password_fd, | 67 int password_fd, |
67 const JoinCallback& callback) { | 68 const JoinCallback& callback) { |
68 callback.Run(authpolicy::types::AD_JOIN_ERROR_NONE); | 69 callback.Run(authpolicy::ERROR_NONE); |
69 } | 70 } |
70 | 71 |
71 void FakeAuthPolicyClient::AuthenticateUser( | 72 void FakeAuthPolicyClient::AuthenticateUser( |
72 const std::string& user_principal_name, | 73 const std::string& user_principal_name, |
73 int password_fd, | 74 int password_fd, |
74 const AuthCallback& callback) { | 75 const AuthCallback& callback) { |
75 callback.Run(authpolicy::AUTH_USER_ERROR_NONE, | 76 callback.Run(authpolicy::ERROR_NONE, base::MD5String(user_principal_name)); |
76 base::MD5String(user_principal_name)); | |
77 } | 77 } |
78 | 78 |
79 void FakeAuthPolicyClient::RefreshDevicePolicy( | 79 void FakeAuthPolicyClient::RefreshDevicePolicy( |
80 const RefreshPolicyCallback& callback) { | 80 const RefreshPolicyCallback& callback) { |
81 if (!base::PostTaskAndReplyWithResult( | 81 if (!base::PostTaskAndReplyWithResult( |
82 base::WorkerPool::GetTaskRunner(false /* task_is_slow */).get(), | 82 base::WorkerPool::GetTaskRunner(false /* task_is_slow */).get(), |
83 FROM_HERE, base::Bind(&WriteDevicePolicyFile), callback)) { | 83 FROM_HERE, base::Bind(&WriteDevicePolicyFile), callback)) { |
84 callback.Run(false); | 84 callback.Run(false); |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 void FakeAuthPolicyClient::RefreshUserPolicy( | 88 void FakeAuthPolicyClient::RefreshUserPolicy( |
89 const std::string& account_id, | 89 const std::string& account_id, |
90 const RefreshPolicyCallback& callback) { | 90 const RefreshPolicyCallback& callback) { |
91 callback.Run(true); | 91 callback.Run(true); |
92 } | 92 } |
93 | 93 |
94 } // namespace chromeos | 94 } // namespace chromeos |
OLD | NEW |