| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 bool FakeSessionManagerClient::IsScreenLocked() const { | 43 bool FakeSessionManagerClient::IsScreenLocked() const { |
| 44 return false; | 44 return false; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void FakeSessionManagerClient::EmitLoginPromptVisible() { | 47 void FakeSessionManagerClient::EmitLoginPromptVisible() { |
| 48 } | 48 } |
| 49 | 49 |
| 50 void FakeSessionManagerClient::RestartJob( | 50 void FakeSessionManagerClient::RestartJob( |
| 51 const std::vector<std::string>& argv) {} | 51 const std::vector<std::string>& argv) {} |
| 52 | 52 |
| 53 void FakeSessionManagerClient::StartSession(const std::string& user_email) { | 53 void FakeSessionManagerClient::StartSession( |
| 54 DCHECK_EQ(0UL, user_sessions_.count(user_email)); | 54 const cryptohome::Identification& cryptohome_id) { |
| 55 DCHECK_EQ(0UL, user_sessions_.count(cryptohome_id)); |
| 55 std::string user_id_hash = | 56 std::string user_id_hash = |
| 56 CryptohomeClient::GetStubSanitizedUsername(user_email); | 57 CryptohomeClient::GetStubSanitizedUsername(cryptohome_id); |
| 57 user_sessions_[user_email] = user_id_hash; | 58 user_sessions_[cryptohome_id] = user_id_hash; |
| 58 } | 59 } |
| 59 | 60 |
| 60 void FakeSessionManagerClient::StopSession() { | 61 void FakeSessionManagerClient::StopSession() { |
| 61 } | 62 } |
| 62 | 63 |
| 63 void FakeSessionManagerClient::NotifySupervisedUserCreationStarted() { | 64 void FakeSessionManagerClient::NotifySupervisedUserCreationStarted() { |
| 64 } | 65 } |
| 65 | 66 |
| 66 void FakeSessionManagerClient::NotifySupervisedUserCreationFinished() { | 67 void FakeSessionManagerClient::NotifySupervisedUserCreationFinished() { |
| 67 } | 68 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 87 FROM_HERE, base::Bind(callback, user_sessions_, true)); | 88 FROM_HERE, base::Bind(callback, user_sessions_, true)); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void FakeSessionManagerClient::RetrieveDevicePolicy( | 91 void FakeSessionManagerClient::RetrieveDevicePolicy( |
| 91 const RetrievePolicyCallback& callback) { | 92 const RetrievePolicyCallback& callback) { |
| 92 base::ThreadTaskRunnerHandle::Get()->PostTask( | 93 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 93 FROM_HERE, base::Bind(callback, device_policy_)); | 94 FROM_HERE, base::Bind(callback, device_policy_)); |
| 94 } | 95 } |
| 95 | 96 |
| 96 void FakeSessionManagerClient::RetrievePolicyForUser( | 97 void FakeSessionManagerClient::RetrievePolicyForUser( |
| 97 const std::string& username, | 98 const cryptohome::Identification& cryptohome_id, |
| 98 const RetrievePolicyCallback& callback) { | 99 const RetrievePolicyCallback& callback) { |
| 99 base::ThreadTaskRunnerHandle::Get()->PostTask( | 100 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 100 FROM_HERE, base::Bind(callback, user_policies_[username])); | 101 FROM_HERE, base::Bind(callback, user_policies_[cryptohome_id])); |
| 101 } | 102 } |
| 102 | 103 |
| 103 std::string FakeSessionManagerClient::BlockingRetrievePolicyForUser( | 104 std::string FakeSessionManagerClient::BlockingRetrievePolicyForUser( |
| 104 const std::string& username) { | 105 const cryptohome::Identification& cryptohome_id) { |
| 105 return user_policies_[username]; | 106 return user_policies_[cryptohome_id]; |
| 106 } | 107 } |
| 107 | 108 |
| 108 void FakeSessionManagerClient::RetrieveDeviceLocalAccountPolicy( | 109 void FakeSessionManagerClient::RetrieveDeviceLocalAccountPolicy( |
| 109 const std::string& account_id, | 110 const std::string& account_id, |
| 110 const RetrievePolicyCallback& callback) { | 111 const RetrievePolicyCallback& callback) { |
| 111 base::ThreadTaskRunnerHandle::Get()->PostTask( | 112 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 112 FROM_HERE, | 113 FROM_HERE, |
| 113 base::Bind(callback, device_local_account_policy_[account_id])); | 114 base::Bind(callback, device_local_account_policy_[account_id])); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void FakeSessionManagerClient::StoreDevicePolicy( | 117 void FakeSessionManagerClient::StoreDevicePolicy( |
| 117 const std::string& policy_blob, | 118 const std::string& policy_blob, |
| 118 const StorePolicyCallback& callback) { | 119 const StorePolicyCallback& callback) { |
| 119 device_policy_ = policy_blob; | 120 device_policy_ = policy_blob; |
| 120 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 121 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 121 base::Bind(callback, true)); | 122 base::Bind(callback, true)); |
| 122 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(true)); | 123 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(true)); |
| 123 } | 124 } |
| 124 | 125 |
| 125 void FakeSessionManagerClient::StorePolicyForUser( | 126 void FakeSessionManagerClient::StorePolicyForUser( |
| 126 const std::string& username, | 127 const cryptohome::Identification& cryptohome_id, |
| 127 const std::string& policy_blob, | 128 const std::string& policy_blob, |
| 128 const StorePolicyCallback& callback) { | 129 const StorePolicyCallback& callback) { |
| 129 user_policies_[username] = policy_blob; | 130 user_policies_[cryptohome_id] = policy_blob; |
| 130 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 131 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 131 base::Bind(callback, true)); | 132 base::Bind(callback, true)); |
| 132 } | 133 } |
| 133 | 134 |
| 134 void FakeSessionManagerClient::StoreDeviceLocalAccountPolicy( | 135 void FakeSessionManagerClient::StoreDeviceLocalAccountPolicy( |
| 135 const std::string& account_id, | 136 const std::string& account_id, |
| 136 const std::string& policy_blob, | 137 const std::string& policy_blob, |
| 137 const StorePolicyCallback& callback) { | 138 const StorePolicyCallback& callback) { |
| 138 device_local_account_policy_[account_id] = policy_blob; | 139 device_local_account_policy_[account_id] = policy_blob; |
| 139 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 140 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 140 base::Bind(callback, true)); | 141 base::Bind(callback, true)); |
| 141 } | 142 } |
| 142 | 143 |
| 143 void FakeSessionManagerClient::SetFlagsForUser( | 144 void FakeSessionManagerClient::SetFlagsForUser( |
| 144 const std::string& username, | 145 const cryptohome::Identification& cryptohome_id, |
| 145 const std::vector<std::string>& flags) { | 146 const std::vector<std::string>& flags) {} |
| 146 } | |
| 147 | 147 |
| 148 void FakeSessionManagerClient::GetServerBackedStateKeys( | 148 void FakeSessionManagerClient::GetServerBackedStateKeys( |
| 149 const StateKeysCallback& callback) { | 149 const StateKeysCallback& callback) { |
| 150 base::ThreadTaskRunnerHandle::Get()->PostTask( | 150 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 151 FROM_HERE, base::Bind(callback, server_backed_state_keys_)); | 151 FROM_HERE, base::Bind(callback, server_backed_state_keys_)); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void FakeSessionManagerClient::CheckArcAvailability( | 154 void FakeSessionManagerClient::CheckArcAvailability( |
| 155 const ArcCallback& callback) { | 155 const ArcCallback& callback) { |
| 156 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 156 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 171 const std::string& FakeSessionManagerClient::device_policy() const { | 171 const std::string& FakeSessionManagerClient::device_policy() const { |
| 172 return device_policy_; | 172 return device_policy_; |
| 173 } | 173 } |
| 174 | 174 |
| 175 void FakeSessionManagerClient::set_device_policy( | 175 void FakeSessionManagerClient::set_device_policy( |
| 176 const std::string& policy_blob) { | 176 const std::string& policy_blob) { |
| 177 device_policy_ = policy_blob; | 177 device_policy_ = policy_blob; |
| 178 } | 178 } |
| 179 | 179 |
| 180 const std::string& FakeSessionManagerClient::user_policy( | 180 const std::string& FakeSessionManagerClient::user_policy( |
| 181 const std::string& username) const { | 181 const cryptohome::Identification& cryptohome_id) const { |
| 182 std::map<std::string, std::string>::const_iterator it = | 182 std::map<cryptohome::Identification, std::string>::const_iterator it = |
| 183 user_policies_.find(username); | 183 user_policies_.find(cryptohome_id); |
| 184 return it == user_policies_.end() ? base::EmptyString() : it->second; | 184 return it == user_policies_.end() ? base::EmptyString() : it->second; |
| 185 } | 185 } |
| 186 | 186 |
| 187 void FakeSessionManagerClient::set_user_policy(const std::string& username, | 187 void FakeSessionManagerClient::set_user_policy( |
| 188 const std::string& policy_blob) { | 188 const cryptohome::Identification& cryptohome_id, |
| 189 user_policies_[username] = policy_blob; | 189 const std::string& policy_blob) { |
| 190 user_policies_[cryptohome_id] = policy_blob; |
| 190 } | 191 } |
| 191 | 192 |
| 192 const std::string& FakeSessionManagerClient::device_local_account_policy( | 193 const std::string& FakeSessionManagerClient::device_local_account_policy( |
| 193 const std::string& account_id) const { | 194 const std::string& account_id) const { |
| 194 std::map<std::string, std::string>::const_iterator entry = | 195 std::map<std::string, std::string>::const_iterator entry = |
| 195 device_local_account_policy_.find(account_id); | 196 device_local_account_policy_.find(account_id); |
| 196 return entry != device_local_account_policy_.end() ? entry->second | 197 return entry != device_local_account_policy_.end() ? entry->second |
| 197 : base::EmptyString(); | 198 : base::EmptyString(); |
| 198 } | 199 } |
| 199 | 200 |
| 200 void FakeSessionManagerClient::set_device_local_account_policy( | 201 void FakeSessionManagerClient::set_device_local_account_policy( |
| 201 const std::string& account_id, | 202 const std::string& account_id, |
| 202 const std::string& policy_blob) { | 203 const std::string& policy_blob) { |
| 203 device_local_account_policy_[account_id] = policy_blob; | 204 device_local_account_policy_[account_id] = policy_blob; |
| 204 } | 205 } |
| 205 | 206 |
| 206 void FakeSessionManagerClient::OnPropertyChangeComplete(bool success) { | 207 void FakeSessionManagerClient::OnPropertyChangeComplete(bool success) { |
| 207 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(success)); | 208 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(success)); |
| 208 } | 209 } |
| 209 | 210 |
| 210 } // namespace chromeos | 211 } // namespace chromeos |
| OLD | NEW |