Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Unified Diff: chrome/browser/notifications/web_notification_delegate.cc

Issue 2941743002: Revert of Deprecate native and extension notification delegates. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/web_notification_delegate.cc
diff --git a/chrome/browser/notifications/web_notification_delegate.cc b/chrome/browser/notifications/web_notification_delegate.cc
index a99bad6e06a9cfd40ff122a91c63c5be223f93bc..8d4e792eb4d48b3ef517254fdb88c3ccac68cfd7 100644
--- a/chrome/browser/notifications/web_notification_delegate.cc
+++ b/chrome/browser/notifications/web_notification_delegate.cc
@@ -7,11 +7,27 @@
#include "base/feature_list.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/nullable_string16.h"
-#include "chrome/browser/notifications/notification_common.h"
#include "chrome/browser/notifications/notification_display_service.h"
#include "chrome/browser/notifications/notification_display_service_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "content/public/browser/web_contents.h"
+#include "ui/message_center/notifier_settings.h"
+using message_center::NotifierId;
+
+namespace features {
+
+const base::Feature kAllowFullscreenWebNotificationsFeature{
+ "FSNotificationsWeb", base::FEATURE_ENABLED_BY_DEFAULT
+};
+
+} // namespace features
WebNotificationDelegate::WebNotificationDelegate(
NotificationCommon::Type notification_type,
@@ -39,16 +55,52 @@
}
bool WebNotificationDelegate::ShouldDisplaySettingsButton() {
- return notification_type_ != NotificationCommon::EXTENSION;
+ return true;
}
bool WebNotificationDelegate::ShouldDisplayOverFullscreen() const {
- NotificationDisplayService* display_service =
- NotificationDisplayServiceFactory::GetForProfile(profile_);
+#if !defined(OS_ANDROID)
+ // Check to see if this notification comes from a webpage that is displaying
+ // fullscreen content.
+ for (auto* browser : *BrowserList::GetInstance()) {
+ // Only consider the browsers for the profile that created the notification
+ if (browser->profile() != profile_)
+ continue;
- return display_service->ShouldDisplayOverFullscreen(origin_,
- notification_type_);
+ const content::WebContents* active_contents =
+ browser->tab_strip_model()->GetActiveWebContents();
+ if (!active_contents)
+ continue;
+
+ // Check to see if
+ // (a) the active tab in the browser shares its origin with the
+ // notification.
+ // (b) the browser is fullscreen
+ // (c) the browser has focus.
+ if (active_contents->GetURL().GetOrigin() == origin_ &&
+ browser->exclusive_access_manager()->context()->IsFullscreen() &&
+ browser->window()->IsActive()) {
+ bool enabled = base::FeatureList::IsEnabled(
+ features::kAllowFullscreenWebNotificationsFeature);
+ if (enabled) {
+ UMA_HISTOGRAM_ENUMERATION("Notifications.Display_Fullscreen.Shown",
+ NotifierId::WEB_PAGE,
+ NotifierId::SIZE);
+ } else {
+ UMA_HISTOGRAM_ENUMERATION(
+ "Notifications.Display_Fullscreen.Suppressed",
+ NotifierId::WEB_PAGE,
+ NotifierId::SIZE);
+ }
+ return enabled;
+ }
+ }
+#endif
+
+ return false;
}
+
+void WebNotificationDelegate::Display() {}
void WebNotificationDelegate::Close(bool by_user) {
auto* display_service =
« no previous file with comments | « chrome/browser/notifications/web_notification_delegate.h ('k') | content/test/mock_platform_notification_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698