Don't preload rarely seen large images
[chromium-blink-merge.git] / chromeos / dbus / fake_session_manager_client.cc
blobc1745cf8278afcfbb154a2d0d5e3b7e74cd0526c
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/single_thread_task_runner.h"
10 #include "base/strings/string_util.h"
11 #include "base/thread_task_runner_handle.h"
12 #include "chromeos/dbus/cryptohome_client.h"
14 namespace chromeos {
16 FakeSessionManagerClient::FakeSessionManagerClient()
17 : start_device_wipe_call_count_(0),
18 notify_lock_screen_shown_call_count_(0),
19 notify_lock_screen_dismissed_call_count_(0) {
22 FakeSessionManagerClient::~FakeSessionManagerClient() {
25 void FakeSessionManagerClient::Init(dbus::Bus* bus) {
28 void FakeSessionManagerClient::SetStubDelegate(StubDelegate* delegate) {
31 void FakeSessionManagerClient::AddObserver(Observer* observer) {
32 observers_.AddObserver(observer);
35 void FakeSessionManagerClient::RemoveObserver(Observer* observer) {
36 observers_.RemoveObserver(observer);
39 bool FakeSessionManagerClient::HasObserver(const Observer* observer) const {
40 return observers_.HasObserver(observer);
43 bool FakeSessionManagerClient::IsScreenLocked() const {
44 return false;
47 void FakeSessionManagerClient::EmitLoginPromptVisible() {
50 void FakeSessionManagerClient::RestartJob(int pid,
51 const std::string& command_line) {
54 void FakeSessionManagerClient::StartSession(const std::string& user_email) {
55 DCHECK_EQ(0UL, user_sessions_.count(user_email));
56 std::string user_id_hash =
57 CryptohomeClient::GetStubSanitizedUsername(user_email);
58 user_sessions_[user_email] = user_id_hash;
61 void FakeSessionManagerClient::StopSession() {
64 void FakeSessionManagerClient::NotifySupervisedUserCreationStarted() {
67 void FakeSessionManagerClient::NotifySupervisedUserCreationFinished() {
70 void FakeSessionManagerClient::StartDeviceWipe() {
71 start_device_wipe_call_count_++;
74 void FakeSessionManagerClient::RequestLockScreen() {
77 void FakeSessionManagerClient::NotifyLockScreenShown() {
78 notify_lock_screen_shown_call_count_++;
81 void FakeSessionManagerClient::NotifyLockScreenDismissed() {
82 notify_lock_screen_dismissed_call_count_++;
85 void FakeSessionManagerClient::RetrieveActiveSessions(
86 const ActiveSessionsCallback& callback) {
87 base::ThreadTaskRunnerHandle::Get()->PostTask(
88 FROM_HERE, base::Bind(callback, user_sessions_, true));
91 void FakeSessionManagerClient::RetrieveDevicePolicy(
92 const RetrievePolicyCallback& callback) {
93 base::ThreadTaskRunnerHandle::Get()->PostTask(
94 FROM_HERE, base::Bind(callback, device_policy_));
97 void FakeSessionManagerClient::RetrievePolicyForUser(
98 const std::string& username,
99 const RetrievePolicyCallback& callback) {
100 base::ThreadTaskRunnerHandle::Get()->PostTask(
101 FROM_HERE, base::Bind(callback, user_policies_[username]));
104 std::string FakeSessionManagerClient::BlockingRetrievePolicyForUser(
105 const std::string& username) {
106 return user_policies_[username];
109 void FakeSessionManagerClient::RetrieveDeviceLocalAccountPolicy(
110 const std::string& account_id,
111 const RetrievePolicyCallback& callback) {
112 base::ThreadTaskRunnerHandle::Get()->PostTask(
113 FROM_HERE,
114 base::Bind(callback, device_local_account_policy_[account_id]));
117 void FakeSessionManagerClient::StoreDevicePolicy(
118 const std::string& policy_blob,
119 const StorePolicyCallback& callback) {
120 device_policy_ = policy_blob;
121 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
122 base::Bind(callback, true));
123 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(true));
126 void FakeSessionManagerClient::StorePolicyForUser(
127 const std::string& username,
128 const std::string& policy_blob,
129 const StorePolicyCallback& callback) {
130 user_policies_[username] = policy_blob;
131 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
132 base::Bind(callback, true));
135 void FakeSessionManagerClient::StoreDeviceLocalAccountPolicy(
136 const std::string& account_id,
137 const std::string& policy_blob,
138 const StorePolicyCallback& callback) {
139 device_local_account_policy_[account_id] = policy_blob;
140 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
141 base::Bind(callback, true));
144 void FakeSessionManagerClient::SetFlagsForUser(
145 const std::string& username,
146 const std::vector<std::string>& flags) {
149 void FakeSessionManagerClient::GetServerBackedStateKeys(
150 const StateKeysCallback& callback) {
151 base::ThreadTaskRunnerHandle::Get()->PostTask(
152 FROM_HERE, base::Bind(callback, server_backed_state_keys_));
155 const std::string& FakeSessionManagerClient::device_policy() const {
156 return device_policy_;
159 void FakeSessionManagerClient::set_device_policy(
160 const std::string& policy_blob) {
161 device_policy_ = policy_blob;
164 const std::string& FakeSessionManagerClient::user_policy(
165 const std::string& username) const {
166 std::map<std::string, std::string>::const_iterator it =
167 user_policies_.find(username);
168 return it == user_policies_.end() ? base::EmptyString() : it->second;
171 void FakeSessionManagerClient::set_user_policy(const std::string& username,
172 const std::string& policy_blob) {
173 user_policies_[username] = policy_blob;
176 const std::string& FakeSessionManagerClient::device_local_account_policy(
177 const std::string& account_id) const {
178 std::map<std::string, std::string>::const_iterator entry =
179 device_local_account_policy_.find(account_id);
180 return entry != device_local_account_policy_.end() ? entry->second
181 : base::EmptyString();
184 void FakeSessionManagerClient::set_device_local_account_policy(
185 const std::string& account_id,
186 const std::string& policy_blob) {
187 device_local_account_policy_[account_id] = policy_blob;
190 void FakeSessionManagerClient::OnPropertyChangeComplete(bool success) {
191 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(success));
194 } // namespace chromeos