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

Unified Diff: content/child/notifications/notification_manager.cc

Issue 1014073002: Implement getting notifications up to the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « content/child/notifications/notification_manager.h ('k') | content/common/platform_notification_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/notifications/notification_manager.cc
diff --git a/content/child/notifications/notification_manager.cc b/content/child/notifications/notification_manager.cc
index b951ba720cc957e5d0ba0c60291305c809f90985..f1dec82547fe0a7048466bf1303b7dfaead70e69 100644
--- a/content/child/notifications/notification_manager.cc
+++ b/content/child/notifications/notification_manager.cc
@@ -13,7 +13,6 @@
#include "content/child/service_worker/web_service_worker_registration_impl.h"
#include "content/child/thread_safe_sender.h"
#include "content/child/worker_task_runner.h"
-#include "content/common/platform_notification_messages.h"
#include "content/public/common/platform_notification_data.h"
#include "third_party/WebKit/public/platform/WebSerializedOrigin.h"
#include "third_party/WebKit/public/platform/modules/notifications/WebNotificationDelegate.h"
@@ -114,6 +113,36 @@ void NotificationManager::showPersistent(
base::Passed(&owned_callbacks)));
}
+void NotificationManager::getNotifications(
+ const blink::WebString& filter_tag,
+ blink::WebServiceWorkerRegistration* service_worker_registration,
+ blink::WebNotificationGetCallbacks* callbacks) {
+ DCHECK(service_worker_registration);
+ DCHECK(callbacks);
+
+ WebServiceWorkerRegistrationImpl* service_worker_registration_impl =
+ static_cast<WebServiceWorkerRegistrationImpl*>(
+ service_worker_registration);
+
+ GURL origin = GURL(service_worker_registration_impl->scope()).GetOrigin();
+ int64 service_worker_registration_id =
+ service_worker_registration_impl->registration_id();
+
+ // TODO(peter): GenerateNotificationId is more of a request id. Consider
+ // renaming the method in the NotificationDispatcher if this makes sense.
+ int request_id =
+ notification_dispatcher_->GenerateNotificationId(CurrentWorkerId());
+
+ pending_get_notification_requests_.AddWithID(callbacks, request_id);
+
+ thread_safe_sender_->Send(
+ new PlatformNotificationHostMsg_GetNotifications(
+ request_id,
+ service_worker_registration_id,
+ origin,
+ base::UTF16ToUTF8(filter_tag)));
+}
+
void NotificationManager::close(blink::WebNotificationDelegate* delegate) {
if (pending_notifications_.CancelPageNotificationFetches(delegate))
return;
@@ -171,6 +200,8 @@ bool NotificationManager::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidShow, OnDidShow);
IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClose, OnDidClose);
IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClick, OnDidClick);
+ IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidGetNotifications,
+ OnDidGetNotifications)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -202,6 +233,34 @@ void NotificationManager::OnDidClick(int notification_id) {
iter->second->dispatchClickEvent();
}
+void NotificationManager::OnDidGetNotifications(
+ int request_id,
+ const std::vector<PersistentNotificationInfo>& notification_infos) {
+ blink::WebNotificationGetCallbacks* callbacks =
+ pending_get_notification_requests_.Lookup(request_id);
+ DCHECK(callbacks);
+ if (!callbacks)
+ return;
+
+ scoped_ptr<blink::WebVector<blink::WebPersistentNotificationInfo>>
+ notifications(new blink::WebVector<blink::WebPersistentNotificationInfo>(
+ notification_infos.size()));
+
+ for (size_t i = 0; i < notification_infos.size(); ++i) {
+ blink::WebPersistentNotificationInfo web_notification_info;
+ web_notification_info.persistentNotificationId =
+ blink::WebString::fromUTF8(notification_infos[i].first);
+ web_notification_info.data =
+ ToWebNotificationData(notification_infos[i].second);
+
+ (*notifications)[i] = web_notification_info;
+ }
+
+ callbacks->onSuccess(notifications.release());
+
+ pending_get_notification_requests_.Remove(request_id);
+}
+
void NotificationManager::DisplayPageNotification(
const blink::WebSerializedOrigin& origin,
const blink::WebNotificationData& notification_data,
« no previous file with comments | « content/child/notifications/notification_manager.h ('k') | content/common/platform_notification_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698