Commit d0ee76d2 authored by tfarina@chromium.org's avatar tfarina@chromium.org

chromeos: Get rid of browser namespace usage in kiosk_mode_idle_logout.*

And while I'm here, clean this mess up!

BUG=133088
R=ben@chromium.org

Review URL: https://chromiumcodereview.appspot.com/10821078

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148920 0039d316-1c4b-4281-b951-d872f2087c98
parent 4adb1d73
...@@ -352,7 +352,7 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() { ...@@ -352,7 +352,7 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() {
// Initialize the screen locker now so that it can receive // Initialize the screen locker now so that it can receive
// LOGIN_USER_CHANGED notification from UserManager. // LOGIN_USER_CHANGED notification from UserManager.
if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) { if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) {
chromeos::InitializeKioskModeIdleLogout(); chromeos::KioskModeIdleLogout::Initialize();
} else { } else {
chromeos::ScreenLocker::InitClass(); chromeos::ScreenLocker::InitClass();
} }
......
...@@ -18,33 +18,28 @@ ...@@ -18,33 +18,28 @@
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
namespace chromeos {
namespace { namespace {
const int64 kLoginIdleTimeout = 100; // seconds const int64 kLoginIdleTimeout = 100; // seconds
} // namespace static base::LazyInstance<KioskModeIdleLogout>
g_kiosk_mode_idle_logout = LAZY_INSTANCE_INITIALIZER;
namespace browser {
void ShowIdleLogoutDialog() { } // namespace
chromeos::IdleLogoutDialogView::ShowDialog();
}
void CloseIdleLogoutDialog() { // static
chromeos::IdleLogoutDialogView::CloseDialog(); void KioskModeIdleLogout::Initialize() {
g_kiosk_mode_idle_logout.Get();
} }
} // namespace browser
namespace chromeos {
KioskModeIdleLogout::KioskModeIdleLogout() { KioskModeIdleLogout::KioskModeIdleLogout() {
if (chromeos::KioskModeSettings::Get()->is_initialized()) if (KioskModeSettings::Get()->is_initialized())
Setup(); Setup();
else else
chromeos::KioskModeSettings::Get()->Initialize( KioskModeSettings::Get()->Initialize(base::Bind(&KioskModeIdleLogout::Setup,
base::Bind(&KioskModeIdleLogout::Setup, base::Unretained(this)));
base::Unretained(this)));
} }
void KioskModeIdleLogout::Setup() { void KioskModeIdleLogout::Setup() {
...@@ -78,12 +73,12 @@ void KioskModeIdleLogout::IdleNotify(int64 threshold) { ...@@ -78,12 +73,12 @@ void KioskModeIdleLogout::IdleNotify(int64 threshold) {
// the logout dialog if it's still up. // the logout dialog if it's still up.
RequestNextActiveNotification(); RequestNextActiveNotification();
browser::ShowIdleLogoutDialog(); IdleLogoutDialogView::ShowDialog();
} }
void KioskModeIdleLogout::ActiveNotify() { void KioskModeIdleLogout::ActiveNotify() {
// Before anything else, close the logout dialog to prevent restart // Before anything else, close the logout dialog to prevent restart
browser::CloseIdleLogoutDialog(); IdleLogoutDialogView::CloseDialog();
// Now that we're active, register a request for notification for // Now that we're active, register a request for notification for
// the next time we go idle. // the next time we go idle.
...@@ -91,28 +86,21 @@ void KioskModeIdleLogout::ActiveNotify() { ...@@ -91,28 +86,21 @@ void KioskModeIdleLogout::ActiveNotify() {
} }
void KioskModeIdleLogout::SetupIdleNotifications() { void KioskModeIdleLogout::SetupIdleNotifications() {
chromeos::PowerManagerClient* power_manager = PowerManagerClient* power_manager =
chromeos::DBusThreadManager::Get()->GetPowerManagerClient(); DBusThreadManager::Get()->GetPowerManagerClient();
if (!power_manager->HasObserver(this)) if (!power_manager->HasObserver(this))
power_manager->AddObserver(this); power_manager->AddObserver(this);
} }
void KioskModeIdleLogout::RequestNextActiveNotification() { void KioskModeIdleLogout::RequestNextActiveNotification() {
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> DBusThreadManager::Get()->GetPowerManagerClient()->
RequestActiveNotification(); RequestActiveNotification();
} }
void KioskModeIdleLogout::RequestNextIdleNotification() { void KioskModeIdleLogout::RequestNextIdleNotification() {
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> DBusThreadManager::Get()->GetPowerManagerClient()->
RequestIdleNotification(chromeos::KioskModeSettings::Get()-> RequestIdleNotification(KioskModeSettings::Get()->
GetIdleLogoutTimeout().InMilliseconds()); GetIdleLogoutTimeout().InMilliseconds());
} }
static base::LazyInstance<KioskModeIdleLogout>
g_kiosk_mode_idle_logout = LAZY_INSTANCE_INITIALIZER;
void InitializeKioskModeIdleLogout() {
g_kiosk_mode_idle_logout.Get();
}
} // namespace chromeos } // namespace chromeos
...@@ -6,50 +6,44 @@ ...@@ -6,50 +6,44 @@
#define CHROME_BROWSER_CHROMEOS_KIOSK_MODE_KIOSK_MODE_IDLE_LOGOUT_H_ #define CHROME_BROWSER_CHROMEOS_KIOSK_MODE_KIOSK_MODE_IDLE_LOGOUT_H_
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "chromeos/dbus/power_manager_client.h" #include "chromeos/dbus/power_manager_client.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
namespace browser {
// Shows or closes the logout dialog for Kiosk Mode.
void ShowIdleLogoutDialog();
void CloseIdleLogoutDialog();
} // namespace browser
namespace chromeos { namespace chromeos {
class KioskModeIdleLogout : public PowerManagerClient::Observer, class KioskModeIdleLogout : public PowerManagerClient::Observer,
public content::NotificationObserver { public content::NotificationObserver {
public: public:
static void Initialize();
KioskModeIdleLogout(); KioskModeIdleLogout();
private:
friend class KioskModeIdleLogoutTest;
// Really initialize idle logout when KioskModeHelper is initialized. // Really initialize idle logout when KioskModeHelper is initialized.
void Setup(); void Setup();
// NotificationObserver overrides: // Overridden from content::NotificationObserver:
virtual void Observe(int type, virtual void Observe(int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE; const content::NotificationDetails& details) OVERRIDE;
// PowerManagerClient::Observer overrides: // Overridden from PowerManagerClient::Observer:
virtual void IdleNotify(int64 threshold) OVERRIDE; virtual void IdleNotify(int64 threshold) OVERRIDE;
virtual void ActiveNotify() OVERRIDE; virtual void ActiveNotify() OVERRIDE;
private:
friend class KioskModeIdleLogoutTest;
content::NotificationRegistrar registrar_;
void SetupIdleNotifications(); void SetupIdleNotifications();
void RequestNextActiveNotification(); void RequestNextActiveNotification();
void RequestNextIdleNotification(); void RequestNextIdleNotification();
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(KioskModeIdleLogout); DISALLOW_COPY_AND_ASSIGN(KioskModeIdleLogout);
}; };
void InitializeKioskModeIdleLogout();
} // namespace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_KIOSK_MODE_KIOSK_MODE_IDLE_LOGOUT_H_ #endif // CHROME_BROWSER_CHROMEOS_KIOSK_MODE_KIOSK_MODE_IDLE_LOGOUT_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment