Index: chromeos/dbus/fake_auth_policy_client.cc |
diff --git a/chromeos/dbus/fake_auth_policy_client.cc b/chromeos/dbus/fake_auth_policy_client.cc |
index edcf52857d7b7d204e333fc71bf0a3470840f50b..fd656f4541cf616b190568fc6c3b0677e0ec0c2d 100644 |
--- a/chromeos/dbus/fake_auth_policy_client.cc |
+++ b/chromeos/dbus/fake_auth_policy_client.cc |
@@ -1,8 +1,19 @@ |
// Copyright (c) 2016 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. |
+ |
#include "chromeos/dbus/fake_auth_policy_client.h" |
+#include "base/files/file_path.h" |
+#include "base/files/file_util.h" |
+#include "base/path_service.h" |
+#include "base/threading/thread_restrictions.h" |
+#include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
+#include "chromeos/chromeos_paths.h" |
+#include "components/policy/proto/device_management_backend.pb.h" |
+ |
+namespace em = enterprise_management; |
+ |
namespace chromeos { |
FakeAuthPolicyClient::FakeAuthPolicyClient() {} |
@@ -20,13 +31,37 @@ void FakeAuthPolicyClient::JoinAdDomain(const std::string& machine_name, |
void FakeAuthPolicyClient::RefreshDevicePolicy( |
const RefreshPolicyCallback& callback) { |
- callback.Run(true); |
-}; |
+ // Create minimal stub device policy file and drop it at the place where |
+ // SessionManagerClientStubImpl is looking for it. |
+ em::ChromeDeviceSettingsProto policy; |
+ em::PolicyData data; |
+ policy.SerializeToString(data.mutable_policy_value()); |
+ data.set_policy_type("google/chromeos/device"); |
+ |
+ em::PolicyFetchResponse response; |
+ data.SerializeToString(response.mutable_policy_data()); |
+ std::string serialized_response; |
+ response.SerializeToString(&serialized_response); |
+ |
+ base::FilePath owner_key_path; |
+ if (!PathService::Get(FILE_OWNER_KEY, &owner_key_path)) { |
+ callback.Run(false); |
+ return; |
+ } |
+ base::FilePath device_policy_path = |
achuithb
2016/11/28 09:05:51
nit const
Thiemo Nagel
2016/11/30 19:11:58
Done.
|
+ owner_key_path.DirName().AppendASCII("stub_device_policy"); |
+ |
+ base::ThreadRestrictions::ScopedAllowIO permit_io_within_current_scope; |
Thiemo Nagel
2016/11/25 15:07:03
Do I really need to post to a different thread in
achuithb
2016/11/28 09:05:51
Yeah, pretty sure you can't use this. Isn't there
|
+ int bytes_written = |
achuithb
2016/11/28 09:05:51
nit const
Thiemo Nagel
2016/11/30 19:11:58
That variable has been removed.
|
+ base::WriteFile(device_policy_path, serialized_response.c_str(), |
+ serialized_response.size()); |
+ callback.Run(bytes_written != -1); |
+} |
void FakeAuthPolicyClient::RefreshUserPolicy( |
const std::string& account_id, |
const RefreshPolicyCallback& callback) { |
callback.Run(true); |
-}; |
+} |
} // namespace chromeos |