| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/notifications/fullscreen_notification_blocker.h" | 5 #include "chrome/browser/notifications/fullscreen_notification_blocker.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/fullscreen.h" | 10 #include "chrome/browser/fullscreen.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 void FullscreenNotificationBlocker::CheckState() { | 65 void FullscreenNotificationBlocker::CheckState() { |
| 66 bool was_fullscreen_mode = is_fullscreen_mode_; | 66 bool was_fullscreen_mode = is_fullscreen_mode_; |
| 67 is_fullscreen_mode_ = DoesFullscreenModeBlockNotifications(); | 67 is_fullscreen_mode_ = DoesFullscreenModeBlockNotifications(); |
| 68 if (is_fullscreen_mode_ != was_fullscreen_mode) | 68 if (is_fullscreen_mode_ != was_fullscreen_mode) |
| 69 NotifyBlockingStateChanged(); | 69 NotifyBlockingStateChanged(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool FullscreenNotificationBlocker::ShouldShowNotificationAsPopup( | 72 bool FullscreenNotificationBlocker::ShouldShowNotificationAsPopup( |
| 73 const message_center::Notification& notification) const { | 73 const message_center::Notification& notification) const { |
| 74 bool enabled = !is_fullscreen_mode_ || | 74 bool enabled = !is_fullscreen_mode_; |
| 75 notification.delegate()->ShouldDisplayOverFullscreen(); | 75 if (is_fullscreen_mode_ && notification.delegate()) |
| 76 enabled = notification.delegate()->ShouldDisplayOverFullscreen(); |
| 77 |
| 76 #if defined(USE_ASH) | 78 #if defined(USE_ASH) |
| 77 if (ash::Shell::HasInstance()) | 79 if (ash::Shell::HasInstance()) |
| 78 enabled = enabled || ash::system_notifier::ShouldAlwaysShowPopups( | 80 enabled = enabled || ash::system_notifier::ShouldAlwaysShowPopups( |
| 79 notification.notifier_id()); | 81 notification.notifier_id()); |
| 80 #endif | 82 #endif |
| 81 | 83 |
| 82 if (enabled && !is_fullscreen_mode_) { | 84 if (enabled && !is_fullscreen_mode_) { |
| 83 UMA_HISTOGRAM_ENUMERATION("Notifications.Display_Windowed", | 85 UMA_HISTOGRAM_ENUMERATION("Notifications.Display_Windowed", |
| 84 notification.notifier_id().type, | 86 notification.notifier_id().type, |
| 85 NotifierId::SIZE); | 87 NotifierId::SIZE); |
| 86 } | 88 } |
| 87 | 89 |
| 88 return enabled; | 90 return enabled; |
| 89 } | 91 } |
| 90 | 92 |
| 91 void FullscreenNotificationBlocker::Observe( | 93 void FullscreenNotificationBlocker::Observe( |
| 92 int type, | 94 int type, |
| 93 const content::NotificationSource& source, | 95 const content::NotificationSource& source, |
| 94 const content::NotificationDetails& details) { | 96 const content::NotificationDetails& details) { |
| 95 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); | 97 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); |
| 96 CheckState(); | 98 CheckState(); |
| 97 } | 99 } |
| OLD | NEW |