Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / notifications / screen_lock_notification_blocker.cc
bloba41b2a8de2336ddd52870b49eef60f7d8f114fec
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 #include "chrome/browser/notifications/screen_lock_notification_blocker.h"
7 #include "base/time/time.h"
8 #include "ui/base/idle/idle.h"
10 namespace {
11 const int kUserStatePollingIntervalSeconds = 1;
14 ScreenLockNotificationBlocker::ScreenLockNotificationBlocker(
15 message_center::MessageCenter* message_center)
16 : NotificationBlocker(message_center),
17 is_locked_(false) {
20 ScreenLockNotificationBlocker::~ScreenLockNotificationBlocker() {
23 void ScreenLockNotificationBlocker::CheckState() {
24 bool was_locked = is_locked_;
25 is_locked_ = ui::CheckIdleStateIsLocked();
26 if (is_locked_ != was_locked)
27 NotifyBlockingStateChanged();
29 if (is_locked_) {
30 timer_.Start(FROM_HERE,
31 base::TimeDelta::FromSeconds(kUserStatePollingIntervalSeconds),
32 this,
33 &ScreenLockNotificationBlocker::CheckState);
37 bool ScreenLockNotificationBlocker::ShouldShowNotificationAsPopup(
38 const message_center::NotifierId& notifier_id) const {
39 return !is_locked_;