Commit 0c91f41c authored by sque@chromium.org's avatar sque@chromium.org

Revert "chromeos: move screen lock handling to power manager client"

    
This reverts commit f9f5f14c.

Revert "Move chromeos specific code to ChromeBrowserMainPartsChromeos"
    
This reverts commit 922cff9c.

Revert "chromeos: remove power manager EXPECTs from login_browsertest"
    
This reverts commit 0a9298b6.



Review URL: http://codereview.chromium.org/8774035

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112651 0039d316-1c4b-4281-b951-d872f2087c98
parent 016ab203
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
#include "chrome/browser/chromeos/audio_handler.h" #include "chrome/browser/chromeos/audio_handler.h"
#include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h" #include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/cros/screen_lock_library.h"
#include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
#include "chrome/browser/chromeos/dbus/power_manager_client.h"
#include "chrome/browser/chromeos/dbus/update_engine_client.h" #include "chrome/browser/chromeos/dbus/update_engine_client.h"
#include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.h" #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.h"
#include "chrome/browser/chromeos/login/existing_user_controller.h" #include "chrome/browser/chromeos/login/existing_user_controller.h"
...@@ -276,7 +276,7 @@ void TestingAutomationProvider::Login(DictionaryValue* args, ...@@ -276,7 +276,7 @@ void TestingAutomationProvider::Login(DictionaryValue* args,
void TestingAutomationProvider::LockScreen(DictionaryValue* args, void TestingAutomationProvider::LockScreen(DictionaryValue* args,
IPC::Message* reply_message) { IPC::Message* reply_message) {
new ScreenLockUnlockObserver(this, reply_message, true); new ScreenLockUnlockObserver(this, reply_message, true);
DBusThreadManager::Get()->GetPowerManagerClient()-> CrosLibrary::Get()->GetScreenLockLibrary()->
NotifyScreenLockRequested(); NotifyScreenLockRequested();
} }
......
This diff is collapsed.
...@@ -56,9 +56,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts { ...@@ -56,9 +56,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts {
const content::MainFunctionParams& parameters); const content::MainFunctionParams& parameters);
// content::BrowserMainParts overrides. // content::BrowserMainParts overrides.
// These are called in-order by content::BrowserMainLoop.
// Each stage calls the same stages in any ChromeBrowserMainExtraParts added
// with AddParts() from ChromeContentBrowserClient::CreateBrowserMainParts.
virtual void PreEarlyInitialization() OVERRIDE; virtual void PreEarlyInitialization() OVERRIDE;
virtual void PostEarlyInitialization() OVERRIDE; virtual void PostEarlyInitialization() OVERRIDE;
virtual void ToolkitInitialized() OVERRIDE; virtual void ToolkitInitialized() OVERRIDE;
...@@ -74,13 +71,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts { ...@@ -74,13 +71,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts {
virtual void PostStopThread(content::BrowserThread::ID identifier) OVERRIDE; virtual void PostStopThread(content::BrowserThread::ID identifier) OVERRIDE;
virtual void PostDestroyThreads() OVERRIDE; virtual void PostDestroyThreads() OVERRIDE;
// Additional stages for ChromeBrowserMainExtraParts. These stages are called
// in order from PreMainMessageLoopStart(). See implementation for details.
virtual void PreProfileInit();
virtual void PostProfileInit();
virtual void PreBrowserStart();
virtual void PostBrowserStart();
// Displays a warning message that we can't find any locale data files. // Displays a warning message that we can't find any locale data files.
virtual void ShowMissingLocaleMessageBox() = 0; virtual void ShowMissingLocaleMessageBox() = 0;
...@@ -92,7 +82,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts { ...@@ -92,7 +82,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts {
} }
Profile* profile() { return profile_; } Profile* profile() { return profile_; }
MetricsService* metrics() { return metrics_; }
private: private:
// Methods for |EarlyInitialization()| --------------------------------------- // Methods for |EarlyInitialization()| ---------------------------------------
......
...@@ -25,16 +25,10 @@ void ChromeBrowserMainExtraParts::PostMainMessageLoopStart() { ...@@ -25,16 +25,10 @@ void ChromeBrowserMainExtraParts::PostMainMessageLoopStart() {
void ChromeBrowserMainExtraParts::ToolkitInitialized() { void ChromeBrowserMainExtraParts::ToolkitInitialized() {
} }
void ChromeBrowserMainExtraParts::PreProfileInit() { void ChromeBrowserMainExtraParts::PostBrowserProcessInit() {
} }
void ChromeBrowserMainExtraParts::PostProfileInit() { void ChromeBrowserMainExtraParts::PostProfileInitialized() {
}
void ChromeBrowserMainExtraParts::PreBrowserStart() {
}
void ChromeBrowserMainExtraParts::PostBrowserStart() {
} }
void ChromeBrowserMainExtraParts::PreMainMessageLoopRun() { void ChromeBrowserMainExtraParts::PreMainMessageLoopRun() {
......
...@@ -32,10 +32,8 @@ class ChromeBrowserMainExtraParts { ...@@ -32,10 +32,8 @@ class ChromeBrowserMainExtraParts {
virtual void PostMainMessageLoopStart(); virtual void PostMainMessageLoopStart();
// MainMessageLoopRun methods. // MainMessageLoopRun methods.
virtual void PreProfileInit(); virtual void PostBrowserProcessInit();
virtual void PostProfileInit(); virtual void PostProfileInitialized();
virtual void PreBrowserStart();
virtual void PostBrowserStart();
virtual void PreMainMessageLoopRun(); virtual void PreMainMessageLoopRun();
virtual void PostMainMessageLoopRun(); virtual void PostMainMessageLoopRun();
......
...@@ -16,7 +16,7 @@ ChromeBrowserMainExtraPartsAura::ChromeBrowserMainExtraPartsAura() ...@@ -16,7 +16,7 @@ ChromeBrowserMainExtraPartsAura::ChromeBrowserMainExtraPartsAura()
: ChromeBrowserMainExtraParts() { : ChromeBrowserMainExtraParts() {
} }
void ChromeBrowserMainExtraPartsAura::PreProfileInit() { void ChromeBrowserMainExtraPartsAura::PostBrowserProcessInit() {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (chromeos::system::runtime_environment::IsRunningOnChromeOS()) if (chromeos::system::runtime_environment::IsRunningOnChromeOS())
aura::Desktop::set_use_fullscreen_host_window(true); aura::Desktop::set_use_fullscreen_host_window(true);
......
...@@ -13,7 +13,7 @@ class ChromeBrowserMainExtraPartsAura : public ChromeBrowserMainExtraParts { ...@@ -13,7 +13,7 @@ class ChromeBrowserMainExtraPartsAura : public ChromeBrowserMainExtraParts {
public: public:
ChromeBrowserMainExtraPartsAura(); ChromeBrowserMainExtraPartsAura();
virtual void PreProfileInit() OVERRIDE; virtual void PostBrowserProcessInit() OVERRIDE;
private: private:
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAura); DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAura);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "chrome/browser/accessibility/accessibility_events.h" #include "chrome/browser/accessibility/accessibility_events.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_notification_types.h"
...@@ -20,9 +21,11 @@ SystemEventObserver* g_system_event_observer = NULL; ...@@ -20,9 +21,11 @@ SystemEventObserver* g_system_event_observer = NULL;
} }
SystemEventObserver::SystemEventObserver() { SystemEventObserver::SystemEventObserver() {
CrosLibrary::Get()->GetScreenLockLibrary()->AddObserver(this);
} }
SystemEventObserver::~SystemEventObserver() { SystemEventObserver::~SystemEventObserver() {
CrosLibrary::Get()->GetScreenLockLibrary()->RemoveObserver(this);
} }
void SystemEventObserver::SystemResumed() { void SystemEventObserver::SystemResumed() {
...@@ -32,16 +35,19 @@ void SystemEventObserver::SystemResumed() { ...@@ -32,16 +35,19 @@ void SystemEventObserver::SystemResumed() {
chrome::NOTIFICATION_ACCESSIBILITY_WOKE_UP, &info); chrome::NOTIFICATION_ACCESSIBILITY_WOKE_UP, &info);
} }
void SystemEventObserver::LockScreen() {} void SystemEventObserver::LockScreen(ScreenLockLibrary* screen_lock_library) {
}
void SystemEventObserver::UnlockScreen() { void SystemEventObserver::UnlockScreen(ScreenLockLibrary* screen_lock_library) {
Profile* profile = ProfileManager::GetDefaultProfile(); Profile* profile = ProfileManager::GetDefaultProfile();
ScreenUnlockedEventInfo info(profile); ScreenUnlockedEventInfo info(profile);
SendAccessibilityNotification( SendAccessibilityNotification(
chrome::NOTIFICATION_ACCESSIBILITY_SCREEN_UNLOCKED, &info); chrome::NOTIFICATION_ACCESSIBILITY_SCREEN_UNLOCKED, &info);
} }
void SystemEventObserver::UnlockScreenFailed() {} void SystemEventObserver::UnlockScreenFailed(
ScreenLockLibrary* screen_lock_library) {
}
// static // static
void SystemEventObserver::Initialize() { void SystemEventObserver::Initialize() {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SYSTEM_EVENT_OBSERVER_H_ #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SYSTEM_EVENT_OBSERVER_H_
#pragma once #pragma once
#include "chrome/browser/chromeos/cros/screen_lock_library.h"
#include "chrome/browser/chromeos/dbus/power_manager_client.h" #include "chrome/browser/chromeos/dbus/power_manager_client.h"
namespace chromeos { namespace chromeos {
...@@ -13,7 +14,8 @@ namespace accessibility { ...@@ -13,7 +14,8 @@ namespace accessibility {
// A singleton class to observe system events like wake up from sleep and // A singleton class to observe system events like wake up from sleep and
// screen unlock. // screen unlock.
class SystemEventObserver : public PowerManagerClient::Observer { class SystemEventObserver : public PowerManagerClient::Observer,
public ScreenLockLibrary::Observer {
public: public:
virtual ~SystemEventObserver(); virtual ~SystemEventObserver();
...@@ -21,13 +23,14 @@ class SystemEventObserver : public PowerManagerClient::Observer { ...@@ -21,13 +23,14 @@ class SystemEventObserver : public PowerManagerClient::Observer {
virtual void SystemResumed() OVERRIDE; virtual void SystemResumed() OVERRIDE;
// ScreenLockLibrary::Observer override. // ScreenLockLibrary::Observer override.
virtual void LockScreen() OVERRIDE; virtual void LockScreen(ScreenLockLibrary* screen_lock_library) OVERRIDE;
// ScreenLockLibrary::Observer override. // ScreenLockLibrary::Observer override.
virtual void UnlockScreen() OVERRIDE; virtual void UnlockScreen(ScreenLockLibrary* screen_lock_library) OVERRIDE;
// ScreenLockLibrary::Observer override. // ScreenLockLibrary::Observer override.
virtual void UnlockScreenFailed() OVERRIDE; virtual void UnlockScreenFailed(ScreenLockLibrary* screen_lock_library)
OVERRIDE;
// Creates the global SystemEventObserver instance. // Creates the global SystemEventObserver instance.
static void Initialize(); static void Initialize();
......
...@@ -27,14 +27,9 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux { ...@@ -27,14 +27,9 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux {
virtual void PreEarlyInitialization() OVERRIDE; virtual void PreEarlyInitialization() OVERRIDE;
virtual void PreMainMessageLoopStart() OVERRIDE; virtual void PreMainMessageLoopStart() OVERRIDE;
virtual void PostMainMessageLoopStart() OVERRIDE; virtual void PostMainMessageLoopStart() OVERRIDE;
virtual void PreMainMessageLoopRun() OVERRIDE;
virtual void PostMainMessageLoopRun() OVERRIDE; virtual void PostMainMessageLoopRun() OVERRIDE;
// ChromeBrowserMainExtraParts overrodes.
virtual void PreProfileInit() OVERRIDE;
virtual void PostProfileInit() OVERRIDE;
virtual void PreBrowserStart() OVERRIDE;
virtual void PostBrowserStart() OVERRIDE;
private: private:
scoped_ptr<chromeos::BrightnessObserver> brightness_observer_; scoped_ptr<chromeos::BrightnessObserver> brightness_observer_;
scoped_ptr<chromeos::SessionManagerObserver> session_manager_observer_; scoped_ptr<chromeos::SessionManagerObserver> session_manager_observer_;
......
...@@ -25,10 +25,6 @@ class MockPowerManagerClient : public PowerManagerClient { ...@@ -25,10 +25,6 @@ class MockPowerManagerClient : public PowerManagerClient {
MOCK_METHOD0(RequestRestart, void(void)); MOCK_METHOD0(RequestRestart, void(void));
MOCK_METHOD0(RequestShutdown, void(void)); MOCK_METHOD0(RequestShutdown, void(void));
MOCK_METHOD1(CalculateIdleTime, void(const CalculateIdleTimeCallback&)); MOCK_METHOD1(CalculateIdleTime, void(const CalculateIdleTimeCallback&));
MOCK_METHOD0(NotifyScreenLockRequested, void(void));
MOCK_METHOD0(NotifyScreenLockCompleted, void(void));
MOCK_METHOD0(NotifyScreenUnlockRequested, void(void));
MOCK_METHOD0(NotifyScreenUnlockCompleted, void(void));
}; };
} // namespace chromeos } // namespace chromeos
......
...@@ -92,29 +92,6 @@ class PowerManagerClientImpl : public PowerManagerClient { ...@@ -92,29 +92,6 @@ class PowerManagerClientImpl : public PowerManagerClient {
weak_ptr_factory_.GetWeakPtr()), weak_ptr_factory_.GetWeakPtr()),
base::Bind(&PowerManagerClientImpl::SignalConnected, base::Bind(&PowerManagerClientImpl::SignalConnected,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
// Monitor the D-Bus signal for screen lock and unlock signals.
power_manager_proxy_->ConnectToSignal(
chromium::kChromiumInterface,
chromium::kLockScreenSignal,
base::Bind(&PowerManagerClientImpl::ScreenLockSignalReceived,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&PowerManagerClientImpl::SignalConnected,
weak_ptr_factory_.GetWeakPtr()));
power_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(
chromium::kChromiumInterface,
chromium::kUnlockScreenFailedSignal,
base::Bind(&PowerManagerClientImpl::ScreenUnlockFailedSignalReceived,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&PowerManagerClientImpl::SignalConnected,
weak_ptr_factory_.GetWeakPtr()));
} }
virtual ~PowerManagerClientImpl() { virtual ~PowerManagerClientImpl() {
...@@ -199,22 +176,6 @@ class PowerManagerClientImpl : public PowerManagerClient { ...@@ -199,22 +176,6 @@ class PowerManagerClientImpl : public PowerManagerClient {
weak_ptr_factory_.GetWeakPtr(), callback)); weak_ptr_factory_.GetWeakPtr(), callback));
} }
virtual void NotifyScreenLockRequested() OVERRIDE {
SimpleMethodCallToPowerManager(power_manager::kRequestLockScreenMethod);
}
virtual void NotifyScreenLockCompleted() OVERRIDE {
SimpleMethodCallToPowerManager(power_manager::kScreenIsLockedMethod);
}
virtual void NotifyScreenUnlockRequested() OVERRIDE {
SimpleMethodCallToPowerManager(power_manager::kRequestUnlockScreenMethod);
}
virtual void NotifyScreenUnlockCompleted() OVERRIDE {
SimpleMethodCallToPowerManager(power_manager::kScreenIsUnlockedMethod);
}
private: private:
// Called when a dbus signal is initially connected. // Called when a dbus signal is initially connected.
void SignalConnected(const std::string& interface_name, void SignalConnected(const std::string& interface_name,
...@@ -224,16 +185,6 @@ class PowerManagerClientImpl : public PowerManagerClient { ...@@ -224,16 +185,6 @@ class PowerManagerClientImpl : public PowerManagerClient {
<< signal_name << "."; << signal_name << ".";
} }
// Make a method call to power manager with no arguments and no response.
void SimpleMethodCallToPowerManager(const std::string& method_name) {
dbus::MethodCall method_call(power_manager::kPowerManagerInterface,
method_name);
power_manager_proxy_->CallMethod(
&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
dbus::ObjectProxy::EmptyResponseCallback());
}
// Called when a brightness change signal is received. // Called when a brightness change signal is received.
void BrightnessChangedReceived(dbus::Signal* signal) { void BrightnessChangedReceived(dbus::Signal* signal) {
dbus::MessageReader reader(signal); dbus::MessageReader reader(signal);
...@@ -341,18 +292,6 @@ class PowerManagerClientImpl : public PowerManagerClient { ...@@ -341,18 +292,6 @@ class PowerManagerClientImpl : public PowerManagerClient {
callback.Run(idle_time_ms/1000); callback.Run(idle_time_ms/1000);
} }
void ScreenLockSignalReceived(dbus::Signal* signal) {
FOR_EACH_OBSERVER(Observer, observers_, LockScreen());
}
void ScreenUnlockSignalReceived(dbus::Signal* signal) {
FOR_EACH_OBSERVER(Observer, observers_, UnlockScreen());
}
void ScreenUnlockFailedSignalReceived(dbus::Signal* signal) {
FOR_EACH_OBSERVER(Observer, observers_, UnlockScreenFailed());
}
dbus::ObjectProxy* power_manager_proxy_; dbus::ObjectProxy* power_manager_proxy_;
ObserverList<Observer> observers_; ObserverList<Observer> observers_;
base::WeakPtrFactory<PowerManagerClientImpl> weak_ptr_factory_; base::WeakPtrFactory<PowerManagerClientImpl> weak_ptr_factory_;
...@@ -413,14 +352,6 @@ class PowerManagerClientStubImpl : public PowerManagerClient { ...@@ -413,14 +352,6 @@ class PowerManagerClientStubImpl : public PowerManagerClient {
callback.Run(0); callback.Run(0);
} }
virtual void NotifyScreenLockRequested() OVERRIDE {}
virtual void NotifyScreenLockCompleted() OVERRIDE {}
virtual void NotifyScreenUnlockRequested() OVERRIDE {}
virtual void NotifyScreenUnlockCompleted() OVERRIDE {}
private: private:
void Update() { void Update() {
// We pause at 0 and 100% so that it's easier to check those conditions. // We pause at 0 and 100% so that it's easier to check those conditions.
......
...@@ -54,15 +54,6 @@ class PowerManagerClient { ...@@ -54,15 +54,6 @@ class PowerManagerClient {
// Called when the system resumes from suspend. // Called when the system resumes from suspend.
virtual void SystemResumed() {} virtual void SystemResumed() {}
// Called when the screen is locked.
virtual void LockScreen() {}
// Called when the screen is unlocked.
virtual void UnlockScreen() {}
// Called when the screen fails to unlock.
virtual void UnlockScreenFailed() {}
}; };
// Adds and removes the observer. // Adds and removes the observer.
...@@ -90,18 +81,6 @@ class PowerManagerClient { ...@@ -90,18 +81,6 @@ class PowerManagerClient {
// encounters some error, it passes -1 to |callback|. // encounters some error, it passes -1 to |callback|.
virtual void CalculateIdleTime(const CalculateIdleTimeCallback& callback) = 0; virtual void CalculateIdleTime(const CalculateIdleTimeCallback& callback) = 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;
// Creates the instance. // Creates the instance.
static PowerManagerClient* Create(dbus::Bus* bus); static PowerManagerClient* Create(dbus::Bus* bus);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "chrome/browser/chromeos/cros/mock_cryptohome_library.h" #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h"
#include "chrome/browser/chromeos/cros/mock_library_loader.h" #include "chrome/browser/chromeos/cros/mock_library_loader.h"
#include "chrome/browser/chromeos/cros/mock_network_library.h" #include "chrome/browser/chromeos/cros/mock_network_library.h"
#include "chrome/browser/chromeos/cros/mock_screen_lock_library.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
...@@ -23,7 +24,8 @@ using ::testing::Return; ...@@ -23,7 +24,8 @@ using ::testing::Return;
class LoginTestBase : public CrosInProcessBrowserTest { class LoginTestBase : public CrosInProcessBrowserTest {
public: public:
LoginTestBase() : mock_cryptohome_library_(NULL) { LoginTestBase() : mock_cryptohome_library_(NULL),
mock_screen_lock_library_(NULL) {
} }
protected: protected:
...@@ -31,12 +33,15 @@ class LoginTestBase : public CrosInProcessBrowserTest { ...@@ -31,12 +33,15 @@ class LoginTestBase : public CrosInProcessBrowserTest {
cros_mock_->InitStatusAreaMocks(); cros_mock_->InitStatusAreaMocks();
cros_mock_->SetStatusAreaMocksExpectations(); cros_mock_->SetStatusAreaMocksExpectations();
cros_mock_->InitMockCryptohomeLibrary(); cros_mock_->InitMockCryptohomeLibrary();
cros_mock_->InitMockScreenLockLibrary();
mock_cryptohome_library_ = cros_mock_->mock_cryptohome_library(); mock_cryptohome_library_ = cros_mock_->mock_cryptohome_library();
mock_screen_lock_library_ = cros_mock_->mock_screen_lock_library();
EXPECT_CALL(*mock_cryptohome_library_, IsMounted()) EXPECT_CALL(*mock_cryptohome_library_, IsMounted())
.WillRepeatedly(Return(true)); .WillRepeatedly(Return(true));
} }
MockCryptohomeLibrary* mock_cryptohome_library_; MockCryptohomeLibrary* mock_cryptohome_library_;
MockScreenLockLibrary* mock_screen_lock_library_;
private: private:
DISALLOW_COPY_AND_ASSIGN(LoginTestBase); DISALLOW_COPY_AND_ASSIGN(LoginTestBase);
...@@ -46,6 +51,12 @@ class LoginUserTest : public LoginTestBase { ...@@ -46,6 +51,12 @@ class LoginUserTest : public LoginTestBase {
protected: protected:
virtual void SetUpInProcessBrowserTestFixture() { virtual void SetUpInProcessBrowserTestFixture() {
LoginTestBase::SetUpInProcessBrowserTestFixture(); LoginTestBase::SetUpInProcessBrowserTestFixture();
EXPECT_CALL(*mock_screen_lock_library_, AddObserver(_))
.Times(AtLeast(1))
.WillRepeatedly(Return());
EXPECT_CALL(*mock_screen_lock_library_, RemoveObserver(_))
.Times(AtLeast(1))
.WillRepeatedly(Return());
} }
virtual void SetUpCommandLine(CommandLine* command_line) { virtual void SetUpCommandLine(CommandLine* command_line) {
......
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/boot_times_loader.h" #include "chrome/browser/chromeos/boot_times_loader.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/screen_lock_library.h"
#include "chrome/browser/chromeos/cros_settings.h" #include "chrome/browser/chromeos/cros_settings.h"
#include "chrome/browser/chromeos/cros_settings_names.h" #include "chrome/browser/chromeos/cros_settings_names.h"
#include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
#include "chrome/browser/chromeos/dbus/power_manager_client.h"
#include "chrome/browser/chromeos/login/login_utils.h" #include "chrome/browser/chromeos/login/login_utils.h"
#include "chrome/browser/chromeos/login/screen_locker.h" #include "chrome/browser/chromeos/login/screen_locker.h"
#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/pref_service.h"
...@@ -367,7 +367,7 @@ void LoginPerformer::RequestScreenLock() { ...@@ -367,7 +367,7 @@ void LoginPerformer::RequestScreenLock() {
ResolveScreenLocked(); ResolveScreenLocked();
} else { } else {
screen_lock_requested_ = true; screen_lock_requested_ = true;
DBusThreadManager::Get()->GetPowerManagerClient()-> chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->
NotifyScreenLockRequested(); NotifyScreenLockRequested();
} }
} }
...@@ -375,7 +375,7 @@ void LoginPerformer::RequestScreenLock() { ...@@ -375,7 +375,7 @@ void LoginPerformer::RequestScreenLock() {
void LoginPerformer::RequestScreenUnlock() { void LoginPerformer::RequestScreenUnlock() {
DVLOG(1) << "Screen unlock requested"; DVLOG(1) << "Screen unlock requested";
if (ScreenLocker::default_screen_locker()) { if (ScreenLocker::default_screen_locker()) {
DBusThreadManager::Get()->GetPowerManagerClient()-> chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->
NotifyScreenUnlockRequested(); NotifyScreenUnlockRequested();
// Will unsubscribe from notifications once unlock is successful. // Will unsubscribe from notifications once unlock is successful.
} else { } else {
......
...@@ -16,8 +16,9 @@ ...@@ -16,8 +16,9 @@
#include "base/string_util.h" #include "base/string_util.h"
#include "base/timer.h" #include "base/timer.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/screen_lock_library.h"
#include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
#include "chrome/browser/chromeos/dbus/power_manager_client.h"
#include "chrome/browser/chromeos/dbus/session_manager_client.h" #include "chrome/browser/chromeos/dbus/session_manager_client.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h" #include "chrome/browser/chromeos/input_method/input_method_manager.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h" #include "chrome/browser/chromeos/input_method/input_method_util.h"
...@@ -54,7 +55,7 @@ using content::BrowserThread; ...@@ -54,7 +55,7 @@ using content::BrowserThread;
namespace { namespace {
// Observer to start ScreenLocker when the screen lock // Observer to start ScreenLocker when the screen lock
class ScreenLockObserver : public chromeos::PowerManagerClient::Observer, class ScreenLockObserver : public chromeos::ScreenLockLibrary::Observer,
public content::NotificationObserver { public content::NotificationObserver {
public: public:
ScreenLockObserver() { ScreenLockObserver() {
...@@ -69,23 +70,22 @@ class ScreenLockObserver : public chromeos::PowerManagerClient::Observer, ...@@ -69,23 +70,22 @@ class ScreenLockObserver : public chromeos::PowerManagerClient::Observer,
if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) {
// Register Screen Lock after login screen to make sure // Register Screen Lock after login screen to make sure
// we don't show the screen lock on top of the login screen by accident. // we don't show the screen lock on top of the login screen by accident.
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->AddObserver(this);
AddObserver(this);
} }
} }
virtual void LockScreen() OVERRIDE { virtual void LockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE {
VLOG(1) << "In: ScreenLockObserver::LockScreen"; VLOG(1) << "In: ScreenLockObserver::LockScreen";
SetupInputMethodsForScreenLocker(); SetupInputMethodsForScreenLocker();
chromeos::ScreenLocker::Show(); chromeos::ScreenLocker::Show();
} }
virtual void UnlockScreen() OVERRIDE { virtual void UnlockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE {
RestoreInputMethods(); RestoreInputMethods();
chromeos::ScreenLocker::Hide(); chromeos::ScreenLocker::Hide();
} }
virtual void UnlockScreenFailed() OVERRIDE { virtual void UnlockScreenFailed(chromeos::ScreenLockLibrary* obj) OVERRIDE {
chromeos::ScreenLocker::UnlockScreenFailed(); chromeos::ScreenLocker::UnlockScreenFailed();
} }
...@@ -271,8 +271,7 @@ void ScreenLocker::OnLoginSuccess( ...@@ -271,8 +271,7 @@ void ScreenLocker::OnLoginSuccess(
service->SetPassphrase(password, false); service->SetPassphrase(password, false);
} }
} }
DBusThreadManager::Get()->GetPowerManagerClient()-> CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockRequested();
NotifyScreenUnlockRequested();
if (login_status_consumer_) if (login_status_consumer_)
login_status_consumer_->OnLoginSuccess(username, password, login_status_consumer_->OnLoginSuccess(username, password,
...@@ -363,8 +362,7 @@ void ScreenLocker::Show() { ...@@ -363,8 +362,7 @@ void ScreenLocker::Show() {
// receive the response within timeout. Just send complete // receive the response within timeout. Just send complete
// signal. // signal.
VLOG(1) << "Show: locker already exists. Just sending completion event."; VLOG(1) << "Show: locker already exists. Just sending completion event.";
DBusThreadManager::Get()->GetPowerManagerClient()-> CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted();
NotifyScreenLockCompleted();
} }
} }
...@@ -418,8 +416,7 @@ ScreenLocker::~ScreenLocker() { ...@@ -418,8 +416,7 @@ ScreenLocker::~ScreenLocker() {
chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
content::Source<ScreenLocker>(this), content::Source<ScreenLocker>(this),
content::Details<bool>(&state)); content::Details<bool>(&state));
DBusThreadManager::Get()->GetPowerManagerClient()-> CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockCompleted();
NotifyScreenUnlockCompleted();
} }
void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { void ScreenLocker::SetAuthenticator(Authenticator* authenticator) {
...@@ -438,8 +435,7 @@ void ScreenLocker::ScreenLockReady() { ...@@ -438,8 +435,7 @@ void ScreenLocker::ScreenLockReady() {
chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
content::Source<ScreenLocker>(this), content::Source<ScreenLocker>(this),
content::Details<bool>(&state)); content::Details<bool>(&state));
DBusThreadManager::Get()->GetPowerManagerClient()-> CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted();
NotifyScreenLockCompleted();
} }
} // namespace chromeos } // namespace chromeos
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "base/message_loop.h" #include "base/message_loop.h"
#include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/automation/ui_controls.h"
#include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h"
#include "chrome/browser/chromeos/dbus/mock_power_manager_client.h" #include "chrome/browser/chromeos/cros/mock_screen_lock_library.h"
#include "chrome/browser/chromeos/login/mock_authenticator.h" #include "chrome/browser/chromeos/login/mock_authenticator.h"
#include "chrome/browser/chromeos/login/screen_locker.h" #include "chrome/browser/chromeos/login/screen_locker.h"
#include "chrome/browser/chromeos/login/screen_locker_tester.h" #include "chrome/browser/chromeos/login/screen_locker_tester.h"
...@@ -97,19 +97,19 @@ namespace chromeos { ...@@ -97,19 +97,19 @@ namespace chromeos {
class ScreenLockerTest : public CrosInProcessBrowserTest { class ScreenLockerTest : public CrosInProcessBrowserTest {
public: public:
ScreenLockerTest() { ScreenLockerTest() : mock_screen_lock_library_(NULL) {
} }
protected: protected:
MockPowerManagerClient mock_power_manager_client_; MockScreenLockLibrary *mock_screen_lock_library_;
// Test the no password mode with different unlock scheme given by // Test the no password mode with different unlock scheme given by
// |unlock| function. // |unlock| function.
void TestNoPassword(void (unlock)(views::Widget*)) { void TestNoPassword(void (unlock)(views::Widget*)) {
EXPECT_CALL(mock_power_manager_client_, NotifyScreenUnlockRequested()) EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockRequested())
.Times(1) .Times(1)
.RetiresOnSaturation(); .RetiresOnSaturation();
EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted()) EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
.Times(1) .Times(1)
.RetiresOnSaturation(); .RetiresOnSaturation();
UserManager::Get()->GuestUserLoggedIn(); UserManager::Get()->GuestUserLoggedIn();
...@@ -151,10 +151,12 @@ class ScreenLockerTest : public CrosInProcessBrowserTest { ...@@ -151,10 +151,12 @@ class ScreenLockerTest : public CrosInProcessBrowserTest {
private: private:
virtual void SetUpInProcessBrowserTestFixture() { virtual void SetUpInProcessBrowserTestFixture() {
cros_mock_->InitStatusAreaMocks(); cros_mock_->InitStatusAreaMocks();
EXPECT_CALL(mock_power_manager_client_, AddObserver(testing::_)) cros_mock_->InitMockScreenLockLibrary();
mock_screen_lock_library_ = cros_mock_->mock_screen_lock_library();
EXPECT_CALL(*mock_screen_lock_library_, AddObserver(testing::_))
.Times(1) .Times(1)
.RetiresOnSaturation(); .RetiresOnSaturation();
EXPECT_CALL(mock_power_manager_client_, NotifyScreenUnlockCompleted()) EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockCompleted())
.Times(1) .Times(1)
.RetiresOnSaturation(); .RetiresOnSaturation();
// Expectations for the status are on the screen lock window. // Expectations for the status are on the screen lock window.
...@@ -174,10 +176,10 @@ class ScreenLockerTest : public CrosInProcessBrowserTest { ...@@ -174,10 +176,10 @@ class ScreenLockerTest : public CrosInProcessBrowserTest {
// Temporarily disabling all screen locker tests while investigating the // Temporarily disabling all screen locker tests while investigating the
// issue crbug.com/78764. // issue crbug.com/78764.
IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestBasic) { IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestBasic) {
EXPECT_CALL(mock_power_manager_client_, NotifyScreenUnlockRequested()) EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockRequested())
.Times(1) .Times(1)
.RetiresOnSaturation(); .RetiresOnSaturation();
EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted()) EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
.Times(1) .Times(1)
.RetiresOnSaturation(); .RetiresOnSaturation();
UserManager::Get()->UserLoggedIn("user"); UserManager::Get()->UserLoggedIn("user");
...@@ -215,10 +217,10 @@ IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestBasic) { ...@@ -215,10 +217,10 @@ IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestBasic) {
} }
IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestFullscreenExit) { IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestFullscreenExit) {
EXPECT_CALL(mock_power_manager_client_, NotifyScreenUnlockRequested()) EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockRequested())
.Times(1) .Times(1)
.RetiresOnSaturation(); .RetiresOnSaturation();
EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted()) EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
.Times(1) .Times(1)
.RetiresOnSaturation(); .RetiresOnSaturation();
scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
...@@ -274,7 +276,7 @@ IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestNoPasswordWithKeyPress) { ...@@ -274,7 +276,7 @@ IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestNoPasswordWithKeyPress) {
} }
IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestShowTwice) { IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestShowTwice) {
EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted()) EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
.Times(2) .Times(2)
.RetiresOnSaturation(); .RetiresOnSaturation();
scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
...@@ -294,7 +296,7 @@ IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestShowTwice) { ...@@ -294,7 +296,7 @@ IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestShowTwice) {
} }
IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestEscape) { IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestEscape) {
EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted()) EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
.Times(1) .Times(1)
.RetiresOnSaturation(); .RetiresOnSaturation();
scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment