summaryrefslogtreecommitdiffstats
path: root/chrome/browser/notifications/screen_lock_notification_blocker.h
blob: 4aff911e885bd1b784be601b6a34fa9cdec0ddb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_NOTIFICATIONS_SCREEN_LOCK_NOTIFICATION_BLOCKER_H_
#define CHROME_BROWSER_NOTIFICATIONS_SCREEN_LOCK_NOTIFICATION_BLOCKER_H_

#include "base/basictypes.h"
#include "base/observer_list.h"
#include "base/timer/timer.h"
#include "ui/message_center/notification_blocker.h"

// A notification blocker which checks the screen lock state constantly.
class ScreenLockNotificationBlocker
    : public message_center::NotificationBlocker {
 public:
  explicit ScreenLockNotificationBlocker(
      message_center::MessageCenter* message_center);
  ~ScreenLockNotificationBlocker() override;

  bool is_locked() const { return is_locked_; }

  // message_center::NotificationBlocker overrides:
  void CheckState() override;
  bool ShouldShowNotificationAsPopup(
      const message_center::NotifierId& notifier_id) const override;

 private:
  bool is_locked_;

  base::OneShotTimer timer_;

  DISALLOW_COPY_AND_ASSIGN(ScreenLockNotificationBlocker);
};

#endif  // CHROME_BROWSER_NOTIFICATIONS_SCREEN_LOCK_NOTIFICATION_BLOCKER_H_