OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_session_manager_client.h" | 5 #include "chromeos/dbus/fake_session_manager_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 base::ThreadTaskRunnerHandle::Get()->PostTask( | 91 base::ThreadTaskRunnerHandle::Get()->PostTask( |
92 FROM_HERE, base::Bind(callback, user_sessions_, true)); | 92 FROM_HERE, base::Bind(callback, user_sessions_, true)); |
93 } | 93 } |
94 | 94 |
95 void FakeSessionManagerClient::RetrieveDevicePolicy( | 95 void FakeSessionManagerClient::RetrieveDevicePolicy( |
96 const RetrievePolicyCallback& callback) { | 96 const RetrievePolicyCallback& callback) { |
97 base::ThreadTaskRunnerHandle::Get()->PostTask( | 97 base::ThreadTaskRunnerHandle::Get()->PostTask( |
98 FROM_HERE, base::Bind(callback, device_policy_)); | 98 FROM_HERE, base::Bind(callback, device_policy_)); |
99 } | 99 } |
100 | 100 |
| 101 std::string FakeSessionManagerClient::BlockingRetrieveDevicePolicy() { |
| 102 return device_policy_; |
| 103 } |
| 104 |
101 void FakeSessionManagerClient::RetrievePolicyForUser( | 105 void FakeSessionManagerClient::RetrievePolicyForUser( |
102 const cryptohome::Identification& cryptohome_id, | 106 const cryptohome::Identification& cryptohome_id, |
103 const RetrievePolicyCallback& callback) { | 107 const RetrievePolicyCallback& callback) { |
104 base::ThreadTaskRunnerHandle::Get()->PostTask( | 108 base::ThreadTaskRunnerHandle::Get()->PostTask( |
105 FROM_HERE, base::Bind(callback, user_policies_[cryptohome_id])); | 109 FROM_HERE, base::Bind(callback, user_policies_[cryptohome_id])); |
106 } | 110 } |
107 | 111 |
108 std::string FakeSessionManagerClient::BlockingRetrievePolicyForUser( | 112 std::string FakeSessionManagerClient::BlockingRetrievePolicyForUser( |
109 const cryptohome::Identification& cryptohome_id) { | 113 const cryptohome::Identification& cryptohome_id) { |
110 return user_policies_[cryptohome_id]; | 114 return user_policies_[cryptohome_id]; |
111 } | 115 } |
112 | 116 |
113 void FakeSessionManagerClient::RetrieveDeviceLocalAccountPolicy( | 117 void FakeSessionManagerClient::RetrieveDeviceLocalAccountPolicy( |
114 const std::string& account_id, | 118 const std::string& account_id, |
115 const RetrievePolicyCallback& callback) { | 119 const RetrievePolicyCallback& callback) { |
116 base::ThreadTaskRunnerHandle::Get()->PostTask( | 120 base::ThreadTaskRunnerHandle::Get()->PostTask( |
117 FROM_HERE, | 121 FROM_HERE, |
118 base::Bind(callback, device_local_account_policy_[account_id])); | 122 base::Bind(callback, device_local_account_policy_[account_id])); |
119 } | 123 } |
120 | 124 |
| 125 std::string FakeSessionManagerClient::BlockingRetrieveDeviceLocalAccountPolicy( |
| 126 const std::string& account_id) { |
| 127 return device_local_account_policy_[account_id]; |
| 128 } |
| 129 |
121 void FakeSessionManagerClient::StoreDevicePolicy( | 130 void FakeSessionManagerClient::StoreDevicePolicy( |
122 const std::string& policy_blob, | 131 const std::string& policy_blob, |
123 const StorePolicyCallback& callback) { | 132 const StorePolicyCallback& callback) { |
124 device_policy_ = policy_blob; | 133 device_policy_ = policy_blob; |
125 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 134 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
126 base::Bind(callback, true)); | 135 base::Bind(callback, true)); |
127 for (auto& observer : observers_) | 136 for (auto& observer : observers_) |
128 observer.PropertyChangeComplete(true); | 137 observer.PropertyChangeComplete(true); |
129 } | 138 } |
130 | 139 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 const std::string& policy_blob) { | 255 const std::string& policy_blob) { |
247 device_local_account_policy_[account_id] = policy_blob; | 256 device_local_account_policy_[account_id] = policy_blob; |
248 } | 257 } |
249 | 258 |
250 void FakeSessionManagerClient::OnPropertyChangeComplete(bool success) { | 259 void FakeSessionManagerClient::OnPropertyChangeComplete(bool success) { |
251 for (auto& observer : observers_) | 260 for (auto& observer : observers_) |
252 observer.PropertyChangeComplete(success); | 261 observer.PropertyChangeComplete(success); |
253 } | 262 } |
254 | 263 |
255 } // namespace chromeos | 264 } // namespace chromeos |
OLD | NEW |