| 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..6090de2b63ab280158d5c4d149d3bdae20559a9c 100644
|
| --- a/chrome/browser/extensions/api/notifications/extension_notification_handler.cc
|
| +++ b/chrome/browser/extensions/api/notifications/extension_notification_handler.cc
|
| @@ -4,18 +4,31 @@
|
|
|
| #include "chrome/browser/extensions/api/notifications/extension_notification_handler.h"
|
|
|
| +#include "base/feature_list.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 +132,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
|
|
|