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

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

Issue 1057573002: Implement the ability to get all notifications in Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-db-Integrate
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
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(

Powered by Google App Engine
This is Rietveld 408576698