Chromium Code Reviews| 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> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 } | 231 } |
| 232 | 232 |
| 233 protected: | 233 protected: |
| 234 virtual void Init(dbus::Bus* bus) OVERRIDE { | 234 virtual void Init(dbus::Bus* bus) OVERRIDE { |
| 235 session_manager_proxy_ = bus->GetObjectProxy( | 235 session_manager_proxy_ = bus->GetObjectProxy( |
| 236 login_manager::kSessionManagerServiceName, | 236 login_manager::kSessionManagerServiceName, |
| 237 dbus::ObjectPath(login_manager::kSessionManagerServicePath)); | 237 dbus::ObjectPath(login_manager::kSessionManagerServicePath)); |
| 238 blocking_method_caller_.reset( | 238 blocking_method_caller_.reset( |
| 239 new BlockingMethodCaller(bus, session_manager_proxy_)); | 239 new BlockingMethodCaller(bus, session_manager_proxy_)); |
| 240 | 240 |
| 241 // Signals emitted on Chromium's interface. Many of these ought to be | |
| 242 // method calls instead. | |
| 243 session_manager_proxy_->ConnectToSignal( | |
| 244 chromium::kChromiumInterface, | |
| 245 chromium::kLockScreenSignal, | |
| 246 base::Bind(&SessionManagerClientImpl::ScreenLockReceived, | |
| 247 weak_ptr_factory_.GetWeakPtr()), | |
| 248 base::Bind(&SessionManagerClientImpl::SignalConnected, | |
| 249 weak_ptr_factory_.GetWeakPtr())); | |
| 250 | |
| 251 // Signals emitted on the session manager's interface. | 241 // Signals emitted on the session manager's interface. |
| 252 session_manager_proxy_->ConnectToSignal( | 242 session_manager_proxy_->ConnectToSignal( |
| 253 login_manager::kSessionManagerInterface, | 243 login_manager::kSessionManagerInterface, |
| 254 login_manager::kOwnerKeySetSignal, | 244 login_manager::kOwnerKeySetSignal, |
| 255 base::Bind(&SessionManagerClientImpl::OwnerKeySetReceived, | 245 base::Bind(&SessionManagerClientImpl::OwnerKeySetReceived, |
| 256 weak_ptr_factory_.GetWeakPtr()), | 246 weak_ptr_factory_.GetWeakPtr()), |
| 257 base::Bind(&SessionManagerClientImpl::SignalConnected, | 247 base::Bind(&SessionManagerClientImpl::SignalConnected, |
| 258 weak_ptr_factory_.GetWeakPtr())); | 248 weak_ptr_factory_.GetWeakPtr())); |
| 259 session_manager_proxy_->ConnectToSignal( | 249 session_manager_proxy_->ConnectToSignal( |
| 260 login_manager::kSessionManagerInterface, | 250 login_manager::kSessionManagerInterface, |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 dbus::MessageReader reader(signal); | 446 dbus::MessageReader reader(signal); |
| 457 std::string result_string; | 447 std::string result_string; |
| 458 if (!reader.PopString(&result_string)) { | 448 if (!reader.PopString(&result_string)) { |
| 459 LOG(ERROR) << "Invalid signal: " << signal->ToString(); | 449 LOG(ERROR) << "Invalid signal: " << signal->ToString(); |
| 460 return; | 450 return; |
| 461 } | 451 } |
| 462 const bool success = StartsWithASCII(result_string, "success", false); | 452 const bool success = StartsWithASCII(result_string, "success", false); |
| 463 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(success)); | 453 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(success)); |
| 464 } | 454 } |
| 465 | 455 |
| 466 void ScreenLockReceived(dbus::Signal* signal) { | |
| 467 FOR_EACH_OBSERVER(Observer, observers_, LockScreen()); | |
| 468 } | |
| 469 | |
| 470 void ScreenIsLockedReceived(dbus::Signal* signal) { | 456 void ScreenIsLockedReceived(dbus::Signal* signal) { |
| 471 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsLocked()); | 457 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsLocked()); |
| 472 } | 458 } |
| 473 | 459 |
| 474 void ScreenIsUnlockedReceived(dbus::Signal* signal) { | 460 void ScreenIsUnlockedReceived(dbus::Signal* signal) { |
| 475 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsUnlocked()); | 461 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsUnlocked()); |
| 476 } | 462 } |
| 477 | 463 |
| 478 // Called when the object is connected to the signal. | 464 // Called when the object is connected to the signal. |
| 479 void SignalConnected(const std::string& interface_name, | 465 void SignalConnected(const std::string& interface_name, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 521 observers_.RemoveObserver(observer); | 507 observers_.RemoveObserver(observer); |
| 522 } | 508 } |
| 523 virtual bool HasObserver(Observer* observer) OVERRIDE { | 509 virtual bool HasObserver(Observer* observer) OVERRIDE { |
| 524 return observers_.HasObserver(observer); | 510 return observers_.HasObserver(observer); |
| 525 } | 511 } |
| 526 virtual void EmitLoginPromptVisible() OVERRIDE {} | 512 virtual void EmitLoginPromptVisible() OVERRIDE {} |
| 527 virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE {} | 513 virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE {} |
| 528 virtual void StartSession(const std::string& user_email) OVERRIDE {} | 514 virtual void StartSession(const std::string& user_email) OVERRIDE {} |
| 529 virtual void StopSession() OVERRIDE {} | 515 virtual void StopSession() OVERRIDE {} |
| 530 virtual void StartDeviceWipe() OVERRIDE {} | 516 virtual void StartDeviceWipe() OVERRIDE {} |
| 531 virtual void RequestLockScreen() OVERRIDE { | 517 virtual void RequestLockScreen() OVERRIDE {} |
| 532 FOR_EACH_OBSERVER(Observer, observers_, LockScreen()); | |
|
Daniel Erat
2014/02/14 23:36:56
Steven, curious about your thoughts about this. Th
stevenjb
2014/02/18 17:32:14
The stub should try to mimic the behavior without
Daniel Erat
2014/02/18 17:47:21
org.chromium.LibCrosService is implemented in c/b/
stevenjb
2014/02/18 17:52:40
OK. I personally would like to see dbus calls move
| |
| 533 } | |
| 534 virtual void NotifyLockScreenShown() OVERRIDE { | 518 virtual void NotifyLockScreenShown() OVERRIDE { |
| 535 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsLocked()); | 519 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsLocked()); |
| 536 } | 520 } |
| 537 virtual void NotifyLockScreenDismissed() OVERRIDE { | 521 virtual void NotifyLockScreenDismissed() OVERRIDE { |
| 538 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsUnlocked()); | 522 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsUnlocked()); |
| 539 } | 523 } |
| 540 virtual void RetrieveActiveSessions( | 524 virtual void RetrieveActiveSessions( |
| 541 const ActiveSessionsCallback& callback) OVERRIDE {} | 525 const ActiveSessionsCallback& callback) OVERRIDE {} |
| 542 virtual void RetrieveDevicePolicy( | 526 virtual void RetrieveDevicePolicy( |
| 543 const RetrievePolicyCallback& callback) OVERRIDE { | 527 const RetrievePolicyCallback& callback) OVERRIDE { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 | 616 |
| 633 SessionManagerClient* SessionManagerClient::Create( | 617 SessionManagerClient* SessionManagerClient::Create( |
| 634 DBusClientImplementationType type) { | 618 DBusClientImplementationType type) { |
| 635 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 619 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 636 return new SessionManagerClientImpl(); | 620 return new SessionManagerClientImpl(); |
| 637 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 621 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 638 return new SessionManagerClientStubImpl(); | 622 return new SessionManagerClientStubImpl(); |
| 639 } | 623 } |
| 640 | 624 |
| 641 } // namespace chromeos | 625 } // namespace chromeos |
| OLD | NEW |