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

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

Issue 2906883003: Deprecate per notification type delegates. (Closed)
Patch Set: review 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') | content/browser/BUILD.gn » ('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..8d4e792eb4d48b3ef517254fdb88c3ccac68cfd7 100644
--- a/chrome/browser/notifications/web_notification_delegate.cc
+++ b/chrome/browser/notifications/web_notification_delegate.cc
@@ -6,7 +6,9 @@
#include "base/feature_list.h"
#include "base/metrics/histogram_macros.h"
-#include "chrome/browser/notifications/notification_common.h"
+#include "base/strings/nullable_string16.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"
@@ -27,12 +29,13 @@ const base::Feature kAllowFullscreenWebNotificationsFeature{
} // 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 +47,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;
@@ -57,13 +60,11 @@ bool WebNotificationDelegate::ShouldDisplaySettingsButton() {
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)
+ if (browser->profile() != profile_)
continue;
const content::WebContents* active_contents =
@@ -98,3 +99,41 @@ bool WebNotificationDelegate::ShouldDisplayOverFullscreen() const {
return false;
}
+
+void WebNotificationDelegate::Display() {}
+
+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());
+}
+
+void WebNotificationDelegate::Click() {
+ auto* display_service =
+ NotificationDisplayServiceFactory::GetForProfile(profile_);
+ display_service->ProcessNotificationOperation(
+ NotificationCommon::CLICK, notification_type_, origin().spec(),
+ notification_id_, -1, base::NullableString16());
+}
+
+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') | content/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698