summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-09 20:32:18 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-09 20:32:18 +0000
commit16f3e30d213bd3708591d6a513889e395c485ac8 (patch)
tree2bdf875eb28b8ecdb6f79cd2600799cad5502376 /chromeos
parentc6f57f9e22339c7beb608a67ac9bb90425ed84e6 (diff)
downloadchromium_src-16f3e30d213bd3708591d6a513889e395c485ac8.zip
chromium_src-16f3e30d213bd3708591d6a513889e395c485ac8.tar.gz
chromium_src-16f3e30d213bd3708591d6a513889e395c485ac8.tar.bz2
chromeos: Request screen lock directly from session manager.
Screen lock and unlock requests were previously sent to powerd, which just forwarded them on to the session manager without doing anything extra. It's simpler for Chrome to just ask the session manager to lock or unlock directly. I'm also moving the LockScreen and UnlockScreen notifications from PowerManagerClient::Observer to SessionManagerClient::Observer. Confusingly, the signals that prompt those notifications are sent by the session manager but were being listened for in PowerManagerClient. BUG=chromium-os:24003 TEST=manual: able to lock the screen from the UI, power button, and by closing the lid; unlocking works too Review URL: https://chromiumcodereview.appspot.com/10693087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/mock_power_manager_client.h3
-rw-r--r--chromeos/dbus/mock_session_manager_client.h4
-rw-r--r--chromeos/dbus/power_manager_client.cc145
-rw-r--r--chromeos/dbus/power_manager_client.h17
-rw-r--r--chromeos/dbus/session_manager_client.cc120
-rw-r--r--chromeos/dbus/session_manager_client.h20
6 files changed, 89 insertions, 220 deletions
diff --git a/chromeos/dbus/mock_power_manager_client.h b/chromeos/dbus/mock_power_manager_client.h
index 4a29e21..51cf36c 100644
--- a/chromeos/dbus/mock_power_manager_client.h
+++ b/chromeos/dbus/mock_power_manager_client.h
@@ -38,11 +38,8 @@ class MockPowerManagerClient : public PowerManagerClient {
uint32,
int,
const PowerStateRequestIdCallback&));
- MOCK_METHOD0(NotifyScreenLockRequested, void(void));
MOCK_METHOD0(NotifyScreenLockCompleted, void(void));
- MOCK_METHOD0(NotifyScreenUnlockRequested, void(void));
MOCK_METHOD0(NotifyScreenUnlockCompleted, void(void));
- MOCK_METHOD0(GetIsScreenLocked, bool(void));
};
} // namespace chromeos
diff --git a/chromeos/dbus/mock_session_manager_client.h b/chromeos/dbus/mock_session_manager_client.h
index b8632b54..2ea212fe 100644
--- a/chromeos/dbus/mock_session_manager_client.h
+++ b/chromeos/dbus/mock_session_manager_client.h
@@ -19,12 +19,16 @@ class MockSessionManagerClient : public SessionManagerClient {
MOCK_METHOD1(AddObserver, void(Observer*));
MOCK_METHOD1(RemoveObserver, void(Observer*));
+ MOCK_METHOD1(HasObserver, bool(Observer*));
MOCK_METHOD0(EmitLoginPromptReady, void(void));
MOCK_METHOD0(EmitLoginPromptVisible, void(void));
MOCK_METHOD0(RestartEntd, void(void));
MOCK_METHOD2(RestartJob, void(int, const std::string&));
MOCK_METHOD1(StartSession, void(const std::string&));
MOCK_METHOD0(StopSession, void(void));
+ MOCK_METHOD0(RequestLockScreen, void(void));
+ MOCK_METHOD0(RequestUnlockScreen, void(void));
+ MOCK_METHOD0(GetIsScreenLocked, bool(void));
MOCK_METHOD1(RetrieveDevicePolicy, void(const RetrievePolicyCallback&));
MOCK_METHOD1(RetrieveUserPolicy, void(const RetrievePolicyCallback&));
MOCK_METHOD2(StoreDevicePolicy, void(const std::string&,
diff --git a/chromeos/dbus/power_manager_client.cc b/chromeos/dbus/power_manager_client.cc
index 6c279fe..d1e7fb5 100644
--- a/chromeos/dbus/power_manager_client.cc
+++ b/chromeos/dbus/power_manager_client.cc
@@ -10,7 +10,6 @@
#include "base/callback.h"
#include "base/format_macros.h"
#include "base/memory/scoped_ptr.h"
-#include "base/metrics/histogram.h"
#include "base/observer_list.h"
#include "base/stringprintf.h"
#include "base/time.h"
@@ -28,25 +27,8 @@ namespace chromeos {
// The PowerManagerClient implementation used in production.
class PowerManagerClientImpl : public PowerManagerClient {
public:
- enum LockScreensState {
- LOCK_SCREEN_REQUESTED, // Lock screen is requested.
- LOCK_SCREEN_REQUEST_SUCCEEDED, // Method call succeeded.
- LOCK_SCREEN_REQUEST_FAILED, // Method call failed.
- LOCK_SCREEN_FINISHED, // Signal is received.
- NUM_LOCK_SCREEN_STATES
- };
-
- enum UnlockScreensState {
- UNLOCK_SCREEN_REQUESTED, // Unlock screen is requested.
- UNLOCK_SCREEN_REQUEST_SUCCEEDED, // Method call succeeded.
- UNLOCK_SCREEN_REQUEST_FAILED, // Method call failed.
- UNLOCK_SCREEN_FINISHED, // Signal is received.
- NUM_UNLOCK_SCREEN_STATES
- };
-
explicit PowerManagerClientImpl(dbus::Bus* bus)
: power_manager_proxy_(NULL),
- screen_locked_(false),
weak_ptr_factory_(this) {
power_manager_proxy_ = bus->GetObjectProxy(
power_manager::kPowerManagerServiceName,
@@ -99,22 +81,6 @@ class PowerManagerClientImpl : public PowerManagerClient {
base::Bind(&PowerManagerClientImpl::SignalConnected,
weak_ptr_factory_.GetWeakPtr()));
- session_manager_proxy_->ConnectToSignal(
- chromium::kChromiumInterface,
- chromium::kLockScreenSignal,
- base::Bind(&PowerManagerClientImpl::ScreenLockSignalReceived,
- weak_ptr_factory_.GetWeakPtr()),
- base::Bind(&PowerManagerClientImpl::SignalConnected,
- weak_ptr_factory_.GetWeakPtr()));
-
- session_manager_proxy_->ConnectToSignal(
- chromium::kChromiumInterface,
- chromium::kUnlockScreenSignal,
- base::Bind(&PowerManagerClientImpl::ScreenUnlockSignalReceived,
- weak_ptr_factory_.GetWeakPtr()),
- base::Bind(&PowerManagerClientImpl::SignalConnected,
- weak_ptr_factory_.GetWeakPtr()));
-
power_manager_proxy_->ConnectToSignal(
power_manager::kPowerManagerInterface,
power_manager::kIdleNotifySignal,
@@ -299,48 +265,14 @@ class PowerManagerClientImpl : public PowerManagerClient {
weak_ptr_factory_.GetWeakPtr(), callback));
}
- virtual void NotifyScreenLockRequested() OVERRIDE {
- dbus::MethodCall method_call(power_manager::kPowerManagerInterface,
- power_manager::kRequestLockScreenMethod);
- UMA_HISTOGRAM_ENUMERATION("LockScreen.LockScreenPath",
- LOCK_SCREEN_REQUESTED,
- NUM_LOCK_SCREEN_STATES);
- power_manager_proxy_->CallMethodWithErrorCallback(
- &method_call,
- dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
- base::Bind(&PowerManagerClientImpl::OnScreenLockRequested,
- weak_ptr_factory_.GetWeakPtr()),
- base::Bind(&PowerManagerClientImpl::OnScreenLockRequestedError,
- weak_ptr_factory_.GetWeakPtr()));
- }
-
virtual void NotifyScreenLockCompleted() OVERRIDE {
SimpleMethodCallToPowerManager(power_manager::kScreenIsLockedMethod);
}
- virtual void NotifyScreenUnlockRequested() OVERRIDE {
- dbus::MethodCall method_call(power_manager::kPowerManagerInterface,
- power_manager::kRequestUnlockScreenMethod);
- UMA_HISTOGRAM_ENUMERATION("LockScreen.UnlockScreenPath",
- UNLOCK_SCREEN_REQUESTED,
- NUM_UNLOCK_SCREEN_STATES);
- power_manager_proxy_->CallMethodWithErrorCallback(
- &method_call,
- dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
- base::Bind(&PowerManagerClientImpl::OnScreenUnlockRequested,
- weak_ptr_factory_.GetWeakPtr()),
- base::Bind(&PowerManagerClientImpl::OnScreenUnlockRequestedError,
- weak_ptr_factory_.GetWeakPtr()));
- }
-
virtual void NotifyScreenUnlockCompleted() OVERRIDE {
SimpleMethodCallToPowerManager(power_manager::kScreenIsUnlockedMethod);
}
- virtual bool GetIsScreenLocked() OVERRIDE {
- return screen_locked_;
- }
-
private:
// Called when a dbus signal is initially connected.
void SignalConnected(const std::string& interface_name,
@@ -503,47 +435,6 @@ class PowerManagerClientImpl : public PowerManagerClient {
callback.Run(request_id);
}
- void OnScreenLockRequested(dbus::Response* response) {
- UMA_HISTOGRAM_ENUMERATION("LockScreen.LockScreenPath",
- LOCK_SCREEN_REQUEST_SUCCEEDED,
- NUM_LOCK_SCREEN_STATES);
- }
-
- void OnScreenLockRequestedError(dbus::ErrorResponse* error_response) {
- if (error_response) {
- dbus::MessageReader reader(error_response);
- std::string error_message;
- reader.PopString(&error_message);
- LOG(ERROR) << "Failed to call ScreenLockRequested: "
- << error_response->GetErrorName()
- << ": " << error_message;
- }
- UMA_HISTOGRAM_ENUMERATION("LockScreen.LockScreenPath",
- LOCK_SCREEN_REQUEST_FAILED,
- NUM_LOCK_SCREEN_STATES);
- }
-
- void OnScreenUnlockRequested(dbus::Response* response) {
- UMA_HISTOGRAM_ENUMERATION("LockScreen.UnlockScreenPath",
- UNLOCK_SCREEN_REQUEST_SUCCEEDED,
- NUM_UNLOCK_SCREEN_STATES);
- }
-
- void OnScreenUnlockRequestedError(dbus::ErrorResponse* error_response) {
- if (error_response) {
- dbus::MessageReader reader(error_response);
- std::string error_message;
- reader.PopString(&error_message);
- LOG(ERROR) << "Failed to call ScreenUnlockRequested: "
- << error_response->GetErrorName()
- << ": " << error_message;
- }
- UMA_HISTOGRAM_ENUMERATION("LockScreen.UnlockScreenPath",
- UNLOCK_SCREEN_REQUEST_FAILED,
- NUM_UNLOCK_SCREEN_STATES);
- }
-
-
void OnGetScreenBrightnessPercent(
const GetScreenBrightnessPercentCallback& callback,
dbus::Response* response) {
@@ -560,26 +451,6 @@ class PowerManagerClientImpl : public PowerManagerClient {
callback.Run(percent);
}
- void ScreenLockSignalReceived(dbus::Signal* signal) {
- // TODO(flackr): This warning is actually a signal that things are working
- // as expected. As per http://crbug.com/126217, this will help determine
- // if the problem is with dbus or in chrome.
- LOG(WARNING) << "LockScreen signal received from power manager.";
- screen_locked_ = true;
- UMA_HISTOGRAM_ENUMERATION("LockScreen.LockScreenPath",
- LOCK_SCREEN_FINISHED,
- NUM_LOCK_SCREEN_STATES);
- FOR_EACH_OBSERVER(Observer, observers_, LockScreen());
- }
-
- void ScreenUnlockSignalReceived(dbus::Signal* signal) {
- screen_locked_ = false;
- UMA_HISTOGRAM_ENUMERATION("LockScreen.UnlockScreenPath",
- UNLOCK_SCREEN_FINISHED,
- NUM_UNLOCK_SCREEN_STATES);
- FOR_EACH_OBSERVER(Observer, observers_, UnlockScreen());
- }
-
void IdleNotifySignalReceived(dbus::Signal* signal) {
dbus::MessageReader reader(signal);
int64 threshold = 0;
@@ -634,7 +505,6 @@ class PowerManagerClientImpl : public PowerManagerClient {
dbus::ObjectProxy* power_manager_proxy_;
dbus::ObjectProxy* session_manager_proxy_;
ObserverList<Observer> observers_;
- bool screen_locked_;
base::WeakPtrFactory<PowerManagerClientImpl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PowerManagerClientImpl);
@@ -648,8 +518,7 @@ class PowerManagerClientStubImpl : public PowerManagerClient {
: discharging_(true),
battery_percentage_(40),
brightness_(50.0),
- pause_count_(2),
- screen_locked_(false) {
+ pause_count_(2) {
}
virtual ~PowerManagerClientStubImpl() {}
@@ -726,19 +595,8 @@ class PowerManagerClientStubImpl : public PowerManagerClient {
int overrides,
const PowerStateRequestIdCallback& callback) OVERRIDE {}
- virtual void NotifyScreenLockRequested() OVERRIDE {
- screen_locked_ = true;
- FOR_EACH_OBSERVER(Observer, observers_, LockScreen());
- }
virtual void NotifyScreenLockCompleted() OVERRIDE {}
- virtual void NotifyScreenUnlockRequested() OVERRIDE {
- screen_locked_ = false;
- FOR_EACH_OBSERVER(Observer, observers_, UnlockScreen());
- }
virtual void NotifyScreenUnlockCompleted() OVERRIDE {}
- virtual bool GetIsScreenLocked() OVERRIDE {
- return screen_locked_;
- }
private:
void Update() {
@@ -786,7 +644,6 @@ class PowerManagerClientStubImpl : public PowerManagerClient {
ObserverList<Observer> observers_;
base::RepeatingTimer<PowerManagerClientStubImpl> timer_;
PowerSupplyStatus status_;
- bool screen_locked_;
};
PowerManagerClient::PowerManagerClient() {
diff --git a/chromeos/dbus/power_manager_client.h b/chromeos/dbus/power_manager_client.h
index dcd9848..3526890 100644
--- a/chromeos/dbus/power_manager_client.h
+++ b/chromeos/dbus/power_manager_client.h
@@ -74,12 +74,6 @@ class CHROMEOS_EXPORT PowerManagerClient {
virtual void LockButtonStateChanged(bool down,
const base::TimeTicks& timestamp) {}
- // Called when the screen is locked.
- virtual void LockScreen() {}
-
- // Called when the screen is unlocked.
- virtual void UnlockScreen() {}
-
// Called when we go idle for threshold time.
virtual void IdleNotify(int64 threshold_secs) {}
@@ -134,23 +128,12 @@ class CHROMEOS_EXPORT PowerManagerClient {
// Requests shutdown of the system.
virtual void RequestShutdown() = 0;
- // Notifies PowerManager that a user requested to lock the screen.
- virtual void NotifyScreenLockRequested() = 0;
-
// Notifies PowerManager that screen lock has been completed.
virtual void NotifyScreenLockCompleted() = 0;
- // Notifies PowerManager that a user unlocked the screen.
- virtual void NotifyScreenUnlockRequested() = 0;
-
// Notifies PowerManager that screen is unlocked.
virtual void NotifyScreenUnlockCompleted() = 0;
- // Return whether or not the screen is locked. Implementation should cache
- // this state so that it can return immediately. Useful for observers that
- // need to know the current screen lock state when they are added.
- virtual bool GetIsScreenLocked() = 0;
-
// Idle management functions:
// Calculates idle time asynchronously, after the idle time request has
diff --git a/chromeos/dbus/session_manager_client.cc b/chromeos/dbus/session_manager_client.cc
index 6c40353..dd90b94 100644
--- a/chromeos/dbus/session_manager_client.cc
+++ b/chromeos/dbus/session_manager_client.cc
@@ -20,12 +20,12 @@ class SessionManagerClientImpl : public SessionManagerClient {
public:
explicit SessionManagerClientImpl(dbus::Bus* bus)
: session_manager_proxy_(NULL),
+ screen_locked_(false),
weak_ptr_factory_(this) {
session_manager_proxy_ = bus->GetObjectProxy(
login_manager::kSessionManagerServiceName,
dbus::ObjectPath(login_manager::kSessionManagerServicePath));
- // Monitor the D-Bus signal for owner key changes.
session_manager_proxy_->ConnectToSignal(
chromium::kChromiumInterface,
chromium::kOwnerKeySetSignal,
@@ -34,7 +34,6 @@ class SessionManagerClientImpl : public SessionManagerClient {
base::Bind(&SessionManagerClientImpl::SignalConnected,
weak_ptr_factory_.GetWeakPtr()));
- // Monitor the D-Bus signal for property changes.
session_manager_proxy_->ConnectToSignal(
chromium::kChromiumInterface,
chromium::kPropertyChangeCompleteSignal,
@@ -42,46 +41,50 @@ class SessionManagerClientImpl : public SessionManagerClient {
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&SessionManagerClientImpl::SignalConnected,
weak_ptr_factory_.GetWeakPtr()));
+
+ session_manager_proxy_->ConnectToSignal(
+ chromium::kChromiumInterface,
+ chromium::kLockScreenSignal,
+ base::Bind(&SessionManagerClientImpl::ScreenLockReceived,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&SessionManagerClientImpl::SignalConnected,
+ weak_ptr_factory_.GetWeakPtr()));
+
+ session_manager_proxy_->ConnectToSignal(
+ chromium::kChromiumInterface,
+ chromium::kUnlockScreenSignal,
+ base::Bind(&SessionManagerClientImpl::ScreenUnlockReceived,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&SessionManagerClientImpl::SignalConnected,
+ weak_ptr_factory_.GetWeakPtr()));
}
virtual ~SessionManagerClientImpl() {
}
- // SessionManagerClient override.
+ // SessionManagerClient overrides:
virtual void AddObserver(Observer* observer) OVERRIDE {
observers_.AddObserver(observer);
}
- // SessionManagerClient override.
virtual void RemoveObserver(Observer* observer) OVERRIDE {
observers_.RemoveObserver(observer);
}
- // SessionManagerClient override.
+ virtual bool HasObserver(Observer* observer) OVERRIDE {
+ return observers_.HasObserver(observer);
+ }
+
virtual void EmitLoginPromptReady() OVERRIDE {
- dbus::MethodCall method_call(
- login_manager::kSessionManagerInterface,
+ SimpleMethodCallToSessionManager(
login_manager::kSessionManagerEmitLoginPromptReady);
- session_manager_proxy_->CallMethod(
- &method_call,
- dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
- base::Bind(&SessionManagerClientImpl::OnEmitLoginPromptReady,
- weak_ptr_factory_.GetWeakPtr()));
}
- // SessionManagerClient override.
virtual void EmitLoginPromptVisible() OVERRIDE {
- dbus::MethodCall method_call(
- login_manager::kSessionManagerInterface,
+ SimpleMethodCallToSessionManager(
login_manager::kSessionManagerEmitLoginPromptVisible);
- session_manager_proxy_->CallMethod(
- &method_call,
- dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
- base::Bind(&SessionManagerClientImpl::OnEmitLoginPromptVisible,
- weak_ptr_factory_.GetWeakPtr()));
}
- // SessionManagerClient override.
virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE {
dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
login_manager::kSessionManagerRestartJob);
@@ -95,18 +98,10 @@ class SessionManagerClientImpl : public SessionManagerClient {
weak_ptr_factory_.GetWeakPtr()));
}
- // SessionManagerClient override.
virtual void RestartEntd() OVERRIDE {
- dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
- login_manager::kSessionManagerRestartEntd);
- session_manager_proxy_->CallMethod(
- &method_call,
- dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
- base::Bind(&SessionManagerClientImpl::OnRestartEntd,
- weak_ptr_factory_.GetWeakPtr()));
+ SimpleMethodCallToSessionManager(login_manager::kSessionManagerRestartEntd);
}
- // SessionManagerClient override.
virtual void StartSession(const std::string& user_email) OVERRIDE {
dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
login_manager::kSessionManagerStartSession);
@@ -120,7 +115,6 @@ class SessionManagerClientImpl : public SessionManagerClient {
weak_ptr_factory_.GetWeakPtr()));
}
- // SessionManagerClient override.
virtual void StopSession() OVERRIDE {
dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
login_manager::kSessionManagerStopSession);
@@ -133,28 +127,37 @@ class SessionManagerClientImpl : public SessionManagerClient {
weak_ptr_factory_.GetWeakPtr()));
}
- // SessionManagerClient override.
+ virtual void RequestLockScreen() OVERRIDE {
+ SimpleMethodCallToSessionManager(login_manager::kSessionManagerLockScreen);
+ }
+
+ virtual void RequestUnlockScreen() OVERRIDE {
+ SimpleMethodCallToSessionManager(
+ login_manager::kSessionManagerUnlockScreen);
+ }
+
+ virtual bool GetIsScreenLocked() OVERRIDE {
+ return screen_locked_;
+ }
+
virtual void RetrieveDevicePolicy(
const RetrievePolicyCallback& callback) OVERRIDE {
CallRetrievePolicy(login_manager::kSessionManagerRetrievePolicy,
callback);
}
- // SessionManagerClient override.
virtual void RetrieveUserPolicy(
const RetrievePolicyCallback& callback) OVERRIDE {
CallRetrievePolicy(login_manager::kSessionManagerRetrieveUserPolicy,
callback);
}
- // SessionManagerClient override.
virtual void StoreDevicePolicy(const std::string& policy_blob,
const StorePolicyCallback& callback) OVERRIDE {
CallStorePolicy(login_manager::kSessionManagerStorePolicy,
policy_blob, callback);
}
- // SessionManagerClient override.
virtual void StoreUserPolicy(const std::string& policy_blob,
const StorePolicyCallback& callback) OVERRIDE {
CallStorePolicy(login_manager::kSessionManagerStoreUserPolicy,
@@ -162,6 +165,17 @@ class SessionManagerClientImpl : public SessionManagerClient {
}
private:
+ // Makes a method call to the session manager with no arguments and no
+ // response.
+ void SimpleMethodCallToSessionManager(const std::string& method_name) {
+ dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
+ method_name);
+ session_manager_proxy_->CallMethod(
+ &method_call,
+ dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ dbus::ObjectProxy::EmptyResponseCallback());
+ }
+
// Helper for Retrieve{User,Device}Policy.
virtual void CallRetrievePolicy(const std::string& method_name,
const RetrievePolicyCallback& callback) {
@@ -195,20 +209,6 @@ class SessionManagerClientImpl : public SessionManagerClient {
callback));
}
- // Called when kSessionManagerEmitLoginPromptReady method is complete.
- void OnEmitLoginPromptReady(dbus::Response* response) {
- LOG_IF(ERROR, !response)
- << "Failed to call "
- << login_manager::kSessionManagerEmitLoginPromptReady;
- }
-
- // Called when kSessionManagerEmitLoginPromptVisible method is complete.
- void OnEmitLoginPromptVisible(dbus::Response* response) {
- LOG_IF(ERROR, !response)
- << "Failed to call "
- << login_manager::kSessionManagerEmitLoginPromptVisible;
- }
-
// Called when kSessionManagerRestartJob method is complete.
void OnRestartJob(dbus::Response* response) {
LOG_IF(ERROR, !response)
@@ -216,13 +216,6 @@ class SessionManagerClientImpl : public SessionManagerClient {
<< login_manager::kSessionManagerRestartJob;
}
- // Called when kSessionManagerRestartEntd method is complete.
- void OnRestartEntd(dbus::Response* response) {
- LOG_IF(ERROR, !response)
- << "Failed to call "
- << login_manager::kSessionManagerRestartEntd;
- }
-
// Called when kSessionManagerStartSession method is complete.
void OnStartSession(dbus::Response* response) {
LOG_IF(ERROR, !response)
@@ -300,6 +293,16 @@ class SessionManagerClientImpl : public SessionManagerClient {
FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(success));
}
+ void ScreenLockReceived(dbus::Signal* signal) {
+ screen_locked_ = true;
+ FOR_EACH_OBSERVER(Observer, observers_, LockScreen());
+ }
+
+ void ScreenUnlockReceived(dbus::Signal* signal) {
+ screen_locked_ = false;
+ FOR_EACH_OBSERVER(Observer, observers_, UnlockScreen());
+ }
+
// Called when the object is connected to the signal.
void SignalConnected(const std::string& interface_name,
const std::string& signal_name,
@@ -309,6 +312,7 @@ class SessionManagerClientImpl : public SessionManagerClient {
dbus::ObjectProxy* session_manager_proxy_;
ObserverList<Observer> observers_;
+ bool screen_locked_;
base::WeakPtrFactory<SessionManagerClientImpl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(SessionManagerClientImpl);
@@ -320,12 +324,16 @@ class SessionManagerClientStubImpl : public SessionManagerClient {
// SessionManagerClient overrides.
virtual void AddObserver(Observer* observer) OVERRIDE {}
virtual void RemoveObserver(Observer* observer) OVERRIDE {}
+ virtual bool HasObserver(Observer* observer) OVERRIDE { return false; }
virtual void EmitLoginPromptReady() OVERRIDE {}
virtual void EmitLoginPromptVisible() OVERRIDE {}
virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE {}
virtual void RestartEntd() OVERRIDE {}
virtual void StartSession(const std::string& user_email) OVERRIDE {}
virtual void StopSession() OVERRIDE {}
+ virtual void RequestLockScreen() OVERRIDE {}
+ virtual void RequestUnlockScreen() OVERRIDE {}
+ virtual bool GetIsScreenLocked() OVERRIDE { return false; }
virtual void RetrieveDevicePolicy(
const RetrievePolicyCallback& callback) OVERRIDE {
callback.Run("");
diff --git a/chromeos/dbus/session_manager_client.h b/chromeos/dbus/session_manager_client.h
index 82382e3..aed121e 100644
--- a/chromeos/dbus/session_manager_client.h
+++ b/chromeos/dbus/session_manager_client.h
@@ -26,13 +26,22 @@ class CHROMEOS_EXPORT SessionManagerClient {
public:
// Called when the owner key is set.
virtual void OwnerKeySet(bool success) {}
+
// Called when the property change is complete.
virtual void PropertyChangeComplete(bool success) {}
+
+ // Called when the screen is locked.
+ virtual void LockScreen() {}
+
+ // Called when the screen is unlocked.
+ virtual void UnlockScreen() {}
+
};
// Adds and removes the observer.
virtual void AddObserver(Observer* observer) = 0;
virtual void RemoveObserver(Observer* observer) = 0;
+ virtual bool HasObserver(Observer* observer) = 0;
// Kicks off an attempt to emit the "login-prompt-ready" upstart signal.
virtual void EmitLoginPromptReady() = 0;
@@ -53,6 +62,17 @@ class CHROMEOS_EXPORT SessionManagerClient {
// Stops the current session.
virtual void StopSession() = 0;
+ // Locks the screen.
+ virtual void RequestLockScreen() = 0;
+
+ // Unlocks the screen.
+ virtual void RequestUnlockScreen() = 0;
+
+ // Returns whether or not the screen is locked. Implementation should cache
+ // this state so that it can return immediately. Useful for observers that
+ // need to know the current screen lock state when they are added.
+ virtual bool GetIsScreenLocked() = 0;
+
// Used for RetrieveDevicePolicy and RetrieveUserPolicy. Takes a serialized
// protocol buffer as string. Upon success, we will pass a protobuf to the
// callback. On failure, we will pass "".