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

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

Issue 2921263002: Remove many delegates, let's see what breaks
Patch Set: compile 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
« no previous file with comments | « chrome/browser/notifications/web_notification_delegate.h ('k') | chrome/tools/build/mac/verify_order » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 86671a5d043199e7aec7122fa882429179c15b2d..1942c6a90fcef105221eb1e4e7a8227fd6ecdece 100644
--- a/chrome/browser/notifications/web_notification_delegate.cc
+++ b/chrome/browser/notifications/web_notification_delegate.cc
@@ -6,33 +6,19 @@
#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(
- content::BrowserContext* browser_context,
+ NotificationCommon::Type notification_type,
+ Profile* profile,
const std::string& notification_id,
const GURL& origin)
- : browser_context_(browser_context),
+ : notification_type_(notification_type),
+ profile_(profile),
notification_id_(notification_id),
origin_(origin) {}
@@ -44,7 +30,7 @@ std::string WebNotificationDelegate::id() const {
bool WebNotificationDelegate::SettingsClick() {
#if !defined(OS_CHROMEOS)
- NotificationCommon::OpenNotificationSettings(browser_context_);
+ NotificationCommon::OpenNotificationSettings(profile_);
return true;
#else
return false;
@@ -52,49 +38,49 @@ bool WebNotificationDelegate::SettingsClick() {
}
bool WebNotificationDelegate::ShouldDisplaySettingsButton() {
- return true;
+ return notification_type_ != NotificationCommon::EXTENSION;
}
bool WebNotificationDelegate::ShouldDisplayOverFullscreen() const {
-#if !defined(OS_ANDROID)
- Profile* profile = Profile::FromBrowserContext(browser_context_);
- DCHECK(profile);
- // 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;
+ NotificationDisplayService* display_service =
+ NotificationDisplayServiceFactory::GetForProfile(profile_);
+
+ return display_service->ShouldDisplayOverFullscreen(origin_,
+ notification_type_);
+}
- const content::WebContents* active_contents =
- browser->tab_strip_model()->GetActiveWebContents();
- if (!active_contents)
- continue;
+void WebNotificationDelegate::Close(bool by_user) {
+ auto* display_service =
+ NotificationDisplayServiceFactory::GetForProfile(profile_);
+ display_service->ProcessNotificationOperation(
+ NotificationCommon::CLOSE, notification_type_, origin().spec(),
+ notification_id_, -1, base::NullableString16());
+}
- // 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
+void WebNotificationDelegate::Click() {
+ auto* display_service =
+ NotificationDisplayServiceFactory::GetForProfile(profile_);
+ display_service->ProcessNotificationOperation(
+ NotificationCommon::CLICK, notification_type_, origin().spec(),
+ notification_id_, -1, base::NullableString16());
+}
- return false;
+void WebNotificationDelegate::ButtonClick(int button_index) {
+ DCHECK(button_index >= 0);
+ auto* display_service =
+ NotificationDisplayServiceFactory::GetForProfile(profile_);
+ display_service->ProcessNotificationOperation(
+ NotificationCommon::CLICK, notification_type_, origin().spec(),
+ notification_id_, button_index, base::NullableString16());
+}
+
+void WebNotificationDelegate::ButtonClickWithReply(
+ int button_index,
+ const base::string16& reply) {
+ auto* display_service =
+ NotificationDisplayServiceFactory::GetForProfile(profile_);
+ display_service->ProcessNotificationOperation(
+ NotificationCommon::CLICK, notification_type_, origin().spec(),
+ notification_id_, button_index,
+ base::NullableString16(reply, false /* is_null */));
}
« no previous file with comments | « chrome/browser/notifications/web_notification_delegate.h ('k') | chrome/tools/build/mac/verify_order » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698