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() {
// Initialize the screen locker now so that it can receive
// LOGIN_USER_CHANGED notification from UserManager.
if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) {
chromeos::InitializeKioskModeIdleLogout();
chromeos::KioskModeIdleLogout::Initialize();
} else {
chromeos::ScreenLocker::InitClass();
}
......
......@@ -18,33 +18,28 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
namespace chromeos {
namespace {
const int64 kLoginIdleTimeout = 100; // seconds
} // namespace
namespace browser {
static base::LazyInstance<KioskModeIdleLogout>
g_kiosk_mode_idle_logout = LAZY_INSTANCE_INITIALIZER;
void ShowIdleLogoutDialog() {
chromeos::IdleLogoutDialogView::ShowDialog();
}
} // namespace
void CloseIdleLogoutDialog() {
chromeos::IdleLogoutDialogView::CloseDialog();
// static
void KioskModeIdleLogout::Initialize() {
g_kiosk_mode_idle_logout.Get();
}
} // namespace browser
namespace chromeos {
KioskModeIdleLogout::KioskModeIdleLogout() {
if (chromeos::KioskModeSettings::Get()->is_initialized())
if (KioskModeSettings::Get()->is_initialized())
Setup();
else
chromeos::KioskModeSettings::Get()->Initialize(
base::Bind(&KioskModeIdleLogout::Setup,
base::Unretained(this)));
KioskModeSettings::Get()->Initialize(base::Bind(&KioskModeIdleLogout::Setup,
base::Unretained(this)));
}
void KioskModeIdleLogout::Setup() {
......@@ -78,12 +73,12 @@ void KioskModeIdleLogout::IdleNotify(int64 threshold) {
// the logout dialog if it's still up.
RequestNextActiveNotification();
browser::ShowIdleLogoutDialog();
IdleLogoutDialogView::ShowDialog();
}
void KioskModeIdleLogout::ActiveNotify() {
// 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
// the next time we go idle.
......@@ -91,28 +86,21 @@ void KioskModeIdleLogout::ActiveNotify() {
}
void KioskModeIdleLogout::SetupIdleNotifications() {
chromeos::PowerManagerClient* power_manager =
chromeos::DBusThreadManager::Get()->GetPowerManagerClient();
PowerManagerClient* power_manager =
DBusThreadManager::Get()->GetPowerManagerClient();
if (!power_manager->HasObserver(this))
power_manager->AddObserver(this);
}
void KioskModeIdleLogout::RequestNextActiveNotification() {
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
DBusThreadManager::Get()->GetPowerManagerClient()->
RequestActiveNotification();
}
void KioskModeIdleLogout::RequestNextIdleNotification() {
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
RequestIdleNotification(chromeos::KioskModeSettings::Get()->
DBusThreadManager::Get()->GetPowerManagerClient()->
RequestIdleNotification(KioskModeSettings::Get()->
GetIdleLogoutTimeout().InMilliseconds());
}
static base::LazyInstance<KioskModeIdleLogout>
g_kiosk_mode_idle_logout = LAZY_INSTANCE_INITIALIZER;
void InitializeKioskModeIdleLogout() {
g_kiosk_mode_idle_logout.Get();
}
} // namespace chromeos
......@@ -6,50 +6,44 @@
#define CHROME_BROWSER_CHROMEOS_KIOSK_MODE_KIOSK_MODE_IDLE_LOGOUT_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "chromeos/dbus/power_manager_client.h"
#include "content/public/browser/notification_observer.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 {
class KioskModeIdleLogout : public PowerManagerClient::Observer,
public content::NotificationObserver {
public:
static void Initialize();
KioskModeIdleLogout();
private:
friend class KioskModeIdleLogoutTest;
// Really initialize idle logout when KioskModeHelper is initialized.
void Setup();
// NotificationObserver overrides:
// Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
// PowerManagerClient::Observer overrides:
// Overridden from PowerManagerClient::Observer:
virtual void IdleNotify(int64 threshold) OVERRIDE;
virtual void ActiveNotify() OVERRIDE;
private:
friend class KioskModeIdleLogoutTest;
content::NotificationRegistrar registrar_;
void SetupIdleNotifications();
void RequestNextActiveNotification();
void RequestNextIdleNotification();
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(KioskModeIdleLogout);
};
void InitializeKioskModeIdleLogout();
} // namespace chromeos
#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