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

Unified Diff: content/browser/notifications/notification_message_filter.cc

Issue 681783004: Implement the PageNotificationDelegate for the new Web Notification path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/Ids/ids/ Created 6 years, 2 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: content/browser/notifications/notification_message_filter.cc
diff --git a/content/browser/notification_message_filter.cc b/content/browser/notifications/notification_message_filter.cc
similarity index 59%
rename from content/browser/notification_message_filter.cc
rename to content/browser/notifications/notification_message_filter.cc
index da666397c9adc34ba9e5fb93374f0272d2c33238..fecd0730b77f8b5bafc47ec04e0ef70cbf8d0ebd 100644
--- a/content/browser/notification_message_filter.cc
+++ b/content/browser/notifications/notification_message_filter.cc
@@ -2,23 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/notification_message_filter.h"
+#include "content/browser/notifications/notification_message_filter.h"
+#include "base/callback.h"
+#include "content/browser/notifications/page_notification_delegate.h"
#include "content/common/platform_notification_messages.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/desktop_notification_delegate.h"
#include "content/public/common/content_client.h"
namespace content {
NotificationMessageFilter::NotificationMessageFilter(
int process_id,
- ResourceContext* resource_context)
+ ResourceContext* resource_context,
+ BrowserContext* browser_context)
: BrowserMessageFilter(PlatformNotificationMsgStart),
process_id_(process_id),
- resource_context_(resource_context) {}
+ resource_context_(resource_context),
+ browser_context_(browser_context) {}
NotificationMessageFilter::~NotificationMessageFilter() {}
+void NotificationMessageFilter::DidCloseNotification(int notification_id) {
+ close_closures_.erase(notification_id);
+}
+
bool NotificationMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(NotificationMessageFilter, message)
@@ -52,14 +63,27 @@ void NotificationMessageFilter::OnCheckNotificationPermission(
void NotificationMessageFilter::OnShowPlatformNotification(
int notification_id, const ShowDesktopNotificationHostMsgParams& params) {
- // TODO(peter): Implement the DesktopNotificationDelegate.
- NOTIMPLEMENTED();
+ scoped_ptr<DesktopNotificationDelegate> delegate(
+ new PageNotificationDelegate(process_id_, notification_id));
+
+ base::Closure close_closure;
+ GetContentClient()->browser()->ShowDesktopNotification(params,
+ browser_context_,
+ process_id_,
+ delegate.Pass(),
+ &close_closure);
+
+ if (!close_closure.is_null())
+ close_closures_[notification_id] = close_closure;
}
void NotificationMessageFilter::OnClosePlatformNotification(
int notification_id) {
- // TODO(peter): Implement the ability to close notifications.
- NOTIMPLEMENTED();
+ if (!close_closures_.count(notification_id))
+ return;
+
+ close_closures_[notification_id].Run();
+ close_closures_.erase(notification_id);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698