| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/notifications/notification_event_dispatcher_impl.h" | 5 #include "content/browser/notifications/notification_event_dispatcher_impl.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/strings/string_number_conversions.h" | |
| 9 #include "content/browser/notifications/platform_notification_context_impl.h" | 8 #include "content/browser/notifications/platform_notification_context_impl.h" |
| 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 9 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 11 #include "content/browser/service_worker/service_worker_registration.h" | 10 #include "content/browser/service_worker/service_worker_registration.h" |
| 12 #include "content/browser/service_worker/service_worker_storage.h" | 11 #include "content/browser/service_worker/service_worker_storage.h" |
| 13 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
| 14 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/notification_database_data.h" | 14 #include "content/public/browser/notification_database_data.h" |
| 16 #include "content/public/browser/storage_partition.h" | 15 #include "content/public/browser/storage_partition.h" |
| 17 #include "content/public/common/platform_notification_data.h" | 16 #include "content/public/common/platform_notification_data.h" |
| 18 | 17 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 ServiceWorkerStatusCode service_worker_status, | 69 ServiceWorkerStatusCode service_worker_status, |
| 71 const scoped_refptr<ServiceWorkerRegistration>& | 70 const scoped_refptr<ServiceWorkerRegistration>& |
| 72 service_worker_registration) { | 71 service_worker_registration) { |
| 73 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 72 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 74 if (service_worker_status == SERVICE_WORKER_OK) { | 73 if (service_worker_status == SERVICE_WORKER_OK) { |
| 75 base::Callback<void(ServiceWorkerStatusCode)> dispatch_event_callback = | 74 base::Callback<void(ServiceWorkerStatusCode)> dispatch_event_callback = |
| 76 base::Bind(&NotificationClickEventFinished, | 75 base::Bind(&NotificationClickEventFinished, |
| 77 dispatch_complete_callback, | 76 dispatch_complete_callback, |
| 78 service_worker_registration); | 77 service_worker_registration); |
| 79 | 78 |
| 80 // TODO(peter): Pass the persistent notification id as an int64_t rather | |
| 81 // than as a string. This depends on the Blink API being updated. | |
| 82 std::string persistent_notification_id_string = | |
| 83 base::Int64ToString(notification_database_data.notification_id); | |
| 84 | |
| 85 service_worker_registration->active_version()-> | 79 service_worker_registration->active_version()-> |
| 86 DispatchNotificationClickEvent( | 80 DispatchNotificationClickEvent( |
| 87 dispatch_event_callback, | 81 dispatch_event_callback, |
| 88 persistent_notification_id_string, | 82 notification_database_data.notification_id, |
| 89 notification_database_data.notification_data); | 83 notification_database_data.notification_data); |
| 90 return; | 84 return; |
| 91 } | 85 } |
| 92 | 86 |
| 93 PersistentNotificationStatus status = PERSISTENT_NOTIFICATION_STATUS_SUCCESS; | 87 PersistentNotificationStatus status = PERSISTENT_NOTIFICATION_STATUS_SUCCESS; |
| 94 switch (service_worker_status) { | 88 switch (service_worker_status) { |
| 95 case SERVICE_WORKER_ERROR_NOT_FOUND: | 89 case SERVICE_WORKER_ERROR_NOT_FOUND: |
| 96 status = PERSISTENT_NOTIFICATION_STATUS_NO_SERVICE_WORKER; | 90 status = PERSISTENT_NOTIFICATION_STATUS_NO_SERVICE_WORKER; |
| 97 break; | 91 break; |
| 98 case SERVICE_WORKER_ERROR_FAILED: | 92 case SERVICE_WORKER_ERROR_FAILED: |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 FROM_HERE, | 200 FROM_HERE, |
| 207 base::Bind(&ReadNotificationDatabaseData, | 201 base::Bind(&ReadNotificationDatabaseData, |
| 208 persistent_notification_id, | 202 persistent_notification_id, |
| 209 origin, | 203 origin, |
| 210 dispatch_complete_callback, | 204 dispatch_complete_callback, |
| 211 service_worker_context, | 205 service_worker_context, |
| 212 notification_context)); | 206 notification_context)); |
| 213 } | 207 } |
| 214 | 208 |
| 215 } // namespace content | 209 } // namespace content |
| OLD | NEW |