summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/automation/testing_automation_provider_chromeos.cc4
-rw-r--r--chrome/browser/chrome_browser_main.cc289
-rw-r--r--chrome/browser/chrome_browser_main.h11
-rw-r--r--chrome/browser/chrome_browser_main_extra_parts.cc10
-rw-r--r--chrome/browser/chrome_browser_main_extra_parts.h6
-rw-r--r--chrome/browser/chrome_browser_main_extra_parts_aura.cc2
-rw-r--r--chrome/browser/chrome_browser_main_extra_parts_aura.h2
-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
18 files changed, 321 insertions, 479 deletions
diff --git a/chrome/browser/automation/testing_automation_provider_chromeos.cc b/chrome/browser/automation/testing_automation_provider_chromeos.cc
index 2ffc792..b4d65dc 100644
--- a/chrome/browser/automation/testing_automation_provider_chromeos.cc
+++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc
@@ -15,8 +15,8 @@
#include "chrome/browser/chromeos/audio_handler.h"
#include "chrome/browser/chromeos/cros/cros_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/power_manager_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/existing_user_controller.h"
@@ -276,7 +276,7 @@ void TestingAutomationProvider::Login(DictionaryValue* args,
void TestingAutomationProvider::LockScreen(DictionaryValue* args,
IPC::Message* reply_message) {
new ScreenLockUnlockObserver(this, reply_message, true);
- DBusThreadManager::Get()->GetPowerManagerClient()->
+ CrosLibrary::Get()->GetScreenLockLibrary()->
NotifyScreenLockRequested();
}
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 92cd54b..246e167 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -76,7 +76,6 @@
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/translate/translate_manager.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_init.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h"
#include "chrome/browser/ui/webui/sync_promo_trial.h"
#include "chrome/browser/web_resource/gpu_blacklist_updater.h"
@@ -128,9 +127,26 @@
#endif
#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/audio_handler.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/customization_document.h"
+#include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
+#include "chrome/browser/chromeos/external_metrics.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/user_manager.h"
+#include "chrome/browser/chromeos/status/status_area_view_chromeos.h"
+#include "chrome/browser/chromeos/system/runtime_environment.h"
+#include "chrome/browser/chromeos/system_key_event_listener.h"
+#include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h"
+#include "chrome/browser/oom_priority_manager.h"
+#include "chrome/browser/ui/views/browser_dialogs.h"
#endif
// TODO(port): several win-only methods have been pulled out of this, but
@@ -431,6 +447,107 @@ Profile* CreateProfile(const content::MainFunctionParams& parameters,
return NULL;
}
+#if defined(OS_CHROMEOS)
+
+// 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_;
+};
+
+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);
+ }
+ }
+}
+
+#endif // defined(OS_CHROMEOS)
+
#if defined(OS_MACOSX)
OSStatus KeychainCallback(SecKeychainEvent keychain_event,
SecKeychainCallbackInfo *info, void *context) {
@@ -1022,6 +1139,12 @@ void ChromeBrowserMainParts::SetupFieldTrials(bool metrics_recording_enabled,
// -----------------------------------------------------------------------------
// TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts.
+#if defined(OS_CHROMEOS)
+// Allows authenticator to be invoked without adding refcounting. The instances
+// will delete themselves upon completion.
+DISABLE_RUNNABLE_METHOD_REFCOUNT(StubLogin);
+#endif
+
#if defined(OS_WIN)
#define DLLEXPORT __declspec(dllexport)
@@ -1303,37 +1426,6 @@ void ChromeBrowserMainParts::PreMainMessageLoopRun() {
chrome_extra_parts_[i]->PreMainMessageLoopRun();
}
-// PreMainMessageLoopRun calls these extra stages in the following order:
-// PreMainMessageLoopRunImpl()
-// ... initial setup, including browser_process_ setup.
-// PreProfileInit()
-// ... additional setup, including CreateProfile()
-// PostProfileInit()
-// ... additional setup
-// PreBrowserStart()
-// ... browser_init_->Start (OR parameters().ui_task->Run())
-// PostBrowserStart()
-
-void ChromeBrowserMainParts::PreProfileInit() {
- for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
- chrome_extra_parts_[i]->PreProfileInit();
-}
-
-void ChromeBrowserMainParts::PostProfileInit() {
- for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
- chrome_extra_parts_[i]->PostProfileInit();
-}
-
-void ChromeBrowserMainParts::PreBrowserStart() {
- for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
- chrome_extra_parts_[i]->PreBrowserStart();
-}
-
-void ChromeBrowserMainParts::PostBrowserStart() {
- for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
- chrome_extra_parts_[i]->PostBrowserStart();
-}
-
int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// Create watchdog thread after creating all other threads because it will
// watch the other threads and they must be running.
@@ -1345,6 +1437,24 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
browser_process_->resource_dispatcher_host();
#endif
+#if defined(OS_CHROMEOS)
+ // 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();
+#endif
+
// Record last shutdown time into a histogram.
browser_shutdown::ReadLastShutdownInfo();
@@ -1430,10 +1540,51 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#endif
// Desktop construction occurs here, (required before profile creation).
- PreProfileInit();
+ for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
+ chrome_extra_parts_[i]->PostBrowserProcessInit();
// Profile creation ----------------------------------------------------------
+#if defined(OS_CHROMEOS)
+ // Initialize the screen locker now so that it can receive
+ // LOGIN_USER_CHANGED notification from UserManager.
+ chromeos::ScreenLocker::InitClass();
+
+ // 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);
+ }
+#endif
+
if (is_first_run_) {
// Warn the ProfileManager that an import process will run, possibly
// locking the WebDataService directory of the next Profile created.
@@ -1452,6 +1603,22 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
}
// Post-profile init ---------------------------------------------------------
+#if defined(OS_CHROMEOS)
+ // 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_);
+#endif
+
#if !defined(OS_MACOSX)
// Importing other browser settings is done in a browser-like process
// that exits when this task has finished.
@@ -1498,9 +1665,10 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
}
#endif
- // TODO(stevenjb): Move WIN and MACOSX specific code to apprpriate Parts.
- // (requires supporting early exit).
- PostProfileInit();
+ // TODO(stevenjb): Move ChromeOS login code into PostProfileInitialized().
+ // (Requires making ChromeBrowserMainPartsChromeos a non "main" Parts).
+ for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
+ chrome_extra_parts_[i]->PostProfileInitialized();
// Show the First Run UI if this is the first time Chrome has been run on
// this computer, or we're being compelled to do so by a command line flag.
@@ -1652,6 +1820,24 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
fragmentation_checker::RecordFragmentationMetricForCurrentModule();
#endif
+#if defined(OS_CHROMEOS)
+ 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();
+#endif
+
// The extension service may be available at this point. If the command line
// specifies --uninstall-extension, attempt the uninstall extension startup
// action.
@@ -1676,6 +1862,13 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
record_search_engine_ = is_first_run_ && !profile_->IsOffTheRecord();
#endif
+#if defined(OS_CHROMEOS)
+ // Wait until here to start the out-of-memory priority manager 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();
+#endif
+
// Create the instance of the cloud print proxy service so that it can launch
// the service process if needed. This is needed because the service process
// might have shutdown because an update was available.
@@ -1693,8 +1886,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
NaClProcessHost::EarlyStartup();
#endif
- PreBrowserStart();
-
// Instantiate the notification UI manager, as this triggers a perf timer
// used to measure startup time. TODO(stevenjb): Figure out what is actually
// triggering the timer and call that explicitly in the approprate place.
@@ -1771,9 +1962,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
}
}
browser_init_.reset();
-
- PostBrowserStart();
-
return result_code_;
}
@@ -1799,6 +1987,10 @@ bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) {
#elif defined(OS_POSIX)
MessageLoopForUI::current()->Run();
#endif
+#if defined(OS_CHROMEOS)
+ chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded",
+ true);
+#endif
return true;
}
@@ -1856,6 +2048,10 @@ void ChromeBrowserMainParts::PostMainMessageLoopRun() {
}
#endif
+#if defined(OS_CHROMEOS)
+ g_browser_process->oom_priority_manager()->Stop();
+#endif
+
// Some tests don't set parameters.ui_task, so they started translate
// language fetch that was never completed so we need to cleanup here
// otherwise it will be done by the destructor in a wrong thread.
@@ -1870,6 +2066,17 @@ void ChromeBrowserMainParts::PostMainMessageLoopRun() {
g_browser_process->metrics_service()->Stop();
+#if defined(OS_CHROMEOS)
+ // 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();
+#endif
+
restart_last_session_ = browser_shutdown::ShutdownPreThreadsStop();
browser_process_->StartTearDown();
}
diff --git a/chrome/browser/chrome_browser_main.h b/chrome/browser/chrome_browser_main.h
index 93bf58f..26f22a6 100644
--- a/chrome/browser/chrome_browser_main.h
+++ b/chrome/browser/chrome_browser_main.h
@@ -56,9 +56,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts {
const content::MainFunctionParams& parameters);
// 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 PostEarlyInitialization() OVERRIDE;
virtual void ToolkitInitialized() OVERRIDE;
@@ -74,13 +71,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts {
virtual void PostStopThread(content::BrowserThread::ID identifier) 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.
virtual void ShowMissingLocaleMessageBox() = 0;
@@ -92,7 +82,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts {
}
Profile* profile() { return profile_; }
- MetricsService* metrics() { return metrics_; }
private:
// Methods for |EarlyInitialization()| ---------------------------------------
diff --git a/chrome/browser/chrome_browser_main_extra_parts.cc b/chrome/browser/chrome_browser_main_extra_parts.cc
index 14362a3..3188931 100644
--- a/chrome/browser/chrome_browser_main_extra_parts.cc
+++ b/chrome/browser/chrome_browser_main_extra_parts.cc
@@ -25,16 +25,10 @@ void ChromeBrowserMainExtraParts::PostMainMessageLoopStart() {
void ChromeBrowserMainExtraParts::ToolkitInitialized() {
}
-void ChromeBrowserMainExtraParts::PreProfileInit() {
+void ChromeBrowserMainExtraParts::PostBrowserProcessInit() {
}
-void ChromeBrowserMainExtraParts::PostProfileInit() {
-}
-
-void ChromeBrowserMainExtraParts::PreBrowserStart() {
-}
-
-void ChromeBrowserMainExtraParts::PostBrowserStart() {
+void ChromeBrowserMainExtraParts::PostProfileInitialized() {
}
void ChromeBrowserMainExtraParts::PreMainMessageLoopRun() {
diff --git a/chrome/browser/chrome_browser_main_extra_parts.h b/chrome/browser/chrome_browser_main_extra_parts.h
index 2bf3f1c..f0cd457 100644
--- a/chrome/browser/chrome_browser_main_extra_parts.h
+++ b/chrome/browser/chrome_browser_main_extra_parts.h
@@ -32,10 +32,8 @@ class ChromeBrowserMainExtraParts {
virtual void PostMainMessageLoopStart();
// MainMessageLoopRun methods.
- virtual void PreProfileInit();
- virtual void PostProfileInit();
- virtual void PreBrowserStart();
- virtual void PostBrowserStart();
+ virtual void PostBrowserProcessInit();
+ virtual void PostProfileInitialized();
virtual void PreMainMessageLoopRun();
virtual void PostMainMessageLoopRun();
diff --git a/chrome/browser/chrome_browser_main_extra_parts_aura.cc b/chrome/browser/chrome_browser_main_extra_parts_aura.cc
index 5eab062..d79867a 100644
--- a/chrome/browser/chrome_browser_main_extra_parts_aura.cc
+++ b/chrome/browser/chrome_browser_main_extra_parts_aura.cc
@@ -16,7 +16,7 @@ ChromeBrowserMainExtraPartsAura::ChromeBrowserMainExtraPartsAura()
: ChromeBrowserMainExtraParts() {
}
-void ChromeBrowserMainExtraPartsAura::PreProfileInit() {
+void ChromeBrowserMainExtraPartsAura::PostBrowserProcessInit() {
#if defined(OS_CHROMEOS)
if (chromeos::system::runtime_environment::IsRunningOnChromeOS())
aura::Desktop::set_use_fullscreen_host_window(true);
diff --git a/chrome/browser/chrome_browser_main_extra_parts_aura.h b/chrome/browser/chrome_browser_main_extra_parts_aura.h
index b8846ee..2af4a18 100644
--- a/chrome/browser/chrome_browser_main_extra_parts_aura.h
+++ b/chrome/browser/chrome_browser_main_extra_parts_aura.h
@@ -13,7 +13,7 @@ class ChromeBrowserMainExtraPartsAura : public ChromeBrowserMainExtraParts {
public:
ChromeBrowserMainExtraPartsAura();
- virtual void PreProfileInit() OVERRIDE;
+ virtual void PostBrowserProcessInit() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAura);
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());