OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/session_manager_client.h" | 5 #include "chromeos/dbus/session_manager_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 class SessionManagerClientImpl : public SessionManagerClient { | 65 class SessionManagerClientImpl : public SessionManagerClient { |
66 public: | 66 public: |
67 SessionManagerClientImpl() | 67 SessionManagerClientImpl() |
68 : session_manager_proxy_(NULL), | 68 : session_manager_proxy_(NULL), |
69 weak_ptr_factory_(this) {} | 69 weak_ptr_factory_(this) {} |
70 | 70 |
71 virtual ~SessionManagerClientImpl() { | 71 virtual ~SessionManagerClientImpl() { |
72 } | 72 } |
73 | 73 |
74 // SessionManagerClient overrides: | 74 // SessionManagerClient overrides: |
75 virtual void SetStubDelegate(StubDelegate* delegate) OVERRIDE { | 75 virtual void SetStubDelegate(StubDelegate* delegate) override { |
76 // Do nothing; this isn't a stub implementation. | 76 // Do nothing; this isn't a stub implementation. |
77 } | 77 } |
78 | 78 |
79 virtual void AddObserver(Observer* observer) OVERRIDE { | 79 virtual void AddObserver(Observer* observer) override { |
80 observers_.AddObserver(observer); | 80 observers_.AddObserver(observer); |
81 } | 81 } |
82 | 82 |
83 virtual void RemoveObserver(Observer* observer) OVERRIDE { | 83 virtual void RemoveObserver(Observer* observer) override { |
84 observers_.RemoveObserver(observer); | 84 observers_.RemoveObserver(observer); |
85 } | 85 } |
86 | 86 |
87 virtual bool HasObserver(Observer* observer) OVERRIDE { | 87 virtual bool HasObserver(Observer* observer) override { |
88 return observers_.HasObserver(observer); | 88 return observers_.HasObserver(observer); |
89 } | 89 } |
90 | 90 |
91 virtual void EmitLoginPromptVisible() OVERRIDE { | 91 virtual void EmitLoginPromptVisible() override { |
92 SimpleMethodCallToSessionManager( | 92 SimpleMethodCallToSessionManager( |
93 login_manager::kSessionManagerEmitLoginPromptVisible); | 93 login_manager::kSessionManagerEmitLoginPromptVisible); |
94 FOR_EACH_OBSERVER(Observer, observers_, EmitLoginPromptVisibleCalled()); | 94 FOR_EACH_OBSERVER(Observer, observers_, EmitLoginPromptVisibleCalled()); |
95 } | 95 } |
96 | 96 |
97 virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE { | 97 virtual void RestartJob(int pid, const std::string& command_line) override { |
98 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 98 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
99 login_manager::kSessionManagerRestartJob); | 99 login_manager::kSessionManagerRestartJob); |
100 dbus::MessageWriter writer(&method_call); | 100 dbus::MessageWriter writer(&method_call); |
101 writer.AppendInt32(pid); | 101 writer.AppendInt32(pid); |
102 writer.AppendString(command_line); | 102 writer.AppendString(command_line); |
103 session_manager_proxy_->CallMethod( | 103 session_manager_proxy_->CallMethod( |
104 &method_call, | 104 &method_call, |
105 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 105 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
106 base::Bind(&SessionManagerClientImpl::OnRestartJob, | 106 base::Bind(&SessionManagerClientImpl::OnRestartJob, |
107 weak_ptr_factory_.GetWeakPtr())); | 107 weak_ptr_factory_.GetWeakPtr())); |
108 } | 108 } |
109 | 109 |
110 virtual void StartSession(const std::string& user_email) OVERRIDE { | 110 virtual void StartSession(const std::string& user_email) override { |
111 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 111 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
112 login_manager::kSessionManagerStartSession); | 112 login_manager::kSessionManagerStartSession); |
113 dbus::MessageWriter writer(&method_call); | 113 dbus::MessageWriter writer(&method_call); |
114 writer.AppendString(user_email); | 114 writer.AppendString(user_email); |
115 writer.AppendString(""); // Unique ID is deprecated | 115 writer.AppendString(""); // Unique ID is deprecated |
116 session_manager_proxy_->CallMethod( | 116 session_manager_proxy_->CallMethod( |
117 &method_call, | 117 &method_call, |
118 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 118 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
119 base::Bind(&SessionManagerClientImpl::OnStartSession, | 119 base::Bind(&SessionManagerClientImpl::OnStartSession, |
120 weak_ptr_factory_.GetWeakPtr())); | 120 weak_ptr_factory_.GetWeakPtr())); |
121 } | 121 } |
122 | 122 |
123 virtual void StopSession() OVERRIDE { | 123 virtual void StopSession() override { |
124 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 124 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
125 login_manager::kSessionManagerStopSession); | 125 login_manager::kSessionManagerStopSession); |
126 dbus::MessageWriter writer(&method_call); | 126 dbus::MessageWriter writer(&method_call); |
127 writer.AppendString(""); // Unique ID is deprecated | 127 writer.AppendString(""); // Unique ID is deprecated |
128 session_manager_proxy_->CallMethod( | 128 session_manager_proxy_->CallMethod( |
129 &method_call, | 129 &method_call, |
130 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 130 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
131 base::Bind(&SessionManagerClientImpl::OnStopSession, | 131 base::Bind(&SessionManagerClientImpl::OnStopSession, |
132 weak_ptr_factory_.GetWeakPtr())); | 132 weak_ptr_factory_.GetWeakPtr())); |
133 } | 133 } |
134 | 134 |
135 virtual void StartDeviceWipe() OVERRIDE { | 135 virtual void StartDeviceWipe() override { |
136 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 136 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
137 login_manager::kSessionManagerStartDeviceWipe); | 137 login_manager::kSessionManagerStartDeviceWipe); |
138 session_manager_proxy_->CallMethod( | 138 session_manager_proxy_->CallMethod( |
139 &method_call, | 139 &method_call, |
140 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 140 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
141 base::Bind(&SessionManagerClientImpl::OnDeviceWipe, | 141 base::Bind(&SessionManagerClientImpl::OnDeviceWipe, |
142 weak_ptr_factory_.GetWeakPtr())); | 142 weak_ptr_factory_.GetWeakPtr())); |
143 } | 143 } |
144 | 144 |
145 virtual void RequestLockScreen() OVERRIDE { | 145 virtual void RequestLockScreen() override { |
146 SimpleMethodCallToSessionManager(login_manager::kSessionManagerLockScreen); | 146 SimpleMethodCallToSessionManager(login_manager::kSessionManagerLockScreen); |
147 } | 147 } |
148 | 148 |
149 virtual void NotifyLockScreenShown() OVERRIDE { | 149 virtual void NotifyLockScreenShown() override { |
150 SimpleMethodCallToSessionManager( | 150 SimpleMethodCallToSessionManager( |
151 login_manager::kSessionManagerHandleLockScreenShown); | 151 login_manager::kSessionManagerHandleLockScreenShown); |
152 } | 152 } |
153 | 153 |
154 virtual void NotifyLockScreenDismissed() OVERRIDE { | 154 virtual void NotifyLockScreenDismissed() override { |
155 SimpleMethodCallToSessionManager( | 155 SimpleMethodCallToSessionManager( |
156 login_manager::kSessionManagerHandleLockScreenDismissed); | 156 login_manager::kSessionManagerHandleLockScreenDismissed); |
157 } | 157 } |
158 | 158 |
159 virtual void RetrieveActiveSessions( | 159 virtual void RetrieveActiveSessions( |
160 const ActiveSessionsCallback& callback) OVERRIDE { | 160 const ActiveSessionsCallback& callback) override { |
161 dbus::MethodCall method_call( | 161 dbus::MethodCall method_call( |
162 login_manager::kSessionManagerInterface, | 162 login_manager::kSessionManagerInterface, |
163 login_manager::kSessionManagerRetrieveActiveSessions); | 163 login_manager::kSessionManagerRetrieveActiveSessions); |
164 | 164 |
165 session_manager_proxy_->CallMethod( | 165 session_manager_proxy_->CallMethod( |
166 &method_call, | 166 &method_call, |
167 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 167 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
168 base::Bind(&SessionManagerClientImpl::OnRetrieveActiveSessions, | 168 base::Bind(&SessionManagerClientImpl::OnRetrieveActiveSessions, |
169 weak_ptr_factory_.GetWeakPtr(), | 169 weak_ptr_factory_.GetWeakPtr(), |
170 login_manager::kSessionManagerRetrieveActiveSessions, | 170 login_manager::kSessionManagerRetrieveActiveSessions, |
171 callback)); | 171 callback)); |
172 } | 172 } |
173 | 173 |
174 virtual void RetrieveDevicePolicy( | 174 virtual void RetrieveDevicePolicy( |
175 const RetrievePolicyCallback& callback) OVERRIDE { | 175 const RetrievePolicyCallback& callback) override { |
176 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 176 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
177 login_manager::kSessionManagerRetrievePolicy); | 177 login_manager::kSessionManagerRetrievePolicy); |
178 session_manager_proxy_->CallMethod( | 178 session_manager_proxy_->CallMethod( |
179 &method_call, | 179 &method_call, |
180 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 180 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
181 base::Bind(&SessionManagerClientImpl::OnRetrievePolicy, | 181 base::Bind(&SessionManagerClientImpl::OnRetrievePolicy, |
182 weak_ptr_factory_.GetWeakPtr(), | 182 weak_ptr_factory_.GetWeakPtr(), |
183 login_manager::kSessionManagerRetrievePolicy, | 183 login_manager::kSessionManagerRetrievePolicy, |
184 callback)); | 184 callback)); |
185 } | 185 } |
186 | 186 |
187 virtual void RetrievePolicyForUser( | 187 virtual void RetrievePolicyForUser( |
188 const std::string& username, | 188 const std::string& username, |
189 const RetrievePolicyCallback& callback) OVERRIDE { | 189 const RetrievePolicyCallback& callback) override { |
190 CallRetrievePolicyByUsername( | 190 CallRetrievePolicyByUsername( |
191 login_manager::kSessionManagerRetrievePolicyForUser, | 191 login_manager::kSessionManagerRetrievePolicyForUser, |
192 username, | 192 username, |
193 callback); | 193 callback); |
194 } | 194 } |
195 | 195 |
196 virtual std::string BlockingRetrievePolicyForUser( | 196 virtual std::string BlockingRetrievePolicyForUser( |
197 const std::string& username) OVERRIDE { | 197 const std::string& username) override { |
198 dbus::MethodCall method_call( | 198 dbus::MethodCall method_call( |
199 login_manager::kSessionManagerInterface, | 199 login_manager::kSessionManagerInterface, |
200 login_manager::kSessionManagerRetrievePolicyForUser); | 200 login_manager::kSessionManagerRetrievePolicyForUser); |
201 dbus::MessageWriter writer(&method_call); | 201 dbus::MessageWriter writer(&method_call); |
202 writer.AppendString(username); | 202 writer.AppendString(username); |
203 scoped_ptr<dbus::Response> response = | 203 scoped_ptr<dbus::Response> response = |
204 blocking_method_caller_->CallMethodAndBlock(&method_call); | 204 blocking_method_caller_->CallMethodAndBlock(&method_call); |
205 std::string policy; | 205 std::string policy; |
206 ExtractString(login_manager::kSessionManagerRetrievePolicyForUser, | 206 ExtractString(login_manager::kSessionManagerRetrievePolicyForUser, |
207 response.get(), | 207 response.get(), |
208 &policy); | 208 &policy); |
209 return policy; | 209 return policy; |
210 } | 210 } |
211 | 211 |
212 virtual void RetrieveDeviceLocalAccountPolicy( | 212 virtual void RetrieveDeviceLocalAccountPolicy( |
213 const std::string& account_name, | 213 const std::string& account_name, |
214 const RetrievePolicyCallback& callback) OVERRIDE { | 214 const RetrievePolicyCallback& callback) override { |
215 CallRetrievePolicyByUsername( | 215 CallRetrievePolicyByUsername( |
216 login_manager::kSessionManagerRetrieveDeviceLocalAccountPolicy, | 216 login_manager::kSessionManagerRetrieveDeviceLocalAccountPolicy, |
217 account_name, | 217 account_name, |
218 callback); | 218 callback); |
219 } | 219 } |
220 | 220 |
221 virtual void StoreDevicePolicy(const std::string& policy_blob, | 221 virtual void StoreDevicePolicy(const std::string& policy_blob, |
222 const StorePolicyCallback& callback) OVERRIDE { | 222 const StorePolicyCallback& callback) override { |
223 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 223 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
224 login_manager::kSessionManagerStorePolicy); | 224 login_manager::kSessionManagerStorePolicy); |
225 dbus::MessageWriter writer(&method_call); | 225 dbus::MessageWriter writer(&method_call); |
226 // static_cast does not work due to signedness. | 226 // static_cast does not work due to signedness. |
227 writer.AppendArrayOfBytes( | 227 writer.AppendArrayOfBytes( |
228 reinterpret_cast<const uint8*>(policy_blob.data()), policy_blob.size()); | 228 reinterpret_cast<const uint8*>(policy_blob.data()), policy_blob.size()); |
229 session_manager_proxy_->CallMethod( | 229 session_manager_proxy_->CallMethod( |
230 &method_call, | 230 &method_call, |
231 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 231 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
232 base::Bind(&SessionManagerClientImpl::OnStorePolicy, | 232 base::Bind(&SessionManagerClientImpl::OnStorePolicy, |
233 weak_ptr_factory_.GetWeakPtr(), | 233 weak_ptr_factory_.GetWeakPtr(), |
234 login_manager::kSessionManagerStorePolicy, | 234 login_manager::kSessionManagerStorePolicy, |
235 callback)); | 235 callback)); |
236 } | 236 } |
237 | 237 |
238 virtual void StorePolicyForUser( | 238 virtual void StorePolicyForUser( |
239 const std::string& username, | 239 const std::string& username, |
240 const std::string& policy_blob, | 240 const std::string& policy_blob, |
241 const StorePolicyCallback& callback) OVERRIDE { | 241 const StorePolicyCallback& callback) override { |
242 CallStorePolicyByUsername(login_manager::kSessionManagerStorePolicyForUser, | 242 CallStorePolicyByUsername(login_manager::kSessionManagerStorePolicyForUser, |
243 username, | 243 username, |
244 policy_blob, | 244 policy_blob, |
245 callback); | 245 callback); |
246 } | 246 } |
247 | 247 |
248 virtual void StoreDeviceLocalAccountPolicy( | 248 virtual void StoreDeviceLocalAccountPolicy( |
249 const std::string& account_name, | 249 const std::string& account_name, |
250 const std::string& policy_blob, | 250 const std::string& policy_blob, |
251 const StorePolicyCallback& callback) OVERRIDE { | 251 const StorePolicyCallback& callback) override { |
252 CallStorePolicyByUsername( | 252 CallStorePolicyByUsername( |
253 login_manager::kSessionManagerStoreDeviceLocalAccountPolicy, | 253 login_manager::kSessionManagerStoreDeviceLocalAccountPolicy, |
254 account_name, | 254 account_name, |
255 policy_blob, | 255 policy_blob, |
256 callback); | 256 callback); |
257 } | 257 } |
258 | 258 |
259 virtual void SetFlagsForUser(const std::string& username, | 259 virtual void SetFlagsForUser(const std::string& username, |
260 const std::vector<std::string>& flags) OVERRIDE { | 260 const std::vector<std::string>& flags) override { |
261 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 261 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
262 login_manager::kSessionManagerSetFlagsForUser); | 262 login_manager::kSessionManagerSetFlagsForUser); |
263 dbus::MessageWriter writer(&method_call); | 263 dbus::MessageWriter writer(&method_call); |
264 writer.AppendString(username); | 264 writer.AppendString(username); |
265 writer.AppendArrayOfStrings(flags); | 265 writer.AppendArrayOfStrings(flags); |
266 session_manager_proxy_->CallMethod( | 266 session_manager_proxy_->CallMethod( |
267 &method_call, | 267 &method_call, |
268 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 268 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
269 dbus::ObjectProxy::EmptyResponseCallback()); | 269 dbus::ObjectProxy::EmptyResponseCallback()); |
270 } | 270 } |
271 | 271 |
272 virtual void GetServerBackedStateKeys(const StateKeysCallback& callback) | 272 virtual void GetServerBackedStateKeys(const StateKeysCallback& callback) |
273 OVERRIDE { | 273 override { |
274 dbus::MethodCall method_call( | 274 dbus::MethodCall method_call( |
275 login_manager::kSessionManagerInterface, | 275 login_manager::kSessionManagerInterface, |
276 login_manager::kSessionManagerGetServerBackedStateKeys); | 276 login_manager::kSessionManagerGetServerBackedStateKeys); |
277 | 277 |
278 session_manager_proxy_->CallMethod( | 278 session_manager_proxy_->CallMethod( |
279 &method_call, | 279 &method_call, |
280 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 280 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
281 base::Bind(&SessionManagerClientImpl::OnGetServerBackedStateKeys, | 281 base::Bind(&SessionManagerClientImpl::OnGetServerBackedStateKeys, |
282 weak_ptr_factory_.GetWeakPtr(), | 282 weak_ptr_factory_.GetWeakPtr(), |
283 callback)); | 283 callback)); |
284 } | 284 } |
285 | 285 |
286 protected: | 286 protected: |
287 virtual void Init(dbus::Bus* bus) OVERRIDE { | 287 virtual void Init(dbus::Bus* bus) override { |
288 session_manager_proxy_ = bus->GetObjectProxy( | 288 session_manager_proxy_ = bus->GetObjectProxy( |
289 login_manager::kSessionManagerServiceName, | 289 login_manager::kSessionManagerServiceName, |
290 dbus::ObjectPath(login_manager::kSessionManagerServicePath)); | 290 dbus::ObjectPath(login_manager::kSessionManagerServicePath)); |
291 blocking_method_caller_.reset( | 291 blocking_method_caller_.reset( |
292 new BlockingMethodCaller(bus, session_manager_proxy_)); | 292 new BlockingMethodCaller(bus, session_manager_proxy_)); |
293 | 293 |
294 // Signals emitted on the session manager's interface. | 294 // Signals emitted on the session manager's interface. |
295 session_manager_proxy_->ConnectToSignal( | 295 session_manager_proxy_->ConnectToSignal( |
296 login_manager::kSessionManagerInterface, | 296 login_manager::kSessionManagerInterface, |
297 login_manager::kOwnerKeySetSignal, | 297 login_manager::kOwnerKeySetSignal, |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 }; | 571 }; |
572 | 572 |
573 // The SessionManagerClient implementation used on Linux desktop, | 573 // The SessionManagerClient implementation used on Linux desktop, |
574 // which does nothing. | 574 // which does nothing. |
575 class SessionManagerClientStubImpl : public SessionManagerClient { | 575 class SessionManagerClientStubImpl : public SessionManagerClient { |
576 public: | 576 public: |
577 SessionManagerClientStubImpl() : delegate_(NULL) {} | 577 SessionManagerClientStubImpl() : delegate_(NULL) {} |
578 virtual ~SessionManagerClientStubImpl() {} | 578 virtual ~SessionManagerClientStubImpl() {} |
579 | 579 |
580 // SessionManagerClient overrides | 580 // SessionManagerClient overrides |
581 virtual void Init(dbus::Bus* bus) OVERRIDE {} | 581 virtual void Init(dbus::Bus* bus) override {} |
582 virtual void SetStubDelegate(StubDelegate* delegate) OVERRIDE { | 582 virtual void SetStubDelegate(StubDelegate* delegate) override { |
583 delegate_ = delegate; | 583 delegate_ = delegate; |
584 } | 584 } |
585 virtual void AddObserver(Observer* observer) OVERRIDE { | 585 virtual void AddObserver(Observer* observer) override { |
586 observers_.AddObserver(observer); | 586 observers_.AddObserver(observer); |
587 } | 587 } |
588 virtual void RemoveObserver(Observer* observer) OVERRIDE { | 588 virtual void RemoveObserver(Observer* observer) override { |
589 observers_.RemoveObserver(observer); | 589 observers_.RemoveObserver(observer); |
590 } | 590 } |
591 virtual bool HasObserver(Observer* observer) OVERRIDE { | 591 virtual bool HasObserver(Observer* observer) override { |
592 return observers_.HasObserver(observer); | 592 return observers_.HasObserver(observer); |
593 } | 593 } |
594 virtual void EmitLoginPromptVisible() OVERRIDE {} | 594 virtual void EmitLoginPromptVisible() override {} |
595 virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE {} | 595 virtual void RestartJob(int pid, const std::string& command_line) override {} |
596 virtual void StartSession(const std::string& user_email) OVERRIDE {} | 596 virtual void StartSession(const std::string& user_email) override {} |
597 virtual void StopSession() OVERRIDE {} | 597 virtual void StopSession() override {} |
598 virtual void StartDeviceWipe() OVERRIDE {} | 598 virtual void StartDeviceWipe() override {} |
599 virtual void RequestLockScreen() OVERRIDE { | 599 virtual void RequestLockScreen() override { |
600 if (delegate_) | 600 if (delegate_) |
601 delegate_->LockScreenForStub(); | 601 delegate_->LockScreenForStub(); |
602 } | 602 } |
603 virtual void NotifyLockScreenShown() OVERRIDE { | 603 virtual void NotifyLockScreenShown() override { |
604 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsLocked()); | 604 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsLocked()); |
605 } | 605 } |
606 virtual void NotifyLockScreenDismissed() OVERRIDE { | 606 virtual void NotifyLockScreenDismissed() override { |
607 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsUnlocked()); | 607 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsUnlocked()); |
608 } | 608 } |
609 virtual void RetrieveActiveSessions( | 609 virtual void RetrieveActiveSessions( |
610 const ActiveSessionsCallback& callback) OVERRIDE {} | 610 const ActiveSessionsCallback& callback) override {} |
611 virtual void RetrieveDevicePolicy( | 611 virtual void RetrieveDevicePolicy( |
612 const RetrievePolicyCallback& callback) OVERRIDE { | 612 const RetrievePolicyCallback& callback) override { |
613 base::FilePath owner_key_path; | 613 base::FilePath owner_key_path; |
614 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)) { | 614 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)) { |
615 callback.Run(""); | 615 callback.Run(""); |
616 return; | 616 return; |
617 } | 617 } |
618 base::FilePath device_policy_path = | 618 base::FilePath device_policy_path = |
619 owner_key_path.DirName().AppendASCII("stub_device_policy"); | 619 owner_key_path.DirName().AppendASCII("stub_device_policy"); |
620 base::PostTaskAndReplyWithResult( | 620 base::PostTaskAndReplyWithResult( |
621 base::WorkerPool::GetTaskRunner(false).get(), | 621 base::WorkerPool::GetTaskRunner(false).get(), |
622 FROM_HERE, | 622 FROM_HERE, |
623 base::Bind(&GetFileContent, device_policy_path), | 623 base::Bind(&GetFileContent, device_policy_path), |
624 callback); | 624 callback); |
625 } | 625 } |
626 virtual void RetrievePolicyForUser( | 626 virtual void RetrievePolicyForUser( |
627 const std::string& username, | 627 const std::string& username, |
628 const RetrievePolicyCallback& callback) OVERRIDE { | 628 const RetrievePolicyCallback& callback) override { |
629 base::PostTaskAndReplyWithResult( | 629 base::PostTaskAndReplyWithResult( |
630 base::WorkerPool::GetTaskRunner(false).get(), | 630 base::WorkerPool::GetTaskRunner(false).get(), |
631 FROM_HERE, | 631 FROM_HERE, |
632 base::Bind(&GetFileContent, GetUserFilePath(username, "stub_policy")), | 632 base::Bind(&GetFileContent, GetUserFilePath(username, "stub_policy")), |
633 callback); | 633 callback); |
634 } | 634 } |
635 virtual std::string BlockingRetrievePolicyForUser( | 635 virtual std::string BlockingRetrievePolicyForUser( |
636 const std::string& username) OVERRIDE { | 636 const std::string& username) override { |
637 return GetFileContent(GetUserFilePath(username, "stub_policy")); | 637 return GetFileContent(GetUserFilePath(username, "stub_policy")); |
638 } | 638 } |
639 virtual void RetrieveDeviceLocalAccountPolicy( | 639 virtual void RetrieveDeviceLocalAccountPolicy( |
640 const std::string& account_name, | 640 const std::string& account_name, |
641 const RetrievePolicyCallback& callback) OVERRIDE { | 641 const RetrievePolicyCallback& callback) override { |
642 RetrievePolicyForUser(account_name, callback); | 642 RetrievePolicyForUser(account_name, callback); |
643 } | 643 } |
644 virtual void StoreDevicePolicy(const std::string& policy_blob, | 644 virtual void StoreDevicePolicy(const std::string& policy_blob, |
645 const StorePolicyCallback& callback) OVERRIDE { | 645 const StorePolicyCallback& callback) override { |
646 enterprise_management::PolicyFetchResponse response; | 646 enterprise_management::PolicyFetchResponse response; |
647 base::FilePath owner_key_path; | 647 base::FilePath owner_key_path; |
648 if (!response.ParseFromString(policy_blob) || | 648 if (!response.ParseFromString(policy_blob) || |
649 !PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)) { | 649 !PathService::Get(chromeos::FILE_OWNER_KEY, &owner_key_path)) { |
650 callback.Run(false); | 650 callback.Run(false); |
651 return; | 651 return; |
652 } | 652 } |
653 | 653 |
654 if (response.has_new_public_key()) { | 654 if (response.has_new_public_key()) { |
655 base::WorkerPool::PostTask( | 655 base::WorkerPool::PostTask( |
(...skipping 11 matching lines...) Expand all Loading... |
667 owner_key_path.DirName().AppendASCII("stub_device_policy"); | 667 owner_key_path.DirName().AppendASCII("stub_device_policy"); |
668 base::WorkerPool::PostTaskAndReply( | 668 base::WorkerPool::PostTaskAndReply( |
669 FROM_HERE, | 669 FROM_HERE, |
670 base::Bind(&StoreFile, device_policy_path, policy_blob), | 670 base::Bind(&StoreFile, device_policy_path, policy_blob), |
671 base::Bind(callback, true), | 671 base::Bind(callback, true), |
672 false); | 672 false); |
673 } | 673 } |
674 virtual void StorePolicyForUser( | 674 virtual void StorePolicyForUser( |
675 const std::string& username, | 675 const std::string& username, |
676 const std::string& policy_blob, | 676 const std::string& policy_blob, |
677 const StorePolicyCallback& callback) OVERRIDE { | 677 const StorePolicyCallback& callback) override { |
678 // The session manager writes the user policy key to a well-known | 678 // The session manager writes the user policy key to a well-known |
679 // location. Do the same with the stub impl, so that user policy works and | 679 // location. Do the same with the stub impl, so that user policy works and |
680 // can be tested on desktop builds. | 680 // can be tested on desktop builds. |
681 enterprise_management::PolicyFetchResponse response; | 681 enterprise_management::PolicyFetchResponse response; |
682 if (!response.ParseFromString(policy_blob)) { | 682 if (!response.ParseFromString(policy_blob)) { |
683 callback.Run(false); | 683 callback.Run(false); |
684 return; | 684 return; |
685 } | 685 } |
686 | 686 |
687 if (response.has_new_public_key()) { | 687 if (response.has_new_public_key()) { |
688 base::FilePath key_path = GetUserFilePath(username, "policy.pub"); | 688 base::FilePath key_path = GetUserFilePath(username, "policy.pub"); |
689 base::WorkerPool::PostTask( | 689 base::WorkerPool::PostTask( |
690 FROM_HERE, | 690 FROM_HERE, |
691 base::Bind(&StoreFile, key_path, response.new_public_key()), | 691 base::Bind(&StoreFile, key_path, response.new_public_key()), |
692 false); | 692 false); |
693 } | 693 } |
694 | 694 |
695 // This file isn't read directly by Chrome, but is used by this class to | 695 // This file isn't read directly by Chrome, but is used by this class to |
696 // reload the user policy across restarts. | 696 // reload the user policy across restarts. |
697 base::FilePath stub_policy_path = GetUserFilePath(username, "stub_policy"); | 697 base::FilePath stub_policy_path = GetUserFilePath(username, "stub_policy"); |
698 base::WorkerPool::PostTaskAndReply( | 698 base::WorkerPool::PostTaskAndReply( |
699 FROM_HERE, | 699 FROM_HERE, |
700 base::Bind(&StoreFile, stub_policy_path, policy_blob), | 700 base::Bind(&StoreFile, stub_policy_path, policy_blob), |
701 base::Bind(callback, true), | 701 base::Bind(callback, true), |
702 false); | 702 false); |
703 } | 703 } |
704 virtual void StoreDeviceLocalAccountPolicy( | 704 virtual void StoreDeviceLocalAccountPolicy( |
705 const std::string& account_name, | 705 const std::string& account_name, |
706 const std::string& policy_blob, | 706 const std::string& policy_blob, |
707 const StorePolicyCallback& callback) OVERRIDE { | 707 const StorePolicyCallback& callback) override { |
708 StorePolicyForUser(account_name, policy_blob, callback); | 708 StorePolicyForUser(account_name, policy_blob, callback); |
709 } | 709 } |
710 virtual void SetFlagsForUser(const std::string& username, | 710 virtual void SetFlagsForUser(const std::string& username, |
711 const std::vector<std::string>& flags) OVERRIDE { | 711 const std::vector<std::string>& flags) override { |
712 } | 712 } |
713 | 713 |
714 virtual void GetServerBackedStateKeys(const StateKeysCallback& callback) | 714 virtual void GetServerBackedStateKeys(const StateKeysCallback& callback) |
715 OVERRIDE { | 715 override { |
716 std::vector<std::string> state_keys; | 716 std::vector<std::string> state_keys; |
717 for (int i = 0; i < 5; ++i) | 717 for (int i = 0; i < 5; ++i) |
718 state_keys.push_back(crypto::SHA256HashString(base::IntToString(i))); | 718 state_keys.push_back(crypto::SHA256HashString(base::IntToString(i))); |
719 | 719 |
720 if (!callback.is_null()) | 720 if (!callback.is_null()) |
721 callback.Run(state_keys, false); | 721 callback.Run(state_keys, false); |
722 } | 722 } |
723 | 723 |
724 private: | 724 private: |
725 StubDelegate* delegate_; // Weak pointer; may be NULL. | 725 StubDelegate* delegate_; // Weak pointer; may be NULL. |
(...skipping 11 matching lines...) Expand all Loading... |
737 | 737 |
738 SessionManagerClient* SessionManagerClient::Create( | 738 SessionManagerClient* SessionManagerClient::Create( |
739 DBusClientImplementationType type) { | 739 DBusClientImplementationType type) { |
740 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 740 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
741 return new SessionManagerClientImpl(); | 741 return new SessionManagerClientImpl(); |
742 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 742 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
743 return new SessionManagerClientStubImpl(); | 743 return new SessionManagerClientStubImpl(); |
744 } | 744 } |
745 | 745 |
746 } // namespace chromeos | 746 } // namespace chromeos |
OLD | NEW |