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

Side by Side Diff: content/browser/notifications/notification_event_dispatcher_impl.cc

Issue 2392343002: Plumbing in notification replies: PlatformNotificationService -> SW (Closed)
Patch Set: Send NullableString through IPC, remove settings check from ButtonClickWithReply, add TODO in messa… Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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/nullable_string16.h"
9 #include "base/strings/utf_string_conversions.h"
Peter Beverloo 2016/10/12 13:58:31 delete both (unused)
awdf 2016/10/12 17:04:01 Done.
8 #include "build/build_config.h" 10 #include "build/build_config.h"
9 #include "content/browser/notifications/platform_notification_context_impl.h" 11 #include "content/browser/notifications/platform_notification_context_impl.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" 12 #include "content/browser/service_worker/service_worker_context_wrapper.h"
11 #include "content/browser/service_worker/service_worker_registration.h" 13 #include "content/browser/service_worker/service_worker_registration.h"
12 #include "content/browser/service_worker/service_worker_storage.h" 14 #include "content/browser/service_worker/service_worker_storage.h"
13 #include "content/common/service_worker/service_worker_messages.h" 15 #include "content/common/service_worker/service_worker_messages.h"
14 #include "content/public/browser/browser_context.h" 16 #include "content/public/browser/browser_context.h"
15 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/storage_partition.h" 18 #include "content/public/browser/storage_partition.h"
17 #include "content/public/common/platform_notification_data.h" 19 #include "content/public/common/platform_notification_data.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 198 }
197 199
198 // ----------------------------------------------------------------------------- 200 // -----------------------------------------------------------------------------
199 201
200 // Dispatches the notificationclick event on |service_worker|. Must be called on 202 // Dispatches the notificationclick event on |service_worker|. Must be called on
201 // the IO thread, and with the worker running. 203 // the IO thread, and with the worker running.
202 void DispatchNotificationClickEventOnWorker( 204 void DispatchNotificationClickEventOnWorker(
203 const scoped_refptr<ServiceWorkerVersion>& service_worker, 205 const scoped_refptr<ServiceWorkerVersion>& service_worker,
204 const NotificationDatabaseData& notification_database_data, 206 const NotificationDatabaseData& notification_database_data,
205 int action_index, 207 int action_index,
208 const base::NullableString16& reply,
206 const ServiceWorkerVersion::StatusCallback& callback) { 209 const ServiceWorkerVersion::StatusCallback& callback) {
207 DCHECK_CURRENTLY_ON(BrowserThread::IO); 210 DCHECK_CURRENTLY_ON(BrowserThread::IO);
208 int request_id = service_worker->StartRequest( 211 int request_id = service_worker->StartRequest(
209 ServiceWorkerMetrics::EventType::NOTIFICATION_CLICK, callback); 212 ServiceWorkerMetrics::EventType::NOTIFICATION_CLICK, callback);
210 service_worker->DispatchSimpleEvent< 213 service_worker->DispatchSimpleEvent<
211 ServiceWorkerHostMsg_NotificationClickEventFinished>( 214 ServiceWorkerHostMsg_NotificationClickEventFinished>(
212 request_id, 215 request_id,
213 ServiceWorkerMsg_NotificationClickEvent( 216 ServiceWorkerMsg_NotificationClickEvent(
214 request_id, notification_database_data.notification_id, 217 request_id, notification_database_data.notification_id,
215 notification_database_data.notification_data, action_index)); 218 notification_database_data.notification_data, action_index, reply));
216 } 219 }
217 220
218 // Dispatches the notification click event on the |service_worker_registration|. 221 // Dispatches the notification click event on the |service_worker_registration|.
219 void DoDispatchNotificationClickEvent( 222 void DoDispatchNotificationClickEvent(
220 int action_index, 223 int action_index,
224 const base::NullableString16& reply,
221 const NotificationDispatchCompleteCallback& dispatch_complete_callback, 225 const NotificationDispatchCompleteCallback& dispatch_complete_callback,
222 const scoped_refptr<PlatformNotificationContext>& notification_context, 226 const scoped_refptr<PlatformNotificationContext>& notification_context,
223 const ServiceWorkerRegistration* service_worker_registration, 227 const ServiceWorkerRegistration* service_worker_registration,
224 const NotificationDatabaseData& notification_database_data) { 228 const NotificationDatabaseData& notification_database_data) {
225 ServiceWorkerVersion::StatusCallback status_callback = base::Bind( 229 ServiceWorkerVersion::StatusCallback status_callback = base::Bind(
226 &ServiceWorkerNotificationEventFinished, dispatch_complete_callback); 230 &ServiceWorkerNotificationEventFinished, dispatch_complete_callback);
227 service_worker_registration->active_version()->RunAfterStartWorker( 231 service_worker_registration->active_version()->RunAfterStartWorker(
228 ServiceWorkerMetrics::EventType::NOTIFICATION_CLICK, 232 ServiceWorkerMetrics::EventType::NOTIFICATION_CLICK,
229 base::Bind( 233 base::Bind(
230 &DispatchNotificationClickEventOnWorker, 234 &DispatchNotificationClickEventOnWorker,
231 make_scoped_refptr(service_worker_registration->active_version()), 235 make_scoped_refptr(service_worker_registration->active_version()),
232 notification_database_data, action_index, status_callback), 236 notification_database_data, action_index, reply, status_callback),
233 status_callback); 237 status_callback);
234 } 238 }
235 239
236 // ----------------------------------------------------------------------------- 240 // -----------------------------------------------------------------------------
237 241
238 // Called when the notification data has been deleted to finish the notification 242 // Called when the notification data has been deleted to finish the notification
239 // close event. 243 // close event.
240 void OnPersistentNotificationDataDeleted( 244 void OnPersistentNotificationDataDeleted(
241 ServiceWorkerStatusCode service_worker_status, 245 ServiceWorkerStatusCode service_worker_status,
242 const NotificationDispatchCompleteCallback& dispatch_complete_callback, 246 const NotificationDispatchCompleteCallback& dispatch_complete_callback,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 357
354 NotificationEventDispatcherImpl::NotificationEventDispatcherImpl() {} 358 NotificationEventDispatcherImpl::NotificationEventDispatcherImpl() {}
355 359
356 NotificationEventDispatcherImpl::~NotificationEventDispatcherImpl() {} 360 NotificationEventDispatcherImpl::~NotificationEventDispatcherImpl() {}
357 361
358 void NotificationEventDispatcherImpl::DispatchNotificationClickEvent( 362 void NotificationEventDispatcherImpl::DispatchNotificationClickEvent(
359 BrowserContext* browser_context, 363 BrowserContext* browser_context,
360 const std::string& notification_id, 364 const std::string& notification_id,
361 const GURL& origin, 365 const GURL& origin,
362 int action_index, 366 int action_index,
367 const base::NullableString16& reply,
363 const NotificationDispatchCompleteCallback& dispatch_complete_callback) { 368 const NotificationDispatchCompleteCallback& dispatch_complete_callback) {
364 DispatchNotificationEvent( 369 DispatchNotificationEvent(
365 browser_context, notification_id, origin, 370 browser_context, notification_id, origin,
366 base::Bind(&DoDispatchNotificationClickEvent, action_index, 371 base::Bind(&DoDispatchNotificationClickEvent, action_index, reply,
367 dispatch_complete_callback), 372 dispatch_complete_callback),
368 dispatch_complete_callback); 373 dispatch_complete_callback);
369 } 374 }
370 375
371 void NotificationEventDispatcherImpl::DispatchNotificationCloseEvent( 376 void NotificationEventDispatcherImpl::DispatchNotificationCloseEvent(
372 BrowserContext* browser_context, 377 BrowserContext* browser_context,
373 const std::string& notification_id, 378 const std::string& notification_id,
374 const GURL& origin, 379 const GURL& origin,
375 bool by_user, 380 bool by_user,
376 const NotificationDispatchCompleteCallback& dispatch_complete_callback) { 381 const NotificationDispatchCompleteCallback& dispatch_complete_callback) {
377 DispatchNotificationEvent( 382 DispatchNotificationEvent(
378 browser_context, notification_id, origin, 383 browser_context, notification_id, origin,
379 base::Bind(&DoDispatchNotificationCloseEvent, notification_id, by_user, 384 base::Bind(&DoDispatchNotificationCloseEvent, notification_id, by_user,
380 dispatch_complete_callback), 385 dispatch_complete_callback),
381 dispatch_complete_callback); 386 dispatch_complete_callback);
382 } 387 }
383 388
384 } // namespace content 389 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698