| 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_message_filter.h" | 5 #include "content/browser/notifications/notification_message_filter.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/feature_list.h" | 11 #include "base/feature_list.h" |
| 12 #include "content/browser/bad_message.h" | 12 #include "content/browser/bad_message.h" |
| 13 #include "content/browser/notifications/notification_event_dispatcher_impl.h" | 13 #include "content/browser/notifications/notification_event_dispatcher_impl.h" |
| 14 #include "content/browser/notifications/notification_id_generator.h" | 14 #include "content/browser/notifications/notification_id_generator.h" |
| 15 #include "content/browser/notifications/page_notification_delegate.h" | |
| 16 #include "content/browser/notifications/platform_notification_context_impl.h" | 15 #include "content/browser/notifications/platform_notification_context_impl.h" |
| 17 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 16 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 18 #include "content/common/platform_notification_messages.h" | 17 #include "content/common/platform_notification_messages.h" |
| 19 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
| 20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/content_browser_client.h" | 20 #include "content/public/browser/content_browser_client.h" |
| 22 #include "content/public/browser/desktop_notification_delegate.h" | |
| 23 #include "content/public/browser/notification_database_data.h" | 21 #include "content/public/browser/notification_database_data.h" |
| 24 #include "content/public/browser/platform_notification_service.h" | 22 #include "content/public/browser/platform_notification_service.h" |
| 25 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
| 26 #include "content/public/common/content_client.h" | 24 #include "content/public/common/content_client.h" |
| 27 #include "content/public/common/content_features.h" | 25 #include "content/public/common/content_features.h" |
| 28 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_switches.h" |
| 29 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onConstants.h" | 27 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onConstants.h" |
| 30 | 28 |
| 31 namespace content { | 29 namespace content { |
| 32 | 30 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 GetContentClient()->browser()->GetPlatformNotificationService(); | 159 GetContentClient()->browser()->GetPlatformNotificationService(); |
| 162 DCHECK(service); | 160 DCHECK(service); |
| 163 | 161 |
| 164 if (!VerifyNotificationPermissionGranted(service, origin)) | 162 if (!VerifyNotificationPermissionGranted(service, origin)) |
| 165 return; | 163 return; |
| 166 | 164 |
| 167 std::string notification_id = | 165 std::string notification_id = |
| 168 GetNotificationIdGenerator()->GenerateForNonPersistentNotification( | 166 GetNotificationIdGenerator()->GenerateForNonPersistentNotification( |
| 169 origin, notification_data.tag, non_persistent_notification_id, | 167 origin, notification_data.tag, non_persistent_notification_id, |
| 170 process_id_); | 168 process_id_); |
| 171 | |
| 172 NotificationEventDispatcherImpl* event_dispatcher = | 169 NotificationEventDispatcherImpl* event_dispatcher = |
| 173 content::NotificationEventDispatcherImpl::GetInstance(); | 170 content::NotificationEventDispatcherImpl::GetInstance(); |
| 174 non_persistent__notification_shown_ = true; | 171 non_persistent__notification_shown_ = true; |
| 175 event_dispatcher->RegisterNonPersistentNotification( | 172 event_dispatcher->RegisterNonPersistentNotification( |
| 176 notification_id, process_id_, non_persistent_notification_id); | 173 notification_id, process_id_, non_persistent_notification_id); |
| 177 | 174 |
| 178 std::unique_ptr<DesktopNotificationDelegate> delegate( | |
| 179 new PageNotificationDelegate(process_id_, non_persistent_notification_id, | |
| 180 notification_id)); | |
| 181 | |
| 182 base::Closure close_closure; | 175 base::Closure close_closure; |
| 183 service->DisplayNotification(browser_context_, notification_id, origin, | 176 service->DisplayNotification(browser_context_, notification_id, origin, |
| 184 SanitizeNotificationData(notification_data), | 177 SanitizeNotificationData(notification_data), |
| 185 notification_resources, std::move(delegate), | 178 notification_resources, &close_closure); |
| 186 &close_closure); | |
| 187 | 179 |
| 188 if (!close_closure.is_null()) | 180 if (!close_closure.is_null()) |
| 189 close_closures_[notification_id] = close_closure; | 181 close_closures_[notification_id] = close_closure; |
| 190 } | 182 } |
| 191 | 183 |
| 192 void NotificationMessageFilter::OnShowPersistentNotification( | 184 void NotificationMessageFilter::OnShowPersistentNotification( |
| 193 int request_id, | 185 int request_id, |
| 194 int64_t service_worker_registration_id, | 186 int64_t service_worker_registration_id, |
| 195 const GURL& origin, | 187 const GURL& origin, |
| 196 const PlatformNotificationData& notification_data, | 188 const PlatformNotificationData& notification_data, |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 bad_message::ReceivedBadMessage(this, bad_message::NMF_NO_PERMISSION_VERIFY); | 396 bad_message::ReceivedBadMessage(this, bad_message::NMF_NO_PERMISSION_VERIFY); |
| 405 return false; | 397 return false; |
| 406 } | 398 } |
| 407 | 399 |
| 408 NotificationIdGenerator* NotificationMessageFilter::GetNotificationIdGenerator() | 400 NotificationIdGenerator* NotificationMessageFilter::GetNotificationIdGenerator() |
| 409 const { | 401 const { |
| 410 return notification_context_->notification_id_generator(); | 402 return notification_context_->notification_id_generator(); |
| 411 } | 403 } |
| 412 | 404 |
| 413 } // namespace content | 405 } // namespace content |
| OLD | NEW |