summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/automation/automation_provider_observers.cc25
-rw-r--r--chrome/browser/automation/automation_provider_observers.h25
-rw-r--r--chrome/browser/automation/testing_automation_provider_chromeos.cc5
3 files changed, 51 insertions, 4 deletions
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index afb04b05..a909824 100644
--- a/chrome/browser/automation/automation_provider_observers.cc
+++ b/chrome/browser/automation/automation_provider_observers.cc
@@ -1161,6 +1161,31 @@ void LoginManagerObserver::Observe(NotificationType type,
reply.SendError("Login failure.");
delete this;
}
+
+ScreenLockUnlockObserver::ScreenLockUnlockObserver(
+ AutomationProvider* automation,
+ IPC::Message* reply_message,
+ bool lock_screen)
+ : automation_(automation),
+ reply_message_(reply_message),
+ lock_screen_(lock_screen) {
+
+ registrar_.Add(this, NotificationType::SCREEN_LOCK_STATE_CHANGED,
+ NotificationService::AllSources());
+}
+
+void ScreenLockUnlockObserver::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK(type == NotificationType::SCREEN_LOCK_STATE_CHANGED);
+ AutomationJSONReply reply(automation_, reply_message_);
+ bool is_screen_locked = *Details<bool>(details).ptr();
+ if (lock_screen_ == is_screen_locked)
+ reply.SendSuccess(NULL);
+ else
+ reply.SendError("Screen lock failure.");
+ delete this;
+}
#endif
AutomationProviderBookmarkModelObserver::
diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h
index 724c79e..8fdc74d 100644
--- a/chrome/browser/automation/automation_provider_observers.h
+++ b/chrome/browser/automation/automation_provider_observers.h
@@ -620,7 +620,7 @@ class InfoBarCountObserver : public NotificationObserver {
};
#if defined(OS_CHROMEOS)
-// Collects LOGIN_AUTHENTICATION notifications and returns
+// Collects LOGIN_USER_CHANGED notifications and returns
// whether authentication succeeded to the automation provider.
class LoginManagerObserver : public NotificationObserver {
public:
@@ -638,6 +638,29 @@ class LoginManagerObserver : public NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(LoginManagerObserver);
};
+
+// Collects SCREEN_LOCK_STATE_CHANGED notifications and returns
+// whether authentication succeeded to the automation provider.
+class ScreenLockUnlockObserver : public NotificationObserver {
+ public:
+ // Set lock_screen to true to observe lock screen events,
+ // false for unlock screen events.
+ ScreenLockUnlockObserver(AutomationProvider* automation,
+ IPC::Message* reply_message,
+ bool lock_screen);
+
+ // NotificationObserver interface.
+ virtual void Observe(NotificationType type, const NotificationSource& source,
+ const NotificationDetails& details);
+
+ private:
+ NotificationRegistrar registrar_;
+ AutomationProvider* automation_;
+ IPC::Message* reply_message_;
+ bool lock_screen_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScreenLockUnlockObserver);
+};
#endif
// Waits for the bookmark model to load.
diff --git a/chrome/browser/automation/testing_automation_provider_chromeos.cc b/chrome/browser/automation/testing_automation_provider_chromeos.cc
index 4b891ce..c34f02a 100644
--- a/chrome/browser/automation/testing_automation_provider_chromeos.cc
+++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc
@@ -51,15 +51,14 @@ void TestingAutomationProvider::Logout(DictionaryValue* args,
void TestingAutomationProvider::ScreenLock(DictionaryValue* args,
IPC::Message* reply_message) {
+ new ScreenLockUnlockObserver(this, reply_message, true);
chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->
NotifyScreenLockRequested();
- AutomationJSONReply(this, reply_message).SendSuccess(NULL);
}
void TestingAutomationProvider::ScreenUnlock(DictionaryValue* args,
IPC::Message* reply_message) {
+ new ScreenLockUnlockObserver(this, reply_message, false);
chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->
NotifyScreenUnlockRequested();
- AutomationJSONReply(this, reply_message).SendSuccess(NULL);
}
-