Index: chrome/browser/extensions/api/notifications/extension_notification_handler.cc |
diff --git a/chrome/browser/extensions/api/notifications/extension_notification_handler.cc b/chrome/browser/extensions/api/notifications/extension_notification_handler.cc |
index 61fc1b8427f650dc2ac3660179e544a9f5959d8c..b0813274683c836e3293ca957b5186a7c8ab448f 100644 |
--- a/chrome/browser/extensions/api/notifications/extension_notification_handler.cc |
+++ b/chrome/browser/extensions/api/notifications/extension_notification_handler.cc |
@@ -5,17 +5,29 @@ |
#include "chrome/browser/extensions/api/notifications/extension_notification_handler.h" |
#include "base/logging.h" |
+#include "base/metrics/histogram_macros.h" |
#include "base/strings/nullable_string16.h" |
#include "base/strings/string_piece.h" |
#include "chrome/browser/extensions/api/notifications/extension_notification_display_helper.h" |
#include "chrome/browser/extensions/api/notifications/extension_notification_display_helper_factory.h" |
+#include "chrome/browser/notifications/notification_common.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/common/extensions/api/notifications.h" |
+#include "chrome/common/features.h" |
+#include "extensions/browser/app_window/app_window.h" |
+#include "extensions/browser/app_window/app_window_registry.h" |
+#include "extensions/browser/app_window/native_app_window.h" |
#include "extensions/common/constants.h" |
+#include "ui/message_center/notifier_settings.h" |
#include "url/gurl.h" |
namespace extensions { |
+namespace notifications = api::notifications; |
+ |
+const base::Feature kAllowFullscreenAppNotificationsFeature{ |
+ "FSNotificationsApp", base::FEATURE_ENABLED_BY_DEFAULT}; |
+ |
namespace { |
std::string GetExtensionId(const std::string& extension_url) { |
@@ -119,4 +131,34 @@ void ExtensionNotificationHandler::SendEvent( |
event_router->DispatchEventToExtension(extension_id, std::move(event)); |
} |
+// Should only display when fullscreen if this app is the source of the |
+// fullscreen window. |
+bool ExtensionNotificationHandler::ShouldDisplayOnFullScreen( |
+ Profile* profile, |
+ const std::string& origin) const { |
+ DCHECK(profile); |
+ AppWindowRegistry::AppWindowList windows = |
+ AppWindowRegistry::Get(profile)->GetAppWindowsForApp( |
+ GetExtensionId(origin)); |
+ for (auto* window : windows) { |
+ // Window must be fullscreen and visible |
+ if (window->IsFullscreen() && window->GetBaseWindow()->IsActive()) { |
+ bool enabled = |
+ base::FeatureList::IsEnabled(kAllowFullscreenAppNotificationsFeature); |
+ if (enabled) { |
+ UMA_HISTOGRAM_ENUMERATION("Notifications.Display_Fullscreen.Shown", |
+ message_center::NotifierId::APPLICATION, |
+ message_center::NotifierId::SIZE); |
+ } else { |
+ UMA_HISTOGRAM_ENUMERATION("Notifications.Display_Fullscreen.Suppressed", |
+ message_center::NotifierId::APPLICATION, |
+ message_center::NotifierId::SIZE); |
+ } |
+ return enabled; |
+ } |
+ } |
+ |
+ return false; |
+} |
+ |
} // namespace extensions |