Get foreground tab on Android
[chromium-blink-merge.git] / ui / message_center / notification_blocker.h
blob437f0eb1238f62f6286bc78fc18dded3fa292b4f
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_MESSAGE_CENTER_NOTIFICATION_BLOCKER_H_
6 #define UI_MESSAGE_CENTER_NOTIFICATION_BLOCKER_H_
8 #include "base/observer_list.h"
9 #include "ui/message_center/message_center_export.h"
10 #include "ui/message_center/notifier_settings.h"
12 namespace message_center {
13 class MessageCenter;
15 // NotificationBlocker manages the availability of notifications based on the
16 // current system status. Each NotificationBlocker implementation covers a
17 // single state such as screen lock or fullscreen.
18 class MESSAGE_CENTER_EXPORT NotificationBlocker {
19 public:
20 class Observer {
21 public:
22 virtual void OnBlockingStateChanged() = 0;
25 explicit NotificationBlocker(MessageCenter* message_center);
26 virtual ~NotificationBlocker();
28 void AddObserver(Observer* observer);
29 void RemoveObserver(Observer* observer);
31 // Checks the current state and updates the availability.
32 virtual void CheckState() {}
34 // Returns true when notifications from |notifier_id| should be shown as
35 // popups on screen. If it's false, those notifications should be queued.
36 // When a blocker starts returning false for a notification which is already
37 // shown as a popup, the notification should be closed as a popup immediately.
38 virtual bool ShouldShowNotificationAsPopup(
39 const NotifierId& notifier_id) const = 0;
41 protected:
42 ObserverList<Observer>& observers() { return observers_; }
44 private:
45 ObserverList<Observer> observers_;
46 MessageCenter* message_center_; // weak
49 } // namespace message_center
51 #endif // UI_MESSAGE_CENTER_NOTIFICATION_BLOCKER_H_