Chromium Code Reviews| Index: chromeos/dbus/fake_session_manager_client.cc |
| diff --git a/chromeos/dbus/fake_session_manager_client.cc b/chromeos/dbus/fake_session_manager_client.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..43e42df54beee195bbfb01decabee78acf27701e |
| --- /dev/null |
| +++ b/chromeos/dbus/fake_session_manager_client.cc |
| @@ -0,0 +1,143 @@ |
| +// Copyright 2013 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_session_manager_client.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/location.h" |
| +#include "base/message_loop.h" |
| +#include "base/string_util.h" |
| + |
| +namespace chromeos { |
| + |
| +FakeSessionManagerClient::FakeSessionManagerClient() { |
| +} |
| + |
| +FakeSessionManagerClient::~FakeSessionManagerClient() { |
| +} |
| + |
| +void FakeSessionManagerClient::AddObserver(Observer* observer) { |
| + observers_.AddObserver(observer); |
| +} |
| + |
| +void FakeSessionManagerClient::RemoveObserver(Observer* observer) { |
| + observers_.RemoveObserver(observer); |
| +} |
| + |
| +bool FakeSessionManagerClient::HasObserver(Observer* observer) { |
| + return observers_.HasObserver(observer); |
| +} |
| + |
| +void FakeSessionManagerClient::EmitLoginPromptReady() { |
| +} |
| + |
| +void FakeSessionManagerClient::EmitLoginPromptVisible() { |
| +} |
| + |
| +void FakeSessionManagerClient::RestartJob(int pid, |
| + const std::string& command_line) { |
| +} |
| + |
| +void FakeSessionManagerClient::RestartEntd() { |
| +} |
| + |
| +void FakeSessionManagerClient::StartSession(const std::string& user_email) { |
| +} |
| + |
| +void FakeSessionManagerClient::StopSession() { |
| +} |
| + |
| +void FakeSessionManagerClient::StartDeviceWipe() { |
| +} |
| + |
| +void FakeSessionManagerClient::RequestLockScreen() { |
| +} |
| + |
| +void FakeSessionManagerClient::NotifyLockScreenShown() { |
| +} |
| + |
| +void FakeSessionManagerClient::RequestUnlockScreen() { |
| +} |
| + |
| +void FakeSessionManagerClient::NotifyLockScreenDismissed() { |
| +} |
| + |
| +void FakeSessionManagerClient::RetrieveDevicePolicy( |
| + const RetrievePolicyCallback& callback) { |
| + MessageLoop::current()->PostTask(FROM_HERE, |
| + base::Bind(callback, device_policy_)); |
| +} |
| + |
| +void FakeSessionManagerClient::RetrieveUserPolicy( |
| + const RetrievePolicyCallback& callback) { |
| + MessageLoop::current()->PostTask(FROM_HERE, |
| + base::Bind(callback, user_policy_)); |
| +} |
| + |
| +void FakeSessionManagerClient::RetrieveDeviceLocalAccountPolicy( |
| + const std::string& account_id, |
| + const RetrievePolicyCallback& callback) { |
| + MessageLoop::current()->PostTask( |
| + FROM_HERE, |
| + base::Bind(callback, device_local_account_policy_[account_id])); |
| +} |
| + |
| +void FakeSessionManagerClient::StoreDevicePolicy(const std::string& policy_blob, |
| + const StorePolicyCallback& callback) { |
|
Mattias Nissler (ping if slow)
2013/03/11 16:26:59
nit: indentation
dconnelly
2013/03/11 17:34:32
Done.
|
| + device_policy_ = policy_blob; |
| + MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); |
| + FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(true)); |
| +} |
| + |
| +void FakeSessionManagerClient::StoreUserPolicy(const std::string& policy_blob, |
| + const StorePolicyCallback& callback) { |
|
Mattias Nissler (ping if slow)
2013/03/11 16:26:59
nit: indentation
dconnelly
2013/03/11 17:34:32
Done.
|
| + user_policy_ = policy_blob; |
| + MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); |
| + FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(true)); |
|
Mattias Nissler (ping if slow)
2013/03/11 16:26:59
This shouldn't send PropertyChangeComplete, that s
dconnelly
2013/03/11 17:34:32
Done.
|
| +} |
| + |
| +void FakeSessionManagerClient::StoreDeviceLocalAccountPolicy( |
| + const std::string& account_id, |
| + const std::string& policy_blob, |
| + const StorePolicyCallback& callback) { |
| + device_local_account_policy_[account_id] = policy_blob; |
| + MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); |
| + FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(true)); |
|
Mattias Nissler (ping if slow)
2013/03/11 16:26:59
ditto
dconnelly
2013/03/11 17:34:32
Done.
|
| +} |
| + |
| +const std::string& FakeSessionManagerClient::device_policy() const { |
| + return device_policy_; |
| +} |
| + |
| +void FakeSessionManagerClient::set_device_policy( |
| + const std::string& policy_blob) { |
| + device_policy_ = policy_blob; |
| + FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(true)); |
|
Mattias Nissler (ping if slow)
2013/03/11 16:26:59
Not sure this is a good idea for existing tests, i
dconnelly
2013/03/11 17:34:32
Done.
|
| +} |
| + |
| +const std::string& FakeSessionManagerClient::user_policy() const { |
| + return user_policy_; |
| +} |
| + |
| +void FakeSessionManagerClient::set_user_policy(const std::string& policy_blob) { |
| + user_policy_ = policy_blob; |
| + FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(true)); |
|
Mattias Nissler (ping if slow)
2013/03/11 16:26:59
only for device policy again
dconnelly
2013/03/11 17:34:32
Done.
|
| +} |
| + |
| +const std::string& FakeSessionManagerClient::device_local_account_policy( |
| + const std::string& account_id) const { |
| + std::map<std::string, std::string>::const_iterator entry = |
| + device_local_account_policy_.find(account_id); |
| + return entry != device_local_account_policy_.end() ? entry->second |
| + : EmptyString(); |
| +} |
| + |
| +void FakeSessionManagerClient::set_device_local_account_policy( |
| + const std::string& account_id, |
| + const std::string& policy_blob) { |
| + device_local_account_policy_[account_id] = policy_blob; |
| + FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(true)); |
|
Mattias Nissler (ping if slow)
2013/03/11 16:26:59
ditto
dconnelly
2013/03/11 17:34:32
Done.
|
| +} |
| + |
| +} // namespace chromeos |