This source file includes following definitions.
- observing_
- LoginStateNotificationBlockerChromeOS
- ShouldShowNotificationAsPopup
- OnLockStateChanged
- OnAppTerminating
- LoggedInStateChanged
- OnUserAddingStarted
- OnUserAddingFinished
#include "chrome/browser/notifications/login_state_notification_blocker_chromeos.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/system/system_notifier.h"
#include "ash/wm/window_properties.h"
#include "chrome/browser/chrome_notification_types.h"
#include "content/public/browser/notification_service.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/message_center/message_center.h"
LoginStateNotificationBlockerChromeOS::LoginStateNotificationBlockerChromeOS(
message_center::MessageCenter* message_center)
: NotificationBlocker(message_center),
locked_(false),
observing_(true) {
ash::Shell::GetInstance()->AddShellObserver(this);
if (chromeos::LoginState::IsInitialized())
chromeos::LoginState::Get()->AddObserver(this);
chromeos::UserAddingScreen::Get()->AddObserver(this);
}
LoginStateNotificationBlockerChromeOS::
~LoginStateNotificationBlockerChromeOS() {
if (chromeos::LoginState::IsInitialized())
chromeos::LoginState::Get()->RemoveObserver(this);
if (observing_) {
if (ash::Shell::HasInstance())
ash::Shell::GetInstance()->RemoveShellObserver(this);
chromeos::UserAddingScreen::Get()->RemoveObserver(this);
}
}
bool LoginStateNotificationBlockerChromeOS::ShouldShowNotificationAsPopup(
const message_center::NotifierId& notifier_id) const {
if (ash::system_notifier::ShouldAlwaysShowPopups(notifier_id))
return true;
if (locked_)
return false;
if (chromeos::UserAddingScreen::Get()->IsRunning())
return false;
if (chromeos::LoginState::IsInitialized())
return chromeos::LoginState::Get()->IsUserLoggedIn();
return true;
}
void LoginStateNotificationBlockerChromeOS::OnLockStateChanged(bool locked) {
locked_ = locked;
NotifyBlockingStateChanged();
}
void LoginStateNotificationBlockerChromeOS::OnAppTerminating() {
ash::Shell::GetInstance()->RemoveShellObserver(this);
chromeos::UserAddingScreen::Get()->RemoveObserver(this);
observing_ = false;
}
void LoginStateNotificationBlockerChromeOS::LoggedInStateChanged() {
NotifyBlockingStateChanged();
}
void LoginStateNotificationBlockerChromeOS::OnUserAddingStarted() {
NotifyBlockingStateChanged();
}
void LoginStateNotificationBlockerChromeOS::OnUserAddingFinished() {
NotifyBlockingStateChanged();
}