| Index: content/browser/notifications/notification_message_filter.cc
|
| diff --git a/content/browser/notifications/notification_message_filter.cc b/content/browser/notifications/notification_message_filter.cc
|
| index 9270ca878806bf2e8ecd2824720bc356e444ffd4..e3270fd199dd71538df3d3db08ce20faba931e74 100644
|
| --- a/content/browser/notifications/notification_message_filter.cc
|
| +++ b/content/browser/notifications/notification_message_filter.cc
|
| @@ -171,14 +171,40 @@ void NotificationMessageFilter::OnGetNotifications(
|
| const GURL& origin,
|
| const std::string& filter_tag) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| + if (GetPermissionForOriginOnIO(origin) !=
|
| + blink::WebNotificationPermissionAllowed) {
|
| + BadMessageReceived();
|
| + return;
|
| + }
|
|
|
| - // TODO(peter): Implement retrieval of persistent Web Notifications from the
|
| - // database. Reply with an empty vector until this has been implemented.
|
| - // Tracked in https://crbug.com/442143.
|
| + notification_context_->ReadAllNotificationDataForServiceWorkerRegistration(
|
| + origin,
|
| + service_worker_registration_id,
|
| + base::Bind(&NotificationMessageFilter::DidGetNotifications,
|
| + weak_factory_.GetWeakPtr(),
|
| + request_id,
|
| + filter_tag));
|
| +}
|
| +
|
| +void NotificationMessageFilter::DidGetNotifications(
|
| + int request_id,
|
| + const std::string& filter_tag,
|
| + bool success,
|
| + const std::vector<NotificationDatabaseData>& notifications) {
|
| + std::vector<PersistentNotificationInfo> persistent_notifications;
|
| + for (const NotificationDatabaseData& database_data : notifications) {
|
| + if (!filter_tag.empty()) {
|
| + const std::string& tag = database_data.notification_data.tag;
|
| + if (tag != filter_tag)
|
| + continue;
|
| + }
|
| +
|
| + persistent_notifications.push_back(std::make_pair(
|
| + database_data.notification_id, database_data.notification_data));
|
| + }
|
|
|
| Send(new PlatformNotificationMsg_DidGetNotifications(
|
| - request_id,
|
| - std::vector<PersistentNotificationInfo>()));
|
| + request_id, persistent_notifications));
|
| }
|
|
|
| void NotificationMessageFilter::OnClosePlatformNotification(
|
|
|