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 <map> | |
8 | |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/file_util.h" | |
12 #include "base/files/file_path.h" | |
13 #include "base/location.h" | |
14 #include "base/path_service.h" | |
9 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/threading/worker_pool.h" | |
17 #include "chromeos/chromeos_paths.h" | |
10 #include "dbus/bus.h" | 18 #include "dbus/bus.h" |
11 #include "dbus/message.h" | 19 #include "dbus/message.h" |
12 #include "dbus/object_path.h" | 20 #include "dbus/object_path.h" |
13 #include "dbus/object_proxy.h" | 21 #include "dbus/object_proxy.h" |
14 #include "third_party/cros_system_api/dbus/service_constants.h" | 22 #include "third_party/cros_system_api/dbus/service_constants.h" |
15 | 23 |
16 namespace chromeos { | 24 namespace chromeos { |
17 | 25 |
18 // The SessionManagerClient implementation used in production. | 26 // The SessionManagerClient implementation used in production. |
19 class SessionManagerClientImpl : public SessionManagerClient { | 27 class SessionManagerClientImpl : public SessionManagerClient { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 login_manager::kSessionManagerUnlockScreen); | 180 login_manager::kSessionManagerUnlockScreen); |
173 } | 181 } |
174 | 182 |
175 virtual void NotifyLockScreenDismissed() OVERRIDE { | 183 virtual void NotifyLockScreenDismissed() OVERRIDE { |
176 SimpleMethodCallToSessionManager( | 184 SimpleMethodCallToSessionManager( |
177 login_manager::kSessionManagerHandleLockScreenDismissed); | 185 login_manager::kSessionManagerHandleLockScreenDismissed); |
178 } | 186 } |
179 | 187 |
180 virtual void RetrieveDevicePolicy( | 188 virtual void RetrieveDevicePolicy( |
181 const RetrievePolicyCallback& callback) OVERRIDE { | 189 const RetrievePolicyCallback& callback) OVERRIDE { |
182 CallRetrievePolicy(login_manager::kSessionManagerRetrievePolicy, | 190 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
183 callback); | 191 login_manager::kSessionManagerRetrievePolicy); |
192 session_manager_proxy_->CallMethod( | |
193 &method_call, | |
194 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | |
195 base::Bind(&SessionManagerClientImpl::OnRetrievePolicy, | |
196 weak_ptr_factory_.GetWeakPtr(), | |
197 login_manager::kSessionManagerRetrievePolicy, | |
198 callback)); | |
184 } | 199 } |
185 | 200 |
186 virtual void RetrieveUserPolicy( | 201 virtual void RetrievePolicyForUser( |
202 const std::string& username, | |
187 const RetrievePolicyCallback& callback) OVERRIDE { | 203 const RetrievePolicyCallback& callback) OVERRIDE { |
188 CallRetrievePolicy(login_manager::kSessionManagerRetrieveUserPolicy, | 204 CallRetrievePolicyForUsername( |
189 callback); | 205 login_manager::kSessionManagerRetrievePolicyForUser, |
206 username, | |
207 callback); | |
190 } | 208 } |
191 | 209 |
192 virtual void RetrieveDeviceLocalAccountPolicy( | 210 virtual void RetrieveDeviceLocalAccountPolicy( |
193 const std::string& account_name, | 211 const std::string& account_name, |
194 const RetrievePolicyCallback& callback) OVERRIDE { | 212 const RetrievePolicyCallback& callback) OVERRIDE { |
195 dbus::MethodCall method_call( | 213 CallRetrievePolicyForUsername( |
196 login_manager::kSessionManagerInterface, | 214 login_manager::kSessionManagerRetrieveDeviceLocalAccountPolicy, |
197 login_manager::kSessionManagerRetrieveDeviceLocalAccountPolicy); | 215 account_name, |
198 dbus::MessageWriter writer(&method_call); | 216 callback); |
199 writer.AppendString(account_name); | |
200 session_manager_proxy_->CallMethod( | |
201 &method_call, | |
202 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | |
203 base::Bind( | |
204 &SessionManagerClientImpl::OnRetrievePolicy, | |
205 weak_ptr_factory_.GetWeakPtr(), | |
206 login_manager::kSessionManagerRetrieveDeviceLocalAccountPolicy, | |
207 callback)); | |
208 } | 217 } |
209 | 218 |
210 virtual void StoreDevicePolicy(const std::string& policy_blob, | 219 virtual void StoreDevicePolicy(const std::string& policy_blob, |
211 const StorePolicyCallback& callback) OVERRIDE { | 220 const StorePolicyCallback& callback) OVERRIDE { |
212 CallStorePolicy(login_manager::kSessionManagerStorePolicy, | 221 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
213 policy_blob, callback); | 222 login_manager::kSessionManagerStorePolicy); |
223 dbus::MessageWriter writer(&method_call); | |
224 // static_cast does not work due to signedness. | |
225 writer.AppendArrayOfBytes( | |
226 reinterpret_cast<const uint8*>(policy_blob.data()), policy_blob.size()); | |
227 session_manager_proxy_->CallMethod( | |
228 &method_call, | |
229 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | |
230 base::Bind(&SessionManagerClientImpl::OnStorePolicy, | |
231 weak_ptr_factory_.GetWeakPtr(), | |
232 login_manager::kSessionManagerStorePolicy, | |
233 callback)); | |
214 } | 234 } |
215 | 235 |
216 virtual void StoreUserPolicy(const std::string& policy_blob, | 236 virtual void StorePolicyForUser( |
217 const StorePolicyCallback& callback) OVERRIDE { | 237 const std::string& username, |
218 CallStorePolicy(login_manager::kSessionManagerStoreUserPolicy, | 238 const std::string& policy_blob, |
219 policy_blob, callback); | 239 const std::string& ignored_policy_key, |
240 const StorePolicyCallback& callback) OVERRIDE { | |
241 CallStorePolicyForUsername(login_manager::kSessionManagerStorePolicyForUser, | |
242 username, | |
243 policy_blob, | |
244 callback); | |
220 } | 245 } |
221 | 246 |
222 virtual void StoreDeviceLocalAccountPolicy( | 247 virtual void StoreDeviceLocalAccountPolicy( |
223 const std::string& account_name, | 248 const std::string& account_name, |
224 const std::string& policy_blob, | 249 const std::string& policy_blob, |
225 const StorePolicyCallback& callback) OVERRIDE { | 250 const StorePolicyCallback& callback) OVERRIDE { |
226 dbus::MethodCall method_call( | 251 CallStorePolicyForUsername( |
227 login_manager::kSessionManagerInterface, | 252 login_manager::kSessionManagerStoreDeviceLocalAccountPolicy, |
228 login_manager::kSessionManagerStoreDeviceLocalAccountPolicy); | 253 account_name, |
229 dbus::MessageWriter writer(&method_call); | 254 policy_blob, |
230 writer.AppendString(account_name); | 255 callback); |
231 // static_cast does not work due to signedness. | |
232 writer.AppendArrayOfBytes( | |
233 reinterpret_cast<const uint8*>(policy_blob.data()), policy_blob.size()); | |
234 session_manager_proxy_->CallMethod( | |
235 &method_call, | |
236 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | |
237 base::Bind( | |
238 &SessionManagerClientImpl::OnStorePolicy, | |
239 weak_ptr_factory_.GetWeakPtr(), | |
240 login_manager::kSessionManagerStoreDeviceLocalAccountPolicy, | |
241 callback)); | |
242 } | 256 } |
243 | 257 |
244 private: | 258 private: |
245 // Makes a method call to the session manager with no arguments and no | 259 // Makes a method call to the session manager with no arguments and no |
246 // response. | 260 // response. |
247 void SimpleMethodCallToSessionManager(const std::string& method_name) { | 261 void SimpleMethodCallToSessionManager(const std::string& method_name) { |
248 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 262 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
249 method_name); | 263 method_name); |
250 session_manager_proxy_->CallMethod( | 264 session_manager_proxy_->CallMethod( |
251 &method_call, | 265 &method_call, |
252 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 266 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
253 dbus::ObjectProxy::EmptyResponseCallback()); | 267 dbus::ObjectProxy::EmptyResponseCallback()); |
254 } | 268 } |
255 | 269 |
256 // Helper for Retrieve{User,Device}Policy. | 270 // Helper for RetrieveDeviceLocalAccountPolicy and RetrievePolicyForUser. |
257 virtual void CallRetrievePolicy(const std::string& method_name, | 271 void CallRetrievePolicyForUsername(const std::string& method_name, |
Mattias Nissler (ping if slow)
2013/05/10 12:40:15
Can we rename to CallRetrievePolicyByUsername in o
Joao da Silva
2013/05/13 09:39:23
Done.
| |
258 const RetrievePolicyCallback& callback) { | 272 const std::string& username, |
273 const RetrievePolicyCallback& callback) { | |
259 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 274 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
260 method_name); | 275 method_name); |
276 dbus::MessageWriter writer(&method_call); | |
277 writer.AppendString(username); | |
261 session_manager_proxy_->CallMethod( | 278 session_manager_proxy_->CallMethod( |
262 &method_call, | 279 &method_call, |
263 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 280 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
264 base::Bind(&SessionManagerClientImpl::OnRetrievePolicy, | 281 base::Bind( |
265 weak_ptr_factory_.GetWeakPtr(), | 282 &SessionManagerClientImpl::OnRetrievePolicy, |
266 method_name, | 283 weak_ptr_factory_.GetWeakPtr(), |
267 callback)); | 284 method_name, |
285 callback)); | |
268 } | 286 } |
269 | 287 |
270 // Helper for Store{User,Device}Policy. | 288 void CallStorePolicyForUsername(const std::string& method_name, |
Mattias Nissler (ping if slow)
2013/05/10 12:40:15
Ditto re nameing, i.e. CallStorePolicyByUsername
Joao da Silva
2013/05/13 09:39:23
Done.
| |
271 virtual void CallStorePolicy(const std::string& method_name, | 289 const std::string& username, |
272 const std::string& policy_blob, | 290 const std::string& policy_blob, |
273 const StorePolicyCallback& callback) { | 291 const StorePolicyCallback& callback) { |
274 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 292 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
275 method_name); | 293 method_name); |
276 dbus::MessageWriter writer(&method_call); | 294 dbus::MessageWriter writer(&method_call); |
295 writer.AppendString(username); | |
277 // static_cast does not work due to signedness. | 296 // static_cast does not work due to signedness. |
278 writer.AppendArrayOfBytes( | 297 writer.AppendArrayOfBytes( |
279 reinterpret_cast<const uint8*>(policy_blob.data()), policy_blob.size()); | 298 reinterpret_cast<const uint8*>(policy_blob.data()), policy_blob.size()); |
280 session_manager_proxy_->CallMethod( | 299 session_manager_proxy_->CallMethod( |
281 &method_call, | 300 &method_call, |
282 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 301 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
283 base::Bind(&SessionManagerClientImpl::OnStorePolicy, | 302 base::Bind( |
284 weak_ptr_factory_.GetWeakPtr(), | 303 &SessionManagerClientImpl::OnStorePolicy, |
285 method_name, | 304 weak_ptr_factory_.GetWeakPtr(), |
286 callback)); | 305 method_name, |
306 callback)); | |
287 } | 307 } |
288 | 308 |
289 // Called when kSessionManagerRestartJob method is complete. | 309 // Called when kSessionManagerRestartJob method is complete. |
290 void OnRestartJob(dbus::Response* response) { | 310 void OnRestartJob(dbus::Response* response) { |
291 LOG_IF(ERROR, !response) | 311 LOG_IF(ERROR, !response) |
292 << "Failed to call " | 312 << "Failed to call " |
293 << login_manager::kSessionManagerRestartJob; | 313 << login_manager::kSessionManagerRestartJob; |
294 } | 314 } |
295 | 315 |
296 // Called when kSessionManagerStartSession method is complete. | 316 // Called when kSessionManagerStartSession method is complete. |
(...skipping 11 matching lines...) Expand all Loading... | |
308 } | 328 } |
309 | 329 |
310 // Called when kSessionManagerStopSession method is complete. | 330 // Called when kSessionManagerStopSession method is complete. |
311 void OnDeviceWipe(dbus::Response* response) { | 331 void OnDeviceWipe(dbus::Response* response) { |
312 LOG_IF(ERROR, !response) | 332 LOG_IF(ERROR, !response) |
313 << "Failed to call " | 333 << "Failed to call " |
314 << login_manager::kSessionManagerStartDeviceWipe; | 334 << login_manager::kSessionManagerStartDeviceWipe; |
315 } | 335 } |
316 | 336 |
317 // Called when kSessionManagerRetrievePolicy or | 337 // Called when kSessionManagerRetrievePolicy or |
318 // kSessionManagerRetrieveUserPolicy method is complete. | 338 // kSessionManagerRetrievePolicyForUser method is complete. |
319 void OnRetrievePolicy(const std::string& method_name, | 339 void OnRetrievePolicy(const std::string& method_name, |
320 const RetrievePolicyCallback& callback, | 340 const RetrievePolicyCallback& callback, |
321 dbus::Response* response) { | 341 dbus::Response* response) { |
322 if (!response) { | 342 if (!response) { |
323 LOG(ERROR) << "Failed to call " << method_name; | 343 LOG(ERROR) << "Failed to call " << method_name; |
324 callback.Run(""); | 344 callback.Run(""); |
325 return; | 345 return; |
326 } | 346 } |
327 dbus::MessageReader reader(response); | 347 dbus::MessageReader reader(response); |
328 uint8* values = NULL; | 348 uint8* values = NULL; |
329 size_t length = 0; | 349 size_t length = 0; |
330 if (!reader.PopArrayOfBytes(&values, &length)) { | 350 if (!reader.PopArrayOfBytes(&values, &length)) { |
331 LOG(ERROR) << "Invalid response: " << response->ToString(); | 351 LOG(ERROR) << "Invalid response: " << response->ToString(); |
332 callback.Run(""); | 352 callback.Run(""); |
333 return; | 353 return; |
334 } | 354 } |
335 // static_cast does not work due to signedness. | 355 // static_cast does not work due to signedness. |
336 std::string serialized_proto(reinterpret_cast<char*>(values), length); | 356 std::string serialized_proto(reinterpret_cast<char*>(values), length); |
337 callback.Run(serialized_proto); | 357 callback.Run(serialized_proto); |
338 } | 358 } |
339 | 359 |
340 // Called when kSessionManagerStorePolicy or kSessionManagerStoreUserPolicy | 360 // Called when kSessionManagerStorePolicy or kSessionManagerStorePolicyForUser |
341 // method is complete. | 361 // method is complete. |
342 void OnStorePolicy(const std::string& method_name, | 362 void OnStorePolicy(const std::string& method_name, |
343 const StorePolicyCallback& callback, | 363 const StorePolicyCallback& callback, |
344 dbus::Response* response) { | 364 dbus::Response* response) { |
345 bool success = false; | 365 bool success = false; |
346 if (!response) { | 366 if (!response) { |
347 LOG(ERROR) << "Failed to call " << method_name; | 367 LOG(ERROR) << "Failed to call " << method_name; |
348 } else { | 368 } else { |
349 dbus::MessageReader reader(response); | 369 dbus::MessageReader reader(response); |
350 if (!reader.PopBool(&success)) | 370 if (!reader.PopBool(&success)) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 // invalidate its weak pointers before any other members are destroyed. | 432 // invalidate its weak pointers before any other members are destroyed. |
413 base::WeakPtrFactory<SessionManagerClientImpl> weak_ptr_factory_; | 433 base::WeakPtrFactory<SessionManagerClientImpl> weak_ptr_factory_; |
414 | 434 |
415 DISALLOW_COPY_AND_ASSIGN(SessionManagerClientImpl); | 435 DISALLOW_COPY_AND_ASSIGN(SessionManagerClientImpl); |
416 }; | 436 }; |
417 | 437 |
418 // The SessionManagerClient implementation used on Linux desktop, | 438 // The SessionManagerClient implementation used on Linux desktop, |
419 // which does nothing. | 439 // which does nothing. |
420 class SessionManagerClientStubImpl : public SessionManagerClient { | 440 class SessionManagerClientStubImpl : public SessionManagerClient { |
421 public: | 441 public: |
422 SessionManagerClientStubImpl() {} | 442 SessionManagerClientStubImpl() { |
443 // Make sure that there are no keys left over from a previous browser run. | |
444 base::FilePath user_policy_key_dir; | |
445 if (PathService::Get(chromeos::DIR_USER_POLICY_KEYS, | |
446 &user_policy_key_dir)) { | |
447 base::WorkerPool::PostTask( | |
448 FROM_HERE, | |
449 base::Bind(base::IgnoreResult(&file_util::Delete), | |
450 user_policy_key_dir, true), | |
451 false); | |
452 } | |
453 } | |
423 virtual ~SessionManagerClientStubImpl() {} | 454 virtual ~SessionManagerClientStubImpl() {} |
424 | 455 |
425 // SessionManagerClient overrides. | 456 // SessionManagerClient overrides. |
426 virtual void AddObserver(Observer* observer) OVERRIDE { | 457 virtual void AddObserver(Observer* observer) OVERRIDE { |
427 observers_.AddObserver(observer); | 458 observers_.AddObserver(observer); |
428 } | 459 } |
429 virtual void RemoveObserver(Observer* observer) OVERRIDE { | 460 virtual void RemoveObserver(Observer* observer) OVERRIDE { |
430 observers_.RemoveObserver(observer); | 461 observers_.RemoveObserver(observer); |
431 } | 462 } |
432 virtual bool HasObserver(Observer* observer) OVERRIDE { | 463 virtual bool HasObserver(Observer* observer) OVERRIDE { |
(...skipping 15 matching lines...) Expand all Loading... | |
448 virtual void RequestUnlockScreen() OVERRIDE { | 479 virtual void RequestUnlockScreen() OVERRIDE { |
449 FOR_EACH_OBSERVER(Observer, observers_, UnlockScreen()); | 480 FOR_EACH_OBSERVER(Observer, observers_, UnlockScreen()); |
450 } | 481 } |
451 virtual void NotifyLockScreenDismissed() OVERRIDE { | 482 virtual void NotifyLockScreenDismissed() OVERRIDE { |
452 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsUnlocked()); | 483 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsUnlocked()); |
453 } | 484 } |
454 virtual void RetrieveDevicePolicy( | 485 virtual void RetrieveDevicePolicy( |
455 const RetrievePolicyCallback& callback) OVERRIDE { | 486 const RetrievePolicyCallback& callback) OVERRIDE { |
456 callback.Run(device_policy_); | 487 callback.Run(device_policy_); |
457 } | 488 } |
458 virtual void RetrieveUserPolicy( | 489 virtual void RetrievePolicyForUser( |
490 const std::string& username, | |
459 const RetrievePolicyCallback& callback) OVERRIDE { | 491 const RetrievePolicyCallback& callback) OVERRIDE { |
460 callback.Run(user_policy_); | 492 callback.Run(user_policies_[username]); |
461 } | 493 } |
462 virtual void RetrieveDeviceLocalAccountPolicy( | 494 virtual void RetrieveDeviceLocalAccountPolicy( |
463 const std::string& account_name, | 495 const std::string& account_name, |
464 const RetrievePolicyCallback& callback) OVERRIDE { | 496 const RetrievePolicyCallback& callback) OVERRIDE { |
465 callback.Run(""); | 497 callback.Run(user_policies_[account_name]); |
466 } | 498 } |
467 virtual void StoreDevicePolicy(const std::string& policy_blob, | 499 virtual void StoreDevicePolicy(const std::string& policy_blob, |
468 const StorePolicyCallback& callback) OVERRIDE { | 500 const StorePolicyCallback& callback) OVERRIDE { |
469 device_policy_ = policy_blob; | 501 device_policy_ = policy_blob; |
470 callback.Run(true); | 502 callback.Run(true); |
471 } | 503 } |
472 virtual void StoreUserPolicy(const std::string& policy_blob, | 504 virtual void StorePolicyForUser( |
473 const StorePolicyCallback& callback) OVERRIDE { | 505 const std::string& username, |
474 user_policy_ = policy_blob; | 506 const std::string& policy_blob, |
475 callback.Run(true); | 507 const std::string& policy_key, |
508 const StorePolicyCallback& callback) OVERRIDE { | |
509 if (policy_key.empty()) { | |
510 user_policies_[username] = policy_blob; | |
511 callback.Run(true); | |
512 return; | |
513 } | |
514 // The session manager writes the user policy key to a well-known | |
515 // location. Do the same with the stub impl, so that user policy works and | |
516 // can be tested on desktop builds. | |
Mattias Nissler (ping if slow)
2013/05/10 12:40:15
If you need this, why not extract the policy key f
Joao da Silva
2013/05/13 09:39:23
That'd be my preferred solution, but chromeos/ can
Mattias Nissler (ping if slow)
2013/05/13 10:27:14
Bummer. Any chance to get an exception into chrome
Joao da Silva
2013/05/13 10:54:19
Can we propose that change in another CL? I'd rath
| |
517 base::FilePath key_path; | |
518 if (!PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &key_path)) { | |
519 callback.Run(false); | |
520 return; | |
521 } | |
522 // Keep this in sync with CryptohomeClientStubImpl::GetSanitizedUsername. | |
523 const std::string sanitized = username + "-profile"; | |
524 key_path = key_path.AppendASCII(sanitized).AppendASCII("policy.pub"); | |
Mattias Nissler (ping if slow)
2013/05/10 12:40:15
This is misleading, please name it policy_key.pub
Joao da Silva
2013/05/13 09:39:23
This has to be the same name that the session_mana
Mattias Nissler (ping if slow)
2013/05/13 10:27:14
Oh right, I guess I should have payed closer atten
| |
525 // Assume that the key write is successful. | |
526 user_policies_[username] = policy_blob; | |
527 base::WorkerPool::PostTaskAndReply( | |
528 FROM_HERE, | |
529 base::Bind(&SessionManagerClientStubImpl::StoreFileInBackground, | |
530 key_path, policy_key), | |
531 base::Bind(callback, true), | |
532 false); | |
476 } | 533 } |
477 virtual void StoreDeviceLocalAccountPolicy( | 534 virtual void StoreDeviceLocalAccountPolicy( |
478 const std::string& account_name, | 535 const std::string& account_name, |
479 const std::string& policy_blob, | 536 const std::string& policy_blob, |
480 const StorePolicyCallback& callback) OVERRIDE { | 537 const StorePolicyCallback& callback) OVERRIDE { |
538 user_policies_[account_name] = policy_blob; | |
481 callback.Run(true); | 539 callback.Run(true); |
482 } | 540 } |
483 | 541 |
542 static void StoreFileInBackground(const base::FilePath& path, | |
543 const std::string& data) { | |
544 const int size = static_cast<int>(data.size()); | |
545 if (!file_util::CreateDirectory(path.DirName()) || | |
546 file_util::WriteFile(path, data.data(), size) != size) { | |
547 LOG(WARNING) << "Failed to write policy key to " << path.value(); | |
548 } | |
549 } | |
550 | |
484 private: | 551 private: |
485 ObserverList<Observer> observers_; | 552 ObserverList<Observer> observers_; |
486 std::string device_policy_; | 553 std::string device_policy_; |
487 std::string user_policy_; | 554 std::map<std::string, std::string> user_policies_; |
488 | 555 |
489 DISALLOW_COPY_AND_ASSIGN(SessionManagerClientStubImpl); | 556 DISALLOW_COPY_AND_ASSIGN(SessionManagerClientStubImpl); |
490 }; | 557 }; |
491 | 558 |
492 SessionManagerClient::SessionManagerClient() { | 559 SessionManagerClient::SessionManagerClient() { |
493 } | 560 } |
494 | 561 |
495 SessionManagerClient::~SessionManagerClient() { | 562 SessionManagerClient::~SessionManagerClient() { |
496 } | 563 } |
497 | 564 |
498 SessionManagerClient* SessionManagerClient::Create( | 565 SessionManagerClient* SessionManagerClient::Create( |
499 DBusClientImplementationType type, | 566 DBusClientImplementationType type, |
500 dbus::Bus* bus) { | 567 dbus::Bus* bus) { |
501 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 568 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
502 return new SessionManagerClientImpl(bus); | 569 return new SessionManagerClientImpl(bus); |
503 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 570 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
504 return new SessionManagerClientStubImpl(); | 571 return new SessionManagerClientStubImpl(); |
505 } | 572 } |
506 | 573 |
507 } // namespace chromeos | 574 } // namespace chromeos |
OLD | NEW |