summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r--chrome/browser/chromeos/accessibility/system_event_observer.cc12
-rw-r--r--chrome/browser/chromeos/accessibility/system_event_observer.h11
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.cc277
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.h7
-rw-r--r--chrome/browser/chromeos/dbus/mock_power_manager_client.h4
-rw-r--r--chrome/browser/chromeos/dbus/power_manager_client.cc69
-rw-r--r--chrome/browser/chromeos/dbus/power_manager_client.h21
-rw-r--r--chrome/browser/chromeos/login/login_browsertest.cc13
-rw-r--r--chrome/browser/chromeos/login/login_performer.cc8
-rw-r--r--chrome/browser/chromeos/login/screen_locker.cc26
-rw-r--r--chrome/browser/chromeos/login/screen_locker_browsertest.cc28
11 files changed, 65 insertions, 411 deletions
diff --git a/chrome/browser/chromeos/accessibility/system_event_observer.cc b/chrome/browser/chromeos/accessibility/system_event_observer.cc
index f6f6d5b..9972e4b 100644
--- a/chrome/browser/chromeos/accessibility/system_event_observer.cc
+++ b/chrome/browser/chromeos/accessibility/system_event_observer.cc
@@ -6,6 +6,7 @@
#include "base/logging.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/profiles/profile_manager.h"
#include "chrome/common/chrome_notification_types.h"
@@ -20,9 +21,11 @@ SystemEventObserver* g_system_event_observer = NULL;
}
SystemEventObserver::SystemEventObserver() {
+ CrosLibrary::Get()->GetScreenLockLibrary()->AddObserver(this);
}
SystemEventObserver::~SystemEventObserver() {
+ CrosLibrary::Get()->GetScreenLockLibrary()->RemoveObserver(this);
}
void SystemEventObserver::SystemResumed() {
@@ -32,16 +35,19 @@ void SystemEventObserver::SystemResumed() {
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();
ScreenUnlockedEventInfo info(profile);
SendAccessibilityNotification(
chrome::NOTIFICATION_ACCESSIBILITY_SCREEN_UNLOCKED, &info);
}
-void SystemEventObserver::UnlockScreenFailed() {}
+void SystemEventObserver::UnlockScreenFailed(
+ ScreenLockLibrary* screen_lock_library) {
+}
// static
void SystemEventObserver::Initialize() {
diff --git a/chrome/browser/chromeos/accessibility/system_event_observer.h b/chrome/browser/chromeos/accessibility/system_event_observer.h
index 72020c4..4102b03 100644
--- a/chrome/browser/chromeos/accessibility/system_event_observer.h
+++ b/chrome/browser/chromeos/accessibility/system_event_observer.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SYSTEM_EVENT_OBSERVER_H_
#pragma once
+#include "chrome/browser/chromeos/cros/screen_lock_library.h"
#include "chrome/browser/chromeos/dbus/power_manager_client.h"
namespace chromeos {
@@ -13,7 +14,8 @@ namespace accessibility {
// A singleton class to observe system events like wake up from sleep and
// screen unlock.
-class SystemEventObserver : public PowerManagerClient::Observer {
+class SystemEventObserver : public PowerManagerClient::Observer,
+ public ScreenLockLibrary::Observer {
public:
virtual ~SystemEventObserver();
@@ -21,13 +23,14 @@ class SystemEventObserver : public PowerManagerClient::Observer {
virtual void SystemResumed() OVERRIDE;
// ScreenLockLibrary::Observer override.
- virtual void LockScreen() OVERRIDE;
+ virtual void LockScreen(ScreenLockLibrary* screen_lock_library) OVERRIDE;
// ScreenLockLibrary::Observer override.
- virtual void UnlockScreen() OVERRIDE;
+ virtual void UnlockScreen(ScreenLockLibrary* screen_lock_library) OVERRIDE;
// ScreenLockLibrary::Observer override.
- virtual void UnlockScreenFailed() OVERRIDE;
+ virtual void UnlockScreenFailed(ScreenLockLibrary* screen_lock_library)
+ OVERRIDE;
// Creates the global SystemEventObserver instance.
static void Initialize();
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
index 1fbbee9..b72519a 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -9,53 +9,27 @@
#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/message_loop.h"
-#include "base/string_number_conversions.h"
-#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/chromeos/accessibility/system_event_observer.h"
-#include "chrome/browser/chromeos/audio_handler.h"
-#include "chrome/browser/chromeos/audio_handler.h"
#include "chrome/browser/chromeos/bluetooth/bluetooth_manager.h"
#include "chrome/browser/chromeos/boot_times_loader.h"
-#include "chrome/browser/chromeos/boot_times_loader.h"
#include "chrome/browser/chromeos/brightness_observer.h"
#include "chrome/browser/chromeos/cros/cros_library.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/power_manager_client.h"
#include "chrome/browser/chromeos/dbus/session_manager_client.h"
#include "chrome/browser/chromeos/disks/disk_mount_manager.h"
-#include "chrome/browser/chromeos/external_metrics.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h"
#include "chrome/browser/chromeos/input_method/xkeyboard.h"
-#include "chrome/browser/chromeos/login/authenticator.h"
-#include "chrome/browser/chromeos/login/login_utils.h"
-#include "chrome/browser/chromeos/login/ownership_service.h"
-#include "chrome/browser/chromeos/login/screen_locker.h"
#include "chrome/browser/chromeos/login/session_manager_observer.h"
-#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h"
#include "chrome/browser/chromeos/net/network_change_notifier_chromeos.h"
-#include "chrome/browser/chromeos/status/status_area_view_chromeos.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "chrome/browser/chromeos/system/statistics_provider.h"
-#include "chrome/browser/chromeos/system_key_event_listener.h"
#include "chrome/browser/chromeos/upgrade_detector_chromeos.h"
-#include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h"
#include "chrome/browser/defaults.h"
-#include "chrome/browser/metrics/metrics_service.h"
-#include "chrome/browser/oom_priority_manager.h"
-#include "chrome/browser/policy/browser_policy_connector.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/views/browser_dialogs.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/logging_chrome.h"
#include "content/public/common/main_function_params.h"
-#include "grit/platform_locale_settings.h"
#include "net/base/network_change_notifier.h"
-#include "net/url_request/url_request.h"
-#include "ui/base/l10n/l10n_util.h"
#if defined(TOOLKIT_USES_GTK)
#include <gtk/gtk.h>
@@ -108,111 +82,6 @@ class MessageLoopObserver : public MessageLoopForUI::Observer {
static base::LazyInstance<MessageLoopObserver> g_message_loop_observer =
LAZY_INSTANCE_INITIALIZER;
-// Login -----------------------------------------------------------------------
-
-// Class is used to login using passed username and password.
-// The instance will be deleted upon success or failure.
-class StubLogin : public chromeos::LoginStatusConsumer,
- public chromeos::LoginUtils::Delegate {
- public:
- StubLogin(std::string username, std::string password)
- : pending_requests_(false),
- profile_prepared_(false) {
- authenticator_ = chromeos::LoginUtils::Get()->CreateAuthenticator(this);
- authenticator_.get()->AuthenticateToLogin(
- g_browser_process->profile_manager()->GetDefaultProfile(),
- username,
- password,
- std::string(),
- std::string());
- }
-
- ~StubLogin() {
- chromeos::LoginUtils::Get()->DelegateDeleted(this);
- }
-
- void OnLoginFailure(const chromeos::LoginFailure& error) {
- LOG(ERROR) << "Login Failure: " << error.GetErrorString();
- delete this;
- }
-
- void OnLoginSuccess(const std::string& username,
- const std::string& password,
- const GaiaAuthConsumer::ClientLoginResult& credentials,
- bool pending_requests,
- bool using_oauth) {
- pending_requests_ = pending_requests;
- if (!profile_prepared_) {
- // Will call OnProfilePrepared in the end.
- chromeos::LoginUtils::Get()->PrepareProfile(username,
- password,
- credentials,
- pending_requests,
- using_oauth,
- false,
- this);
- } else if (!pending_requests) {
- delete this;
- }
- }
-
- // LoginUtils::Delegate implementation:
- virtual void OnProfilePrepared(Profile* profile) {
- profile_prepared_ = true;
- chromeos::LoginUtils::DoBrowserLaunch(profile, NULL);
- if (!pending_requests_)
- delete this;
- }
-
- scoped_refptr<chromeos::Authenticator> authenticator_;
- bool pending_requests_;
- bool profile_prepared_;
-};
-
-// Allows authenticator to be invoked without adding refcounting. The instances
-// will delete themselves upon completion.
-DISABLE_RUNNABLE_METHOD_REFCOUNT(StubLogin);
-
-void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line,
- Profile* profile) {
- if (parsed_command_line.HasSwitch(switches::kLoginManager)) {
- std::string first_screen =
- parsed_command_line.GetSwitchValueASCII(switches::kLoginScreen);
- std::string size_arg =
- parsed_command_line.GetSwitchValueASCII(
- switches::kLoginScreenSize);
- gfx::Size size(0, 0);
- // Allow the size of the login window to be set explicitly. If not set,
- // default to the entire screen. This is mostly useful for testing.
- if (size_arg.size()) {
- std::vector<std::string> dimensions;
- base::SplitString(size_arg, ',', &dimensions);
- if (dimensions.size() == 2) {
- int width, height;
- if (base::StringToInt(dimensions[0], &width) &&
- base::StringToInt(dimensions[1], &height))
- size.SetSize(width, height);
- }
- }
- browser::ShowLoginWizard(first_screen, size);
- } else if (parsed_command_line.HasSwitch(switches::kLoginUser) &&
- parsed_command_line.HasSwitch(switches::kLoginPassword)) {
- chromeos::BootTimesLoader::Get()->RecordLoginAttempted();
- new StubLogin(
- parsed_command_line.GetSwitchValueASCII(switches::kLoginUser),
- parsed_command_line.GetSwitchValueASCII(switches::kLoginPassword));
- } else {
- if (!parsed_command_line.HasSwitch(switches::kTestName)) {
- // We did not log in (we crashed or are debugging), so we need to
- // set the user name for sync.
- chromeos::LoginUtils::Get()->RestoreAuthenticationSession(
- chromeos::UserManager::Get()->logged_in_user().email(), profile);
- }
- }
-}
-
-// ChromeBrowserMainPartsChromeos ----------------------------------------------
-
ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos(
const content::MainFunctionParams& parameters)
: ChromeBrowserMainPartsLinux(parameters) {
@@ -233,9 +102,8 @@ ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() {
chromeos::BootTimesLoader::Get()->WriteLogoutTimes();
}
-// content::BrowserMainParts and ChromeBrowserMainExtraParts overrides ---------
-
void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() {
+ ChromeBrowserMainPartsLinux::PreEarlyInitialization();
if (parsed_command_line().HasSwitch(switches::kGuestSession)) {
// Disable sync and extensions if we're in "browse without sign-in" mode.
CommandLine* singleton_command_line = CommandLine::ForCurrentProcess();
@@ -243,11 +111,10 @@ void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() {
singleton_command_line->AppendSwitch(switches::kDisableExtensions);
browser_defaults::bookmarks_enabled = false;
}
-
- ChromeBrowserMainPartsLinux::PreEarlyInitialization();
}
void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() {
+ ChromeBrowserMainPartsLinux::PreMainMessageLoopStart();
// Initialize CrosLibrary only for the browser, unless running tests
// (which do their own CrosLibrary setup).
if (!parameters().ui_task) {
@@ -258,126 +125,11 @@ void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() {
// implementation.
net::NetworkChangeNotifier::SetFactory(
new chromeos::CrosNetworkChangeNotifierFactory());
-
- ChromeBrowserMainPartsLinux::PreMainMessageLoopStart();
}
-void ChromeBrowserMainPartsChromeos::PreProfileInit() {
- // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun()
- // -- immediately before Profile creation().
-
- // Now that the file thread exists we can record our stats.
- chromeos::BootTimesLoader::Get()->RecordChromeMainStats();
-
-#if defined(TOOLKIT_USES_GTK)
- // Read locale-specific GTK resource information.
- std::string gtkrc = l10n_util::GetStringUTF8(IDS_LOCALE_GTKRC);
- if (!gtkrc.empty())
- gtk_rc_parse_string(gtkrc.c_str());
-#else
- // TODO(saintlou): Need to provide an Aura equivalent.
- NOTIMPLEMENTED();
-#endif
-
- // Trigger prefetching of ownership status.
- chromeos::OwnershipService::GetSharedInstance()->Prewarm();
-
- // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun()
- // -- just before CreateProfile().
-
- // This forces the ProfileManager to be created and register for the
- // notification it needs to track the logged in user.
- g_browser_process->profile_manager();
-
- // TODO(abarth): Should this move to InitializeNetworkOptions()?
- // Allow access to file:// on ChromeOS for tests.
- if (parsed_command_line().HasSwitch(switches::kAllowFileAccess))
- net::URLRequest::AllowFileAccess();
-
- // There are two use cases for kLoginUser:
- // 1) if passed in tandem with kLoginPassword, to drive a "StubLogin"
- // 2) if passed alone, to signal that the indicated user has already
- // logged in and we should behave accordingly.
- // This handles case 2.
- if (parsed_command_line().HasSwitch(switches::kLoginUser) &&
- !parsed_command_line().HasSwitch(switches::kLoginPassword)) {
- std::string username =
- parsed_command_line().GetSwitchValueASCII(switches::kLoginUser);
- VLOG(1) << "Relaunching browser for user: " << username;
- chromeos::UserManager::Get()->UserLoggedIn(username);
-
- // Redirects Chrome logging to the user data dir.
- logging::RedirectChromeLogging(parsed_command_line());
-
- // Initialize user policy before creating the profile so the profile
- // initialization code sees policy settings.
- g_browser_process->browser_policy_connector()->InitializeUserPolicy(
- username, false /* wait_for_policy_fetch */);
- } else if (parsed_command_line().HasSwitch(switches::kLoginManager)) {
- // Initialize status area mode early on.
- chromeos::StatusAreaViewChromeos::
- SetScreenMode(chromeos::StatusAreaViewChromeos::LOGIN_MODE_WEBUI);
- }
-
- // In Aura builds this will initialize aura_shell::Shell.
- ChromeBrowserMainPartsLinux::PreProfileInit();
-}
-
-void ChromeBrowserMainPartsChromeos::PostProfileInit() {
- // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun()
- // -- just after CreateProfile().
-
- // Pass the TokenService pointer to the policy connector so user policy can
- // grab a token and register with the policy server.
- // TODO(mnissler): Remove once OAuth is the only authentication mechanism.
- if (parsed_command_line().HasSwitch(switches::kLoginUser) &&
- !parsed_command_line().HasSwitch(switches::kLoginPassword)) {
- g_browser_process->browser_policy_connector()->SetUserPolicyTokenService(
- profile()->GetTokenService());
- }
-
- // Tests should be able to tune login manager before showing it.
- // Thus only show login manager in normal (non-testing) mode.
- if (!parameters().ui_task)
- OptionallyRunChromeOSLoginManager(parsed_command_line(), profile());
-
- ChromeBrowserMainPartsLinux::PostProfileInit();
-}
-
-void ChromeBrowserMainPartsChromeos::PreBrowserStart() {
- // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun()
- // -- just before MetricsService::LogNeedForCleanShutdown().
-
- metrics()->StartExternalMetrics();
-
- // Initialize the audio handler on ChromeOS.
- chromeos::AudioHandler::Initialize();
-
- // Listen for system key events so that the user will be able to adjust the
- // volume on the login screen, if Chrome is running on Chrome OS
- // (i.e. not Linux desktop), and in non-test mode.
- if (chromeos::system::runtime_environment::IsRunningOnChromeOS() &&
- !parameters().ui_task) { // ui_task is non-NULL when running tests.
- chromeos::SystemKeyEventListener::Initialize();
- }
-
- // Listen for XI_HierarchyChanged events.
- chromeos::XInputHierarchyChangedEventListener::GetInstance();
-
- // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun()
- // -- immediately after ChildProcess::WaitForDebugger().
-
- // Start the out-of-memory priority manager here so that we give the most
- // amount of time for the other services to start up before we start
- // adjusting the oom priority.
- g_browser_process->oom_priority_manager()->Start();
-
- ChromeBrowserMainPartsLinux::PreBrowserStart();
-}
-
-void ChromeBrowserMainPartsChromeos::PostBrowserStart() {
+void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() {
// FILE thread is created in ChromeBrowserMainParts::PreMainMessageLoopRun().
-
+ ChromeBrowserMainPartsLinux::PreMainMessageLoopRun();
// Get the statistics provider instance here to start loading statistcs
// on the background FILE thread.
chromeos::system::StatisticsProvider::GetInstance();
@@ -391,11 +143,10 @@ void ChromeBrowserMainPartsChromeos::PostBrowserStart() {
if (parsed_command_line().HasSwitch(switches::kEnableBluetooth)) {
chromeos::BluetoothManager::Initialize();
}
-
- ChromeBrowserMainPartsLinux::PostBrowserStart();
}
void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() {
+ ChromeBrowserMainPartsLinux::PostMainMessageLoopStart();
MessageLoopForUI* message_loop = MessageLoopForUI::current();
message_loop->AddObserver(g_message_loop_observer.Pointer());
@@ -445,25 +196,11 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() {
new chromeos::InitialBrowserWindowObserver);
#endif
}
-
- ChromeBrowserMainPartsLinux::PostMainMessageLoopStart();
}
// Shut down services before the browser process, etc are destroyed.
void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
- chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded",
- true);
-
- g_browser_process->oom_priority_manager()->Stop();
-
- // The XInput2 event listener needs to be shut down earlier than when
- // Singletons are finally destroyed in AtExitManager.
- chromeos::XInputHierarchyChangedEventListener::GetInstance()->Stop();
-
- // chromeos::SystemKeyEventListener::Shutdown() is always safe to call,
- // even if Initialize() wasn't called.
- chromeos::SystemKeyEventListener::Shutdown();
- chromeos::AudioHandler::Shutdown();
+ ChromeBrowserMainPartsLinux::PostMainMessageLoopRun();
// Shutdown the upgrade detector for Chrome OS. The upgrade detector
// stops monitoring changes from the update engine.
@@ -492,6 +229,4 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
// these.
chromeos::accessibility::SystemEventObserver::Shutdown();
chromeos::BluetoothManager::Shutdown();
-
- ChromeBrowserMainPartsLinux::PostMainMessageLoopRun();
}
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.h b/chrome/browser/chromeos/chrome_browser_main_chromeos.h
index 80df066..449d9fa 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.h
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.h
@@ -27,14 +27,9 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux {
virtual void PreEarlyInitialization() OVERRIDE;
virtual void PreMainMessageLoopStart() OVERRIDE;
virtual void PostMainMessageLoopStart() OVERRIDE;
+ virtual void PreMainMessageLoopRun() OVERRIDE;
virtual void PostMainMessageLoopRun() OVERRIDE;
- // ChromeBrowserMainExtraParts overrodes.
- virtual void PreProfileInit() OVERRIDE;
- virtual void PostProfileInit() OVERRIDE;
- virtual void PreBrowserStart() OVERRIDE;
- virtual void PostBrowserStart() OVERRIDE;
-
private:
scoped_ptr<chromeos::BrightnessObserver> brightness_observer_;
scoped_ptr<chromeos::SessionManagerObserver> session_manager_observer_;
diff --git a/chrome/browser/chromeos/dbus/mock_power_manager_client.h b/chrome/browser/chromeos/dbus/mock_power_manager_client.h
index 4ac80fd..7f6f71b 100644
--- a/chrome/browser/chromeos/dbus/mock_power_manager_client.h
+++ b/chrome/browser/chromeos/dbus/mock_power_manager_client.h
@@ -25,10 +25,6 @@ class MockPowerManagerClient : public PowerManagerClient {
MOCK_METHOD0(RequestRestart, void(void));
MOCK_METHOD0(RequestShutdown, void(void));
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
diff --git a/chrome/browser/chromeos/dbus/power_manager_client.cc b/chrome/browser/chromeos/dbus/power_manager_client.cc
index c73ff0a..476a301 100644
--- a/chrome/browser/chromeos/dbus/power_manager_client.cc
+++ b/chrome/browser/chromeos/dbus/power_manager_client.cc
@@ -92,29 +92,6 @@ class PowerManagerClientImpl : public PowerManagerClient {
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&PowerManagerClientImpl::SignalConnected,
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() {
@@ -199,22 +176,6 @@ class PowerManagerClientImpl : public PowerManagerClient {
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:
// Called when a dbus signal is initially connected.
void SignalConnected(const std::string& interface_name,
@@ -224,16 +185,6 @@ class PowerManagerClientImpl : public PowerManagerClient {
<< 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.
void BrightnessChangedReceived(dbus::Signal* signal) {
dbus::MessageReader reader(signal);
@@ -341,18 +292,6 @@ class PowerManagerClientImpl : public PowerManagerClient {
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_;
ObserverList<Observer> observers_;
base::WeakPtrFactory<PowerManagerClientImpl> weak_ptr_factory_;
@@ -413,14 +352,6 @@ class PowerManagerClientStubImpl : public PowerManagerClient {
callback.Run(0);
}
- virtual void NotifyScreenLockRequested() OVERRIDE {}
-
- virtual void NotifyScreenLockCompleted() OVERRIDE {}
-
- virtual void NotifyScreenUnlockRequested() OVERRIDE {}
-
- virtual void NotifyScreenUnlockCompleted() OVERRIDE {}
-
private:
void Update() {
// We pause at 0 and 100% so that it's easier to check those conditions.
diff --git a/chrome/browser/chromeos/dbus/power_manager_client.h b/chrome/browser/chromeos/dbus/power_manager_client.h
index 28e3993..43f58a4 100644
--- a/chrome/browser/chromeos/dbus/power_manager_client.h
+++ b/chrome/browser/chromeos/dbus/power_manager_client.h
@@ -54,15 +54,6 @@ class PowerManagerClient {
// Called when the system resumes from suspend.
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.
@@ -90,18 +81,6 @@ class PowerManagerClient {
// encounters some error, it passes -1 to |callback|.
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.
static PowerManagerClient* Create(dbus::Bus* bus);
diff --git a/chrome/browser/chromeos/login/login_browsertest.cc b/chrome/browser/chromeos/login/login_browsertest.cc
index c4ee33d..ebbf3e8 100644
--- a/chrome/browser/chromeos/login/login_browsertest.cc
+++ b/chrome/browser/chromeos/login/login_browsertest.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/chromeos/cros/mock_cryptohome_library.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_screen_lock_library.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
@@ -23,7 +24,8 @@ using ::testing::Return;
class LoginTestBase : public CrosInProcessBrowserTest {
public:
- LoginTestBase() : mock_cryptohome_library_(NULL) {
+ LoginTestBase() : mock_cryptohome_library_(NULL),
+ mock_screen_lock_library_(NULL) {
}
protected:
@@ -31,12 +33,15 @@ class LoginTestBase : public CrosInProcessBrowserTest {
cros_mock_->InitStatusAreaMocks();
cros_mock_->SetStatusAreaMocksExpectations();
cros_mock_->InitMockCryptohomeLibrary();
+ cros_mock_->InitMockScreenLockLibrary();
mock_cryptohome_library_ = cros_mock_->mock_cryptohome_library();
+ mock_screen_lock_library_ = cros_mock_->mock_screen_lock_library();
EXPECT_CALL(*mock_cryptohome_library_, IsMounted())
.WillRepeatedly(Return(true));
}
MockCryptohomeLibrary* mock_cryptohome_library_;
+ MockScreenLockLibrary* mock_screen_lock_library_;
private:
DISALLOW_COPY_AND_ASSIGN(LoginTestBase);
@@ -46,6 +51,12 @@ class LoginUserTest : public LoginTestBase {
protected:
virtual void 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) {
diff --git a/chrome/browser/chromeos/login/login_performer.cc b/chrome/browser/chromeos/login/login_performer.cc
index d98662e..910cdb2 100644
--- a/chrome/browser/chromeos/login/login_performer.cc
+++ b/chrome/browser/chromeos/login/login_performer.cc
@@ -14,10 +14,10 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.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_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/screen_locker.h"
#include "chrome/browser/prefs/pref_service.h"
@@ -367,7 +367,7 @@ void LoginPerformer::RequestScreenLock() {
ResolveScreenLocked();
} else {
screen_lock_requested_ = true;
- DBusThreadManager::Get()->GetPowerManagerClient()->
+ chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->
NotifyScreenLockRequested();
}
}
@@ -375,7 +375,7 @@ void LoginPerformer::RequestScreenLock() {
void LoginPerformer::RequestScreenUnlock() {
DVLOG(1) << "Screen unlock requested";
if (ScreenLocker::default_screen_locker()) {
- DBusThreadManager::Get()->GetPowerManagerClient()->
+ chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->
NotifyScreenUnlockRequested();
// Will unsubscribe from notifications once unlock is successful.
} else {
diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc
index 5c0e1f6..6e13b98 100644
--- a/chrome/browser/chromeos/login/screen_locker.cc
+++ b/chrome/browser/chromeos/login/screen_locker.cc
@@ -16,8 +16,9 @@
#include "base/string_util.h"
#include "base/timer.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/power_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_util.h"
@@ -54,7 +55,7 @@ using content::BrowserThread;
namespace {
// Observer to start ScreenLocker when the screen lock
-class ScreenLockObserver : public chromeos::PowerManagerClient::Observer,
+class ScreenLockObserver : public chromeos::ScreenLockLibrary::Observer,
public content::NotificationObserver {
public:
ScreenLockObserver() {
@@ -69,23 +70,22 @@ class ScreenLockObserver : public chromeos::PowerManagerClient::Observer,
if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) {
// Register Screen Lock after login screen to make sure
// we don't show the screen lock on top of the login screen by accident.
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
- AddObserver(this);
+ chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->AddObserver(this);
}
}
- virtual void LockScreen() OVERRIDE {
+ virtual void LockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE {
VLOG(1) << "In: ScreenLockObserver::LockScreen";
SetupInputMethodsForScreenLocker();
chromeos::ScreenLocker::Show();
}
- virtual void UnlockScreen() OVERRIDE {
+ virtual void UnlockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE {
RestoreInputMethods();
chromeos::ScreenLocker::Hide();
}
- virtual void UnlockScreenFailed() OVERRIDE {
+ virtual void UnlockScreenFailed(chromeos::ScreenLockLibrary* obj) OVERRIDE {
chromeos::ScreenLocker::UnlockScreenFailed();
}
@@ -271,8 +271,7 @@ void ScreenLocker::OnLoginSuccess(
service->SetPassphrase(password, false);
}
}
- DBusThreadManager::Get()->GetPowerManagerClient()->
- NotifyScreenUnlockRequested();
+ CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockRequested();
if (login_status_consumer_)
login_status_consumer_->OnLoginSuccess(username, password,
@@ -363,8 +362,7 @@ void ScreenLocker::Show() {
// receive the response within timeout. Just send complete
// signal.
VLOG(1) << "Show: locker already exists. Just sending completion event.";
- DBusThreadManager::Get()->GetPowerManagerClient()->
- NotifyScreenLockCompleted();
+ CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted();
}
}
@@ -418,8 +416,7 @@ ScreenLocker::~ScreenLocker() {
chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
content::Source<ScreenLocker>(this),
content::Details<bool>(&state));
- DBusThreadManager::Get()->GetPowerManagerClient()->
- NotifyScreenUnlockCompleted();
+ CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockCompleted();
}
void ScreenLocker::SetAuthenticator(Authenticator* authenticator) {
@@ -438,8 +435,7 @@ void ScreenLocker::ScreenLockReady() {
chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
content::Source<ScreenLocker>(this),
content::Details<bool>(&state));
- DBusThreadManager::Get()->GetPowerManagerClient()->
- NotifyScreenLockCompleted();
+ CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted();
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/screen_locker_browsertest.cc b/chrome/browser/chromeos/login/screen_locker_browsertest.cc
index bc7a40c..d7a7b89 100644
--- a/chrome/browser/chromeos/login/screen_locker_browsertest.cc
+++ b/chrome/browser/chromeos/login/screen_locker_browsertest.cc
@@ -7,7 +7,7 @@
#include "base/message_loop.h"
#include "chrome/browser/automation/ui_controls.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/screen_locker.h"
#include "chrome/browser/chromeos/login/screen_locker_tester.h"
@@ -97,19 +97,19 @@ namespace chromeos {
class ScreenLockerTest : public CrosInProcessBrowserTest {
public:
- ScreenLockerTest() {
+ ScreenLockerTest() : mock_screen_lock_library_(NULL) {
}
protected:
- MockPowerManagerClient mock_power_manager_client_;
+ MockScreenLockLibrary *mock_screen_lock_library_;
// Test the no password mode with different unlock scheme given by
// |unlock| function.
void TestNoPassword(void (unlock)(views::Widget*)) {
- EXPECT_CALL(mock_power_manager_client_, NotifyScreenUnlockRequested())
+ EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockRequested())
.Times(1)
.RetiresOnSaturation();
- EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted())
+ EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
.Times(1)
.RetiresOnSaturation();
UserManager::Get()->GuestUserLoggedIn();
@@ -151,10 +151,12 @@ class ScreenLockerTest : public CrosInProcessBrowserTest {
private:
virtual void SetUpInProcessBrowserTestFixture() {
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)
.RetiresOnSaturation();
- EXPECT_CALL(mock_power_manager_client_, NotifyScreenUnlockCompleted())
+ EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockCompleted())
.Times(1)
.RetiresOnSaturation();
// Expectations for the status are on the screen lock window.
@@ -174,10 +176,10 @@ class ScreenLockerTest : public CrosInProcessBrowserTest {
// Temporarily disabling all screen locker tests while investigating the
// issue crbug.com/78764.
IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestBasic) {
- EXPECT_CALL(mock_power_manager_client_, NotifyScreenUnlockRequested())
+ EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockRequested())
.Times(1)
.RetiresOnSaturation();
- EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted())
+ EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
.Times(1)
.RetiresOnSaturation();
UserManager::Get()->UserLoggedIn("user");
@@ -215,10 +217,10 @@ IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestBasic) {
}
IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestFullscreenExit) {
- EXPECT_CALL(mock_power_manager_client_, NotifyScreenUnlockRequested())
+ EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenUnlockRequested())
.Times(1)
.RetiresOnSaturation();
- EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted())
+ EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
.Times(1)
.RetiresOnSaturation();
scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
@@ -274,7 +276,7 @@ IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestNoPasswordWithKeyPress) {
}
IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestShowTwice) {
- EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted())
+ EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
.Times(2)
.RetiresOnSaturation();
scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
@@ -294,7 +296,7 @@ IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestShowTwice) {
}
IN_PROC_BROWSER_TEST_F(ScreenLockerTest, DISABLED_TestEscape) {
- EXPECT_CALL(mock_power_manager_client_, NotifyScreenLockCompleted())
+ EXPECT_CALL(*mock_screen_lock_library_, NotifyScreenLockCompleted())
.Times(1)
.RetiresOnSaturation();
scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());