Add type annotations to exif_parser.js.
[chromium-blink-merge.git] / chromeos / dbus / fake_session_manager_client.cc
blobf16e9c612595a58b6b8d8202387a2ae166d8e7e9
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/message_loop.h"
10 #include "base/strings/string_util.h"
11 #include "chromeos/dbus/cryptohome_client.h"
13 namespace chromeos {
15 FakeSessionManagerClient::FakeSessionManagerClient()
16 : start_device_wipe_call_count_(0),
17 notify_lock_screen_shown_call_count_(0),
18 notify_lock_screen_dismissed_call_count_(0) {
21 FakeSessionManagerClient::~FakeSessionManagerClient() {
24 void FakeSessionManagerClient::Init(dbus::Bus* bus) {
27 void FakeSessionManagerClient::SetStubDelegate(StubDelegate* delegate) {
30 void FakeSessionManagerClient::AddObserver(Observer* observer) {
31 observers_.AddObserver(observer);
34 void FakeSessionManagerClient::RemoveObserver(Observer* observer) {
35 observers_.RemoveObserver(observer);
38 bool FakeSessionManagerClient::HasObserver(const Observer* observer) const {
39 return observers_.HasObserver(observer);
42 void FakeSessionManagerClient::EmitLoginPromptVisible() {
45 void FakeSessionManagerClient::RestartJob(int pid,
46 const std::string& command_line) {
49 void FakeSessionManagerClient::StartSession(const std::string& user_email) {
50 DCHECK_EQ(0UL, user_sessions_.count(user_email));
51 std::string user_id_hash =
52 CryptohomeClient::GetStubSanitizedUsername(user_email);
53 user_sessions_[user_email] = user_id_hash;
56 void FakeSessionManagerClient::StopSession() {
59 void FakeSessionManagerClient::NotifySupervisedUserCreationStarted() {
62 void FakeSessionManagerClient::NotifySupervisedUserCreationFinished() {
65 void FakeSessionManagerClient::StartDeviceWipe() {
66 start_device_wipe_call_count_++;
69 void FakeSessionManagerClient::RequestLockScreen() {
72 void FakeSessionManagerClient::NotifyLockScreenShown() {
73 notify_lock_screen_shown_call_count_++;
76 void FakeSessionManagerClient::NotifyLockScreenDismissed() {
77 notify_lock_screen_dismissed_call_count_++;
80 void FakeSessionManagerClient::RetrieveActiveSessions(
81 const ActiveSessionsCallback& callback) {
82 base::MessageLoop::current()->PostTask(
83 FROM_HERE, base::Bind(callback, user_sessions_, true));
86 void FakeSessionManagerClient::RetrieveDevicePolicy(
87 const RetrievePolicyCallback& callback) {
88 base::MessageLoop::current()->PostTask(FROM_HERE,
89 base::Bind(callback, device_policy_));
92 void FakeSessionManagerClient::RetrievePolicyForUser(
93 const std::string& username,
94 const RetrievePolicyCallback& callback) {
95 base::MessageLoop::current()->PostTask(
96 FROM_HERE, base::Bind(callback, user_policies_[username]));
99 std::string FakeSessionManagerClient::BlockingRetrievePolicyForUser(
100 const std::string& username) {
101 return user_policies_[username];
104 void FakeSessionManagerClient::RetrieveDeviceLocalAccountPolicy(
105 const std::string& account_id,
106 const RetrievePolicyCallback& callback) {
107 base::MessageLoop::current()->PostTask(
108 FROM_HERE,
109 base::Bind(callback, device_local_account_policy_[account_id]));
112 void FakeSessionManagerClient::StoreDevicePolicy(
113 const std::string& policy_blob,
114 const StorePolicyCallback& callback) {
115 device_policy_ = policy_blob;
116 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true));
117 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(true));
120 void FakeSessionManagerClient::StorePolicyForUser(
121 const std::string& username,
122 const std::string& policy_blob,
123 const StorePolicyCallback& callback) {
124 user_policies_[username] = policy_blob;
125 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true));
128 void FakeSessionManagerClient::StoreDeviceLocalAccountPolicy(
129 const std::string& account_id,
130 const std::string& policy_blob,
131 const StorePolicyCallback& callback) {
132 device_local_account_policy_[account_id] = policy_blob;
133 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true));
136 void FakeSessionManagerClient::SetFlagsForUser(
137 const std::string& username,
138 const std::vector<std::string>& flags) {
141 void FakeSessionManagerClient::GetServerBackedStateKeys(
142 const StateKeysCallback& callback) {
143 base::MessageLoop::current()->PostTask(
144 FROM_HERE, base::Bind(callback, server_backed_state_keys_));
147 const std::string& FakeSessionManagerClient::device_policy() const {
148 return device_policy_;
151 void FakeSessionManagerClient::set_device_policy(
152 const std::string& policy_blob) {
153 device_policy_ = policy_blob;
156 const std::string& FakeSessionManagerClient::user_policy(
157 const std::string& username) const {
158 std::map<std::string, std::string>::const_iterator it =
159 user_policies_.find(username);
160 return it == user_policies_.end() ? base::EmptyString() : it->second;
163 void FakeSessionManagerClient::set_user_policy(const std::string& username,
164 const std::string& policy_blob) {
165 user_policies_[username] = policy_blob;
168 const std::string& FakeSessionManagerClient::device_local_account_policy(
169 const std::string& account_id) const {
170 std::map<std::string, std::string>::const_iterator entry =
171 device_local_account_policy_.find(account_id);
172 return entry != device_local_account_policy_.end() ? entry->second
173 : base::EmptyString();
176 void FakeSessionManagerClient::set_device_local_account_policy(
177 const std::string& account_id,
178 const std::string& policy_blob) {
179 device_local_account_policy_[account_id] = policy_blob;
182 void FakeSessionManagerClient::OnPropertyChangeComplete(bool success) {
183 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(success));
186 } // namespace chromeos