diff options
author | dtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-05 00:00:21 +0000 |
---|---|---|
committer | dtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-05 00:00:21 +0000 |
commit | cfc34b79cb374bb5577fdcda6c3638c093d6e153 (patch) | |
tree | 3d5a5a6e699f26adb87277fe61ba75540ca287e7 /chrome | |
parent | dd9919a6b88d8ab8f5a306ae38bf3cc781f14169 (diff) | |
download | chromium_src-cfc34b79cb374bb5577fdcda6c3638c093d6e153.zip chromium_src-cfc34b79cb374bb5577fdcda6c3638c093d6e153.tar.gz chromium_src-cfc34b79cb374bb5577fdcda6c3638c093d6e153.tar.bz2 |
Right now the lock and unlock automation calls return immediately. Instead, it should block until the lock/unlock completes.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6250121
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73875 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
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); } - |