Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / chromeos / dbus / fake_session_manager_client.cc
blob2b671ec06a5bde71ede269db89f8ca83ad65cf01
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
3 // found in the LICENSE file.
5 #include "chromeos/dbus/fake_session_manager_client.h"
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/message_loop.h"
10 #include "base/string_util.h"
12 namespace chromeos {
14 FakeSessionManagerClient::FakeSessionManagerClient() {
17 FakeSessionManagerClient::~FakeSessionManagerClient() {
20 void FakeSessionManagerClient::AddObserver(Observer* observer) {
21 observers_.AddObserver(observer);
24 void FakeSessionManagerClient::RemoveObserver(Observer* observer) {
25 observers_.RemoveObserver(observer);
28 bool FakeSessionManagerClient::HasObserver(Observer* observer) {
29 return observers_.HasObserver(observer);
32 void FakeSessionManagerClient::EmitLoginPromptReady() {
35 void FakeSessionManagerClient::EmitLoginPromptVisible() {
38 void FakeSessionManagerClient::RestartJob(int pid,
39 const std::string& command_line) {
42 void FakeSessionManagerClient::RestartEntd() {
45 void FakeSessionManagerClient::StartSession(const std::string& user_email) {
48 void FakeSessionManagerClient::StopSession() {
51 void FakeSessionManagerClient::StartDeviceWipe() {
54 void FakeSessionManagerClient::RequestLockScreen() {
57 void FakeSessionManagerClient::NotifyLockScreenShown() {
60 void FakeSessionManagerClient::RequestUnlockScreen() {
63 void FakeSessionManagerClient::NotifyLockScreenDismissed() {
66 void FakeSessionManagerClient::RetrieveDevicePolicy(
67 const RetrievePolicyCallback& callback) {
68 MessageLoop::current()->PostTask(FROM_HERE,
69 base::Bind(callback, device_policy_));
72 void FakeSessionManagerClient::RetrieveUserPolicy(
73 const RetrievePolicyCallback& callback) {
74 MessageLoop::current()->PostTask(FROM_HERE,
75 base::Bind(callback, user_policy_));
78 void FakeSessionManagerClient::RetrieveDeviceLocalAccountPolicy(
79 const std::string& account_id,
80 const RetrievePolicyCallback& callback) {
81 MessageLoop::current()->PostTask(
82 FROM_HERE,
83 base::Bind(callback, device_local_account_policy_[account_id]));
86 void FakeSessionManagerClient::StoreDevicePolicy(
87 const std::string& policy_blob,
88 const StorePolicyCallback& callback) {
89 device_policy_ = policy_blob;
90 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true));
91 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(true));
94 void FakeSessionManagerClient::StoreUserPolicy(
95 const std::string& policy_blob,
96 const StorePolicyCallback& callback) {
97 user_policy_ = policy_blob;
98 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true));
101 void FakeSessionManagerClient::StoreDeviceLocalAccountPolicy(
102 const std::string& account_id,
103 const std::string& policy_blob,
104 const StorePolicyCallback& callback) {
105 device_local_account_policy_[account_id] = policy_blob;
106 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true));
109 const std::string& FakeSessionManagerClient::device_policy() const {
110 return device_policy_;
113 void FakeSessionManagerClient::set_device_policy(
114 const std::string& policy_blob) {
115 device_policy_ = policy_blob;
118 const std::string& FakeSessionManagerClient::user_policy() const {
119 return user_policy_;
122 void FakeSessionManagerClient::set_user_policy(const std::string& policy_blob) {
123 user_policy_ = policy_blob;
126 const std::string& FakeSessionManagerClient::device_local_account_policy(
127 const std::string& account_id) const {
128 std::map<std::string, std::string>::const_iterator entry =
129 device_local_account_policy_.find(account_id);
130 return entry != device_local_account_policy_.end() ? entry->second
131 : EmptyString();
134 void FakeSessionManagerClient::set_device_local_account_policy(
135 const std::string& account_id,
136 const std::string& policy_blob) {
137 device_local_account_policy_[account_id] = policy_blob;
140 void FakeSessionManagerClient::OnPropertyChangeComplete(bool success) {
141 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(success));
144 } // namespace chromeos