Index: content/browser/notifications/page_notification_delegate.cc |
diff --git a/content/browser/notifications/page_notification_delegate.cc b/content/browser/notifications/page_notification_delegate.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e7af1a4ae509aecf094775ca55a8523b1e980437 |
--- /dev/null |
+++ b/content/browser/notifications/page_notification_delegate.cc |
@@ -0,0 +1,56 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/notifications/page_notification_delegate.h" |
+ |
+#include "content/browser/notifications/notification_message_filter.h" |
+#include "content/browser/renderer_host/render_process_host_impl.h" |
+#include "content/common/platform_notification_messages.h" |
+#include "content/public/browser/render_process_host.h" |
+ |
+namespace content { |
+ |
+PageNotificationDelegate::PageNotificationDelegate(int render_process_id, |
+ int notification_id) |
+ : render_process_id_(render_process_id), |
+ notification_id_(notification_id) {} |
+ |
+PageNotificationDelegate::~PageNotificationDelegate() {} |
+ |
+void PageNotificationDelegate::NotificationDisplayed() { |
+ RenderProcessHost* sender = RenderProcessHost::FromID(render_process_id_); |
+ if (!sender) |
+ return; |
+ |
+ sender->Send(new PlatformNotificationMsg_DidShow(notification_id_)); |
+} |
+ |
+void PageNotificationDelegate::NotificationError() { |
+ RenderProcessHost* sender = RenderProcessHost::FromID(render_process_id_); |
+ if (!sender) |
+ return; |
+ |
+ sender->Send(new PlatformNotificationMsg_DidError(notification_id_)); |
+} |
+ |
+// TODO(peter): Remove |by_user| since we're not using that anywhere. |
+void PageNotificationDelegate::NotificationClosed(bool by_user) { |
+ RenderProcessHost* sender = RenderProcessHost::FromID(render_process_id_); |
+ if (!sender) |
+ return; |
+ |
+ sender->Send(new PlatformNotificationMsg_DidClose(notification_id_)); |
+ static_cast<RenderProcessHostImpl*>(sender) |
+ ->notification_message_filter()->DidCloseNotification(notification_id_); |
+} |
+ |
+void PageNotificationDelegate::NotificationClick() { |
+ RenderProcessHost* sender = RenderProcessHost::FromID(render_process_id_); |
+ if (!sender) |
+ return; |
+ |
+ sender->Send(new PlatformNotificationMsg_DidClick(notification_id_)); |
+} |
+ |
+} // namespace content |