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

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

Issue 1021293002: Have the browser process confirm creation of a persistent notification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-db-BlowAway
Patch Set: rebase 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 f1dec82547fe0a7048466bf1303b7dfaead70e69..6f5e8fefdb49b9bf4b086661e4ba56c772ef8d16 100644
--- a/content/child/notifications/notification_manager.cc
+++ b/content/child/notifications/notification_manager.cc
@@ -198,6 +198,8 @@ bool NotificationManager::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(NotificationManager, message)
IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidShow, OnDidShow);
+ IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidShowPersistent,
+ OnDidShowPersistent)
IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClose, OnDidClose);
IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClick, OnDidClick);
IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidGetNotifications,
@@ -216,6 +218,22 @@ void NotificationManager::OnDidShow(int notification_id) {
iter->second->dispatchShowEvent();
}
+void NotificationManager::OnDidShowPersistent(int request_id, bool success) {
+ blink::WebNotificationShowCallbacks* callbacks =
+ pending_show_notification_requests_.Lookup(request_id);
+ DCHECK(callbacks);
+
+ if (!callbacks)
+ return;
+
+ if (success)
+ callbacks->onSuccess();
+ else
+ callbacks->onError();
+
+ pending_show_notification_requests_.Remove(request_id);
+}
+
void NotificationManager::OnDidClose(int notification_id) {
const auto& iter = active_page_notifications_.find(notification_id);
if (iter == active_page_notifications_.end())
@@ -284,16 +302,21 @@ void NotificationManager::DisplayPersistentNotification(
int64 service_worker_registration_id,
scoped_ptr<blink::WebNotificationShowCallbacks> callbacks,
const SkBitmap& icon) {
+ // 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_show_notification_requests_.AddWithID(callbacks.release(),
+ request_id);
+
thread_safe_sender_->Send(
new PlatformNotificationHostMsg_ShowPersistent(
+ request_id,
service_worker_registration_id,
GURL(origin.string()),
icon,
ToPlatformNotificationData(notification_data)));
-
- // There currently isn't a case in which the promise would be rejected per
- // our implementation, so always resolve it here.
- callbacks->onSuccess();
}
} // namespace content
« 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