| 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/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "dbus/bus.h" | 10 #include "dbus/bus.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 login_manager::kSessionManagerStopSession); | 120 login_manager::kSessionManagerStopSession); |
| 121 dbus::MessageWriter writer(&method_call); | 121 dbus::MessageWriter writer(&method_call); |
| 122 writer.AppendString(""); // Unique ID is deprecated | 122 writer.AppendString(""); // Unique ID is deprecated |
| 123 session_manager_proxy_->CallMethod( | 123 session_manager_proxy_->CallMethod( |
| 124 &method_call, | 124 &method_call, |
| 125 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 125 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 126 base::Bind(&SessionManagerClientImpl::OnStopSession, | 126 base::Bind(&SessionManagerClientImpl::OnStopSession, |
| 127 weak_ptr_factory_.GetWeakPtr())); | 127 weak_ptr_factory_.GetWeakPtr())); |
| 128 } | 128 } |
| 129 | 129 |
| 130 virtual void StartDeviceWipe() OVERRIDE { |
| 131 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
| 132 login_manager::kSessionManagerStartDeviceWipe); |
| 133 session_manager_proxy_->CallMethod( |
| 134 &method_call, |
| 135 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 136 base::Bind(&SessionManagerClientImpl::OnDeviceWipe, |
| 137 weak_ptr_factory_.GetWeakPtr())); |
| 138 } |
| 139 |
| 130 virtual void RequestLockScreen() OVERRIDE { | 140 virtual void RequestLockScreen() OVERRIDE { |
| 131 SimpleMethodCallToSessionManager(login_manager::kSessionManagerLockScreen); | 141 SimpleMethodCallToSessionManager(login_manager::kSessionManagerLockScreen); |
| 132 } | 142 } |
| 133 | 143 |
| 134 virtual void NotifyLockScreenShown() OVERRIDE { | 144 virtual void NotifyLockScreenShown() OVERRIDE { |
| 135 SimpleMethodCallToSessionManager( | 145 SimpleMethodCallToSessionManager( |
| 136 login_manager::kSessionManagerHandleLockScreenShown); | 146 login_manager::kSessionManagerHandleLockScreenShown); |
| 137 } | 147 } |
| 138 | 148 |
| 139 virtual void RequestUnlockScreen() OVERRIDE { | 149 virtual void RequestUnlockScreen() OVERRIDE { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 << login_manager::kSessionManagerStartSession; | 243 << login_manager::kSessionManagerStartSession; |
| 234 } | 244 } |
| 235 | 245 |
| 236 // Called when kSessionManagerStopSession method is complete. | 246 // Called when kSessionManagerStopSession method is complete. |
| 237 void OnStopSession(dbus::Response* response) { | 247 void OnStopSession(dbus::Response* response) { |
| 238 LOG_IF(ERROR, !response) | 248 LOG_IF(ERROR, !response) |
| 239 << "Failed to call " | 249 << "Failed to call " |
| 240 << login_manager::kSessionManagerStopSession; | 250 << login_manager::kSessionManagerStopSession; |
| 241 } | 251 } |
| 242 | 252 |
| 253 // Called when kSessionManagerStopSession method is complete. |
| 254 void OnDeviceWipe(dbus::Response* response) { |
| 255 LOG_IF(ERROR, !response) |
| 256 << "Failed to call " |
| 257 << login_manager::kSessionManagerStartDeviceWipe; |
| 258 } |
| 259 |
| 243 // Called when kSessionManagerRetrievePolicy or | 260 // Called when kSessionManagerRetrievePolicy or |
| 244 // kSessionManagerRetrieveUserPolicy method is complete. | 261 // kSessionManagerRetrieveUserPolicy method is complete. |
| 245 void OnRetrievePolicy(const std::string& method_name, | 262 void OnRetrievePolicy(const std::string& method_name, |
| 246 const RetrievePolicyCallback& callback, | 263 const RetrievePolicyCallback& callback, |
| 247 dbus::Response* response) { | 264 dbus::Response* response) { |
| 248 if (!response) { | 265 if (!response) { |
| 249 LOG(ERROR) << "Failed to call " << method_name; | 266 LOG(ERROR) << "Failed to call " << method_name; |
| 250 callback.Run(""); | 267 callback.Run(""); |
| 251 return; | 268 return; |
| 252 } | 269 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 364 } |
| 348 virtual bool HasObserver(Observer* observer) OVERRIDE { | 365 virtual bool HasObserver(Observer* observer) OVERRIDE { |
| 349 return observers_.HasObserver(observer); | 366 return observers_.HasObserver(observer); |
| 350 } | 367 } |
| 351 virtual void EmitLoginPromptReady() OVERRIDE {} | 368 virtual void EmitLoginPromptReady() OVERRIDE {} |
| 352 virtual void EmitLoginPromptVisible() OVERRIDE {} | 369 virtual void EmitLoginPromptVisible() OVERRIDE {} |
| 353 virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE {} | 370 virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE {} |
| 354 virtual void RestartEntd() OVERRIDE {} | 371 virtual void RestartEntd() OVERRIDE {} |
| 355 virtual void StartSession(const std::string& user_email) OVERRIDE {} | 372 virtual void StartSession(const std::string& user_email) OVERRIDE {} |
| 356 virtual void StopSession() OVERRIDE {} | 373 virtual void StopSession() OVERRIDE {} |
| 374 virtual void StartDeviceWipe() OVERRIDE {} |
| 357 virtual void RequestLockScreen() OVERRIDE { | 375 virtual void RequestLockScreen() OVERRIDE { |
| 358 screen_locked_ = true; | 376 screen_locked_ = true; |
| 359 FOR_EACH_OBSERVER(Observer, observers_, LockScreen()); | 377 FOR_EACH_OBSERVER(Observer, observers_, LockScreen()); |
| 360 } | 378 } |
| 361 virtual void NotifyLockScreenShown() OVERRIDE {} | 379 virtual void NotifyLockScreenShown() OVERRIDE {} |
| 362 virtual void RequestUnlockScreen() OVERRIDE { | 380 virtual void RequestUnlockScreen() OVERRIDE { |
| 363 screen_locked_ = false; | 381 screen_locked_ = false; |
| 364 FOR_EACH_OBSERVER(Observer, observers_, UnlockScreen()); | 382 FOR_EACH_OBSERVER(Observer, observers_, UnlockScreen()); |
| 365 } | 383 } |
| 366 virtual void NotifyLockScreenDismissed() OVERRIDE {} | 384 virtual void NotifyLockScreenDismissed() OVERRIDE {} |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 SessionManagerClient* SessionManagerClient::Create( | 416 SessionManagerClient* SessionManagerClient::Create( |
| 399 DBusClientImplementationType type, | 417 DBusClientImplementationType type, |
| 400 dbus::Bus* bus) { | 418 dbus::Bus* bus) { |
| 401 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 419 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 402 return new SessionManagerClientImpl(bus); | 420 return new SessionManagerClientImpl(bus); |
| 403 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 421 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 404 return new SessionManagerClientStubImpl(); | 422 return new SessionManagerClientStubImpl(); |
| 405 } | 423 } |
| 406 | 424 |
| 407 } // namespace chromeos | 425 } // namespace chromeos |
| OLD | NEW |